couchdb-web-node-plugin 1.0.522 → 1.0.525

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 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=n()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&o(a,r.prototype),a}).apply(null,arguments)}function n(){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}}function o(e,t){return o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},o(e,t)}function a(){return a=Object.assign||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},a.apply(this,arguments)}function i(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 l(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)?l(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 l(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:()=>c,default:()=>p});var c=function(){function e(){}return e.authenticate=function(e,t,r,n,o,a,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===a&&(a="_id"),void 0===l&&(l="-type"),void 0===c&&(c="_design/"),void 0===p&&(p=!1);var u=null!==(s=e[l])&&void 0!==s?s:t&&t[l];if(!u)return!0;var m=p?"read":"write",y={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,a)&&e[a].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&&u&&Object.prototype.hasOwnProperty.call(o,u)){for(var h,g,v=o[u],O=i(["read","write"]);!(h=O()).done;)y[g=h.value]=y[g].concat(v[g]||[]);y.properties=v.properties}for(var b,w,P=y[m],j=i(r.roles);!(b=j()).done;)if(w=b.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 "+m+' action: "'+[].concat(y[m]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,t,n,o,l,c,p){void 0===c&&(c={});var s=function(e,t,r){var n;void 0===t&&(t="forbidden"),void 0===r&&(r={});for(var o=((n={})[t]=e,n.message=e,n.name=t,n),a=0,i=Object.entries(r);a<i.length;a++){var l=i[a],c=l[0],p=l[1];o[c]=p}throw o},u=new Date,m=Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate(),u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.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="",O="",b=function(){v=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",O=Object.prototype.hasOwnProperty.call(e,h)?e[h]:""};if(b(),Object.prototype.hasOwnProperty.call(o,l.property.name.validatedDocumentsCache)&&o[l.property.name.validatedDocumentsCache].has(v+"-"+O))return o[l.property.name.validatedDocumentsCache].delete(v+"-"+O),e;["latest","upsert"].includes(O)&&(t&&Object.prototype.hasOwnProperty.call(t,h)?O=e[h]=t[h]:"latest"===O?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],C=A[0],S=A[1];if(Object.prototype.hasOwnProperty.call(S,d.oldType)&&![null,void 0].includes(S[d.oldType]))for(var k,T,E=i([].concat(S[d.oldType]));!(k=E()).done;)T=k.value,j[T]=C}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 D=function(e){return e instanceof Error?""+e:P(e)},z=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},M=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return new RegExp(r.fileName.regularExpressionPattern).test(t)}return e===t},U=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},_=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var o=z(e);if(o){var i,l=(t?"return ":"")+o,c=a({},L,{code:l},n),p=Object.keys(c);try{i=r(Function,p.concat([l]))}catch(e){s(D(e),"compilation",{code:l,error:e,scope:c})}var u={code:l,result:void 0,scope:c};try{u.result=i.apply(void 0,p.map((function(e){return c[e]})))}catch(e){s(D(e),"runtime",{code:l,error:e,scope:c})}return u}s("No expression to evaluate provided.","empty")},H=function(e,t,n){void 0===n&&(n=[]);var o=n.length?" in "+n.join(" -> "):"",a=[],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 u=e[g],m=c[u],v=null;Object.prototype.hasOwnProperty.call(m,d.additional)&&m[d.additional]&&(v=m[d.additional]);var O=function(a,l,c,p,y){void 0===y&&(y=["constraintExecution","constraintExpression"]);for(var d,f,h=i(y);!(d=h()).done;)if(f=d.value,Object.prototype.hasOwnProperty.call(c,f)){var g,v=void 0;try{v=_(c[f].evaluation,f.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,name:l,type:f,newDocument:e,newValue:a,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(null==(g=v)||!g.result){var O=z(c[f].description);s(f.charAt(0).toUpperCase()+(f.substring(1)+": ")+(O?r(Function,Object.keys(v.scope).concat(["return "+O])).apply(void 0,Object.values(v.scope)):'Property "'+l+'" should satisfy constraint "'+v.code+'" (given "'+D(a)+'")'+o+"."))}}},P=function(e,t,r,a){void 0===a&&(a=null);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 u,m,d=!1,h=i(p);!(u=h()).done;)if(m=u.value,Object.prototype.hasOwnProperty.call(c,m)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]!==m&&"migrate"===w&&1===p.length&&(e[g]=m,l=n.concat(t,"migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]===m){var v=H(e,a,n.concat(t));if(v.changedPath.length&&(l=v.changedPath),e=v.newDocument,D(e)===D({}))return{newValue:null,changedPath:l};d=!0;break}1===p.length&&s('NestedType: Under key "'+t+'" isn\'t of type "'+m+'" (given "'+D(e)+'" of type '+typeof e+")"+o+".")}else if("DateTime"===m){var b=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 "'+D(b).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof b+'")'+o+".")}else if(["boolean","integer","number","string"].includes(m)){if(!("number"==typeof e&&isNaN(e)||"integer"!==m&&typeof e!==m||"integer"===m&&parseInt(e,10)!==e)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t of (valid) type "${type}" (given "'+D(e)+'" of type "'+typeof e+'")'+o+".")}else if("string"==typeof m&&m.startsWith("foreignKey:")){var P=c[m.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 "'+D(e)+'" of type "'+typeof e+'")'+o+".")}else{if("any"===m||D(e)===D(m)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t value "'+m+'" (given "'+D(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+o+".")}if(d||s('PropertyType: None of the specified types "'+p.join('", "')+'" for property "'+t+'" matches value "'+D(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+o+"."),"string"==typeof e&&(![null,void 0].includes(r.minimumLength)&&e.length<r.minimumLength&&s('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+o+"."),![null,void 0].includes(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&&(![null,void 0].includes(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+"."),![null,void 0].includes(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+".")}return[null,void 0].includes(r.regularExpressionPattern)||new RegExp(r.regularExpressionPattern).test(e)?![null,void 0].includes(r.invertedRegularExpressionPattern)&&new RegExp(r.invertedRegularExpressionPattern).test(e)&&s('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+r.invertedRegularExpressionPattern+' (given "'+e+'")'+o+"."):s('PatternMatch: Property "'+t+'" should match regular expression pattern '+r.regularExpressionPattern+' (given "'+e+'")'+o+"."),O(e,t,r,a),D(e)!==D(a)&&(l=n.concat(t,"value updated")),{newValue:e,changedPath:l}},x=function(e,t,r,o,i){var c=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&D(c)===D(r[o]))return o!==f&&"incremental"===w&&delete t[o],!0;s('Readonly: Property "'+o+'" is not writable (old document "'+D(r)+'")'+i+".")}else s('Readonly: Property "'+o+'" is not writable'+i+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(D(c)===D(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 "'+D(r)+'")'+i+".")}if(null===c){if(e.nullable)return delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(a=n.concat(o,"delete property")),!0;s('NotNull: Property "'+o+'" should not be "null"'+i+".")}return!1},N=function(e,t,r,a){if(!r)for(var l,c,p=i(["onCreateExecution","onCreateExpression"]);!(l=p()).done;)if(c=l.value,Object.prototype.hasOwnProperty.call(e,c)){var y=void 0;try{y=_(e[c],c.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,name:a,type:c,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 "'+c+'" has invalid code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+c+'" has throw an error with code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}y&&![null,void 0].includes(y.result)&&(t[a]=y.result)}},A=function(e,t,r,a){if(Object.prototype.hasOwnProperty.call(t,a)){e.trim&&"string"==typeof t[a]&&(t[a]=t[a].trim()),e.emptyEqualsToNull&&(""===t[a]||Array.isArray(t[a])&&0===t[a].length||null!==t[a]&&"object"==typeof t[a]&&0===Object.keys(t).length)&&(t[a]=null);for(var l,c,p=i(["onUpdateExecution","onUpdateExpression"]);!(l=p()).done;)if(c=l.value,Object.prototype.hasOwnProperty.call(e,c))try{t[a]=_(e[c],c.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,name:a,type:c,newDocument:t,oldDocument:r,newValue:t[a],oldValue:r&&r[a],parentNames:n,pathDescription:o,propertySpecification:e}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+c+'" has invalid code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+c+'" has throw an error with code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}}},C=Object.keys(m).filter((function(e){return![d.additional,d.allowedRoles,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].includes(e)}));if("migrate"===w)for(var S,k,T=i(C);!(S=T()).done;)if(k=S.value,![null,void 0].includes(m[k].oldName))for(var E,U,L=i([].concat(m[k].oldName));!(E=L()).done;)U=E.value,Object.prototype.hasOwnProperty.call(e,U)&&(e[k]=e[U],delete e[U]);if(!t)for(var I,W=0,V=[d.create.execution,d.create.expression];W<V.length;W++)if(I=V[W],Object.prototype.hasOwnProperty.call(m,I)){var F=void 0;try{F=_(m[I],I.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,type:I,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 "'+I+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+I+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(F)||(e=F),p(),u=e[g],0===n.length&&b()}for(var B,$=0,q=[d.update.execution,d.update.expression];$<q.length;$++)if(B=q[$],Object.prototype.hasOwnProperty.call(m,B)){var Y=void 0;try{Y=_(m[B],B.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,type:B,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 "'+B+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+B+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(Y)||(e=Y),p(),u=e[g],0===n.length&&b()}for(var J,G=function(){var r=J.value;if(d.attachment===r)for(var l=function(){var l=p[c],u=l[0],m=l[1];Object.prototype.hasOwnProperty.call(e,r)&&null!==e[r]||(e[r]={}),t&&!Object.prototype.hasOwnProperty.call(t,r)&&(t[r]={});var y=Object.keys(e[r]).filter((function(t){return null!==e[r][t].data&&M(u,t,m)})),d=e[r],f=[];if(t){var h=t[r];f=Object.keys(h).filter((function(e){return!(Object.prototype.hasOwnProperty.call(d,e)&&Object.prototype.hasOwnProperty.call(d[e],"data")&&null===d[e].data)&&!!h[e]&&(Object.prototype.hasOwnProperty.call(h[e],"data")&&null!==h[e].data||h[e].stub&&!!h[e].digest)&&!!M(u,e,m)}))}for(var g,v,O=m,b=i(y);!(g=b()).done;)v=g.value,N(O,d,t&&t[r]?t[r]:null,v);for(var P,j,x=i(y);!(P=x()).done;)j=P.value,A(O,d,t&&t[r]?t[r]:null,j);if([null,void 0].includes(O.default)){if(O.nullable||0<y.length||0<f.length||s('AttachmentMissing: Missing attachment for type "'+u+'"'+o+"."),"fillUp"===w&&0===y.length&&0<f.length)for(var C,S,k=i(f);!(C=k()).done;)S=C.value,null===d[S]?a=n.concat(r,S,"file removed"):d[S]=t[r][S]}else if(0===y.length)if(0===f.length)for(var T in O.default)Object.prototype.hasOwnProperty.call(O.default,T)&&(d[T]=O.default[T],a=n.concat(r,u,"add default file"));else if("fillUp"===w)for(var E,D,z=i(f);!(E=z()).done;)D=E.value,d[D]=t[r][D]},c=0,p=Object.entries(m[r]);c<p.length;c++)l();else{var u=C.includes(r)?m[r]:v;N(u,e,t,r),A(u,e,t,r),[null,void 0].includes(u.default)?(!(u.nullable||Object.prototype.hasOwnProperty.call(e,r)||t&&Object.prototype.hasOwnProperty.call(t,r)&&w)&&s('MissingProperty: Missing property "'+r+'"'+o+"."),!Object.prototype.hasOwnProperty.call(e,r)&&t&&Object.prototype.hasOwnProperty.call(t,r)&&("fillUp"===w?e[r]=t[r]:!w&&(a=n.concat(r,"property removed")))):(!Object.prototype.hasOwnProperty.call(e,r)||null===e[r])&&(t&&Object.prototype.hasOwnProperty.call(t,r)?"fillUp"===w?e[r]=t[r]:"migrate"===w&&(e[r]=u.default,a=n.concat(r,"migrate default value")):(e[r]=u.default,a=a.concat(r,"add default value")))}},K=i(C.concat(v?Object.keys(e).filter((function(e){return!C.includes(e)})):[]));!(J=K()).done;)G();if(t&&"incremental"===w)for(var Z=0,Q=Object.entries(e);Z<Q.length;Z++){var X=Q[Z],ee=X[0],te=X[1];!Object.prototype.hasOwnProperty.call(t,ee)||l.property.name.reserved.concat(f,h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,g).includes(ee)||t[ee]!==te&&D(t[ee])!==D(te)||delete e[ee]}for(var re=0,ne=Object.entries(e);re<ne.length;re++){var oe=ne[re],ae=oe[0],ie=oe[1];if(!l.property.name.reserved.concat(h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,d.strategy).includes(ae)){var le=void 0;if(Object.prototype.hasOwnProperty.call(m,ae))le=m[ae];else if(v)le=v;else{if("migrate"===w){delete e[ae],a=n.concat(ae,"migrate removed property");continue}s('Property: Given property "'+ae+'" isn\'t specified in model "'+u+'"'+o+".")}if(!le)continue;if(d.attachment===ae){var ce=ie;for(var pe in ce)if(Object.prototype.hasOwnProperty.call(ce,pe))for(var se in m[ae])if(M(se,pe,m[ae][se])){x(m[ae][se],e,t,pe,o);break}continue}if(x(le,e,t,ae,o))continue;if("string"==typeof le.type&&le.type.endsWith("[]")||Array.isArray(le.type)&&le.type.length&&Array.isArray(le.type[0])){var ue,me=ie;Array.isArray(me)?![null,void 0].includes(le.minimumNumber)&&me.length<le.minimumNumber?s('MinimumArrayLength: Property "'+ae+'" (array of length '+me.length+") doesn't fullfill minimum array length of "+le.minimumNumber+o+"."):![null,void 0].includes(le.maximumNumber)&&le.maximumNumber<me.length&&s('MaximumArrayLength: Property "'+ae+'" (array of length '+me.length+") doesn't fullfill maximum array length of "+le.maximumNumber+o+"."):s('PropertyType: Property "'+ae+'" isn\'t of type "array -> '+le.type+'" (given "'+D(me)+'")'+o+"."),O(me,ae,le,t&&Object.prototype.hasOwnProperty.call(t,ae)&&t[ae]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var ye={};for(var de in le)Object.prototype.hasOwnProperty.call(le,de)&&(ye[de]="type"===de?Array.isArray(le[de])?le[de][0]:[le[de].substring(0,le.type.length-2)]:le[de]);if(1===(null==(ue=ye.type)?void 0:ue.length)&&Object.prototype.hasOwnProperty.call(c,ye.type[0]))for(var fe,he,ge=i(me.slice());!(fe=ge()).done;)"object"!=typeof(he=fe.value)||Object.getPrototypeOf(he)!==Object.prototype||Object.prototype.hasOwnProperty.call(he,g)||(he[g]=ye.type[0]);for(var ve,Oe,be=0,we=i(me.slice());!(ve=we()).done;)Oe=ve.value,me[be]=P(Oe,be+1+". value in "+ae,ye).newValue,null===Oe&&me.splice(be,1),be+=1;t&&Object.prototype.hasOwnProperty.call(t,ae)&&Array.isArray(t[ae])&&t[ae].length===me.length&&D(t[ae])===D(me)||(a=n.concat(ae,"array updated"))}else{var Pe=t&&Object.prototype.hasOwnProperty.call(t,ae)?t[ae]:null,je=P(ie,ae,le,Pe);e[ae]=je.newValue,je.changedPath.length&&(a=je.changedPath),null===e[ae]&&(null!==Pe&&(a=n.concat(ae,"property removed")),delete e[ae])}}}for(var xe,Ne=0,Ae=Object.keys(d.constraint);Ne<Ae.length;Ne++)if(xe=Ae[Ne],(xe=d.constraint[xe])&&Object.prototype.hasOwnProperty.call(m,xe))for(var Ce,Se=i([].concat(m[xe]));!(Ce=Se()).done;){var ke,Te=Ce.value,Ee=void 0;try{Ee=_(Te.evaluation,xe===d.constraint.expression,{checkPropertyContent:P,model:m,modelName:u,type:xe,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+xe+'" has invalid code "'+e.code+'": "'+e.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+xe+'" has thrown an error with code "'+e.code+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(null==(ke=Ee)||!ke.result){var De=xe.replace(/^[^a-zA-Z]+/,"");s(De.charAt(0).toUpperCase()+(De.substring(1)+": ")+(Te.description?r(Function,Object.keys(Ee.scope).concat(["return "+Te.description.trim()])).apply(void 0,Object.values(Ee.scope)):'Model "'+u+'" should satisfy constraint "'+Ee.code+'" (given "'+D(e)+'")'+o+"."))}}if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var ze=e[d.attachment];("object"!=typeof ze||Object.getPrototypeOf(ze)!==Object.prototype)&&s("AttachmentType: given attachment has invalid type"+o+".");var Re=null;if(t&&Object.prototype.hasOwnProperty.call(t,d.attachment)&&(null!==(Re=t[d.attachment])&&"object"==typeof Re))for(var Me=0,Ue=Object.entries(Re);Me<Ue.length;Me++){var _e=Ue[Me],He=_e[0],Le=_e[1];if(Object.prototype.hasOwnProperty.call(ze,He)){var Ie=ze[He];null===Ie||null===Ie.data||Ie.content_type===Le.content_type&&(Ie.data===Le.data||Ie.digest===Le.digest)?((null===Ie||null===Ie.data)&&(a=n.concat(d.attachment,He,"attachment removed")),"incremental"===w&&delete ze[He]):a=n.concat(d.attachment,He,"attachment updated")}else"fillUp"===w?ze[He]=Le:w||(a=n.concat(d.attachment,He,"attachment removed"))}for(var We=0,Ve=Object.entries(ze);We<Ve.length;We++){var Fe=Ve[We],Be=Fe[0],$e=Fe[1];[null,void 0].includes($e)||null===$e.data?delete ze[Be]:(!Re||!Object.prototype.hasOwnProperty.call(Re,Be)||$e.content_type!==Re[Be].content_type||$e.data!==Re[Be].data&&$e.digest!==Re[Be].digest)&&(a=n.concat(d.attachment,Be,"attachment updated"))}0===Object.keys(ze).length&&delete e[d.attachment];for(var qe={},Ye=0,Je=Object.keys(m[d.attachment]);Ye<Je.length;Ye++)qe[Je[Ye]]=[];for(var Ge=0,Ke=Object.keys(ze);Ge<Ke.length;Ge++){for(var Ze=Ke[Ge],Qe=!1,Xe=0,et=Object.entries(m[d.attachment]);Xe<et.length;Xe++){var tt=et[Xe],rt=tt[0],nt=tt[1];if(M(rt,Ze,nt)){qe[rt].push(Ze),Qe=!0;break}}Qe||s('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(m[d.attachment]).join('", "')+'") matches given one ("'+Ze+'")'+o+".")}for(var ot=0,at=0,it=Object.keys(qe);at<it.length;at++){var lt=it[at],ct=m[d.attachment][lt];if(Object.prototype.hasOwnProperty.call(qe,lt)){var pt=qe[lt].length;null!==ct.maximumNumber&&pt>ct.maximumNumber&&s("AttachmentMaximum: given number of attachments ("+pt+") doesn't satisfy specified maximum of "+ct.maximumNumber+' from type "'+lt+'"'+o+"."),(!ct.nullable||0!==pt)&&pt<ct.minimumNumber&&s("AttachmentMinimum: given number of attachments ("+pt+") doesn't satisfy specified minimum of "+ct.minimumNumber+' from type "'+lt+'"'+o+".");for(var st,ut=0,mt=i(qe[lt]);!(st=mt()).done;){var yt,dt,ft=st.value;null!=(yt=ct.fileName)&&yt.regularExpressionPattern&&!new RegExp(ct.fileName.regularExpressionPattern).test(ft)?s('AttachmentName: given attachment name "'+ft+'" doesn\'t satisfy specified regular expression pattern "'+ct.fileName.regularExpressionPattern+'" from type "'+lt+'"'+o+"."):null!=(dt=ct.fileName)&&dt.invertedRegularExpressionPattern&&new RegExp(ct.fileName.invertedRegularExpressionPattern).test(ft)?s('InvertedAttachmentName: given attachment name "'+ft+'" does satisfy specified regular expression pattern "'+ct.fileName.invertedRegularExpressionPattern+'" from type "'+lt+'"'+o+"."):!([null,void 0].includes(ct.contentTypeRegularExpressionPattern)||ze[ft].content_type&&new RegExp(ct.contentTypeRegularExpressionPattern).test(ze[ft].content_type))&&s('AttachmentContentType: given attachment content type "'+ze[ft].content_type+'" doesn\'t satisfy specified regular expression pattern "'+ct.contentTypeRegularExpressionPattern+'" from type "'+lt+'"'+o+".");var ht=ct.invertedContentTypeRegularExpressionPattern;[null,void 0].includes(ht)||ze[ft].content_type&&!new RegExp(ht).test(ze[ft].content_type)||s('InvertedAttachmentContentType: given attachment content type "'+ze[ft].content_type+'" does satisfy specified regular expression pattern "'+ht+'" from type "'+lt+'"'+o+".");var gt=0;"length"in ze[ft]?gt=ze[ft].length:"data"in ze[ft]&&(gt=Buffer&&"byteLength"in Buffer?Buffer.byteLength(ze[ft].data,"base64"):ze[ft].data.length),![null,void 0].includes(ct.minimumSize)&&ct.minimumSize>gt?s("AttachmentMinimumSize: given attachment size "+gt+" byte doesn't satisfy specified minimum of "+ct.minimumSize+" byte "+o+"."):![null,void 0].includes(ct.maximumSize)&&ct.maximumSize<gt&&s("AttachmentMaximumSize: given attachment size "+gt+" byte doesn't satisfy specified maximum of "+ct.maximumSize+" byte "+o+"."),ut+=gt}![null,void 0].includes(ct.minimumAggregatedSize)&&ct.minimumAggregatedSize>ut?s('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+lt+'" '+ut+" byte doesn't satisfy specified minimum of "+ct.minimumAggregatedSize+" byte "+o+"."):![null,void 0].includes(ct.maximumAggregatedSize)&&ct.maximumAggregatedSize<ut&&s('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+lt+'" '+ut+" byte doesn't satisfy specified maximum of "+ct.maximumAggregatedSize+" byte "+o+"."),ot+=ut}}Object.prototype.hasOwnProperty.call(m,d.minimumAggregatedSize)&&![null,void 0].includes(m[d.minimumAggregatedSize])&&m[d.minimumAggregatedSize]>ot?s("AggregatedMinimumSize: given aggregated size "+ot+" byte doesn't satisfy specified minimum of "+m[d.minimumAggregatedSize]+" byte "+o+"."):![null,void 0].includes(m[d.maximumAggregatedSize])&&m[d.maximumAggregatedSize]<ot&&s("AggregatedMaximumSize: given aggregated size "+ot+" byte doesn't satisfy specified maximum of "+m[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===a.length&&t&&"migrate"===w)for(var vt,Ot=0,bt=Object.keys(t);Ot<bt.length;Ot++)vt=bt[Ot],Object.prototype.hasOwnProperty.call(e,vt)||(a=n.concat(vt,"migrate removed property"));return{changedPath:a,newDocument:e}},L={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var r=e[d.attachment],n=U(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:H,getFileNameByPrefix:U,serialize:D,id:v,revision:O,idName:f,revisionName:h,specialNames:d,typeName:g,modelConfiguration:l,models:c,now:u,nowUTCTimestamp:m,securitySettings:o,userContext:n},I=H(e,t);return(!I.newDocument._deleted||t)&&(I.newDocument._deleted&&I.newDocument._deleted!==(null==t?void 0:t._deleted)||I.changedPath.length)||s("NoChange: No new data given. new document: "+D(e)+"; old document: "+D(t)+"."),Object.prototype.hasOwnProperty.call(o,l.property.name.validatedDocumentsCache)?o[l.property.name.validatedDocumentsCache].add(v+"-"+O):o[l.property.name.validatedDocumentsCache]=new Set([v+"-"+O]),I.newDocument},e}();const p=c;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=n()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&o(a,r.prototype),a}).apply(null,arguments)}function n(){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}}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function a(){return a=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},a.apply(this,arguments)}function i(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 l(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)?l(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 l(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:()=>c,default:()=>p});var c=function(){function e(){}return e.authenticate=function(e,t,r,n,o,a,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===a&&(a="_id"),void 0===l&&(l="-type"),void 0===c&&(c="_design/"),void 0===p&&(p=!1);var u=null!==(s=e[l])&&void 0!==s?s:t&&t[l];if(!u)return!0;var m=p?"read":"write",y={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,a)&&e[a].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&&u&&Object.prototype.hasOwnProperty.call(o,u)){for(var h,g,v=o[u],O=i(["read","write"]);!(h=O()).done;)y[g=h.value]=y[g].concat(v[g]||[]);y.properties=v.properties}for(var b,w,P=y[m],j=i(r.roles);!(b=j()).done;)if(w=b.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 "+m+' action: "'+[].concat(y[m]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,t,n,o,l,c,p){void 0===c&&(c={});var s=function(e,t,r){var n;void 0===t&&(t="forbidden"),void 0===r&&(r={});for(var o=((n={})[t]=e,n.message=e,n.name=t,n),a=0,i=Object.entries(r);a<i.length;a++){var l=i[a],c=l[0],p=l[1];o[c]=p}throw o},u=new Date,m=Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate(),u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.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="",O="",b=function(){v=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",O=Object.prototype.hasOwnProperty.call(e,h)?e[h]:""};if(b(),Object.prototype.hasOwnProperty.call(o,l.property.name.validatedDocumentsCache)&&o[l.property.name.validatedDocumentsCache].has(v+"-"+O))return o[l.property.name.validatedDocumentsCache].delete(v+"-"+O),e;["latest","upsert"].includes(O)&&(t&&Object.prototype.hasOwnProperty.call(t,h)?O=e[h]=t[h]:"latest"===O?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],C=A[0],S=A[1];if(Object.prototype.hasOwnProperty.call(S,d.oldType)&&![null,void 0].includes(S[d.oldType]))for(var k,T,E=i([].concat(S[d.oldType]));!(k=E()).done;)T=k.value,j[T]=C}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 D=function(e){return e instanceof Error?""+e:P(e)},z=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},M=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return new RegExp(r.fileName.regularExpressionPattern).test(t)}return e===t},U=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},_=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var o=z(e);if(o){var i,l=(t?"return ":"")+o,c=a({},L,{code:l},n),p=Object.keys(c);try{i=r(Function,p.concat([l]))}catch(e){s(D(e),"compilation",{code:l,error:e,scope:c})}var u={code:l,result:void 0,scope:c};try{u.result=i.apply(void 0,p.map((function(e){return c[e]})))}catch(e){s(D(e),"runtime",{code:l,error:e,scope:c})}return u}s("No expression to evaluate provided.","empty")},H=function(e,t,n){void 0===n&&(n=[]);var o=n.length?" in "+n.join(" -> "):"",a=[],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 u=e[g],m=c[u],v=null;Object.prototype.hasOwnProperty.call(m,d.additional)&&m[d.additional]&&(v=m[d.additional]);var O=function(a,l,c,p,y){void 0===y&&(y=["constraintExecution","constraintExpression"]);for(var d,f,h=i(y);!(d=h()).done;)if(f=d.value,Object.prototype.hasOwnProperty.call(c,f)){var g,v=void 0;try{v=_(c[f].evaluation,f.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,name:l,type:f,newDocument:e,newValue:a,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(null==(g=v)||!g.result){var O=z(c[f].description);s(f.charAt(0).toUpperCase()+(f.substring(1)+": ")+(O?r(Function,Object.keys(v.scope).concat(["return "+O])).apply(void 0,Object.values(v.scope)):'Property "'+l+'" should satisfy constraint "'+v.code+'" (given "'+D(a)+'")'+o+"."))}}},P=function(e,t,r,a){void 0===a&&(a=null);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 u,m,d=!1,h=i(p);!(u=h()).done;)if(m=u.value,Object.prototype.hasOwnProperty.call(c,m)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]!==m&&"migrate"===w&&1===p.length&&(e[g]=m,l=n.concat(t,"migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,g)&&e[g]===m){var v=H(e,a,n.concat(t));if(v.changedPath.length&&(l=v.changedPath),e=v.newDocument,D(e)===D({}))return{newValue:null,changedPath:l};d=!0;break}1===p.length&&s('NestedType: Under key "'+t+'" isn\'t of type "'+m+'" (given "'+D(e)+'" of type '+typeof e+")"+o+".")}else if("DateTime"===m){var b=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 "'+D(b).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof b+'")'+o+".")}else if(["boolean","integer","number","string"].includes(m)){if(!("number"==typeof e&&isNaN(e)||"integer"!==m&&typeof e!==m||"integer"===m&&parseInt(e,10)!==e)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t of (valid) type "${type}" (given "'+D(e)+'" of type "'+typeof e+'")'+o+".")}else if("string"==typeof m&&m.startsWith("foreignKey:")){var P=c[m.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 "'+D(e)+'" of type "'+typeof e+'")'+o+".")}else{if("any"===m||D(e)===D(m)){d=!0;break}1===p.length&&s('PropertyType: Property "'+t+'" isn\'t value "'+m+'" (given "'+D(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+o+".")}if(d||s('PropertyType: None of the specified types "'+p.join('", "')+'" for property "'+t+'" matches value "'+D(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+o+"."),"string"==typeof e&&(![null,void 0].includes(r.minimumLength)&&e.length<r.minimumLength&&s('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+o+"."),![null,void 0].includes(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&&(![null,void 0].includes(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+"."),![null,void 0].includes(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+".")}return[null,void 0].includes(r.regularExpressionPattern)||new RegExp(r.regularExpressionPattern).test(e)?![null,void 0].includes(r.invertedRegularExpressionPattern)&&new RegExp(r.invertedRegularExpressionPattern).test(e)&&s('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+r.invertedRegularExpressionPattern+' (given "'+e+'")'+o+"."):s('PatternMatch: Property "'+t+'" should match regular expression pattern '+r.regularExpressionPattern+' (given "'+e+'")'+o+"."),O(e,t,r,a),D(e)!==D(a)&&(l=n.concat(t,"value updated")),{newValue:e,changedPath:l}},x=function(e,t,r,o,i){var c=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&D(c)===D(r[o]))return o!==f&&"incremental"===w&&delete t[o],!0;s('Readonly: Property "'+o+'" is not writable (old document "'+D(r)+'")'+i+".")}else s('Readonly: Property "'+o+'" is not writable'+i+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(D(c)===D(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 "'+D(r)+'")'+i+".")}if(null===c){if(e.nullable)return delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(a=n.concat(o,"delete property")),!0;s('NotNull: Property "'+o+'" should not be "null"'+i+".")}return!1},N=function(e,t,r,a){if(!r)for(var l,c,p=i(["onCreateExecution","onCreateExpression"]);!(l=p()).done;)if(c=l.value,Object.prototype.hasOwnProperty.call(e,c)){var y=void 0;try{y=_(e[c],c.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,name:a,type:c,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 "'+c+'" has invalid code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+c+'" has throw an error with code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}y&&![null,void 0].includes(y.result)&&(t[a]=y.result)}},A=function(e,t,r,a){if(Object.prototype.hasOwnProperty.call(t,a)){e.trim&&"string"==typeof t[a]&&(t[a]=t[a].trim()),e.emptyEqualsToNull&&(""===t[a]||Array.isArray(t[a])&&0===t[a].length||null!==t[a]&&"object"==typeof t[a]&&0===Object.keys(t).length)&&(t[a]=null);for(var l,c,p=i(["onUpdateExecution","onUpdateExpression"]);!(l=p()).done;)if(c=l.value,Object.prototype.hasOwnProperty.call(e,c))try{t[a]=_(e[c],c.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,name:a,type:c,newDocument:t,oldDocument:r,newValue:t[a],oldValue:r&&r[a],parentNames:n,pathDescription:o,propertySpecification:e}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+c+'" has invalid code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+c+'" has throw an error with code "'+e.code+'" for property "'+a+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}}},C=Object.keys(m).filter((function(e){return![d.additional,d.allowedRoles,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].includes(e)}));if("migrate"===w)for(var S,k,T=i(C);!(S=T()).done;)if(k=S.value,![null,void 0].includes(m[k].oldName))for(var E,U,L=i([].concat(m[k].oldName));!(E=L()).done;)U=E.value,Object.prototype.hasOwnProperty.call(e,U)&&(e[k]=e[U],delete e[U]);if(!t)for(var I,W=0,V=[d.create.execution,d.create.expression];W<V.length;W++)if(I=V[W],Object.prototype.hasOwnProperty.call(m,I)){var F=void 0;try{F=_(m[I],I.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,type:I,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 "'+I+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+I+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(F)||(e=F),p(),u=e[g],0===n.length&&b()}for(var B,$=0,q=[d.update.execution,d.update.expression];$<q.length;$++)if(B=q[$],Object.prototype.hasOwnProperty.call(m,B)){var Y=void 0;try{Y=_(m[B],B.endsWith("Expression"),{checkPropertyContent:P,model:m,modelName:u,type:B,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 "'+B+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+B+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(Y)||(e=Y),p(),u=e[g],0===n.length&&b()}for(var J,G=function(){var r=J.value;if(d.attachment===r)for(var l=function(){var l=p[c],u=l[0],m=l[1];Object.prototype.hasOwnProperty.call(e,r)&&null!==e[r]||(e[r]={}),t&&!Object.prototype.hasOwnProperty.call(t,r)&&(t[r]={});var y=Object.keys(e[r]).filter((function(t){return null!==e[r][t].data&&M(u,t,m)})),d=e[r],f=[];if(t){var h=t[r];f=Object.keys(h).filter((function(e){return!(Object.prototype.hasOwnProperty.call(d,e)&&Object.prototype.hasOwnProperty.call(d[e],"data")&&null===d[e].data)&&!!h[e]&&(Object.prototype.hasOwnProperty.call(h[e],"data")&&null!==h[e].data||h[e].stub&&!!h[e].digest)&&!!M(u,e,m)}))}for(var g,v,O=m,b=i(y);!(g=b()).done;)v=g.value,N(O,d,t&&t[r]?t[r]:null,v);for(var P,j,x=i(y);!(P=x()).done;)j=P.value,A(O,d,t&&t[r]?t[r]:null,j);if([null,void 0].includes(O.default)){if(O.nullable||0<y.length||0<f.length||s('AttachmentMissing: Missing attachment for type "'+u+'"'+o+"."),"fillUp"===w&&0===y.length&&0<f.length)for(var C,S,k=i(f);!(C=k()).done;)S=C.value,null===d[S]?a=n.concat(r,S,"file removed"):d[S]=t[r][S]}else if(0===y.length)if(0===f.length)for(var T in O.default)Object.prototype.hasOwnProperty.call(O.default,T)&&(d[T]=O.default[T],a=n.concat(r,u,"add default file"));else if("fillUp"===w)for(var E,D,z=i(f);!(E=z()).done;)D=E.value,d[D]=t[r][D]},c=0,p=Object.entries(m[r]);c<p.length;c++)l();else{var u=C.includes(r)?m[r]:v;N(u,e,t,r),A(u,e,t,r),[null,void 0].includes(u.default)?(!(u.nullable||Object.prototype.hasOwnProperty.call(e,r)||t&&Object.prototype.hasOwnProperty.call(t,r)&&w)&&s('MissingProperty: Missing property "'+r+'"'+o+"."),!Object.prototype.hasOwnProperty.call(e,r)&&t&&Object.prototype.hasOwnProperty.call(t,r)&&("fillUp"===w?e[r]=t[r]:!w&&(a=n.concat(r,"property removed")))):(!Object.prototype.hasOwnProperty.call(e,r)||null===e[r])&&(t&&Object.prototype.hasOwnProperty.call(t,r)?"fillUp"===w?e[r]=t[r]:"migrate"===w&&(e[r]=u.default,a=n.concat(r,"migrate default value")):(e[r]=u.default,a=a.concat(r,"add default value")))}},K=i(C.concat(v?Object.keys(e).filter((function(e){return!C.includes(e)})):[]));!(J=K()).done;)G();if(t&&"incremental"===w)for(var Z=0,Q=Object.entries(e);Z<Q.length;Z++){var X=Q[Z],ee=X[0],te=X[1];!Object.prototype.hasOwnProperty.call(t,ee)||l.property.name.reserved.concat(f,h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,g).includes(ee)||t[ee]!==te&&D(t[ee])!==D(te)||delete e[ee]}for(var re=0,ne=Object.entries(e);re<ne.length;re++){var oe=ne[re],ae=oe[0],ie=oe[1];if(!l.property.name.reserved.concat(h,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,d.strategy).includes(ae)){var le=void 0;if(Object.prototype.hasOwnProperty.call(m,ae))le=m[ae];else if(v)le=v;else{if("migrate"===w){delete e[ae],a=n.concat(ae,"migrate removed property");continue}s('Property: Given property "'+ae+'" isn\'t specified in model "'+u+'"'+o+".")}if(!le)continue;if(d.attachment===ae){var ce=ie;for(var pe in ce)if(Object.prototype.hasOwnProperty.call(ce,pe))for(var se in m[ae])if(M(se,pe,m[ae][se])){x(m[ae][se],e,t,pe,o);break}continue}if(x(le,e,t,ae,o))continue;if("string"==typeof le.type&&le.type.endsWith("[]")||Array.isArray(le.type)&&le.type.length&&Array.isArray(le.type[0])){var ue,me=ie;Array.isArray(me)?![null,void 0].includes(le.minimumNumber)&&me.length<le.minimumNumber?s('MinimumArrayLength: Property "'+ae+'" (array of length '+me.length+") doesn't fullfill minimum array length of "+le.minimumNumber+o+"."):![null,void 0].includes(le.maximumNumber)&&le.maximumNumber<me.length&&s('MaximumArrayLength: Property "'+ae+'" (array of length '+me.length+") doesn't fullfill maximum array length of "+le.maximumNumber+o+"."):s('PropertyType: Property "'+ae+'" isn\'t of type "array -> '+le.type+'" (given "'+D(me)+'")'+o+"."),O(me,ae,le,t&&Object.prototype.hasOwnProperty.call(t,ae)&&t[ae]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var ye={};for(var de in le)Object.prototype.hasOwnProperty.call(le,de)&&(ye[de]="type"===de?Array.isArray(le[de])?le[de][0]:[le[de].substring(0,le.type.length-2)]:le[de]);if(1===(null==(ue=ye.type)?void 0:ue.length)&&Object.prototype.hasOwnProperty.call(c,ye.type[0]))for(var fe,he,ge=i(me.slice());!(fe=ge()).done;)"object"!=typeof(he=fe.value)||Object.getPrototypeOf(he)!==Object.prototype||Object.prototype.hasOwnProperty.call(he,g)||(he[g]=ye.type[0]);for(var ve,Oe,be=0,we=i(me.slice());!(ve=we()).done;)Oe=ve.value,me[be]=P(Oe,be+1+". value in "+ae,ye).newValue,null===Oe&&me.splice(be,1),be+=1;t&&Object.prototype.hasOwnProperty.call(t,ae)&&Array.isArray(t[ae])&&t[ae].length===me.length&&D(t[ae])===D(me)||(a=n.concat(ae,"array updated"))}else{var Pe=t&&Object.prototype.hasOwnProperty.call(t,ae)?t[ae]:null,je=P(ie,ae,le,Pe);e[ae]=je.newValue,je.changedPath.length&&(a=je.changedPath),null===e[ae]&&(null!==Pe&&(a=n.concat(ae,"property removed")),delete e[ae])}}}for(var xe,Ne=0,Ae=Object.keys(d.constraint);Ne<Ae.length;Ne++)if(xe=Ae[Ne],(xe=d.constraint[xe])&&Object.prototype.hasOwnProperty.call(m,xe))for(var Ce,Se=i([].concat(m[xe]));!(Ce=Se()).done;){var ke,Te=Ce.value,Ee=void 0;try{Ee=_(Te.evaluation,xe===d.constraint.expression,{checkPropertyContent:P,model:m,modelName:u,type:xe,newDocument:e,oldDocument:t,parentNames:n,pathDescription:o})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&s('Compilation: Hook "'+xe+'" has invalid code "'+e.code+'": "'+e.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&s('Runtime: Hook "'+xe+'" has thrown an error with code "'+e.code+'": '+e.message+o+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(null==(ke=Ee)||!ke.result){var De=xe.replace(/^[^a-zA-Z]+/,"");s(De.charAt(0).toUpperCase()+(De.substring(1)+": ")+(Te.description?r(Function,Object.keys(Ee.scope).concat(["return "+Te.description.trim()])).apply(void 0,Object.values(Ee.scope)):'Model "'+u+'" should satisfy constraint "'+Ee.code+'" (given "'+D(e)+'")'+o+"."))}}if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var ze=e[d.attachment];("object"!=typeof ze||Object.getPrototypeOf(ze)!==Object.prototype)&&s("AttachmentType: given attachment has invalid type"+o+".");var Re=null;if(t&&Object.prototype.hasOwnProperty.call(t,d.attachment)&&(null!==(Re=t[d.attachment])&&"object"==typeof Re))for(var Me=0,Ue=Object.entries(Re);Me<Ue.length;Me++){var _e=Ue[Me],He=_e[0],Le=_e[1];if(Object.prototype.hasOwnProperty.call(ze,He)){var Ie=ze[He];null===Ie||null===Ie.data||Ie.content_type===Le.content_type&&(Ie.data===Le.data||Ie.digest===Le.digest)?((null===Ie||null===Ie.data)&&(a=n.concat(d.attachment,He,"attachment removed")),"incremental"===w&&delete ze[He]):a=n.concat(d.attachment,He,"attachment updated")}else"fillUp"===w?ze[He]=Le:w||(a=n.concat(d.attachment,He,"attachment removed"))}for(var We=0,Ve=Object.entries(ze);We<Ve.length;We++){var Fe=Ve[We],Be=Fe[0],$e=Fe[1];[null,void 0].includes($e)||null===$e.data?delete ze[Be]:(!Re||!Object.prototype.hasOwnProperty.call(Re,Be)||$e.content_type!==Re[Be].content_type||$e.data!==Re[Be].data&&$e.digest!==Re[Be].digest)&&(a=n.concat(d.attachment,Be,"attachment updated"))}0===Object.keys(ze).length&&delete e[d.attachment];for(var qe={},Ye=0,Je=Object.keys(m[d.attachment]);Ye<Je.length;Ye++)qe[Je[Ye]]=[];for(var Ge=0,Ke=Object.keys(ze);Ge<Ke.length;Ge++){for(var Ze=Ke[Ge],Qe=!1,Xe=0,et=Object.entries(m[d.attachment]);Xe<et.length;Xe++){var tt=et[Xe],rt=tt[0],nt=tt[1];if(M(rt,Ze,nt)){qe[rt].push(Ze),Qe=!0;break}}Qe||s('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(m[d.attachment]).join('", "')+'") matches given one ("'+Ze+'")'+o+".")}for(var ot=0,at=0,it=Object.keys(qe);at<it.length;at++){var lt=it[at],ct=m[d.attachment][lt];if(Object.prototype.hasOwnProperty.call(qe,lt)){var pt=qe[lt].length;null!==ct.maximumNumber&&pt>ct.maximumNumber&&s("AttachmentMaximum: given number of attachments ("+pt+") doesn't satisfy specified maximum of "+ct.maximumNumber+' from type "'+lt+'"'+o+"."),(!ct.nullable||0!==pt)&&pt<ct.minimumNumber&&s("AttachmentMinimum: given number of attachments ("+pt+") doesn't satisfy specified minimum of "+ct.minimumNumber+' from type "'+lt+'"'+o+".");for(var st,ut=0,mt=i(qe[lt]);!(st=mt()).done;){var yt,dt,ft=st.value;null!=(yt=ct.fileName)&&yt.regularExpressionPattern&&!new RegExp(ct.fileName.regularExpressionPattern).test(ft)?s('AttachmentName: given attachment name "'+ft+'" doesn\'t satisfy specified regular expression pattern "'+ct.fileName.regularExpressionPattern+'" from type "'+lt+'"'+o+"."):null!=(dt=ct.fileName)&&dt.invertedRegularExpressionPattern&&new RegExp(ct.fileName.invertedRegularExpressionPattern).test(ft)?s('InvertedAttachmentName: given attachment name "'+ft+'" does satisfy specified regular expression pattern "'+ct.fileName.invertedRegularExpressionPattern+'" from type "'+lt+'"'+o+"."):!([null,void 0].includes(ct.contentTypeRegularExpressionPattern)||ze[ft].content_type&&new RegExp(ct.contentTypeRegularExpressionPattern).test(ze[ft].content_type))&&s('AttachmentContentType: given attachment content type "'+ze[ft].content_type+'" doesn\'t satisfy specified regular expression pattern "'+ct.contentTypeRegularExpressionPattern+'" from type "'+lt+'"'+o+".");var ht=ct.invertedContentTypeRegularExpressionPattern;[null,void 0].includes(ht)||ze[ft].content_type&&!new RegExp(ht).test(ze[ft].content_type)||s('InvertedAttachmentContentType: given attachment content type "'+ze[ft].content_type+'" does satisfy specified regular expression pattern "'+ht+'" from type "'+lt+'"'+o+".");var gt=0;"length"in ze[ft]?gt=ze[ft].length:"data"in ze[ft]&&(gt=Buffer&&"byteLength"in Buffer?Buffer.byteLength(ze[ft].data,"base64"):ze[ft].data.length),![null,void 0].includes(ct.minimumSize)&&ct.minimumSize>gt?s("AttachmentMinimumSize: given attachment size "+gt+" byte doesn't satisfy specified minimum of "+ct.minimumSize+" byte "+o+"."):![null,void 0].includes(ct.maximumSize)&&ct.maximumSize<gt&&s("AttachmentMaximumSize: given attachment size "+gt+" byte doesn't satisfy specified maximum of "+ct.maximumSize+" byte "+o+"."),ut+=gt}![null,void 0].includes(ct.minimumAggregatedSize)&&ct.minimumAggregatedSize>ut?s('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+lt+'" '+ut+" byte doesn't satisfy specified minimum of "+ct.minimumAggregatedSize+" byte "+o+"."):![null,void 0].includes(ct.maximumAggregatedSize)&&ct.maximumAggregatedSize<ut&&s('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+lt+'" '+ut+" byte doesn't satisfy specified maximum of "+ct.maximumAggregatedSize+" byte "+o+"."),ot+=ut}}Object.prototype.hasOwnProperty.call(m,d.minimumAggregatedSize)&&![null,void 0].includes(m[d.minimumAggregatedSize])&&m[d.minimumAggregatedSize]>ot?s("AggregatedMinimumSize: given aggregated size "+ot+" byte doesn't satisfy specified minimum of "+m[d.minimumAggregatedSize]+" byte "+o+"."):![null,void 0].includes(m[d.maximumAggregatedSize])&&m[d.maximumAggregatedSize]<ot&&s("AggregatedMaximumSize: given aggregated size "+ot+" byte doesn't satisfy specified maximum of "+m[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===a.length&&t&&"migrate"===w)for(var vt,Ot=0,bt=Object.keys(t);Ot<bt.length;Ot++)vt=bt[Ot],Object.prototype.hasOwnProperty.call(e,vt)||(a=n.concat(vt,"migrate removed property"));return{changedPath:a,newDocument:e}},L={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,d.attachment)){var r=e[d.attachment],n=U(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:H,getFileNameByPrefix:U,serialize:D,id:v,revision:O,idName:f,revisionName:h,specialNames:d,typeName:g,modelConfiguration:l,models:c,now:u,nowUTCTimestamp:m,securitySettings:o,userContext:n},I=H(e,t);return(!I.newDocument._deleted||t)&&(I.newDocument._deleted&&I.newDocument._deleted!==(null==t?void 0:t._deleted)||I.changedPath.length)||s("NoChange: No new data given. new document: "+D(e)+"; old document: "+D(t)+"."),Object.prototype.hasOwnProperty.call(o,l.property.name.validatedDocumentsCache)?o[l.property.name.validatedDocumentsCache].add(v+"-"+O):o[l.property.name.validatedDocumentsCache]=new Set([v+"-"+O]),I.newDocument},e}();const p=c;module.exports=t})();
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("child_process")},e=>{"use strict";e.exports=require("clientnode")},e=>{"use strict";e.exports=require("pouchdb/node_modules/node-fetch/lib/index.js")},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{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__),child_process__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(5),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(6),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__);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 Helper=function(){function Helper(){}return Helper.getConnectorOptions=function(e){return e.couchdb.connector.fetch?{fetch:function(t,r){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(t,clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.couchdb.connector.fetch),r||{}))}}:{fetch:function(e,t){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(e,t)}}},Helper.mayStripRepresentation=function(e,t,r){var n=clientnode__WEBPACK_IMPORTED_MODULE_4___default().represent(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},Helper.ensureValidationDocumentPresence=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,n,a,o,c,i){var s,l,u;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===o&&(o=!0),void 0===c&&(c="_id"),void 0===i&&(i="_design/"),l=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(((s={})[c]=""+i+r,s.language="javascript",s),n),e.prev=4,e.next=7,t.get(""+i+r);case 7:return u=e.sent,l._rev=u._rev,e.next=11,t.put(l);case 11:case 20:e.next=26;break;case 14:return e.prev=14,e.t0=e.catch(4),o&&e.t0.error,e.prev=17,e.next=20,t.put(l);case 23:throw e.prev=23,e.t1=e.catch(17),new Error(a+" couldn't be installed/updated: \""+clientnode__WEBPACK_IMPORTED_MODULE_4___default().represent(e.t1)+'".');case 26:case"end":return e.stop()}}),e,null,[[4,14],[17,23]])})));return function(){return e.apply(this,arguments)}}(),Helper.initializeConnection=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,a,o,c,i,s;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(r.couchdb.url,r.couchdb.user.name+":"+r.couchdb.user.password+"@")+"/"+r.couchdb.databaseName,t.couchdb.connection=new t.couchdb.connector(n,Helper.getConnectorOptions(r)),t.couchdb.connection.setMaxListeners(1/0),a=r.couchdb.model.property.name.special.id,o=r.couchdb.model.property.name.special.revision,c=function(){var e=s.value,n=t.couchdb.connection[e].bind(t.couchdb.connection);t.couchdb.connection[e]=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var c,i,s,l,u,p=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,c=p.length,i=Array(1<c?c-1:0),s=1;s<c;s++)i[s-1]=p[s];return e.next=4,n.apply(void 0,[t].concat(i));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!(a in t&&r.couchdb.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(l=e.t0.message)&&l.startsWith("NoChange:"))){e.next=21;break}if(u={id:t[a],ok:!0},!(o in t)||["latest","upsert"].includes(t[o])){e.next=15;break}e.t1=t[o],e.next=19;break;case 15:return e.next=17,this.get(u.id);case 17:e.t2=o,e.t1=e.sent[e.t2];case 19:return u.rev=e.t1,e.abrupt("return",u);case 21:throw e.t0;case 22:case"end":return e.stop()}}),e,this,[[0,7]])})))},i=_createForOfIteratorHelperLoose(["post","put"]);!(s=i()).done;)c();return e.prev=7,e.next=10,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(n);case 10:e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(7),e.next=17,clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(n,{method:"PUT"});case 17:return e.abrupt("return",t);case 18:case"end":return e.stop()}}),e,null,[[7,12]])})));return function(){return e.apply(this,arguments)}}(),Helper.startServer=function(){function startServer(){return _startServer.apply(this,arguments)}var _startServer=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee4(services,configuration){var _this=this;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context4){for(;;)switch(_context4.prev=_context4.next){case 0:if(!Object.prototype.hasOwnProperty.call(services.couchdb.server.runner,"configurationFile")){_context4.next=12;break}return _context4.prev=1,_context4.next=4,fs__WEBPACK_IMPORTED_MODULE_6__.promises.mkdir(path__WEBPACK_IMPORTED_MODULE_7___default().dirname(services.couchdb.server.runner.configurationFile.path),{recursive:!0});case 4:_context4.next=10;break;case 6:if(_context4.prev=6,_context4.t0=_context4.catch(1),"EEXIST"===_context4.t0.code){_context4.next=10;break}throw _context4.t0;case 10:return _context4.next=12,fs__WEBPACK_IMPORTED_MODULE_6__.promises.writeFile(services.couchdb.server.runner.configurationFile.path,services.couchdb.server.runner.configurationFile.content,{encoding:configuration.core.encoding});case 12:return services.couchdb.server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_3__.spawn)("default"===configuration.couchdb.binary.memoryInMegaByte?services.couchdb.server.runner.binaryFilePath:configuration.couchdb.binary.nodePath,("default"===configuration.couchdb.binary.memoryInMegaByte?[]:["--max-old-space-size="+configuration.couchdb.binary.memoryInMegaByte,services.couchdb.server.runner.binaryFilePath]).concat(services.couchdb.server.runner.arguments?services.couchdb.server.runner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(services.couchdb.server.runner,"environment")?_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},eval("process").env,services.couchdb.server.runner.environment):eval("process").env,shell:!0,stdio:"inherit"}),new Promise((function(e,t){for(var r,n,a=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(r=a()).done;)n=r.value,services.couchdb.server.process.on(n,clientnode__WEBPACK_IMPORTED_MODULE_4___default().getProcessCloseHandler(e,t,{process:services.couchdb.server.process,reason:n}))})).then((function(e){var t,r;null!=(t=services.couchdb)&&null!=(r=t.server)&&r.resolve&&services.couchdb.server.resolve.call(_this,e)}),(function(e){var t,r;null!=(t=services.couchdb)&&null!=(r=t.server)&&r.resolve&&services.couchdb.server.reject.call(_this,e)})),_context4.next=16,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(configuration.couchdb.url,""),{wait:!0});case 16:case"end":return _context4.stop()}}),_callee4,null,[[1,6]])})));return startServer}(),Helper.restartServer=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,n,a){var o,c;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.couchdb.server.resolve,c=t.couchdb.server.reject,t.couchdb.server.resolve=t.couchdb.server.reject=clientnode__WEBPACK_IMPORTED_MODULE_4___default().noop,e.next=5,Helper.stopServer(t,r);case 5:return t.couchdb.server.resolve=o,t.couchdb.server.reject=c,e.next=9,Helper.startServer(t,r);case 9:return Helper.initializeConnection(t,r),e.next=12,a.callStack("restartCouchdb",n,r,t);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Helper.stopServer=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){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.couchdb.connection&&t.couchdb.connection.close(),t.couchdb.server.process&&t.couchdb.server.process.kill("SIGINT"),e.next=4,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkUnreachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(r.couchdb.url,""),{wait:!0});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Helper.determineAllowedModelRolesMapping=function(e){for(var t=e.property.name.special.allowedRoles,r={},n=Helper.extendModels(e),a=0,o=Object.entries(n);a<o.length;a++){var c=o[a],i=c[0],s=c[1];if(Object.prototype.hasOwnProperty.call(s,t)){r[i]=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({properties:{}},Helper.normalizeAllowedRoles(s[t]));for(var l=0,u=Object.entries(s);l<u.length;l++){var p=u[l],d=p[0],_=p[1];null!==_&&"object"==typeof _&&_.allowedRoles&&(r[i].properties[d]=Helper.normalizeAllowedRoles(_.allowedRoles))}}else r[i]={properties:{},read:[],write:[]}}return r},Helper.determineGenericIndexablePropertyNames=function(e,t){var r=e.property.name.special;return Object.keys(t).filter((function(n){return null!==t[n]&&"object"==typeof t[n]&&(Object.prototype.hasOwnProperty.call(t[n],"index")&&t[n].index||!(Object.prototype.hasOwnProperty.call(t[n],"index")&&!t[n].index||e.property.name.reserved.concat(r.additional,r.allowedRoles,r.attachment,r.conflict,r.constraint.execution,r.constraint.expression,r.deleted,r.deletedConflict,r.extend,r.id,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType,r.revision,r.revisions,r.revisionsInformation,r.type).includes(n)||t[n].type&&("string"==typeof t[n].type&&t[n].type.endsWith("[]")||Array.isArray(t[n].type)&&t[n].type.length&&Array.isArray(t[n].type[0])||Object.prototype.hasOwnProperty.call(e.entities,t[n].type))))})).concat(r.id,r.revision).sort()},Helper.extendModel=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,a,o=_createForOfIteratorHelperLoose([].concat(t[e][r]));!(n=o()).done;)a=n.value,t[e]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(Helper.extendModel(a,t,r)),t[e]);delete t[e][r]}return t[e]},Helper.extendModels=function(e){for(var t,r=e.property.name.special,n={},a=0,o=Object.keys(e.entities);a<o.length;a++){if(t=o[a],!new RegExp(e.property.name.typeRegularExpressionPattern.public).test(t)&&!new RegExp(e.property.name.typeRegularExpressionPattern.private).test(t))throw new Error('Model names have to match "'+e.property.name.typeRegularExpressionPattern.public+'" or "'+e.property.name.typeRegularExpressionPattern.private+'" for private one (given name: "'+t+'").');n[t]=Helper.extendModel(t,e.entities,r.extend)}for(var c,i=0,s=Object.values(n);i<s.length;i++){c=s[i];for(var l=0,u=Object.entries(c);l<u.length;l++){var p=u[l],d=p[0],_=p[1];if(d===r.attachment)for(var m=0,f=Object.entries(_);m<f.length;m++){var b=f[m],h=b[0],y=b[1];_[h]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),y)}else[r.allowedRoles,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(d)||(c[d]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),_))}}return n},Helper.normalizeAllowedRoles=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,r={read:[],write:[]},n=0,a=Object.keys(r);n<a.length;n++)t=a[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]}},Helper}();const __WEBPACK_DEFAULT_EXPORT__=Helper},e=>{!function(){"use strict";function t(){return(t=r()?Reflect.construct:function(e,t,r){var a=[null];a.push.apply(a,t);var o=new(Function.bind.apply(e,a));return r&&n(o,r.prototype),o}).apply(null,arguments)}function r(){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}}function n(e,t){return n=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n(e,t)}function a(){return a=Object.assign||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},a.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 c(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)?c(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 c(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 i={d:function(e,t){for(var r in t)i.o(t,r)&&!i.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})}},s={};i.r(s),i.d(s,{DatabaseHelper:function(){return l},default:function(){return u}});var l=function(){function e(){}return e.authenticate=function(e,t,r,n,a,c,i,s,l){var u;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===i&&(i="-type"),void 0===s&&(s="_design/"),void 0===l&&(l=!1);var p=null!==(u=e[i])&&void 0!==u?u:t&&t[i];if(!p)return!0;var d=l?"read":"write",_={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,c)&&e[c].startsWith(s)&&_.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&&p&&Object.prototype.hasOwnProperty.call(a,p)){for(var b,h,y=a[p],v=o(["read","write"]);!(b=v()).done;)_[h=b.value]=_[h].concat(y[h]||[]);_.properties=y.properties}for(var g,O,x=_[d],P=o(r.roles);!(g=P()).done;)if(O=g.value,x.includes(O))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 "+d+' action: "'+[].concat(_[d]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,r,n,c,i,s,l){void 0===s&&(s={});var u=function(e,t,r){var n;void 0===t&&(t="forbidden"),void 0===r&&(r={});for(var a=((n={})[t]=e,n.message=e,n.name=t,n),o=0,c=Object.entries(r);o<c.length;o++){var i=c[o],s=i[0],l=i[1];a[s]=l}throw a},p=new Date,d=Date.UTC(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate(),p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds(),p.getUTCMilliseconds())/1e3,_=!i.dateTimeFormat.startsWith("iso"),m=i.property.name.special,f=m.id,b=m.revision,h=m.type;r&&r[h]&&!e[h]&&(e[h]=r[h]);var y="",v="",g=function(){y=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",v=Object.prototype.hasOwnProperty.call(e,b)?e[b]:""};if(g(),Object.prototype.hasOwnProperty.call(c,i.property.name.validatedDocumentsCache)&&c[i.property.name.validatedDocumentsCache].has(y+"-"+v))return c[i.property.name.validatedDocumentsCache].delete(y+"-"+v),e;["latest","upsert"].includes(v)&&(r&&Object.prototype.hasOwnProperty.call(r,b)?v=e[b]=r[b]:"latest"===v?u("Revision: No old document available to update."):delete e[b]);var O=i.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(O=e[m.strategy],delete e[m.strategy]);var x,P={};if("migrate"===O)for(var w=0,E=Object.entries(s);w<E.length;w++){var k=E[w],D=k[0],j=k[1];if(Object.prototype.hasOwnProperty.call(j,m.oldType)&&![null,void 0].includes(j[m.oldType]))for(var M,A,C=o([].concat(j[m.oldType]));!(M=C()).done;)A=M.value,P[A]=D}l?x=l:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?x=function(e){return JSON.stringify(e,null,4)}:u('Needed "serializer" is not available.');var T=function(e){return e instanceof Error?""+e:x(e)},R=function(e){return"string"==typeof e?e.trim():""},I=function(e){if(_)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},S=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return new RegExp(r.fileName.regularExpressionPattern).test(t)}return e===t},U=function(t,r){if(r||(r=e[m.attachment]),t){for(var n,a=0,o=Object.keys(r);a<o.length;a++)if((n=o[a]).startsWith(t))return n}else{var c=Object.keys(r);if(c.length)return c[0]}return null},L=function(e,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var o=R(e);if(o){var c,i=(r?"return ":"")+o,s=a({},W,{code:i},n),l=Object.keys(s);try{c=t(Function,l.concat([i]))}catch(e){u(T(e),"compilation",{code:i,error:e,scope:s})}var p={code:i,result:void 0,scope:s};try{p.result=c.apply(void 0,l.map((function(e){return s[e]})))}catch(e){u(T(e),"runtime",{code:i,error:e,scope:s})}return p}u("No expression to evaluate provided.","empty")},N=function(e,r,n){void 0===n&&(n=[]);var a=n.length?" in "+n.join(" -> "):"",c=[],l=function(){Object.prototype.hasOwnProperty.call(e,h)||(r&&Object.prototype.hasOwnProperty.call(r,h)&&["fillUp","migrate"].includes(O)?e[h]=r[h]:u('Type: You have to specify a model type via property "'+h+'"'+a+".")),n.length||new RegExp(i.property.name.typeRegularExpressionPattern.public).test(e[h])||u('TypeName: You have to specify a model type which matches "'+i.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+e[h]+'")'+a+"."),Object.prototype.hasOwnProperty.call(s,e[h])||(Object.prototype.hasOwnProperty.call(P,e[h])?e[h]=P[e[h]]:u('Model: Given model "'+e[h]+'" is not specified'+a+"."))};l();var p=e[h],d=s[p],y=null;Object.prototype.hasOwnProperty.call(d,m.additional)&&d[m.additional]&&(y=d[m.additional]);var v=function c(i,s,l,_,m){void 0===m&&(m=["constraintExecution","constraintExpression"]);for(var f,b,h=o(m);!(f=h()).done;)if(b=f.value,Object.prototype.hasOwnProperty.call(l,b)){var y,v=void 0;try{v=L(l[b].evaluation,b.endsWith("Expression"),{checkPropertyContent:c,model:d,modelName:p,name:s,type:b,newDocument:e,newValue:i,oldDocument:r,oldValue:_,parentNames:n,pathDescription:a,propertySpecification:l})}catch(s){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(s)&&u('Compilation: Hook "'+b+'" has invalid code "'+s.code+'": "'+s.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(s)&&u('Runtime: Hook "'+b+'" has throw an error with code "'+s.code+'": "'+s.message+'"'+a+"."),!Object.prototype.hasOwnProperty.call(s,"empty"))throw s}if(null==(y=v)||!y.result){var g=R(l[b].description);u(b.charAt(0).toUpperCase()+(b.substring(1)+": ")+(g?t(Function,Object.keys(v.scope).concat(["return "+g])).apply(void 0,Object.values(v.scope)):'Property "'+s+'" should satisfy constraint "'+v.code+'" (given "'+T(i)+'")'+a+"."))}}},x=function(e,t,r,c){void 0===c&&(c=null);var i=[],l=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,h)&&1===l.length&&Object.prototype.hasOwnProperty.call(s,l[0])&&(e[h]=l[0]);for(var p,d,m=!1,b=o(l);!(p=b()).done;)if(d=p.value,Object.prototype.hasOwnProperty.call(s,d)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]!==d&&"migrate"===O&&1===l.length&&(e[h]=d,i=n.concat(t,"migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]===d){var y=N(e,c,n.concat(t));if(y.changedPath.length&&(i=y.changedPath),e=y.newDocument,T(e)===T({}))return{newValue:null,changedPath:i};m=!0;break}1===l.length&&u('NestedType: Under key "'+t+'" isn\'t of type "'+d+'" (given "'+T(e)+'" of type '+typeof e+")"+a+".")}else if("DateTime"===d){var g=e;if(e=I(e),!(_&&("number"!=typeof e||isNaN(e))||!_&&"string"!=typeof e)){m=!0;break}1===l.length&&u('PropertyType: Property "'+t+'" isn\'t of (valid) type "DateTime" (given "'+T(g).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof g+'")'+a+".")}else if(["boolean","integer","number","string"].includes(d)){if(!("number"==typeof e&&isNaN(e)||"integer"!==d&&typeof e!==d||"integer"===d&&parseInt(e,10)!==e)){m=!0;break}1===l.length&&u('PropertyType: Property "'+t+'" isn\'t of (valid) type "${type}" (given "'+T(e)+'" of type "'+typeof e+'")'+a+".")}else if("string"==typeof d&&d.startsWith("foreignKey:")){var x=s[d.substring(11)][f].type;if(x===typeof e){m=!0;break}1===l.length&&u('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+x+'" (given "'+T(e)+'" of type "'+typeof e+'")'+a+".")}else{if("any"===d||T(e)===T(d)){m=!0;break}1===l.length&&u('PropertyType: Property "'+t+'" isn\'t value "'+d+'" (given "'+T(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+a+".")}if(m||u('PropertyType: None of the specified types "'+l.join('", "')+'" for property "'+t+'" matches value "'+T(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+a+"."),"string"==typeof e&&(![null,void 0].includes(r.minimumLength)&&e.length<r.minimumLength&&u('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+a+"."),![null,void 0].includes(r.maximumLength)&&e.length>r.maximumLength&&u('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+a+".")),"number"==typeof e&&(![null,void 0].includes(r.minimum)&&e<r.minimum&&u('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+a+"."),![null,void 0].includes(r.maximum)&&e>r.maximum&&u('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(I)),P.includes(e)||u('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+P.join('", "')+'". But is "'+e+'"'+a+".")}return[null,void 0].includes(r.regularExpressionPattern)||new RegExp(r.regularExpressionPattern).test(e)?![null,void 0].includes(r.invertedRegularExpressionPattern)&&new RegExp(r.invertedRegularExpressionPattern).test(e)&&u('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+r.invertedRegularExpressionPattern+' (given "'+e+'")'+a+"."):u('PatternMatch: Property "'+t+'" should match regular expression pattern '+r.regularExpressionPattern+' (given "'+e+'")'+a+"."),v(e,t,r,c),T(e)!==T(c)&&(i=n.concat(t,"value updated")),{newValue:e,changedPath:i}},w=function(e,t,r,a,o){var s=t[a];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,a)&&T(s)===T(r[a]))return a!==f&&"incremental"===O&&delete t[a],!0;u('Readonly: Property "'+a+'" is not writable (old document "'+T(r)+'")'+o+".")}else u('Readonly: Property "'+a+'" is not writable'+o+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,a)){if(T(s)===T(r[a]))return"incremental"!==O||i.property.name.reserved.concat(m.deleted,f,b).includes(a)||delete t[a],!0;"migrate"!==O&&u('Immutable: Property "'+a+'" is not writable (old document "'+T(r)+'")'+o+".")}if(null===s){if(e.nullable)return delete t[a],r&&Object.prototype.hasOwnProperty.call(r,a)&&(c=n.concat(a,"delete property")),!0;u('NotNull: Property "'+a+'" should not be "null"'+o+".")}return!1},E=function(e,t,r,c){if(!r)for(var i,s,l=o(["onCreateExecution","onCreateExpression"]);!(i=l()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s)){var _=void 0;try{_=L(e[s],s.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,name:c,type:s,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:a,propertySpecification:e})}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&u('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&u('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}_&&![null,void 0].includes(_.result)&&(t[c]=_.result)}},k=function(e,t,r,c){if(Object.prototype.hasOwnProperty.call(t,c)){e.trim&&"string"==typeof t[c]&&(t[c]=t[c].trim()),e.emptyEqualsToNull&&(""===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,l=o(["onUpdateExecution","onUpdateExpression"]);!(i=l()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s))try{t[c]=L(e[s],s.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,name:c,type:s,newDocument:t,oldDocument:r,newValue:t[c],oldValue:r&&r[c],parentNames:n,pathDescription:a,propertySpecification:e}).result}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&u('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&u('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}}},D=Object.keys(d).filter((function(e){return![m.additional,m.allowedRoles,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].includes(e)}));if("migrate"===O)for(var j,M,A=o(D);!(j=A()).done;)if(M=j.value,![null,void 0].includes(d[M].oldName))for(var C,U,W=o([].concat(d[M].oldName));!(C=W()).done;)U=C.value,Object.prototype.hasOwnProperty.call(e,U)&&(e[M]=e[U],delete e[U]);if(!r)for(var B,K=0,q=[m.create.execution,m.create.expression];K<q.length;K++)if(B=q[K],Object.prototype.hasOwnProperty.call(d,B)){var z=void 0;try{z=L(d[B],B.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,type:B,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&u('Compilation: Hook "'+B+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&u('Runtime: Hook "'+B+'" 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(z)||(e=z),l(),p=e[h],0===n.length&&g()}for(var H,F=0,G=[m.update.execution,m.update.expression];F<G.length;F++)if(H=G[F],Object.prototype.hasOwnProperty.call(d,H)){var V=void 0;try{V=L(d[H],H.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,type:H,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&u('Compilation: Hook "'+H+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&u('Runtime: Hook "'+H+'" 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),l(),p=e[h],0===n.length&&g()}for(var J,$=function t(){var a=J.value;if(m.attachment===a)for(var i=function(){var i=l[s],u=i[0],p=i[1];Object.prototype.hasOwnProperty.call(e,a)&&null!==e[a]||(e[a]={}),r&&!Object.prototype.hasOwnProperty.call(r,a)&&(r[a]={});var d=Object.keys(e[a]).filter((function(t){return null!==e[a][t].data&&S(u,t,p)})),_=e[a],m=[];if(r){var f=r[a];m=Object.keys(f).filter((function(e){return!(Object.prototype.hasOwnProperty.call(_,e)&&Object.prototype.hasOwnProperty.call(_[e],"data")&&null===_[e].data)&&!!f[e]&&(Object.prototype.hasOwnProperty.call(f[e],"data")&&null!==f[e].data||f[e].stub&&!!f[e].digest)&&!!S(u,e,p)}))}for(var b,h,y=p,v=o(d);!(b=v()).done;)h=b.value,E(y,_,r&&r[a]?r[a]:null,h);for(var g,x,P=o(d);!(g=P()).done;)x=g.value,k(y,_,r&&r[a]?r[a]:null,x);if([null,void 0].includes(y.default)){if(y.nullable||0<d.length||0<m.length||t(),"fillUp"===O&&0===d.length&&0<m.length)for(var w,D,j=o(m);!(w=j()).done;)D=w.value,null===_[D]?c=n.concat(a,D,"file removed"):_[D]=r[a][D]}else if(0===d.length)if(0===m.length)for(var M in y.default)Object.prototype.hasOwnProperty.call(y.default,M)&&(_[M]=y.default[M],c=n.concat(a,u,"add default file"));else if("fillUp"===O)for(var A,C,T=o(m);!(A=T()).done;)C=A.value,_[C]=r[a][C]},s=0,l=Object.entries(d[a]);s<l.length;s++)i();else{var u=D.includes(a)?d[a]:y;E(u,e,r,a),k(u,e,r,a),[null,void 0].includes(u.default)?(!(u.nullable||Object.prototype.hasOwnProperty.call(e,a)||r&&Object.prototype.hasOwnProperty.call(r,a)&&O)&&t(),!Object.prototype.hasOwnProperty.call(e,a)&&r&&Object.prototype.hasOwnProperty.call(r,a)&&("fillUp"===O?e[a]=r[a]:!O&&(c=n.concat(a,"property removed")))):(!Object.prototype.hasOwnProperty.call(e,a)||null===e[a])&&(r&&Object.prototype.hasOwnProperty.call(r,a)?"fillUp"===O?e[a]=r[a]:"migrate"===O&&(e[a]=u.default,c=n.concat(a,"migrate default value")):(e[a]=u.default,c=c.concat(a,"add default value")))}},Y=o(D.concat(y?Object.keys(e).filter((function(e){return!D.includes(e)})):[]));!(J=Y()).done;)$();if(r&&"incremental"===O)for(var X=0,Z=Object.entries(e);X<Z.length;X++){var Q=Z[X],ee=Q[0],te=Q[1];!Object.prototype.hasOwnProperty.call(r,ee)||i.property.name.reserved.concat(f,b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,h).includes(ee)||r[ee]!==te&&T(r[ee])!==T(te)||delete e[ee]}for(var re=0,ne=Object.entries(e);re<ne.length;re++){var ae=ne[re],oe=ae[0],ce=ae[1];if(!i.property.name.reserved.concat(b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(oe)){var ie=void 0;if(Object.prototype.hasOwnProperty.call(d,oe))ie=d[oe];else if(y)ie=y;else{if("migrate"===O){delete e[oe],c=n.concat(oe,"migrate removed property");continue}u('Property: Given property "'+oe+'" isn\'t specified in model "'+p+'"'+a+".")}if(!ie)continue;if(m.attachment===oe){var se=ce;for(var le in se)if(Object.prototype.hasOwnProperty.call(se,le))for(var ue in d[oe])if(S(ue,le,d[oe][ue])){w(d[oe][ue],e,r,le,a);break}continue}if(w(ie,e,r,oe,a))continue;if("string"==typeof ie.type&&ie.type.endsWith("[]")||Array.isArray(ie.type)&&ie.type.length&&Array.isArray(ie.type[0])){var pe,de=ce;Array.isArray(de)?![null,void 0].includes(ie.minimumNumber)&&de.length<ie.minimumNumber?u('MinimumArrayLength: Property "'+oe+'" (array of length '+de.length+") doesn't fullfill minimum array length of "+ie.minimumNumber+a+"."):![null,void 0].includes(ie.maximumNumber)&&ie.maximumNumber<de.length&&u('MaximumArrayLength: Property "'+oe+'" (array of length '+de.length+") doesn't fullfill maximum array length of "+ie.maximumNumber+a+"."):u('PropertyType: Property "'+oe+'" isn\'t of type "array -> '+ie.type+'" (given "'+T(de)+'")'+a+"."),v(de,oe,ie,r&&Object.prototype.hasOwnProperty.call(r,oe)&&r[oe]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var _e={};for(var me in ie)Object.prototype.hasOwnProperty.call(ie,me)&&(_e[me]="type"===me?Array.isArray(ie[me])?ie[me][0]:[ie[me].substring(0,ie.type.length-2)]:ie[me]);if(1===(null==(pe=_e.type)?void 0:pe.length)&&Object.prototype.hasOwnProperty.call(s,_e.type[0]))for(var fe,be,he=o(de.slice());!(fe=he()).done;)"object"!=typeof(be=fe.value)||Object.getPrototypeOf(be)!==Object.prototype||Object.prototype.hasOwnProperty.call(be,h)||(be[h]=_e.type[0]);for(var ye,ve,ge=0,Oe=o(de.slice());!(ye=Oe()).done;)ve=ye.value,de[ge]=x(ve,ge+1+". value in "+oe,_e).newValue,null===ve&&de.splice(ge,1),ge+=1;r&&Object.prototype.hasOwnProperty.call(r,oe)&&Array.isArray(r[oe])&&r[oe].length===de.length&&T(r[oe])===T(de)||(c=n.concat(oe,"array updated"))}else{var xe=r&&Object.prototype.hasOwnProperty.call(r,oe)?r[oe]:null,Pe=x(ce,oe,ie,xe);e[oe]=Pe.newValue,Pe.changedPath.length&&(c=Pe.changedPath),null===e[oe]&&(null!==xe&&(c=n.concat(oe,"property removed")),delete e[oe])}}}for(var we,Ee=0,ke=Object.keys(m.constraint);Ee<ke.length;Ee++)if(we=ke[Ee],(we=m.constraint[we])&&Object.prototype.hasOwnProperty.call(d,we))for(var De,je=o([].concat(d[we]));!(De=je()).done;){var Me,Ae=De.value,Ce=void 0;try{Ce=L(Ae.evaluation,we===m.constraint.expression,{checkPropertyContent:x,model:d,modelName:p,type:we,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&u('Compilation: Hook "'+we+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&u('Runtime: Hook "'+we+'" has thrown an error with code "'+e.code+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(null==(Me=Ce)||!Me.result){var Te=we.replace(/^[^a-zA-Z]+/,"");u(Te.charAt(0).toUpperCase()+(Te.substring(1)+": ")+(Ae.description?t(Function,Object.keys(Ce.scope).concat(["return "+Ae.description.trim()])).apply(void 0,Object.values(Ce.scope)):'Model "'+p+'" should satisfy constraint "'+Ce.code+'" (given "'+T(e)+'")'+a+"."))}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var Re=e[m.attachment];("object"!=typeof Re||Object.getPrototypeOf(Re)!==Object.prototype)&&u("AttachmentType: given attachment has invalid type"+a+".");var Ie=null;if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&null!==(Ie=r[m.attachment])&&"object"==typeof Ie)for(var Se=0,Ue=Object.entries(Ie);Se<Ue.length;Se++){var Le=Ue[Se],Ne=Le[0],We=Le[1];if(Object.prototype.hasOwnProperty.call(Re,Ne)){var Be=Re[Ne];null===Be||null===Be.data||Be.content_type===We.content_type&&(Be.data===We.data||Be.digest===We.digest)?((null===Be||null===Be.data)&&(c=n.concat(m.attachment,Ne,"attachment removed")),"incremental"===O&&delete Re[Ne]):c=n.concat(m.attachment,Ne,"attachment updated")}else"fillUp"===O?Re[Ne]=We:O||(c=n.concat(m.attachment,Ne,"attachment removed"))}for(var Ke=0,qe=Object.entries(Re);Ke<qe.length;Ke++){var ze=qe[Ke],He=ze[0],Fe=ze[1];[null,void 0].includes(Fe)||null===Fe.data?delete Re[He]:(!Ie||!Object.prototype.hasOwnProperty.call(Ie,He)||Fe.content_type!==Ie[He].content_type||Fe.data!==Ie[He].data&&Fe.digest!==Ie[He].digest)&&(c=n.concat(m.attachment,He,"attachment updated"))}0===Object.keys(Re).length&&delete e[m.attachment];for(var Ge={},Ve=0,Je=Object.keys(d[m.attachment]);Ve<Je.length;Ve++)Ge[Je[Ve]]=[];for(var $e=0,Ye=Object.keys(Re);$e<Ye.length;$e++){for(var Xe=Ye[$e],Ze=!1,Qe=0,et=Object.entries(d[m.attachment]);Qe<et.length;Qe++){var tt=et[Qe],rt=tt[0],nt=tt[1];if(S(rt,Xe,nt)){Ge[rt].push(Xe),Ze=!0;break}}Ze||u('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(d[m.attachment]).join('", "')+'") matches given one ("'+Xe+'")'+a+".")}for(var at=0,ot=0,ct=Object.keys(Ge);ot<ct.length;ot++){var it=ct[ot],st=d[m.attachment][it];if(Object.prototype.hasOwnProperty.call(Ge,it)){var lt=Ge[it].length;null!==st.maximumNumber&&lt>st.maximumNumber&&u("AttachmentMaximum: given number of attachments ("+lt+") doesn't satisfy specified maximum of "+st.maximumNumber+' from type "'+it+'"'+a+"."),(!st.nullable||0!==lt)&&lt<st.minimumNumber&&u("AttachmentMinimum: given number of attachments ("+lt+") doesn't satisfy specified minimum of "+st.minimumNumber+' from type "'+it+'"'+a+".");for(var ut,pt=0,dt=o(Ge[it]);!(ut=dt()).done;){var _t,mt,ft=ut.value;null!=(_t=st.fileName)&&_t.regularExpressionPattern&&!new RegExp(st.fileName.regularExpressionPattern).test(ft)?u('AttachmentName: given attachment name "'+ft+'" doesn\'t satisfy specified regular expression pattern "'+st.fileName.regularExpressionPattern+'" from type "'+it+'"'+a+"."):null!=(mt=st.fileName)&&mt.invertedRegularExpressionPattern&&new RegExp(st.fileName.invertedRegularExpressionPattern).test(ft)?u('InvertedAttachmentName: given attachment name "'+ft+'" does satisfy specified regular expression pattern "'+st.fileName.invertedRegularExpressionPattern+'" from type "'+it+'"'+a+"."):!([null,void 0].includes(st.contentTypeRegularExpressionPattern)||Re[ft].content_type&&new RegExp(st.contentTypeRegularExpressionPattern).test(Re[ft].content_type))&&u('AttachmentContentType: given attachment content type "'+Re[ft].content_type+'" doesn\'t satisfy specified regular expression pattern "'+st.contentTypeRegularExpressionPattern+'" from type "'+it+'"'+a+".");var bt=st.invertedContentTypeRegularExpressionPattern;[null,void 0].includes(bt)||Re[ft].content_type&&!new RegExp(bt).test(Re[ft].content_type)||u('InvertedAttachmentContentType: given attachment content type "'+Re[ft].content_type+'" does satisfy specified regular expression pattern "'+bt+'" from type "'+it+'"'+a+".");var ht=0;"length"in Re[ft]?ht=Re[ft].length:"data"in Re[ft]&&(ht=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Re[ft].data,"base64"):Re[ft].data.length),![null,void 0].includes(st.minimumSize)&&st.minimumSize>ht?u("AttachmentMinimumSize: given attachment size "+ht+" byte doesn't satisfy specified minimum of "+st.minimumSize+" byte "+a+"."):![null,void 0].includes(st.maximumSize)&&st.maximumSize<ht&&u("AttachmentMaximumSize: given attachment size "+ht+" byte doesn't satisfy specified maximum of "+st.maximumSize+" byte "+a+"."),pt+=ht}![null,void 0].includes(st.minimumAggregatedSize)&&st.minimumAggregatedSize>pt?u('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+it+'" '+pt+" byte doesn't satisfy specified minimum of "+st.minimumAggregatedSize+" byte "+a+"."):![null,void 0].includes(st.maximumAggregatedSize)&&st.maximumAggregatedSize<pt&&u('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+it+'" '+pt+" byte doesn't satisfy specified maximum of "+st.maximumAggregatedSize+" byte "+a+"."),at+=pt}}Object.prototype.hasOwnProperty.call(d,m.minimumAggregatedSize)&&![null,void 0].includes(d[m.minimumAggregatedSize])&&d[m.minimumAggregatedSize]>at?u("AggregatedMinimumSize: given aggregated size "+at+" byte doesn't satisfy specified minimum of "+d[m.minimumAggregatedSize]+" byte "+a+"."):![null,void 0].includes(d[m.maximumAggregatedSize])&&d[m.maximumAggregatedSize]<at&&u("AggregatedMaximumSize: given aggregated size "+at+" byte doesn't satisfy specified maximum of "+d[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"===O)for(var yt,vt=0,gt=Object.keys(r);vt<gt.length;vt++)yt=gt[vt],Object.prototype.hasOwnProperty.call(e,yt)||(c=n.concat(yt,"migrate removed property"));return{changedPath:c,newDocument:e}},W={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var r=e[m.attachment],n=U(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:N,getFileNameByPrefix:U,serialize:T,id:y,revision:v,idName:f,revisionName:b,specialNames:m,typeName:h,modelConfiguration:i,models:s,now:p,nowUTCTimestamp:d,securitySettings:c,userContext:n},B=N(e,r);return(!B.newDocument._deleted||r)&&(B.newDocument._deleted&&B.newDocument._deleted!==(null==r?void 0:r._deleted)||B.changedPath.length)||u("NoChange: No new data given. new document: "+T(e)+"; old document: "+T(r)+"."),Object.prototype.hasOwnProperty.call(c,i.property.name.validatedDocumentsCache)?c[i.property.name.validatedDocumentsCache].add(y+"-"+v):c[i.property.name.validatedDocumentsCache]=new Set([y+"-"+v]),B.newDocument},e}(),u=l;e.exports=s}()}],__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:()=>y,default:()=>v});var e=__webpack_require__(1),t=__webpack_require__.n(e),r=__webpack_require__(2),n=__webpack_require__.n(r),a=__webpack_require__(4),o=__webpack_require__.n(a),c=__webpack_require__(6),i=__webpack_require__(7),s=__webpack_require__.n(i);const l=require("pouchdb");var u=__webpack_require__.n(l);const p=require("pouchdb-find");var d=__webpack_require__.n(p),_=__webpack_require__(9),m=__webpack_require__.n(_),f=__webpack_require__(8);function b(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 h(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)?h(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 h(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 y=function(){function e(){}return e.loadService=function(){var e=t()(n().mark((function e(t,r,i){var l,u,p,d,_,h,y,v,g,O,x,P,w,E,k,D,j,M,A,C,T,R,I,S,U,L,N,W,B,K,q,z,H,F,G,V,J,$,Y,X,Z,Q,ee,te,re,ne,ae,oe,ce,ie,se,le,ue,pe,de,_e,me,fe,be,he,ye,ve,ge,Oe,xe,Pe,we,Ee,ke,De,je,Me,Ae,Ce,Te,Re,Ie,Se,Ue,Le,Ne,We,Be,Ke,qe,ze,He,Fe,Ge,Ve,Je;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(l=null,!Object.prototype.hasOwnProperty.call(r.couchdb.server,"runner")){e.next=8;break}return e.next=4,f.default.startServer(r,i);case 4:r.couchdb.server.restart=f.default.restartServer,r.couchdb.server.start=f.default.startServer,r.couchdb.server.stop=f.default.stopServer,l=new Promise((function(e,t){r.couchdb.server.resolve=e,r.couchdb.server.reject=t}));case 8:if(!Object.prototype.hasOwnProperty.call(r.couchdb,"connection")){e.next=10;break}return e.abrupt("return",{name:"couchdb",promise:l});case 10:if(u=o().stringFormat(i.couchdb.url,i.couchdb.user.name+":"+i.couchdb.user.password+"@"),!i.couchdb.ensureAdminPresence){e.next=42;break}return p=new r.couchdb.connector(o().stringFormat(i.couchdb.url,"")+"/_users",f.default.getConnectorOptions(i)),e.prev=13,e.next=16,p.allDocs();case 16:return e.next=19,a.globalContext.fetch(o().stringFormat(i.couchdb.url,"")+"/"+r.couchdb.server.runner.adminUserConfigurationPath+"/"+i.couchdb.user.name,{body:'"'+i.couchdb.user.password+'"',method:"PUT"});case 19:e.next=39;break;case 21:if(e.prev=21,e.t0=e.catch(13),"unauthorized"!==e.t0.name){e.next=38;break}return d=new r.couchdb.connector(u+"/_users",f.default.getConnectorOptions(i)),e.prev=25,e.next=28,d.allDocs();case 28:e.next=33;break;case 30:e.prev=30,e.t1=e.catch(25);case 33:return e.prev=33,d.close(),e.finish(33);case 36:e.next=39;break;case 38:case 39:return e.prev=39,p.close(),e.finish(39);case 42:if(!i.couchdb.ensureUserPresence){e.next=77;break}_=0,h=[i.couchdb.security.admins,i.couchdb.security.members];case 44:if(!(_<h.length)){e.next=77;break}y=h[_],v=b(y.names);case 47:if((g=v()).done){e.next=74;break}return O=g.value,x=new r.couchdb.connector(u+"/_users",f.default.getConnectorOptions(i)),e.prev=50,e.next=53,x.get("org.couchdb.user:"+O);case 53:e.next=69;break;case 55:if(e.prev=55,e.t2=e.catch(50),"not_found"!==e.t2.error){e.next=68;break}return e.prev=58,e.next=61,x.put(((P={})[i.couchdb.model.property.name.special.id]="org.couchdb.user:"+O,P.name=O,P.password=O,P.roles=[].concat(y.roles.includes(O+"s")?O+"s":[]),P.type="user",P));case 61:e.next=66;break;case 63:throw e.prev=63,e.t3=e.catch(58),new Error("Couldn't create missing user \""+O+'": '+o().represent(e.t3));case 66:e.next=69;break;case 68:throw new Error("Couldn't check for presence of user \""+O+'": '+o().represent(e.t2));case 69:return e.prev=69,x.close(),e.finish(69);case 72:e.next=47;break;case 74:_++,e.next=44;break;case 77:if(!i.couchdb.model.updateConfiguration){e.next=132;break}w=b(i.couchdb.backend.prefixes);case 79:if((E=w()).done){e.next=132;break}k=E.value,e.t4=n().keys(i.couchdb.backend.configuration);case 82:if((e.t5=e.t4()).done){e.next=130;break}if(D=e.t5.value,!Object.prototype.hasOwnProperty.call(i.couchdb.backend.configuration,D)){e.next=128;break}return j="/"+k+(k.trim()?"/":"")+D,M=""+u+j,A=i.couchdb.backend.configuration[D],C=void 0,e.prev=89,e.next=92,a.globalContext.fetch(M);case 92:C=e.sent,e.next=98;break;case 95:e.prev=95,e.t6=e.catch(89);case 98:if(!C){e.next=128;break}if(!C.ok){e.next=127;break}if(T=!0,"function"!=typeof C.text){e.next=113;break}return e.prev=102,e.t7=A,e.next=106,C["string"==typeof A?"text":"json"]();case 106:e.t8=e.sent,T=e.t7===e.t8,e.next=113;break;case 110:e.prev=110,e.t9=e.catch(102);case 113:if(!T){e.next=124;break}return e.prev=114,e.next=117,a.globalContext.fetch(M,{body:'"'+i.couchdb.backend.configuration[D]+'"',method:"PUT"});case 117:e.next=122;break;case 119:e.prev=119,e.t10=e.catch(114);case 122:e.next=125;break;case 124:case 125:e.next=128;break;case 127:case 128:e.next=82;break;case 130:e.next=79;break;case 132:return e.next=134,f.default.initializeConnection(r,i);case 134:if(R=i.couchdb.model.property.name.special.id,I=i.couchdb.model.property.name.special.type,!i.couchdb.ensureSecuritySettingsPresence){e.next=145;break}return e.prev=137,e.next=140,a.globalContext.fetch(u+"/"+i.couchdb.databaseName+"/_security",{body:JSON.stringify(i.couchdb.security),method:"PUT"});case 140:e.next=145;break;case 142:e.prev=142,e.t11=e.catch(137);case 145:if(delete(S=o().copy(i.couchdb.model)).property.defaultSpecification,delete S.entities,U=f.default.extendModels(i.couchdb.model),!i.couchdb.model.updateValidation){e.next=213;break}return e.next=152,c.promises.readFile(a.currentRequire.resolve("./databaseHelper"),{encoding:i.core.encoding,flag:"r"});case 152:L=e.sent,N=b([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(S)+", "+JSON.stringify(U)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify(f.default.determineAllowedModelRolesMapping(i.couchdb.model))+", '"+R+"', '"+I+"', '"+i.couchdb.model.property.name.special.designDocumentNamePrefix+"'"}]);case 154:if((W=N()).done){e.next=169;break}B=W.value,K="function(...parameters) {\n return require('helper').default."+B.methodName+"(...parameters.concat(["+B.serializedParameter+"]))\n}",e.prev=157,new Function("return "+K),e.next=164;break;case 161:throw e.prev=161,e.t12=e.catch(157),new Error("Generated "+B.name+' code "'+K+"\" doesn't compile: "+o().represent(e.t12));case 164:return i.core.debug,e.next=167,f.default.ensureValidationDocumentPresence(r.couchdb.connection,B.name,{helper:L,validate_doc_update:K},B.description,!0,R,S.property.name.special.designDocumentNamePrefix);case 167:e.next=154;break;case 169:q=0,z=Object.entries(U);case 170:if(!(q<z.length)){e.next=213;break}H=z[q],F=H[0],G=H[1],V=0,J=Object.entries(G);case 173:if(!(V<J.length)){e.next=210;break}if($=J[V],Y=$[0],X=$[1],![S.property.name.special.constraint.execution,S.property.name.special.constraint.expression].includes(Y)){e.next=191;break}Z=b([].concat(X));case 177:if((Q=Z()).done){e.next=189;break}if(!(ee=Q.value).description){e.next=187;break}e.prev=180,new Function("return "+ee.description),e.next=187;break;case 184:throw e.prev=184,e.t13=e.catch(180),new Error('Specified constraint description "'+ee.description+'" for model "'+F+'" doesn\'t compile: "'+o().represent(e.t13)+'".');case 187:e.next=177;break;case 189:e.next=207;break;case 191:te=X,re=b(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 193:if((ne=re()).done){e.next=207;break}if(ae=ne.value,null===te||"object"!=typeof te){e.next=205;break}if(null==(oe=te[ae])||!oe.description){e.next=205;break}e.prev=198,new Function(oe.description),e.next=205;break;case 202:throw e.prev=202,e.t14=e.catch(198),new Error('Specified constraint description "'+oe.description+'" for model "'+F+'" in property "'+Y+'" as "'+ae+'" doesn\'t compile: "'+o().represent(e.t14)+'".');case 205:e.next=193;break;case 207:V++,e.next=173;break;case 210:q++,e.next=170;break;case 213:if(!i.couchdb.model.autoMigrationPath){e.next=305;break}return ce={},e.next=217,o().isDirectory(s().resolve(i.couchdb.model.autoMigrationPath));case 217:if(!e.sent){e.next=257;break}return e.t15=b,e.next=221,o().walkDirectoryRecursively(s().resolve(i.couchdb.model.autoMigrationPath),i.couchdb.debug?o().noop:function(e){return"debug"!==e.name});case 221:e.t16=e.sent,ie=(0,e.t15)(e.t16);case 223:if((se=ie()).done){e.next=257;break}if(le=se.value,ue=s().extname(le.name),pe=s().basename(le.name,ue),".json"!==ue){e.next=254;break}return de=void 0,e.prev=229,e.t17=JSON,e.next=233,c.promises.readFile(le.path,{encoding:i.core.encoding,flag:"r"});case 233:e.t18=e.sent,de=e.t17.parse.call(e.t17,e.t18),e.next=240;break;case 237:throw e.prev=237,e.t19=e.catch(229),new Error('Parsing document "'+le.path+'" to include by automigration of has failed: '+o().represent(e.t19));case 240:return de[R]=pe,de[i.couchdb.model.property.name.special.revision]="upsert",e.prev=242,e.next=245,r.couchdb.connection.put(de);case 245:e.next=251;break;case 247:throw e.prev=247,e.t20=e.catch(242),null!=(_e=e.t20.forbidden)&&_e.startsWith("NoChange:"),new Error('Migrating document "'+de[R]+'" of type "'+de[I]+'" has failed: '+o().represent(e.t20));case 251:e.next=255;break;case 254:".js"===s().extname(le.name)&&(ce[le.path]=(0,a.currentRequire)(le.path).default);case 255:e.next=223;break;case 257:return e.t21=b,e.next=260,r.couchdb.connection.allDocs({include_docs:!0});case 260:e.t22=e.sent.rows,me=(0,e.t21)(e.t22);case 262:if((fe=me()).done){e.next=305;break}if("string"==typeof(be=fe.value).id&&be.id.startsWith(i.couchdb.model.property.name.special.designDocumentNamePrefix)){e.next=303;break}he=be.doc,(ye=o().copy(he))[i.couchdb.model.property.name.special.strategy]="migrate",ve=b(Object.keys(ce).sort());case 269:if((ge=ve()).done){e.next=282;break}Oe=ge.value,xe=null,e.prev=272,xe=ce[Oe](ye,{configuration:i,databaseHelper:m(),idName:R,migrater:ce,models:U,modelConfiguration:S,selfFilePath:Oe,services:r,tools:o(),typeName:I}),e.next=279;break;case 276:throw e.prev=276,e.t23=e.catch(272),new Error('Running migrater "'+Oe+'" in document '+f.default.mayStripRepresentation(he,i.couchdb.maximumRepresentationTryLength,i.couchdb.maximumRepresentationLength)+'" failed: '+o().represent(e.t23));case 279:xe&&(ye=xe);case 280:e.next=269;break;case 282:e.prev=282,m().validateDocumentUpdate(o().copy(ye),o().copy(he),{db:i.couchdb.databaseName,name:i.couchdb.user.name,roles:["_admin"]},o().copy(i.couchdb.security),S,U),e.next=294;break;case 286:if(e.prev=286,e.t24=e.catch(282),!Object.prototype.hasOwnProperty.call(e.t24,"forbidden")){e.next=293;break}return e.t24.forbidden.startsWith("NoChange:"),e.abrupt("continue",303);case 293:throw e.t24;case 294:return e.prev=294,e.next=297,r.couchdb.connection.put(ye);case 297:e.next=302;break;case 299:throw e.prev=299,e.t25=e.catch(294),new Error('Replaceing auto migrated document "'+ye[R]+'" has failed: '+o().represent(e.t25));case 302:case 303:e.next=262;break;case 305:if(!i.couchdb.createGenericFlatIndex||!i.couchdb.model.autoMigrationPath){e.next=360;break}return e.next=308,r.couchdb.connection.getIndexes();case 308:Pe=e.sent.indexes,we=0,Ee=Object.entries(U);case 310:if(!(we<Ee.length)){e.next=341;break}if(ke=Ee[we],De=ke[0],je=ke[1],!new RegExp(i.couchdb.model.property.name.typeRegularExpressionPattern.public).test(De)){e.next=338;break}return e.next=315,r.couchdb.connection.createIndex({index:{ddoc:De+"-GenericIndex",fields:[I],name:De+"-GenericIndex"}});case 315:Me=b(f.default.determineGenericIndexablePropertyNames(i.couchdb.model,je));case 316:if((Ae=Me()).done){e.next=338;break}Ce=Ae.value,Te=De+"-"+Ce+"-GenericIndex",Re=-1,Ie=0,Se=b(Pe);case 322:if((Ue=Se()).done){e.next=330;break}if(Ue.value.name!==Te){e.next=327;break}return Re=Ie,e.abrupt("break",330);case 327:Ie+=1;case 328:e.next=322;break;case 330:if(-1!==Re){e.next=335;break}return e.next=333,r.couchdb.connection.createIndex({index:{ddoc:Te,fields:[I,Ce],name:Te}});case 333:e.next=336;break;case 335:Pe.slice(Ie,1);case 336:e.next=316;break;case 338:we++,e.next=310;break;case 341:Le=b(Pe);case 342:if((Ne=Le()).done){e.next=360;break}if(!(We=Ne.value).name.endsWith("-GenericIndex")){e.next=358;break}Be=!1,Ke=0,qe=Object.entries(U);case 347:if(!(Ke<qe.length)){e.next=355;break}if(ze=qe[Ke],He=ze[0],Fe=ze[1],!We.name.startsWith(He+"-")){e.next=352;break}for(Ge=b(f.default.determineGenericIndexablePropertyNames(i.couchdb.model,Fe));!(Ve=Ge()).done;)Je=Ve.value,[He+"-"+Je+"-GenericIndex",He+"-GenericIndex"].includes(We.name)&&(Be=!0);return e.abrupt("break",355);case 352:Ke++,e.next=347;break;case 355:if(Be){e.next=358;break}return e.next=358,r.couchdb.connection.deleteIndex(We);case 358:e.next=342;break;case 360:if(!i.couchdb.model.triggerInitialCompaction){e.next=369;break}return e.prev=361,e.next=364,r.couchdb.connection.compact();case 364:e.next=369;break;case 366:e.prev=366,e.t26=e.catch(361);case 369:return e.abrupt("return",{name:"couchdb",promise:l});case 370:case"end":return e.stop()}}),e,null,[[13,21,39,42],[25,30,33,36],[50,55,69,72],[58,63],[89,95],[102,110],[114,119],[137,142],[157,161],[180,184],[198,202],[229,237],[242,247],[272,276],[282,286],[294,299],[361,366]])})));return function(){return e.apply(this,arguments)}}(),e.postLoadService=function(r,a,c,i,s){var l=0;setInterval((function(){0<l&&(l=0)}),3e4);var u=o().debounce(t()(n().mark((function r(){return n().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return e.changesStream&&e.changesStream.cancel(),e.changesStream=a.couchdb.connection.changes(o().extend(!0,o().copy(c.couchdb.changesStream),e.additionalChangesStreamOptions)),e.changesStream.on("error",t()(n().mark((function t(){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(3<(l+=1))){t.next=9;break}return l=0,e.changesStream.cancel(),t.next=7,a.couchdb.server.restart(a,c,i,s);case 7:t.next=10;break;case 9:case 10:u();case 11:case"end":return t.stop()}}),t)})))),r.next=5,s.callStack("couchdbInitializeChangesStream",i,c,e.changesStream,a);case 5:case"end":return r.stop()}}),r)}))));return c.couchdb.attachAutoRestarter&&u(),r},e.preLoadService=function(){var r=t()(n().mark((function r(a,c){var i,l,p,_,m,f,h,y,v,g,O,x,P,w;return n().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Object.prototype.hasOwnProperty.call(a,"couchdb")||(a.couchdb={}),Object.prototype.hasOwnProperty.call(a.couchdb,"connector")||(i=c.couchdb.model.property.name.special.id,l=c.couchdb.model.property.name.special.revision,a.couchdb.connector=u(),p=a.couchdb.connector.prototype.bulkDocs.bind(a.couchdb.connection),a.couchdb.connector.plugin({bulkDocs:function(){var r=t()(n().mark((function t(r){var a,o,s,u,d,_,m,f,h,y,v,g,O,x,P,w,E,k,D=arguments;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(o=D.length,s=Array(1<o?o-1:0),u=1;u<o;u++)s[u-1]=D[u];return d=0<s.length&&s[s.length-1]===e.toggleIDDetermining,_=d?!e.skipIDDetermining:e.skipIDDetermining,d&&s.pop(),m=!Array.isArray(r)&&null!==r&&"object"==typeof r&&i in r?[r]:r,null!=(a=c.couchdb.connector.fetch)&&a.timeout&&(0===s.length||"object"!=typeof s[0])&&s.unshift({timeout:c.couchdb.connector.fetch.timeout}),t.next=8,p.call.apply(p,[this,m].concat(s));case 8:f=t.sent,h=[],y=[],v=0,g=b(f);case 13:if((O=g()).done){t.next=36;break}if(x=O.value,"object"!=typeof m[v]){t.next=33;break}if(!(l in m[v])||"conflict"!==x.name||!["latest","upsert"].includes(m[v][l])){t.next=21;break}y.push(m[v]),h.push(v),t.next=33;break;case 21:if(!(i in m[v]&&c.couchdb.ignoreNoChangeError&&"name"in x&&"forbidden"===x.name&&"message"in x&&x.message.startsWith("NoChange:"))){t.next=33;break}if(f[v]={id:m[v][i],ok:!0},_){t.next=33;break}if(!(l in m[v])||["latest","upsert"].includes(m[v][l])){t.next=28;break}t.t0=m[v][l],t.next=32;break;case 28:return t.next=30,this.get(f[v].id);case 30:t.t1=l,t.t0=t.sent[t.t1];case 32:f[v].rev=t.t0;case 33:v+=1;case 34:t.next=13;break;case 36:if(!y.length){t.next=43;break}return m=y,d&&s.push(e.toggleIDDetermining),t.next=41,this.bulkDocs.apply(this,[m].concat(s));case 41:for(P=t.sent,w=b(P);!(E=w()).done;)k=E.value,f[h.shift()]=k;case 43:return t.abrupt("return",f);case 44:case"end":return t.stop()}}),t,this)})));return function(){return r.apply(this,arguments)}}()}),c.couchdb.debug&&a.couchdb.connector.debug.enable("*"),a.couchdb.connector=a.couchdb.connector.plugin(d())),Object.prototype.hasOwnProperty.call(a.couchdb,"server")){r.next=34;break}a.couchdb.server={},_=[],m=b([].concat(c.couchdb.binary.runner));case 6:if((f=m()).done){r.next=32;break}h=f.value,y=b([].concat(h.location));case 9:if((v=y()).done){r.next=28;break}g=v.value,O=b([].concat(h.name));case 12:if((x=O()).done){r.next=24;break}return P=x.value,w=s().resolve(g,P),_.push(w),r.next=18,o().isFile(w);case 18:if(!r.sent){r.next=22;break}return h.binaryFilePath=w,a.couchdb.server.runner=h,r.abrupt("break",24);case 22:r.next=12;break;case 24:if(!Object.prototype.hasOwnProperty.call(a.couchdb.server,"runner")){r.next=26;break}return r.abrupt("break",28);case 26:r.next=9;break;case 28:if(!Object.prototype.hasOwnProperty.call(a.couchdb.server,"runner")){r.next=30;break}return r.abrupt("break",32);case 30:r.next=6;break;case 32:if(Object.prototype.hasOwnProperty.call(a.couchdb.server,"runner")){r.next=34;break}throw new Error('No binary file in one of the following locations found: "'+_.join('", "')+'".');case 34:return r.abrupt("return",a);case 35:case"end":return r.stop()}}),r)})));return function(){return r.apply(this,arguments)}}(),e.shouldExit=function(){var e=t()(n().mark((function e(t,r){var a;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f.default.stopServer(t,r);case 2:return delete t.couchdb,a="log.txt",e.next=6,o().isFile(a);case 6:if(!e.sent){e.next=9;break}return e.next=9,c.promises.unlink(a);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),e}();y.additionalChangesStreamOptions={},y.changesStream=void 0,y.skipIDDetermining=!0,y.toggleIDDetermining=Symbol("toggleIDDetermining");const v=y})(),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("child_process")},e=>{"use strict";e.exports=require("clientnode")},e=>{"use strict";e.exports=require("pouchdb/node_modules/node-fetch/lib/index.js")},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{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__),child_process__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(5),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(6),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__);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 Helper=function(){function Helper(){}return Helper.getConnectorOptions=function(e){return e.couchdb.connector.fetch?{fetch:function(t,r){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(t,clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.couchdb.connector.fetch),r||{}))}}:{fetch:function(e,t){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(e,t)}}},Helper.mayStripRepresentation=function(e,t,r){var n=clientnode__WEBPACK_IMPORTED_MODULE_4___default().represent(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},Helper.ensureValidationDocumentPresence=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,n,a,o,c,i){var s,l,u;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===o&&(o=!0),void 0===c&&(c="_id"),void 0===i&&(i="_design/"),l=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(((s={})[c]=""+i+r,s.language="javascript",s),n),e.prev=4,e.next=7,t.get(""+i+r);case 7:return u=e.sent,l._rev=u._rev,e.next=11,t.put(l);case 11:case 20:e.next=26;break;case 14:return e.prev=14,e.t0=e.catch(4),o&&e.t0.error,e.prev=17,e.next=20,t.put(l);case 23:throw e.prev=23,e.t1=e.catch(17),new Error(a+" couldn't be installed/updated: \""+clientnode__WEBPACK_IMPORTED_MODULE_4___default().represent(e.t1)+'".');case 26:case"end":return e.stop()}}),e,null,[[4,14],[17,23]])})));return function(){return e.apply(this,arguments)}}(),Helper.initializeConnection=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,a,o,c,i,s;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(n=clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(r.couchdb.url,r.couchdb.user.name+":"+r.couchdb.user.password+"@")+"/"+r.couchdb.databaseName,t.couchdb.connection=new t.couchdb.connector(n,Helper.getConnectorOptions(r)),t.couchdb.connection.setMaxListeners(1/0),a=r.couchdb.model.property.name.special.id,o=r.couchdb.model.property.name.special.revision,c=function(){var e=s.value,n=t.couchdb.connection[e].bind(t.couchdb.connection);t.couchdb.connection[e]=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var c,i,s,l,u,p=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(e.prev=0,c=p.length,i=Array(1<c?c-1:0),s=1;s<c;s++)i[s-1]=p[s];return e.next=4,n.apply(void 0,[t].concat(i));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!(a in t&&r.couchdb.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(l=e.t0.message)&&l.startsWith("NoChange:"))){e.next=21;break}if(u={id:t[a],ok:!0},!(o in t)||["latest","upsert"].includes(t[o])){e.next=15;break}e.t1=t[o],e.next=19;break;case 15:return e.next=17,this.get(u.id);case 17:e.t2=o,e.t1=e.sent[e.t2];case 19:return u.rev=e.t1,e.abrupt("return",u);case 21:throw e.t0;case 22:case"end":return e.stop()}}),e,this,[[0,7]])})))},i=_createForOfIteratorHelperLoose(["post","put"]);!(s=i()).done;)c();return e.prev=7,e.next=10,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(n);case 10:e.next=17;break;case 12:return e.prev=12,e.t0=e.catch(7),e.next=17,clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(n,{method:"PUT"});case 17:return e.abrupt("return",t);case 18:case"end":return e.stop()}}),e,null,[[7,12]])})));return function(){return e.apply(this,arguments)}}(),Helper.startServer=function(){function startServer(){return _startServer.apply(this,arguments)}var _startServer=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee4(services,configuration){var _this=this;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context4){for(;;)switch(_context4.prev=_context4.next){case 0:if(!Object.prototype.hasOwnProperty.call(services.couchdb.server.runner,"configurationFile")){_context4.next=12;break}return _context4.prev=1,_context4.next=4,fs__WEBPACK_IMPORTED_MODULE_6__.promises.mkdir(path__WEBPACK_IMPORTED_MODULE_7___default().dirname(services.couchdb.server.runner.configurationFile.path),{recursive:!0});case 4:_context4.next=10;break;case 6:if(_context4.prev=6,_context4.t0=_context4.catch(1),"EEXIST"===_context4.t0.code){_context4.next=10;break}throw _context4.t0;case 10:return _context4.next=12,fs__WEBPACK_IMPORTED_MODULE_6__.promises.writeFile(services.couchdb.server.runner.configurationFile.path,services.couchdb.server.runner.configurationFile.content,{encoding:configuration.core.encoding});case 12:return services.couchdb.server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_3__.spawn)("default"===configuration.couchdb.binary.memoryInMegaByte?services.couchdb.server.runner.binaryFilePath:configuration.couchdb.binary.nodePath,("default"===configuration.couchdb.binary.memoryInMegaByte?[]:["--max-old-space-size="+configuration.couchdb.binary.memoryInMegaByte,services.couchdb.server.runner.binaryFilePath]).concat(services.couchdb.server.runner.arguments?services.couchdb.server.runner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(services.couchdb.server.runner,"environment")?_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},eval("process").env,services.couchdb.server.runner.environment):eval("process").env,shell:!0,stdio:"inherit"}),new Promise((function(e,t){for(var r,n,a=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(r=a()).done;)n=r.value,services.couchdb.server.process.on(n,clientnode__WEBPACK_IMPORTED_MODULE_4___default().getProcessCloseHandler(e,t,{process:services.couchdb.server.process,reason:n}))})).then((function(e){var t,r;null!=(t=services.couchdb)&&null!=(r=t.server)&&r.resolve&&services.couchdb.server.resolve.call(_this,e)}),(function(e){var t,r;null!=(t=services.couchdb)&&null!=(r=t.server)&&r.resolve&&services.couchdb.server.reject.call(_this,e)})),_context4.next=16,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(configuration.couchdb.url,""),{wait:!0});case 16:case"end":return _context4.stop()}}),_callee4,null,[[1,6]])})));return startServer}(),Helper.restartServer=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,n,a){var o,c;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t.couchdb.server.resolve,c=t.couchdb.server.reject,t.couchdb.server.resolve=t.couchdb.server.reject=clientnode__WEBPACK_IMPORTED_MODULE_4___default().noop,e.next=5,Helper.stopServer(t,r);case 5:return t.couchdb.server.resolve=o,t.couchdb.server.reject=c,e.next=9,Helper.startServer(t,r);case 9:return Helper.initializeConnection(t,r),e.next=12,a.callStack("restartCouchdb",n,r,t);case 12:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Helper.stopServer=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){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.couchdb.connection&&t.couchdb.connection.close(),t.couchdb.server.process&&t.couchdb.server.process.kill("SIGINT"),e.next=4,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkUnreachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(r.couchdb.url,""),{wait:!0});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Helper.determineAllowedModelRolesMapping=function(e){for(var t=e.property.name.special.allowedRoles,r={},n=Helper.extendModels(e),a=0,o=Object.entries(n);a<o.length;a++){var c=o[a],i=c[0],s=c[1];if(Object.prototype.hasOwnProperty.call(s,t)){r[i]=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({properties:{}},Helper.normalizeAllowedRoles(s[t]));for(var l=0,u=Object.entries(s);l<u.length;l++){var p=u[l],d=p[0],_=p[1];null!==_&&"object"==typeof _&&_.allowedRoles&&(r[i].properties[d]=Helper.normalizeAllowedRoles(_.allowedRoles))}}else r[i]={properties:{},read:[],write:[]}}return r},Helper.determineGenericIndexablePropertyNames=function(e,t){var r=e.property.name.special;return Object.keys(t).filter((function(n){return null!==t[n]&&"object"==typeof t[n]&&(Object.prototype.hasOwnProperty.call(t[n],"index")&&t[n].index||!(Object.prototype.hasOwnProperty.call(t[n],"index")&&!t[n].index||e.property.name.reserved.concat(r.additional,r.allowedRoles,r.attachment,r.conflict,r.constraint.execution,r.constraint.expression,r.deleted,r.deletedConflict,r.extend,r.id,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType,r.revision,r.revisions,r.revisionsInformation,r.type).includes(n)||t[n].type&&("string"==typeof t[n].type&&t[n].type.endsWith("[]")||Array.isArray(t[n].type)&&t[n].type.length&&Array.isArray(t[n].type[0])||Object.prototype.hasOwnProperty.call(e.entities,t[n].type))))})).concat(r.id,r.revision).sort()},Helper.extendModel=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,a,o=_createForOfIteratorHelperLoose([].concat(t[e][r]));!(n=o()).done;)a=n.value,t[e]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(Helper.extendModel(a,t,r)),t[e]);delete t[e][r]}return t[e]},Helper.extendModels=function(e){for(var t,r=e.property.name.special,n={},a=0,o=Object.keys(e.entities);a<o.length;a++){if(t=o[a],!new RegExp(e.property.name.typeRegularExpressionPattern.public).test(t)&&!new RegExp(e.property.name.typeRegularExpressionPattern.private).test(t))throw new Error('Model names have to match "'+e.property.name.typeRegularExpressionPattern.public+'" or "'+e.property.name.typeRegularExpressionPattern.private+'" for private one (given name: "'+t+'").');n[t]=Helper.extendModel(t,e.entities,r.extend)}for(var c,i=0,s=Object.values(n);i<s.length;i++){c=s[i];for(var l=0,u=Object.entries(c);l<u.length;l++){var p=u[l],d=p[0],_=p[1];if(d===r.attachment)for(var m=0,f=Object.entries(_);m<f.length;m++){var b=f[m],h=b[0],y=b[1];_[h]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),y)}else[r.allowedRoles,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(d)||(c[d]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),_))}}return n},Helper.normalizeAllowedRoles=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,r={read:[],write:[]},n=0,a=Object.keys(r);n<a.length;n++)t=a[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]}},Helper}();const __WEBPACK_DEFAULT_EXPORT__=Helper},e=>{!function(){"use strict";function t(){return(t=r()?Reflect.construct.bind():function(e,t,r){var a=[null];a.push.apply(a,t);var o=new(Function.bind.apply(e,a));return r&&n(o,r.prototype),o}).apply(null,arguments)}function r(){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}}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function a(){return a=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},a.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 c(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)?c(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 c(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 i={d:function(e,t){for(var r in t)i.o(t,r)&&!i.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})}},s={};i.r(s),i.d(s,{DatabaseHelper:function(){return l},default:function(){return u}});var l=function(){function e(){}return e.authenticate=function(e,t,r,n,a,c,i,s,l){var u;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===i&&(i="-type"),void 0===s&&(s="_design/"),void 0===l&&(l=!1);var p=null!==(u=e[i])&&void 0!==u?u:t&&t[i];if(!p)return!0;var d=l?"read":"write",_={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,c)&&e[c].startsWith(s)&&_.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&&p&&Object.prototype.hasOwnProperty.call(a,p)){for(var b,h,y=a[p],v=o(["read","write"]);!(b=v()).done;)_[h=b.value]=_[h].concat(y[h]||[]);_.properties=y.properties}for(var g,O,x=_[d],P=o(r.roles);!(g=P()).done;)if(O=g.value,x.includes(O))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 "+d+' action: "'+[].concat(_[d]).join('", "')+'". '+f+"."}},e.validateDocumentUpdate=function(e,r,n,c,i,s,l){void 0===s&&(s={});var u=function(e,t,r){var n;void 0===t&&(t="forbidden"),void 0===r&&(r={});for(var a=((n={})[t]=e,n.message=e,n.name=t,n),o=0,c=Object.entries(r);o<c.length;o++){var i=c[o],s=i[0],l=i[1];a[s]=l}throw a},p=new Date,d=Date.UTC(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate(),p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds(),p.getUTCMilliseconds())/1e3,_=!i.dateTimeFormat.startsWith("iso"),m=i.property.name.special,f=m.id,b=m.revision,h=m.type;r&&r[h]&&!e[h]&&(e[h]=r[h]);var y="",v="",g=function(){y=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",v=Object.prototype.hasOwnProperty.call(e,b)?e[b]:""};if(g(),Object.prototype.hasOwnProperty.call(c,i.property.name.validatedDocumentsCache)&&c[i.property.name.validatedDocumentsCache].has(y+"-"+v))return c[i.property.name.validatedDocumentsCache].delete(y+"-"+v),e;["latest","upsert"].includes(v)&&(r&&Object.prototype.hasOwnProperty.call(r,b)?v=e[b]=r[b]:"latest"===v?u("Revision: No old document available to update."):delete e[b]);var O=i.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(O=e[m.strategy],delete e[m.strategy]);var x,P={};if("migrate"===O)for(var w=0,E=Object.entries(s);w<E.length;w++){var k=E[w],D=k[0],j=k[1];if(Object.prototype.hasOwnProperty.call(j,m.oldType)&&![null,void 0].includes(j[m.oldType]))for(var M,A,C=o([].concat(j[m.oldType]));!(M=C()).done;)A=M.value,P[A]=D}l?x=l:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?x=function(e){return JSON.stringify(e,null,4)}:u('Needed "serializer" is not available.');var T=function(e){return e instanceof Error?""+e:x(e)},R=function(e){return"string"==typeof e?e.trim():""},I=function(e){if(_)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},S=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.regularExpressionPattern)return new RegExp(r.fileName.regularExpressionPattern).test(t)}return e===t},U=function(t,r){if(r||(r=e[m.attachment]),t){for(var n,a=0,o=Object.keys(r);a<o.length;a++)if((n=o[a]).startsWith(t))return n}else{var c=Object.keys(r);if(c.length)return c[0]}return null},L=function(e,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var o=R(e);if(o){var c,i=(r?"return ":"")+o,s=a({},W,{code:i},n),l=Object.keys(s);try{c=t(Function,l.concat([i]))}catch(e){u(T(e),"compilation",{code:i,error:e,scope:s})}var p={code:i,result:void 0,scope:s};try{p.result=c.apply(void 0,l.map((function(e){return s[e]})))}catch(e){u(T(e),"runtime",{code:i,error:e,scope:s})}return p}u("No expression to evaluate provided.","empty")},N=function(e,r,n){void 0===n&&(n=[]);var a=n.length?" in "+n.join(" -> "):"",c=[],l=function(){Object.prototype.hasOwnProperty.call(e,h)||(r&&Object.prototype.hasOwnProperty.call(r,h)&&["fillUp","migrate"].includes(O)?e[h]=r[h]:u('Type: You have to specify a model type via property "'+h+'"'+a+".")),n.length||new RegExp(i.property.name.typeRegularExpressionPattern.public).test(e[h])||u('TypeName: You have to specify a model type which matches "'+i.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+e[h]+'")'+a+"."),Object.prototype.hasOwnProperty.call(s,e[h])||(Object.prototype.hasOwnProperty.call(P,e[h])?e[h]=P[e[h]]:u('Model: Given model "'+e[h]+'" is not specified'+a+"."))};l();var p=e[h],d=s[p],y=null;Object.prototype.hasOwnProperty.call(d,m.additional)&&d[m.additional]&&(y=d[m.additional]);var v=function c(i,s,l,_,m){void 0===m&&(m=["constraintExecution","constraintExpression"]);for(var f,b,h=o(m);!(f=h()).done;)if(b=f.value,Object.prototype.hasOwnProperty.call(l,b)){var y,v=void 0;try{v=L(l[b].evaluation,b.endsWith("Expression"),{checkPropertyContent:c,model:d,modelName:p,name:s,type:b,newDocument:e,newValue:i,oldDocument:r,oldValue:_,parentNames:n,pathDescription:a,propertySpecification:l})}catch(s){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(s)&&u('Compilation: Hook "'+b+'" has invalid code "'+s.code+'": "'+s.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(s)&&u('Runtime: Hook "'+b+'" has throw an error with code "'+s.code+'": "'+s.message+'"'+a+"."),!Object.prototype.hasOwnProperty.call(s,"empty"))throw s}if(null==(y=v)||!y.result){var g=R(l[b].description);u(b.charAt(0).toUpperCase()+(b.substring(1)+": ")+(g?t(Function,Object.keys(v.scope).concat(["return "+g])).apply(void 0,Object.values(v.scope)):'Property "'+s+'" should satisfy constraint "'+v.code+'" (given "'+T(i)+'")'+a+"."))}}},x=function(e,t,r,c){void 0===c&&(c=null);var i=[],l=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,h)&&1===l.length&&Object.prototype.hasOwnProperty.call(s,l[0])&&(e[h]=l[0]);for(var p,d,m=!1,b=o(l);!(p=b()).done;)if(d=p.value,Object.prototype.hasOwnProperty.call(s,d)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]!==d&&"migrate"===O&&1===l.length&&(e[h]=d,i=n.concat(t,"migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]===d){var y=N(e,c,n.concat(t));if(y.changedPath.length&&(i=y.changedPath),e=y.newDocument,T(e)===T({}))return{newValue:null,changedPath:i};m=!0;break}1===l.length&&u('NestedType: Under key "'+t+'" isn\'t of type "'+d+'" (given "'+T(e)+'" of type '+typeof e+")"+a+".")}else if("DateTime"===d){var g=e;if(e=I(e),!(_&&("number"!=typeof e||isNaN(e))||!_&&"string"!=typeof e)){m=!0;break}1===l.length&&u('PropertyType: Property "'+t+'" isn\'t of (valid) type "DateTime" (given "'+T(g).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof g+'")'+a+".")}else if(["boolean","integer","number","string"].includes(d)){if(!("number"==typeof e&&isNaN(e)||"integer"!==d&&typeof e!==d||"integer"===d&&parseInt(e,10)!==e)){m=!0;break}1===l.length&&u('PropertyType: Property "'+t+'" isn\'t of (valid) type "${type}" (given "'+T(e)+'" of type "'+typeof e+'")'+a+".")}else if("string"==typeof d&&d.startsWith("foreignKey:")){var x=s[d.substring(11)][f].type;if(x===typeof e){m=!0;break}1===l.length&&u('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+x+'" (given "'+T(e)+'" of type "'+typeof e+'")'+a+".")}else{if("any"===d||T(e)===T(d)){m=!0;break}1===l.length&&u('PropertyType: Property "'+t+'" isn\'t value "'+d+'" (given "'+T(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+a+".")}if(m||u('PropertyType: None of the specified types "'+l.join('", "')+'" for property "'+t+'" matches value "'+T(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+a+"."),"string"==typeof e&&(![null,void 0].includes(r.minimumLength)&&e.length<r.minimumLength&&u('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length i"+e.length+") "+a+"."),![null,void 0].includes(r.maximumLength)&&e.length>r.maximumLength&&u('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+a+".")),"number"==typeof e&&(![null,void 0].includes(r.minimum)&&e<r.minimum&&u('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+a+"."),![null,void 0].includes(r.maximum)&&e>r.maximum&&u('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(I)),P.includes(e)||u('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+P.join('", "')+'". But is "'+e+'"'+a+".")}return[null,void 0].includes(r.regularExpressionPattern)||new RegExp(r.regularExpressionPattern).test(e)?![null,void 0].includes(r.invertedRegularExpressionPattern)&&new RegExp(r.invertedRegularExpressionPattern).test(e)&&u('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+r.invertedRegularExpressionPattern+' (given "'+e+'")'+a+"."):u('PatternMatch: Property "'+t+'" should match regular expression pattern '+r.regularExpressionPattern+' (given "'+e+'")'+a+"."),v(e,t,r,c),T(e)!==T(c)&&(i=n.concat(t,"value updated")),{newValue:e,changedPath:i}},w=function(e,t,r,a,o){var s=t[a];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,a)&&T(s)===T(r[a]))return a!==f&&"incremental"===O&&delete t[a],!0;u('Readonly: Property "'+a+'" is not writable (old document "'+T(r)+'")'+o+".")}else u('Readonly: Property "'+a+'" is not writable'+o+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,a)){if(T(s)===T(r[a]))return"incremental"!==O||i.property.name.reserved.concat(m.deleted,f,b).includes(a)||delete t[a],!0;"migrate"!==O&&u('Immutable: Property "'+a+'" is not writable (old document "'+T(r)+'")'+o+".")}if(null===s){if(e.nullable)return delete t[a],r&&Object.prototype.hasOwnProperty.call(r,a)&&(c=n.concat(a,"delete property")),!0;u('NotNull: Property "'+a+'" should not be "null"'+o+".")}return!1},E=function(e,t,r,c){if(!r)for(var i,s,l=o(["onCreateExecution","onCreateExpression"]);!(i=l()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s)){var _=void 0;try{_=L(e[s],s.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,name:c,type:s,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:a,propertySpecification:e})}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&u('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&u('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}_&&![null,void 0].includes(_.result)&&(t[c]=_.result)}},k=function(e,t,r,c){if(Object.prototype.hasOwnProperty.call(t,c)){e.trim&&"string"==typeof t[c]&&(t[c]=t[c].trim()),e.emptyEqualsToNull&&(""===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,l=o(["onUpdateExecution","onUpdateExpression"]);!(i=l()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s))try{t[c]=L(e[s],s.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,name:c,type:s,newDocument:t,oldDocument:r,newValue:t[c],oldValue:r&&r[c],parentNames:n,pathDescription:a,propertySpecification:e}).result}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&u('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&u('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+c+'": '+i.message+a+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}}},D=Object.keys(d).filter((function(e){return![m.additional,m.allowedRoles,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].includes(e)}));if("migrate"===O)for(var j,M,A=o(D);!(j=A()).done;)if(M=j.value,![null,void 0].includes(d[M].oldName))for(var C,U,W=o([].concat(d[M].oldName));!(C=W()).done;)U=C.value,Object.prototype.hasOwnProperty.call(e,U)&&(e[M]=e[U],delete e[U]);if(!r)for(var B,K=0,q=[m.create.execution,m.create.expression];K<q.length;K++)if(B=q[K],Object.prototype.hasOwnProperty.call(d,B)){var z=void 0;try{z=L(d[B],B.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,type:B,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&u('Compilation: Hook "'+B+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&u('Runtime: Hook "'+B+'" 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(z)||(e=z),l(),p=e[h],0===n.length&&g()}for(var H,F=0,G=[m.update.execution,m.update.expression];F<G.length;F++)if(H=G[F],Object.prototype.hasOwnProperty.call(d,H)){var V=void 0;try{V=L(d[H],H.endsWith("Expression"),{checkPropertyContent:x,model:d,modelName:p,type:H,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&u('Compilation: Hook "'+H+'" has invalid code "'+e.code+'" for document "'+p+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&u('Runtime: Hook "'+H+'" 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),l(),p=e[h],0===n.length&&g()}for(var J,$=function t(){var a=J.value;if(m.attachment===a)for(var i=function(){var i=l[s],u=i[0],p=i[1];Object.prototype.hasOwnProperty.call(e,a)&&null!==e[a]||(e[a]={}),r&&!Object.prototype.hasOwnProperty.call(r,a)&&(r[a]={});var d=Object.keys(e[a]).filter((function(t){return null!==e[a][t].data&&S(u,t,p)})),_=e[a],m=[];if(r){var f=r[a];m=Object.keys(f).filter((function(e){return!(Object.prototype.hasOwnProperty.call(_,e)&&Object.prototype.hasOwnProperty.call(_[e],"data")&&null===_[e].data)&&!!f[e]&&(Object.prototype.hasOwnProperty.call(f[e],"data")&&null!==f[e].data||f[e].stub&&!!f[e].digest)&&!!S(u,e,p)}))}for(var b,h,y=p,v=o(d);!(b=v()).done;)h=b.value,E(y,_,r&&r[a]?r[a]:null,h);for(var g,x,P=o(d);!(g=P()).done;)x=g.value,k(y,_,r&&r[a]?r[a]:null,x);if([null,void 0].includes(y.default)){if(y.nullable||0<d.length||0<m.length||t(),"fillUp"===O&&0===d.length&&0<m.length)for(var w,D,j=o(m);!(w=j()).done;)D=w.value,null===_[D]?c=n.concat(a,D,"file removed"):_[D]=r[a][D]}else if(0===d.length)if(0===m.length)for(var M in y.default)Object.prototype.hasOwnProperty.call(y.default,M)&&(_[M]=y.default[M],c=n.concat(a,u,"add default file"));else if("fillUp"===O)for(var A,C,T=o(m);!(A=T()).done;)C=A.value,_[C]=r[a][C]},s=0,l=Object.entries(d[a]);s<l.length;s++)i();else{var u=D.includes(a)?d[a]:y;E(u,e,r,a),k(u,e,r,a),[null,void 0].includes(u.default)?(!(u.nullable||Object.prototype.hasOwnProperty.call(e,a)||r&&Object.prototype.hasOwnProperty.call(r,a)&&O)&&t(),!Object.prototype.hasOwnProperty.call(e,a)&&r&&Object.prototype.hasOwnProperty.call(r,a)&&("fillUp"===O?e[a]=r[a]:!O&&(c=n.concat(a,"property removed")))):(!Object.prototype.hasOwnProperty.call(e,a)||null===e[a])&&(r&&Object.prototype.hasOwnProperty.call(r,a)?"fillUp"===O?e[a]=r[a]:"migrate"===O&&(e[a]=u.default,c=n.concat(a,"migrate default value")):(e[a]=u.default,c=c.concat(a,"add default value")))}},Y=o(D.concat(y?Object.keys(e).filter((function(e){return!D.includes(e)})):[]));!(J=Y()).done;)$();if(r&&"incremental"===O)for(var X=0,Z=Object.entries(e);X<Z.length;X++){var Q=Z[X],ee=Q[0],te=Q[1];!Object.prototype.hasOwnProperty.call(r,ee)||i.property.name.reserved.concat(f,b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,h).includes(ee)||r[ee]!==te&&T(r[ee])!==T(te)||delete e[ee]}for(var re=0,ne=Object.entries(e);re<ne.length;re++){var ae=ne[re],oe=ae[0],ce=ae[1];if(!i.property.name.reserved.concat(b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(oe)){var ie=void 0;if(Object.prototype.hasOwnProperty.call(d,oe))ie=d[oe];else if(y)ie=y;else{if("migrate"===O){delete e[oe],c=n.concat(oe,"migrate removed property");continue}u('Property: Given property "'+oe+'" isn\'t specified in model "'+p+'"'+a+".")}if(!ie)continue;if(m.attachment===oe){var se=ce;for(var le in se)if(Object.prototype.hasOwnProperty.call(se,le))for(var ue in d[oe])if(S(ue,le,d[oe][ue])){w(d[oe][ue],e,r,le,a);break}continue}if(w(ie,e,r,oe,a))continue;if("string"==typeof ie.type&&ie.type.endsWith("[]")||Array.isArray(ie.type)&&ie.type.length&&Array.isArray(ie.type[0])){var pe,de=ce;Array.isArray(de)?![null,void 0].includes(ie.minimumNumber)&&de.length<ie.minimumNumber?u('MinimumArrayLength: Property "'+oe+'" (array of length '+de.length+") doesn't fullfill minimum array length of "+ie.minimumNumber+a+"."):![null,void 0].includes(ie.maximumNumber)&&ie.maximumNumber<de.length&&u('MaximumArrayLength: Property "'+oe+'" (array of length '+de.length+") doesn't fullfill maximum array length of "+ie.maximumNumber+a+"."):u('PropertyType: Property "'+oe+'" isn\'t of type "array -> '+ie.type+'" (given "'+T(de)+'")'+a+"."),v(de,oe,ie,r&&Object.prototype.hasOwnProperty.call(r,oe)&&r[oe]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var _e={};for(var me in ie)Object.prototype.hasOwnProperty.call(ie,me)&&(_e[me]="type"===me?Array.isArray(ie[me])?ie[me][0]:[ie[me].substring(0,ie.type.length-2)]:ie[me]);if(1===(null==(pe=_e.type)?void 0:pe.length)&&Object.prototype.hasOwnProperty.call(s,_e.type[0]))for(var fe,be,he=o(de.slice());!(fe=he()).done;)"object"!=typeof(be=fe.value)||Object.getPrototypeOf(be)!==Object.prototype||Object.prototype.hasOwnProperty.call(be,h)||(be[h]=_e.type[0]);for(var ye,ve,ge=0,Oe=o(de.slice());!(ye=Oe()).done;)ve=ye.value,de[ge]=x(ve,ge+1+". value in "+oe,_e).newValue,null===ve&&de.splice(ge,1),ge+=1;r&&Object.prototype.hasOwnProperty.call(r,oe)&&Array.isArray(r[oe])&&r[oe].length===de.length&&T(r[oe])===T(de)||(c=n.concat(oe,"array updated"))}else{var xe=r&&Object.prototype.hasOwnProperty.call(r,oe)?r[oe]:null,Pe=x(ce,oe,ie,xe);e[oe]=Pe.newValue,Pe.changedPath.length&&(c=Pe.changedPath),null===e[oe]&&(null!==xe&&(c=n.concat(oe,"property removed")),delete e[oe])}}}for(var we,Ee=0,ke=Object.keys(m.constraint);Ee<ke.length;Ee++)if(we=ke[Ee],(we=m.constraint[we])&&Object.prototype.hasOwnProperty.call(d,we))for(var De,je=o([].concat(d[we]));!(De=je()).done;){var Me,Ae=De.value,Ce=void 0;try{Ce=L(Ae.evaluation,we===m.constraint.expression,{checkPropertyContent:x,model:d,modelName:p,type:we,newDocument:e,oldDocument:r,parentNames:n,pathDescription:a})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&u('Compilation: Hook "'+we+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&u('Runtime: Hook "'+we+'" has thrown an error with code "'+e.code+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(null==(Me=Ce)||!Me.result){var Te=we.replace(/^[^a-zA-Z]+/,"");u(Te.charAt(0).toUpperCase()+(Te.substring(1)+": ")+(Ae.description?t(Function,Object.keys(Ce.scope).concat(["return "+Ae.description.trim()])).apply(void 0,Object.values(Ce.scope)):'Model "'+p+'" should satisfy constraint "'+Ce.code+'" (given "'+T(e)+'")'+a+"."))}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var Re=e[m.attachment];("object"!=typeof Re||Object.getPrototypeOf(Re)!==Object.prototype)&&u("AttachmentType: given attachment has invalid type"+a+".");var Ie=null;if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&null!==(Ie=r[m.attachment])&&"object"==typeof Ie)for(var Se=0,Ue=Object.entries(Ie);Se<Ue.length;Se++){var Le=Ue[Se],Ne=Le[0],We=Le[1];if(Object.prototype.hasOwnProperty.call(Re,Ne)){var Be=Re[Ne];null===Be||null===Be.data||Be.content_type===We.content_type&&(Be.data===We.data||Be.digest===We.digest)?((null===Be||null===Be.data)&&(c=n.concat(m.attachment,Ne,"attachment removed")),"incremental"===O&&delete Re[Ne]):c=n.concat(m.attachment,Ne,"attachment updated")}else"fillUp"===O?Re[Ne]=We:O||(c=n.concat(m.attachment,Ne,"attachment removed"))}for(var Ke=0,qe=Object.entries(Re);Ke<qe.length;Ke++){var ze=qe[Ke],He=ze[0],Fe=ze[1];[null,void 0].includes(Fe)||null===Fe.data?delete Re[He]:(!Ie||!Object.prototype.hasOwnProperty.call(Ie,He)||Fe.content_type!==Ie[He].content_type||Fe.data!==Ie[He].data&&Fe.digest!==Ie[He].digest)&&(c=n.concat(m.attachment,He,"attachment updated"))}0===Object.keys(Re).length&&delete e[m.attachment];for(var Ge={},Ve=0,Je=Object.keys(d[m.attachment]);Ve<Je.length;Ve++)Ge[Je[Ve]]=[];for(var $e=0,Ye=Object.keys(Re);$e<Ye.length;$e++){for(var Xe=Ye[$e],Ze=!1,Qe=0,et=Object.entries(d[m.attachment]);Qe<et.length;Qe++){var tt=et[Qe],rt=tt[0],nt=tt[1];if(S(rt,Xe,nt)){Ge[rt].push(Xe),Ze=!0;break}}Ze||u('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(d[m.attachment]).join('", "')+'") matches given one ("'+Xe+'")'+a+".")}for(var at=0,ot=0,ct=Object.keys(Ge);ot<ct.length;ot++){var it=ct[ot],st=d[m.attachment][it];if(Object.prototype.hasOwnProperty.call(Ge,it)){var lt=Ge[it].length;null!==st.maximumNumber&&lt>st.maximumNumber&&u("AttachmentMaximum: given number of attachments ("+lt+") doesn't satisfy specified maximum of "+st.maximumNumber+' from type "'+it+'"'+a+"."),(!st.nullable||0!==lt)&&lt<st.minimumNumber&&u("AttachmentMinimum: given number of attachments ("+lt+") doesn't satisfy specified minimum of "+st.minimumNumber+' from type "'+it+'"'+a+".");for(var ut,pt=0,dt=o(Ge[it]);!(ut=dt()).done;){var _t,mt,ft=ut.value;null!=(_t=st.fileName)&&_t.regularExpressionPattern&&!new RegExp(st.fileName.regularExpressionPattern).test(ft)?u('AttachmentName: given attachment name "'+ft+'" doesn\'t satisfy specified regular expression pattern "'+st.fileName.regularExpressionPattern+'" from type "'+it+'"'+a+"."):null!=(mt=st.fileName)&&mt.invertedRegularExpressionPattern&&new RegExp(st.fileName.invertedRegularExpressionPattern).test(ft)?u('InvertedAttachmentName: given attachment name "'+ft+'" does satisfy specified regular expression pattern "'+st.fileName.invertedRegularExpressionPattern+'" from type "'+it+'"'+a+"."):!([null,void 0].includes(st.contentTypeRegularExpressionPattern)||Re[ft].content_type&&new RegExp(st.contentTypeRegularExpressionPattern).test(Re[ft].content_type))&&u('AttachmentContentType: given attachment content type "'+Re[ft].content_type+'" doesn\'t satisfy specified regular expression pattern "'+st.contentTypeRegularExpressionPattern+'" from type "'+it+'"'+a+".");var bt=st.invertedContentTypeRegularExpressionPattern;[null,void 0].includes(bt)||Re[ft].content_type&&!new RegExp(bt).test(Re[ft].content_type)||u('InvertedAttachmentContentType: given attachment content type "'+Re[ft].content_type+'" does satisfy specified regular expression pattern "'+bt+'" from type "'+it+'"'+a+".");var ht=0;"length"in Re[ft]?ht=Re[ft].length:"data"in Re[ft]&&(ht=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Re[ft].data,"base64"):Re[ft].data.length),![null,void 0].includes(st.minimumSize)&&st.minimumSize>ht?u("AttachmentMinimumSize: given attachment size "+ht+" byte doesn't satisfy specified minimum of "+st.minimumSize+" byte "+a+"."):![null,void 0].includes(st.maximumSize)&&st.maximumSize<ht&&u("AttachmentMaximumSize: given attachment size "+ht+" byte doesn't satisfy specified maximum of "+st.maximumSize+" byte "+a+"."),pt+=ht}![null,void 0].includes(st.minimumAggregatedSize)&&st.minimumAggregatedSize>pt?u('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+it+'" '+pt+" byte doesn't satisfy specified minimum of "+st.minimumAggregatedSize+" byte "+a+"."):![null,void 0].includes(st.maximumAggregatedSize)&&st.maximumAggregatedSize<pt&&u('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+it+'" '+pt+" byte doesn't satisfy specified maximum of "+st.maximumAggregatedSize+" byte "+a+"."),at+=pt}}Object.prototype.hasOwnProperty.call(d,m.minimumAggregatedSize)&&![null,void 0].includes(d[m.minimumAggregatedSize])&&d[m.minimumAggregatedSize]>at?u("AggregatedMinimumSize: given aggregated size "+at+" byte doesn't satisfy specified minimum of "+d[m.minimumAggregatedSize]+" byte "+a+"."):![null,void 0].includes(d[m.maximumAggregatedSize])&&d[m.maximumAggregatedSize]<at&&u("AggregatedMaximumSize: given aggregated size "+at+" byte doesn't satisfy specified maximum of "+d[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"===O)for(var yt,vt=0,gt=Object.keys(r);vt<gt.length;vt++)yt=gt[vt],Object.prototype.hasOwnProperty.call(e,yt)||(c=n.concat(yt,"migrate removed property"));return{changedPath:c,newDocument:e}},W={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var r=e[m.attachment],n=U(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:N,getFileNameByPrefix:U,serialize:T,id:y,revision:v,idName:f,revisionName:b,specialNames:m,typeName:h,modelConfiguration:i,models:s,now:p,nowUTCTimestamp:d,securitySettings:c,userContext:n},B=N(e,r);return(!B.newDocument._deleted||r)&&(B.newDocument._deleted&&B.newDocument._deleted!==(null==r?void 0:r._deleted)||B.changedPath.length)||u("NoChange: No new data given. new document: "+T(e)+"; old document: "+T(r)+"."),Object.prototype.hasOwnProperty.call(c,i.property.name.validatedDocumentsCache)?c[i.property.name.validatedDocumentsCache].add(y+"-"+v):c[i.property.name.validatedDocumentsCache]=new Set([y+"-"+v]),B.newDocument},e}(),u=l;e.exports=s}()}],__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:()=>y,default:()=>v});var e=__webpack_require__(1),t=__webpack_require__.n(e),r=__webpack_require__(2),n=__webpack_require__.n(r),a=__webpack_require__(4),o=__webpack_require__.n(a),c=__webpack_require__(6),i=__webpack_require__(7),s=__webpack_require__.n(i);const l=require("pouchdb");var u=__webpack_require__.n(l);const p=require("pouchdb-find");var d=__webpack_require__.n(p),_=__webpack_require__(9),m=__webpack_require__.n(_),f=__webpack_require__(8);function b(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 h(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)?h(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 h(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 y=function(){function e(){}return e.loadService=function(){var e=t()(n().mark((function e(t,r,i){var l,u,p,d,_,h,y,v,g,O,x,P,w,E,k,D,j,M,A,C,T,R,I,S,U,L,N,W,B,K,q,z,H,F,G,V,J,$,Y,X,Z,Q,ee,te,re,ne,ae,oe,ce,ie,se,le,ue,pe,de,_e,me,fe,be,he,ye,ve,ge,Oe,xe,Pe,we,Ee,ke,De,je,Me,Ae,Ce,Te,Re,Ie,Se,Ue,Le,Ne,We,Be,Ke,qe,ze,He,Fe,Ge,Ve,Je;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(l=null,!Object.prototype.hasOwnProperty.call(r.couchdb.server,"runner")){e.next=8;break}return e.next=4,f.default.startServer(r,i);case 4:r.couchdb.server.restart=f.default.restartServer,r.couchdb.server.start=f.default.startServer,r.couchdb.server.stop=f.default.stopServer,l=new Promise((function(e,t){r.couchdb.server.resolve=e,r.couchdb.server.reject=t}));case 8:if(!Object.prototype.hasOwnProperty.call(r.couchdb,"connection")){e.next=10;break}return e.abrupt("return",{name:"couchdb",promise:l});case 10:if(u=o().stringFormat(i.couchdb.url,i.couchdb.user.name+":"+i.couchdb.user.password+"@"),!i.couchdb.ensureAdminPresence){e.next=42;break}return p=new r.couchdb.connector(o().stringFormat(i.couchdb.url,"")+"/_users",f.default.getConnectorOptions(i)),e.prev=13,e.next=16,p.allDocs();case 16:return e.next=19,a.globalContext.fetch(o().stringFormat(i.couchdb.url,"")+"/"+r.couchdb.server.runner.adminUserConfigurationPath+"/"+i.couchdb.user.name,{body:'"'+i.couchdb.user.password+'"',method:"PUT"});case 19:e.next=39;break;case 21:if(e.prev=21,e.t0=e.catch(13),"unauthorized"!==e.t0.name){e.next=38;break}return d=new r.couchdb.connector(u+"/_users",f.default.getConnectorOptions(i)),e.prev=25,e.next=28,d.allDocs();case 28:e.next=33;break;case 30:e.prev=30,e.t1=e.catch(25);case 33:return e.prev=33,d.close(),e.finish(33);case 36:e.next=39;break;case 38:case 39:return e.prev=39,p.close(),e.finish(39);case 42:if(!i.couchdb.ensureUserPresence){e.next=77;break}_=0,h=[i.couchdb.security.admins,i.couchdb.security.members];case 44:if(!(_<h.length)){e.next=77;break}y=h[_],v=b(y.names);case 47:if((g=v()).done){e.next=74;break}return O=g.value,x=new r.couchdb.connector(u+"/_users",f.default.getConnectorOptions(i)),e.prev=50,e.next=53,x.get("org.couchdb.user:"+O);case 53:e.next=69;break;case 55:if(e.prev=55,e.t2=e.catch(50),"not_found"!==e.t2.error){e.next=68;break}return e.prev=58,e.next=61,x.put(((P={})[i.couchdb.model.property.name.special.id]="org.couchdb.user:"+O,P.name=O,P.password=O,P.roles=[].concat(y.roles.includes(O+"s")?O+"s":[]),P.type="user",P));case 61:e.next=66;break;case 63:throw e.prev=63,e.t3=e.catch(58),new Error("Couldn't create missing user \""+O+'": '+o().represent(e.t3));case 66:e.next=69;break;case 68:throw new Error("Couldn't check for presence of user \""+O+'": '+o().represent(e.t2));case 69:return e.prev=69,x.close(),e.finish(69);case 72:e.next=47;break;case 74:_++,e.next=44;break;case 77:if(!i.couchdb.model.updateConfiguration){e.next=132;break}w=b(i.couchdb.backend.prefixes);case 79:if((E=w()).done){e.next=132;break}k=E.value,e.t4=n().keys(i.couchdb.backend.configuration);case 82:if((e.t5=e.t4()).done){e.next=130;break}if(D=e.t5.value,!Object.prototype.hasOwnProperty.call(i.couchdb.backend.configuration,D)){e.next=128;break}return j="/"+k+(k.trim()?"/":"")+D,M=""+u+j,A=i.couchdb.backend.configuration[D],C=void 0,e.prev=89,e.next=92,a.globalContext.fetch(M);case 92:C=e.sent,e.next=98;break;case 95:e.prev=95,e.t6=e.catch(89);case 98:if(!C){e.next=128;break}if(!C.ok){e.next=127;break}if(T=!0,"function"!=typeof C.text){e.next=113;break}return e.prev=102,e.t7=A,e.next=106,C["string"==typeof A?"text":"json"]();case 106:e.t8=e.sent,T=e.t7===e.t8,e.next=113;break;case 110:e.prev=110,e.t9=e.catch(102);case 113:if(!T){e.next=124;break}return e.prev=114,e.next=117,a.globalContext.fetch(M,{body:'"'+i.couchdb.backend.configuration[D]+'"',method:"PUT"});case 117:e.next=122;break;case 119:e.prev=119,e.t10=e.catch(114);case 122:e.next=125;break;case 124:case 125:e.next=128;break;case 127:case 128:e.next=82;break;case 130:e.next=79;break;case 132:return e.next=134,f.default.initializeConnection(r,i);case 134:if(R=i.couchdb.model.property.name.special.id,I=i.couchdb.model.property.name.special.type,!i.couchdb.ensureSecuritySettingsPresence){e.next=145;break}return e.prev=137,e.next=140,a.globalContext.fetch(u+"/"+i.couchdb.databaseName+"/_security",{body:JSON.stringify(i.couchdb.security),method:"PUT"});case 140:e.next=145;break;case 142:e.prev=142,e.t11=e.catch(137);case 145:if(delete(S=o().copy(i.couchdb.model)).property.defaultSpecification,delete S.entities,U=f.default.extendModels(i.couchdb.model),!i.couchdb.model.updateValidation){e.next=213;break}return e.next=152,c.promises.readFile(a.currentRequire.resolve("./databaseHelper"),{encoding:i.core.encoding,flag:"r"});case 152:L=e.sent,N=b([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(S)+", "+JSON.stringify(U)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify(f.default.determineAllowedModelRolesMapping(i.couchdb.model))+", '"+R+"', '"+I+"', '"+i.couchdb.model.property.name.special.designDocumentNamePrefix+"'"}]);case 154:if((W=N()).done){e.next=169;break}B=W.value,K="function(...parameters) {\n return require('helper').default."+B.methodName+"(...parameters.concat(["+B.serializedParameter+"]))\n}",e.prev=157,new Function("return "+K),e.next=164;break;case 161:throw e.prev=161,e.t12=e.catch(157),new Error("Generated "+B.name+' code "'+K+"\" doesn't compile: "+o().represent(e.t12));case 164:return i.core.debug,e.next=167,f.default.ensureValidationDocumentPresence(r.couchdb.connection,B.name,{helper:L,validate_doc_update:K},B.description,!0,R,S.property.name.special.designDocumentNamePrefix);case 167:e.next=154;break;case 169:q=0,z=Object.entries(U);case 170:if(!(q<z.length)){e.next=213;break}H=z[q],F=H[0],G=H[1],V=0,J=Object.entries(G);case 173:if(!(V<J.length)){e.next=210;break}if($=J[V],Y=$[0],X=$[1],![S.property.name.special.constraint.execution,S.property.name.special.constraint.expression].includes(Y)){e.next=191;break}Z=b([].concat(X));case 177:if((Q=Z()).done){e.next=189;break}if(!(ee=Q.value).description){e.next=187;break}e.prev=180,new Function("return "+ee.description),e.next=187;break;case 184:throw e.prev=184,e.t13=e.catch(180),new Error('Specified constraint description "'+ee.description+'" for model "'+F+'" doesn\'t compile: "'+o().represent(e.t13)+'".');case 187:e.next=177;break;case 189:e.next=207;break;case 191:te=X,re=b(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 193:if((ne=re()).done){e.next=207;break}if(ae=ne.value,null===te||"object"!=typeof te){e.next=205;break}if(null==(oe=te[ae])||!oe.description){e.next=205;break}e.prev=198,new Function(oe.description),e.next=205;break;case 202:throw e.prev=202,e.t14=e.catch(198),new Error('Specified constraint description "'+oe.description+'" for model "'+F+'" in property "'+Y+'" as "'+ae+'" doesn\'t compile: "'+o().represent(e.t14)+'".');case 205:e.next=193;break;case 207:V++,e.next=173;break;case 210:q++,e.next=170;break;case 213:if(!i.couchdb.model.autoMigrationPath){e.next=305;break}return ce={},e.next=217,o().isDirectory(s().resolve(i.couchdb.model.autoMigrationPath));case 217:if(!e.sent){e.next=257;break}return e.t15=b,e.next=221,o().walkDirectoryRecursively(s().resolve(i.couchdb.model.autoMigrationPath),i.couchdb.debug?o().noop:function(e){return"debug"!==e.name});case 221:e.t16=e.sent,ie=(0,e.t15)(e.t16);case 223:if((se=ie()).done){e.next=257;break}if(le=se.value,ue=s().extname(le.name),pe=s().basename(le.name,ue),".json"!==ue){e.next=254;break}return de=void 0,e.prev=229,e.t17=JSON,e.next=233,c.promises.readFile(le.path,{encoding:i.core.encoding,flag:"r"});case 233:e.t18=e.sent,de=e.t17.parse.call(e.t17,e.t18),e.next=240;break;case 237:throw e.prev=237,e.t19=e.catch(229),new Error('Parsing document "'+le.path+'" to include by automigration of has failed: '+o().represent(e.t19));case 240:return de[R]=pe,de[i.couchdb.model.property.name.special.revision]="upsert",e.prev=242,e.next=245,r.couchdb.connection.put(de);case 245:e.next=251;break;case 247:throw e.prev=247,e.t20=e.catch(242),null!=(_e=e.t20.forbidden)&&_e.startsWith("NoChange:"),new Error('Migrating document "'+de[R]+'" of type "'+de[I]+'" has failed: '+o().represent(e.t20));case 251:e.next=255;break;case 254:".js"===s().extname(le.name)&&(ce[le.path]=(0,a.currentRequire)(le.path).default);case 255:e.next=223;break;case 257:return e.t21=b,e.next=260,r.couchdb.connection.allDocs({include_docs:!0});case 260:e.t22=e.sent.rows,me=(0,e.t21)(e.t22);case 262:if((fe=me()).done){e.next=305;break}if("string"==typeof(be=fe.value).id&&be.id.startsWith(i.couchdb.model.property.name.special.designDocumentNamePrefix)){e.next=303;break}he=be.doc,(ye=o().copy(he))[i.couchdb.model.property.name.special.strategy]="migrate",ve=b(Object.keys(ce).sort());case 269:if((ge=ve()).done){e.next=282;break}Oe=ge.value,xe=null,e.prev=272,xe=ce[Oe](ye,{configuration:i,databaseHelper:m(),idName:R,migrater:ce,models:U,modelConfiguration:S,selfFilePath:Oe,services:r,tools:o(),typeName:I}),e.next=279;break;case 276:throw e.prev=276,e.t23=e.catch(272),new Error('Running migrater "'+Oe+'" in document '+f.default.mayStripRepresentation(he,i.couchdb.maximumRepresentationTryLength,i.couchdb.maximumRepresentationLength)+'" failed: '+o().represent(e.t23));case 279:xe&&(ye=xe);case 280:e.next=269;break;case 282:e.prev=282,m().validateDocumentUpdate(o().copy(ye),o().copy(he),{db:i.couchdb.databaseName,name:i.couchdb.user.name,roles:["_admin"]},o().copy(i.couchdb.security),S,U),e.next=294;break;case 286:if(e.prev=286,e.t24=e.catch(282),!Object.prototype.hasOwnProperty.call(e.t24,"forbidden")){e.next=293;break}return e.t24.forbidden.startsWith("NoChange:"),e.abrupt("continue",303);case 293:throw e.t24;case 294:return e.prev=294,e.next=297,r.couchdb.connection.put(ye);case 297:e.next=302;break;case 299:throw e.prev=299,e.t25=e.catch(294),new Error('Replaceing auto migrated document "'+ye[R]+'" has failed: '+o().represent(e.t25));case 302:case 303:e.next=262;break;case 305:if(!i.couchdb.createGenericFlatIndex||!i.couchdb.model.autoMigrationPath){e.next=360;break}return e.next=308,r.couchdb.connection.getIndexes();case 308:Pe=e.sent.indexes,we=0,Ee=Object.entries(U);case 310:if(!(we<Ee.length)){e.next=341;break}if(ke=Ee[we],De=ke[0],je=ke[1],!new RegExp(i.couchdb.model.property.name.typeRegularExpressionPattern.public).test(De)){e.next=338;break}return e.next=315,r.couchdb.connection.createIndex({index:{ddoc:De+"-GenericIndex",fields:[I],name:De+"-GenericIndex"}});case 315:Me=b(f.default.determineGenericIndexablePropertyNames(i.couchdb.model,je));case 316:if((Ae=Me()).done){e.next=338;break}Ce=Ae.value,Te=De+"-"+Ce+"-GenericIndex",Re=-1,Ie=0,Se=b(Pe);case 322:if((Ue=Se()).done){e.next=330;break}if(Ue.value.name!==Te){e.next=327;break}return Re=Ie,e.abrupt("break",330);case 327:Ie+=1;case 328:e.next=322;break;case 330:if(-1!==Re){e.next=335;break}return e.next=333,r.couchdb.connection.createIndex({index:{ddoc:Te,fields:[I,Ce],name:Te}});case 333:e.next=336;break;case 335:Pe.slice(Ie,1);case 336:e.next=316;break;case 338:we++,e.next=310;break;case 341:Le=b(Pe);case 342:if((Ne=Le()).done){e.next=360;break}if(!(We=Ne.value).name.endsWith("-GenericIndex")){e.next=358;break}Be=!1,Ke=0,qe=Object.entries(U);case 347:if(!(Ke<qe.length)){e.next=355;break}if(ze=qe[Ke],He=ze[0],Fe=ze[1],!We.name.startsWith(He+"-")){e.next=352;break}for(Ge=b(f.default.determineGenericIndexablePropertyNames(i.couchdb.model,Fe));!(Ve=Ge()).done;)Je=Ve.value,[He+"-"+Je+"-GenericIndex",He+"-GenericIndex"].includes(We.name)&&(Be=!0);return e.abrupt("break",355);case 352:Ke++,e.next=347;break;case 355:if(Be){e.next=358;break}return e.next=358,r.couchdb.connection.deleteIndex(We);case 358:e.next=342;break;case 360:if(!i.couchdb.model.triggerInitialCompaction){e.next=369;break}return e.prev=361,e.next=364,r.couchdb.connection.compact();case 364:e.next=369;break;case 366:e.prev=366,e.t26=e.catch(361);case 369:return e.abrupt("return",{name:"couchdb",promise:l});case 370:case"end":return e.stop()}}),e,null,[[13,21,39,42],[25,30,33,36],[50,55,69,72],[58,63],[89,95],[102,110],[114,119],[137,142],[157,161],[180,184],[198,202],[229,237],[242,247],[272,276],[282,286],[294,299],[361,366]])})));return function(){return e.apply(this,arguments)}}(),e.postLoadService=function(r,a,c,i,s){var l=0;setInterval((function(){0<l&&(l=0)}),3e4);var u=o().debounce(t()(n().mark((function r(){return n().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return e.changesStream&&e.changesStream.cancel(),e.changesStream=a.couchdb.connection.changes(o().extend(!0,o().copy(c.couchdb.changesStream),e.additionalChangesStreamOptions)),e.changesStream.on("error",t()(n().mark((function t(){return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(3<(l+=1))){t.next=9;break}return l=0,e.changesStream.cancel(),t.next=7,a.couchdb.server.restart(a,c,i,s);case 7:t.next=10;break;case 9:case 10:u();case 11:case"end":return t.stop()}}),t)})))),r.next=5,s.callStack("couchdbInitializeChangesStream",i,c,e.changesStream,a);case 5:case"end":return r.stop()}}),r)}))));return c.couchdb.attachAutoRestarter&&u(),r},e.preLoadService=function(){var r=t()(n().mark((function r(a,c){var i,l,p,_,m,f,h,y,v,g,O,x,P,w;return n().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(Object.prototype.hasOwnProperty.call(a,"couchdb")||(a.couchdb={}),Object.prototype.hasOwnProperty.call(a.couchdb,"connector")||(i=c.couchdb.model.property.name.special.id,l=c.couchdb.model.property.name.special.revision,a.couchdb.connector=u(),p=a.couchdb.connector.prototype.bulkDocs,a.couchdb.connector.plugin({bulkDocs:function(){var r=t()(n().mark((function t(r){var a,o,s,u,d,_,m,f,h,y,v,g,O,x,P,w,E,k,D=arguments;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(o=D.length,s=Array(1<o?o-1:0),u=1;u<o;u++)s[u-1]=D[u];return d=0<s.length&&s[s.length-1]===e.toggleIDDetermining,_=d?!e.skipIDDetermining:e.skipIDDetermining,d&&s.pop(),m=!Array.isArray(r)&&null!==r&&"object"==typeof r&&i in r?[r]:r,null!=(a=c.couchdb.connector.fetch)&&a.timeout&&(0===s.length||"object"!=typeof s[0])&&s.unshift({timeout:c.couchdb.connector.fetch.timeout}),t.next=8,p.call.apply(p,[this,m].concat(s));case 8:f=t.sent,h=[],y=[],v=0,g=b(f);case 13:if((O=g()).done){t.next=36;break}if(x=O.value,"object"!=typeof m[v]){t.next=33;break}if(!(l in m[v])||"conflict"!==x.name||!["latest","upsert"].includes(m[v][l])){t.next=21;break}y.push(m[v]),h.push(v),t.next=33;break;case 21:if(!(i in m[v]&&c.couchdb.ignoreNoChangeError&&"name"in x&&"forbidden"===x.name&&"message"in x&&x.message.startsWith("NoChange:"))){t.next=33;break}if(f[v]={id:m[v][i],ok:!0},_){t.next=33;break}if(!(l in m[v])||["latest","upsert"].includes(m[v][l])){t.next=28;break}t.t0=m[v][l],t.next=32;break;case 28:return t.next=30,this.get(f[v].id);case 30:t.t1=l,t.t0=t.sent[t.t1];case 32:f[v].rev=t.t0;case 33:v+=1;case 34:t.next=13;break;case 36:if(!y.length){t.next=43;break}return m=y,d&&s.push(e.toggleIDDetermining),t.next=41,this.bulkDocs.apply(this,[m].concat(s));case 41:for(P=t.sent,w=b(P);!(E=w()).done;)k=E.value,f[h.shift()]=k;case 43:return t.abrupt("return",f);case 44:case"end":return t.stop()}}),t,this)})));return function(){return r.apply(this,arguments)}}()}),c.couchdb.debug&&a.couchdb.connector.debug.enable("*"),a.couchdb.connector=a.couchdb.connector.plugin(d())),Object.prototype.hasOwnProperty.call(a.couchdb,"server")){r.next=34;break}a.couchdb.server={},_=[],m=b([].concat(c.couchdb.binary.runner));case 6:if((f=m()).done){r.next=32;break}h=f.value,y=b([].concat(h.location));case 9:if((v=y()).done){r.next=28;break}g=v.value,O=b([].concat(h.name));case 12:if((x=O()).done){r.next=24;break}return P=x.value,w=s().resolve(g,P),_.push(w),r.next=18,o().isFile(w);case 18:if(!r.sent){r.next=22;break}return h.binaryFilePath=w,a.couchdb.server.runner=h,r.abrupt("break",24);case 22:r.next=12;break;case 24:if(!Object.prototype.hasOwnProperty.call(a.couchdb.server,"runner")){r.next=26;break}return r.abrupt("break",28);case 26:r.next=9;break;case 28:if(!Object.prototype.hasOwnProperty.call(a.couchdb.server,"runner")){r.next=30;break}return r.abrupt("break",32);case 30:r.next=6;break;case 32:if(Object.prototype.hasOwnProperty.call(a.couchdb.server,"runner")){r.next=34;break}throw new Error('No binary file in one of the following locations found: "'+_.join('", "')+'".');case 34:return r.abrupt("return",a);case 35:case"end":return r.stop()}}),r)})));return function(){return r.apply(this,arguments)}}(),e.shouldExit=function(){var e=t()(n().mark((function e(t,r){var a;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f.default.stopServer(t,r);case 2:return delete t.couchdb,a="log.txt",e.next=6,o().isFile(a);case 6:if(!e.sent){e.next=9;break}return e.next=9,c.promises.unlink(a);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),e}();y.additionalChangesStreamOptions={},y.changesStream=void 0,y.skipIDDetermining=!0,y.toggleIDDetermining=Symbol("toggleIDDetermining");const v=y})(),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.522",
3
+ "version": "1.0.525",
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",