couchdb-web-node-plugin 1.0.509 → 1.0.513

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
- (()=>{var e=[(e,t,r)=>{var o=r(1),n=r(2);function a(t,r,i){return n()?(e.exports=a=Reflect.construct,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=a=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},e.exports.__esModule=!0,e.exports.default=e.exports),a.apply(null,arguments)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},e=>{function t(r,o){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,o)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},e=>{e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}],t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{DatabaseHelper:()=>i,default:()=>l});var e=r(0),t=r.n(e);function n(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}var i=function(){function e(){}return e.authenticate=function(e,t,r,o,a,i,l,p,c){var s;void 0===t&&(t=null),void 0===r&&(r={db:"dummy",name:'"unknown"',roles:[]}),void 0===o&&(o={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===i&&(i="_id"),void 0===l&&(l="-type"),void 0===p&&(p="_design/"),void 0===c&&(c=!1);var u=null!==(s=e[l])&&void 0!==s?s:t&&t[l];if(!u)return!0;var y=c?"read":"write",m={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,i)&&e[i].startsWith(p)&&m.read.push("readonlymember");var d="Current user doesn't own any role";if(r)if("name"in r||(r.name='"unknown"'),r.roles.length){if(a&&u&&Object.prototype.hasOwnProperty.call(a,u)){for(var f,h,g=a[u],v=n(["read","write"]);!(f=v()).done;)m[h=f.value]=m[h].concat(g[h]||[]);g.properties&&(m.properties=g.properties)}for(var O,b,w=m[y],P=n(r.roles);!(O=P()).done;)if(b=O.value,w.includes(b))return!0;d='Current user "'+r.name+'" owns the following roles: "'+r.roles.join('", "')+'"'}else d='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 "+y+' action: "'+m[y].join('", "')+'". '+d+"."}},e.validateDocumentUpdate=function(e,r,o,a,i,l,p){void 0===l&&(l={});var c=function(e,t,r){var o;void 0===t&&(t="forbidden"),void 0===r&&(r={});var n=((o={})[t]=e,o.message=e,o.name=t,o);for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(n[a]=r[a]);throw n},s=new Date,u=Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds())/1e3,y=!i.dateTimeFormat.startsWith("iso"),m=i.property.name.special,d=m.id,f=m.revision,h=m.type;r&&r[h]&&!e[h]&&(e[h]=r[h]);var g="",v="",O=function(){g=Object.prototype.hasOwnProperty.call(e,d)?e[d]:"",v=Object.prototype.hasOwnProperty.call(e,f)?e[f]:""};if(O(),Object.prototype.hasOwnProperty.call(a,i.property.name.validatedDocumentsCache)&&a[i.property.name.validatedDocumentsCache].has(g+"-"+v))return a[i.property.name.validatedDocumentsCache].delete(g+"-"+v),e;["latest","upsert"].includes(v)&&(r&&Object.prototype.hasOwnProperty.call(r,f)?v=e[f]=r[f]:"latest"===v?c("Revision: No old document available to update."):delete e[f]);var b,w=i.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(w=e[m.strategy],delete e[m.strategy]),p?b=p:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?b=function(e){return JSON.stringify(e,null,4)}:c('Needed "serializer" is not available.');var P=function(e){return e instanceof Error?""+e:b(e)},j={};if("migrate"===w)for(var x in l)if(Object.prototype.hasOwnProperty.call(l,x)&&Object.prototype.hasOwnProperty.call(l[x],m.oldType)&&![null,void 0].includes(l[x][m.oldType]))for(var N,A,C=n([].concat(l[x][m.oldType]));!(N=C()).done;)A=N.value,j[A]=x;var S=function(e){return"string"==typeof e?e.trim():""},T=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},E=function(t,r){if(r||(r=e[m.attachment]),t){for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o)&&o.startsWith(t))return o}else{var n=Object.keys(r);if(n.length)return n[0]}return null},k=function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var r=e[m.attachment],o=E(t);if(o)return Object.prototype.hasOwnProperty.call(r[o],"stub")&&r[o].stub||Object.prototype.hasOwnProperty.call(r[o],"data")&&![null,void 0].includes(r[o].data)}return!1},D=function(e,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var p=S(e);if(p){var y=(r?"return ":"")+p,g={attachmentWithPrefixExists:k,checkDocument:M,code:y,getFileNameByPrefix:E,idName:d,modelConfiguration:i,models:l,now:s,nowUTCTimestamp:u,revisionName:f,securitySettings:a,serialize:P,specialNames:m,typeName:h,userContext:o};for(var v in n)Object.prototype.hasOwnProperty.call(n,v)&&(g[v]=n[v]);var O,b=Object.keys(g);try{O=t()(Function,b.concat([y]))}catch(e){c(P(e),"compilation",{code:y,error:e,scope:g})}var w={code:y,result:void 0,scope:g};try{w.result=O.apply(void 0,b.map((function(e){return g[e]})))}catch(e){c(P(e),"runtime",{code:y,error:e,scope:g})}return w}c("No expression to evaluate provided.","empty")},M=function(e,r,o){void 0===o&&(o=[]);var a=o.length?" in "+o.join(" -> "):"",p=[],s=function(){Object.prototype.hasOwnProperty.call(e,h)||(r&&Object.prototype.hasOwnProperty.call(r,h)&&["fillUp","migrate"].includes(w)?e[h]=r[h]:c('Type: You have to specify a model type via property "'+h+'"'+a+".")),o.length||new RegExp(i.property.name.typeRegularExpressionPattern.public).test(e[h])||c('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(l,e[h])||(Object.prototype.hasOwnProperty.call(j,e[h])?e[h]=j[e[h]]:c('Model: Given model "'+e[h]+'" is not specified'+a+"."))};s();var u=e[h],v=l[u],b=null;Object.prototype.hasOwnProperty.call(v,m.additional)&&v[m.additional]&&(b=v[m.additional]);var x=function(i,l,p,s,y){void 0===y&&(y=["constraintExecution","constraintExpression"]);for(var m,d,f=n(y);!(m=f()).done;)if(d=m.value,Object.prototype.hasOwnProperty.call(p,d)){var h=void 0;try{h=D(p[d].evaluation,d.endsWith("Expression"),{checkPropertyContent:N,code:p[d].evaluation,model:v,modelName:u,name:l,newDocument:e,newValue:i,oldDocument:r,oldValue:s,parentNames:o,pathDescription:a,propertySpecification:p,type:d})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+d+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+d+'" has throw an error with code "'+e.code+'": "'+e.message+'"'+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(!h.result){var g=S(p[d].description);c(d.charAt(0).toUpperCase()+(d.substring(1)+": ")+(g?t()(Function,Object.keys(h.scope).concat(["return "+g])).apply(void 0,Object.values(h.scope)):'Property "'+l+'" should satisfy constraint "'+h.code+'" (given "'+P(i)+'")'+a+"."))}}},N=function(e,t,r,i){void 0===i&&(i=null);var p=[],s=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,h)&&1===s.length&&Object.prototype.hasOwnProperty.call(l,s[0])&&(e[h]=s[0]);for(var u,m,f=!1,g=n(s);!(u=g()).done;)if(m=u.value,Object.prototype.hasOwnProperty.call(l,m)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]!==m&&"migrate"===w&&1===s.length&&(e[h]=m,p=o.concat(t,"migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]===m){var v=M(e,i,o.concat(t));if(v.changedPath.length&&(p=v.changedPath),e=v.newDocument,P(e)===P({}))return{newValue:null,changedPath:p};f=!0;break}1===s.length&&c('NestedType: Under key "'+t+'" isn\'t of type "'+m+'" (given "'+P(e)+'" of type '+typeof e+")"+a+".")}else if("DateTime"===m){var O=e;if(y)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{e=new Date(e);try{e=e.toISOString()}catch(e){}}if(!(y&&("number"!=typeof e||isNaN(e))||!y&&"string"!=typeof e)){f=!0;break}1===s.length&&c('PropertyType: Property "'+t+'" isn\'t of (valid) type "DateTime" (given "'+P(O).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof O+'")'+a+".")}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)){f=!0;break}1===s.length&&c('PropertyType: Property "'+t+'" isn\'t of (valid) type "${type}" (given "'+P(e)+'" of type "'+typeof e+'")'+a+".")}else if("string"==typeof m&&m.startsWith("foreignKey:")){var b=l[m.substring(11)][d].type;if(b===typeof e){f=!0;break}1===s.length&&c('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+b+'" (given "'+P(e)+'" of type "'+typeof e+'")'+a+".")}else{if("any"===m||P(e)===P(m)){f=!0;break}1===s.length&&c('PropertyType: Property "'+t+'" isn\'t value "'+m+'" (given "'+P(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+a+".")}if(f||c('PropertyType: None of the specified types "'+s.join('", "')+'" for property "'+t+'" matches value "'+P(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+a+"."),"string"==typeof e&&(![null,void 0].includes(r.minimumLength)&&e.length<r.minimumLength&&c('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&&c('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&&c('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&&c('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+a+".")),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);j.includes(e)||c('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+j.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)&&c('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+r.invertedRegularExpressionPattern+' (given "'+e+'")'+a+"."):c('PatternMatch: Property "'+t+'" should match regular expression pattern '+r.regularExpressionPattern+' (given "'+e+'")'+a+"."),x(e,t,r,i),P(e)!==P(i)&&(p=o.concat(t,"value updated")),{newValue:e,changedPath:p}},A=function(e,t,r,o){if(!r)for(var i,l,p=n(["onCreateExecution","onCreateExpression"]);!(i=p()).done;)if(l=i.value,Object.prototype.hasOwnProperty.call(e,l)){var s=void 0;try{s=D(e[l],l.endsWith("Expression"),{checkPropertyContent:N,code:e[l],model:v,modelName:u,name:o,newDocument:t,oldDocument:r,propertySpecification:e,type:l})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+l+'" has invalid code "'+e.code+'" for property "'+o+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+l+'" has throw an error with code "'+e.code+'" for property "'+o+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(s.result)||(t[o]=s.result)}},C=function(e,t,r,i){if(Object.prototype.hasOwnProperty.call(t,i)){e.trim&&"string"==typeof t[i]&&(t[i]=t[i].trim()),e.emptyEqualsToNull&&(""===t[i]||Array.isArray(t[i])&&0===t[i].length||null!==t[i]&&"object"==typeof t[i]&&0===Object.keys(t).length)&&(t[i]=null);for(var l,p,s=n(["onUpdateExecution","onUpdateExpression"]);!(l=s()).done;)if(p=l.value,Object.prototype.hasOwnProperty.call(e,p))try{t[i]=D(e[p],p.endsWith("Expression"),{checkPropertyContent:N,code:e[p],modelName:u,name:i,newDocument:t,oldDocument:r,parentNames:o,pathDescription:a,propertySpecification:e,type:p}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+p+'" has invalid code "'+e.code+'" for property "'+i+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+p+'" has throw an error with code "'+e.code+'" for property "'+i+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}}},E=Object.keys(v).filter((function(e){return![m.additional,m.allowedRole,m.constraint.execution,m.constraint.expression,m.create.execution,m.create.expression,m.extend,m.maximumAggregatedSize,m.minimumAggregatedSize,m.oldType,m.update.execution,m.update.expression].includes(e)}));if("migrate"===w)for(var k,_,z=n(E);!(k=z()).done;)if(_=k.value,![null,void 0].includes(v[_].oldName))for(var R,U,H=n([].concat(v[_].oldName));!(R=H()).done;)U=R.value,Object.prototype.hasOwnProperty.call(e,U)&&(e[_]=e[U],delete e[U]);if(!r)for(var L,I=0,W=[m.create.execution,m.create.expression];I<W.length;I++)if(L=W[I],Object.prototype.hasOwnProperty.call(v,L)){var F=void 0;try{F=D(v[L],L.endsWith("Expression"),{checkPropertyContent:N,code:v[L],id:g,model:v,modelName:u,newDocument:e,oldDocument:r,parentNames:o,pathDescription:a,type:L}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+L+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+L+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(F)||(e=F),s(),u=e[h],0===o.length&&O()}for(var B,V=0,$=[m.update.execution,m.update.expression];V<$.length;V++)if(B=$[V],Object.prototype.hasOwnProperty.call(v,B)){var q=void 0;try{q=D(v[B],B.endsWith("Expression"),{checkPropertyContent:N,code:v[B],id:g,model:v,modelName:u,newDocument:e,oldDocument:r,parentNames:o,pathDescription:a,type:B}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+B+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+B+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(q)||(e=q),s(),u=e[h],0===o.length&&O()}for(var Y,J=function(){var t=Y.value;if(m.attachment===t){var i=function(i){if(Object.prototype.hasOwnProperty.call(v[t],i)){Object.prototype.hasOwnProperty.call(e,t)&&null!==e[t]||(e[t]={}),r&&!Object.prototype.hasOwnProperty.call(r,t)&&(r[t]={});var l=Object.keys(e[t]).filter((function(r){return null!==e[t][r].data&&T(i,r,v[t][i])})),s=e[t],u=[];if(r){var y=r[t];u=Object.keys(y).filter((function(e){return!(Object.prototype.hasOwnProperty.call(s,e)&&Object.prototype.hasOwnProperty.call(s[e],"data")&&null===s[e].data)&&y[e]&&(Object.prototype.hasOwnProperty.call(y[e],"data")&&null!==y[e].data||y[e].stub&&y[e].digest)&&T(i,e,v[t][i])}))}for(var m,d,f=v[t][i],h=n(l);!(m=h()).done;)d=m.value,A(f,s,r&&r[t]?r[t]:null,d);for(var g,O,b=n(l);!(g=b()).done;)O=g.value,C(f,s,r&&r[t]?r[t]:null,O);if([null,void 0].includes(f.default)){if(f.nullable||0<l.length||0<u.length||c('AttachmentMissing: Missing attachment for type "'+i+'"'+a+"."),"fillUp"===w&&0===l.length&&0<u.length)for(var P,j,x=n(u);!(P=x()).done;)j=P.value,null===s[j]?p=o.concat(t,j,"file removed"):s[j]=r[t][j]}else if(0===l.length)if(0===u.length)for(var N in f.default)Object.prototype.hasOwnProperty.call(f.default,N)&&(s[N]=f.default[N],p=o.concat(t,i,"add default file"));else if("fillUp"===w)for(var S,E,k=n(u);!(S=k()).done;)E=S.value,s[E]=r[t][E]}};for(var l in v[t])i(l)}else{var s=E.includes(t)?v[t]:b;A(s,e,r,t),C(s,e,r,t),[null,void 0].includes(s.default)?(!(s.nullable||Object.prototype.hasOwnProperty.call(e,t)||r&&Object.prototype.hasOwnProperty.call(r,t)&&w)&&c('MissingProperty: Missing property "'+t+'"'+a+"."),!Object.prototype.hasOwnProperty.call(e,t)&&r&&Object.prototype.hasOwnProperty.call(r,t)&&("fillUp"===w?e[t]=r[t]:!w&&(p=o.concat(t,"property removed")))):(!Object.prototype.hasOwnProperty.call(e,t)||null===e[t])&&(r&&Object.prototype.hasOwnProperty.call(r,t)?"fillUp"===w?e[t]=r[t]:"migrate"===w&&(e[t]=s.default,p=o.concat(t,"migrate default value")):(e[t]=s.default,p=p.concat(t,"add default value")))}},G=n(E.concat(b?Object.keys(e).filter((function(e){return!E.includes(e)})):[]));!(Y=G()).done;)J();if(r&&"incremental"===w)for(var K in e)if(Object.prototype.hasOwnProperty.call(e,K)&&Object.prototype.hasOwnProperty.call(r,K)&&!i.property.name.reserved.concat(d,f,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,h).includes(K)&&(r[K]===e[K]||P(r[K])===P(e[K]))){delete e[K];continue}for(var Z in e)if(Object.prototype.hasOwnProperty.call(e,Z)&&!i.property.name.reserved.concat(f,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(Z)){var Q=void 0;if(Object.prototype.hasOwnProperty.call(v,Z))Q=v[Z];else if(b)Q=b;else{if("migrate"===w){delete e[Z],p=o.concat(Z,"migrate removed property");continue}c('Property: Given property "'+Z+'" isn\'t specified in model "'+u+'"'+a+".")}if(!Q)continue;var X=function(e,t,r,n){if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,n)&&P(t[n])===P(r[n]))return n!==d&&"incremental"===w&&delete t[n],!0;c('Readonly: Property "'+n+'" is not writable (old document "'+P(r)+'")'+a+".")}else c('Readonly: Property "'+n+'" is not writable'+a+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,n)){if(P(t[n])===P(r[n]))return"incremental"!==w||i.property.name.reserved.concat(m.deleted,d,f).includes(n)||delete t[n],!0;"migrate"!==w&&c('Immutable: Property "'+n+'" is not writable (old document "'+P(r)+'")'+a+".")}if(null===t[n]){if(e.nullable)return delete t[n],r&&Object.prototype.hasOwnProperty.call(r,n)&&(p=o.concat(n,"delete property")),!0;c('NotNull: Property "'+n+'" should not by "null"'+a+".")}return!1};if(m.attachment===Z){var ee=e[Z];for(var te in ee)if(Object.prototype.hasOwnProperty.call(ee,te))for(var re in v[Z])if(T(re,te,v[Z][re])){X(v[Z][re],e,r,te);break}continue}if(X(Q,e,r,Z))continue;if("string"==typeof Q.type&&Q.type.endsWith("[]")||Array.isArray(Q.type)&&Q.type.length&&Array.isArray(Q.type[0])){var oe,ne=e[Z];Array.isArray(ne)?![null,void 0].includes(Q.minimumNumber)&&ne.length<Q.minimumNumber?c('MinimumArrayLength: Property "'+Z+'" (array of length '+ne.length+") doesn't fullfill minimum array length of "+Q.minimumNumber+a+"."):![null,void 0].includes(Q.maximumNumber)&&Q.maximumNumber<ne.length&&c('MaximumArrayLength: Property "'+Z+'" (array of length '+ne.length+") doesn't fullfill maximum array length of "+Q.maximumNumber+a+"."):c('PropertyType: Property "'+Z+'" isn\'t of type "array -> '+Q.type+'" (given "'+P(ne)+'")'+a+"."),x(ne,Z,Q,r&&Object.prototype.hasOwnProperty.call(r,Z)&&r[Z]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var ae={};for(var ie in Q)Object.prototype.hasOwnProperty.call(Q,ie)&&(ae[ie]="type"===ie?Array.isArray(Q[ie])?Q[ie][0]:[Q[ie].substring(0,Q.type.length-2)]:Q[ie]);if(1===(null==(oe=ae.type)?void 0:oe.length)&&Object.prototype.hasOwnProperty.call(l,ae.type[0]))for(var le,pe,ce=n(ne.slice());!(le=ce()).done;)"object"!=typeof(pe=le.value)||Object.getPrototypeOf(pe)!==Object.prototype||Object.prototype.hasOwnProperty.call(pe,h)||(pe[h]=ae.type[0]);for(var se,ue,ye=0,me=n(ne.slice());!(se=me()).done;)ue=se.value,ne[ye]=N(ue,ye+1+". value in "+Z,ae).newValue,null===ue&&ne.splice(ye,1),ye+=1;r&&Object.prototype.hasOwnProperty.call(r,Z)&&Array.isArray(r[Z])&&r[Z].length===ne.length&&P(r[Z])===P(ne)||(p=o.concat(Z,"array updated"))}else{var de=r&&Object.prototype.hasOwnProperty.call(r,Z)?r[Z]:null,fe=N(e[Z],Z,Q,de);e[Z]=fe.newValue,fe.changedPath.length&&(p=fe.changedPath),null===e[Z]&&(null!==de&&(p=o.concat(Z,"property removed")),delete e[Z])}}for(var he in m.constraint)if(Object.prototype.hasOwnProperty.call(m.constraint,he)&&(he=m.constraint[he])&&Object.prototype.hasOwnProperty.call(v,he))for(var ge,ve=n([].concat(v[he]));!(ge=ve()).done;){var Oe=ge.value,be=void 0;try{be=D(Oe.evaluation,he===m.constraint.expression,{checkPropertyContent:N,code:Oe.evaluation,model:v,modelName:u,newDocument:e,oldDocument:r,parentNames:o,pathDescription:a,type:he})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+he+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+he+'" has thrown an error with code "'+e.code+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(!be.result){var we=he.replace(/^[^a-zA-Z]+/,"");c(we.charAt(0).toUpperCase()+(we.substring(1)+": ")+(Oe.description?t()(Function,Object.keys(be.scope).concat(["return "+Oe.description.trim()])).apply(void 0,Object.values(be.scope)):'Model "'+u+'" should satisfy constraint "'+be.code+'" (given "'+P(e)+'")'+a+"."))}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var Pe=e[m.attachment];("object"!=typeof Pe||Object.getPrototypeOf(Pe)!==Object.prototype)&&c("AttachmentType: given attachment has invalid type"+a+".");var je=null;if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&(null!==(je=r[m.attachment])&&"object"==typeof je))for(var xe in je)Object.prototype.hasOwnProperty.call(je,xe)&&(Object.prototype.hasOwnProperty.call(Pe,xe)?null===Pe[xe]||null===Pe[xe].data||Pe[xe].content_type===je[xe].content_type&&(Pe[xe].data===je[xe].data||Pe[xe].digest===je[xe].digest)?((null===Pe[xe]||null===Pe[xe].data)&&(p=o.concat(m.attachment,xe,"attachment removed")),"incremental"===w&&delete Pe[xe]):p=o.concat(m.attachment,xe,"attachment updated"):"fillUp"===w?Pe[xe]=je[xe]:w||(p=o.concat(m.attachment,xe,"attachment removed")));for(var Ne in Pe)Object.prototype.hasOwnProperty.call(Pe,Ne)&&([null,void 0].includes(Pe[Ne])||null===Pe[Ne].data?delete Pe[Ne]:je&&Object.prototype.hasOwnProperty.call(je,Ne)&&Pe[Ne].content_type===je[Ne].content_type&&(Pe[Ne].data===je[Ne].data||Pe[Ne].digest===je[Ne].digest)||(p=o.concat(m.attachment,Ne,"attachment updated")));0===Object.keys(Pe).length&&delete e[m.attachment];var Ae={};for(var Ce in v[m.attachment])Object.prototype.hasOwnProperty.call(v[m.attachment],Ce)&&(Ae[Ce]=[]);for(var Se in Pe)if(Object.prototype.hasOwnProperty.call(Pe,Se)){var Te=!1;for(var Ee in v[m.attachment])if(T(Ee,Se,v[m.attachment][Ee])){Ae[Ee].push(Se),Te=!0;break}Te||c('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(v[m.attachment]).join('", "')+'") matches given one ("'+Se+'")'+a+".")}for(var ke=0,De=0,Me=Object.keys(Ae);De<Me.length;De++){var _e=Me[De],ze=v[m.attachment][_e];if(Object.prototype.hasOwnProperty.call(Ae,_e)){var Re=Ae[_e].length;null!==ze.maximumNumber&&Re>ze.maximumNumber&&c("AttachmentMaximum: given number of attachments ("+Re+") doesn't satisfy specified maximum of "+ze.maximumNumber+' from type "'+_e+'"'+a+"."),(!ze.nullable||0!==Re)&&Re<ze.minimumNumber&&c("AttachmentMinimum: given number of attachments ("+Re+") doesn't satisfy specified minimum of "+ze.minimumNumber+' from type "'+_e+'"'+a+".");for(var Ue,He=0,Le=n(Ae[_e]);!(Ue=Le()).done;){var Ie,We,Fe=Ue.value;null!=(Ie=ze.fileName)&&Ie.regularExpressionPattern&&!new RegExp(ze.fileName.regularExpressionPattern).test(Fe)?c('AttachmentName: given attachment name "'+Fe+'" doesn\'t satisfy specified regular expression pattern "'+ze.fileName.regularExpressionPattern+'" from type "'+_e+'"'+a+"."):null!=(We=ze.fileName)&&We.invertedRegularExpressionPattern&&new RegExp(ze.fileName.invertedRegularExpressionPattern).test(Fe)?c('InvertedAttachmentName: given attachment name "'+Fe+'" does satisfy specified regular expression pattern "'+ze.fileName.invertedRegularExpressionPattern+'" from type "'+_e+'"'+a+"."):!([null,void 0].includes(ze.contentTypeRegularExpressionPattern)||Pe[Fe].content_type&&new RegExp(ze.contentTypeRegularExpressionPattern).test(Pe[Fe].content_type))&&c('AttachmentContentType: given attachment content type "'+Pe[Fe].content_type+'" doesn\'t satisfy specified regular expression pattern "'+ze.contentTypeRegularExpressionPattern+'" from type "'+_e+'"'+a+".");var Be=ze.invertedContentTypeRegularExpressionPattern;[null,void 0].includes(Be)||Pe[Fe].content_type&&!new RegExp(Be).test(Pe[Fe].content_type)||c('InvertedAttachmentContentType: given attachment content type "'+Pe[Fe].content_type+'" does satisfy specified regular expression pattern "'+Be+'" from type "'+_e+'"'+a+".");var Ve=0;"length"in Pe[Fe]?Ve=Pe[Fe].length:"data"in Pe[Fe]&&(Ve=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Pe[Fe].data,"base64"):Pe[Fe].data.length),![null,void 0].includes(ze.minimumSize)&&ze.minimumSize>Ve?c("AttachmentMinimumSize: given attachment size "+Ve+" byte doesn't satisfy specified minimum of "+ze.minimumSize+" byte "+a+"."):![null,void 0].includes(ze.maximumSize)&&ze.maximumSize<Ve&&c("AttachmentMaximumSize: given attachment size "+Ve+" byte doesn't satisfy specified maximum of "+ze.maximumSize+" byte "+a+"."),He+=Ve}![null,void 0].includes(ze.minimumAggregatedSize)&&ze.minimumAggregatedSize>He?c('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+_e+'" '+He+" byte doesn't satisfy specified minimum of "+ze.minimumAggregatedSize+" byte "+a+"."):![null,void 0].includes(ze.maximumAggregatedSize)&&ze.maximumAggregatedSize<He&&c('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+_e+'" '+He+" byte doesn't satisfy specified maximum of "+ze.maximumAggregatedSize+" byte "+a+"."),ke+=He}}Object.prototype.hasOwnProperty.call(v,m.minimumAggregatedSize)&&![null,void 0].includes(v[m.minimumAggregatedSize])&&v[m.minimumAggregatedSize]>ke?c("AggregatedMinimumSize: given aggregated size "+ke+" byte doesn't satisfy specified minimum of "+v[m.minimumAggregatedSize]+" byte "+a+"."):![null,void 0].includes(v[m.maximumAggregatedSize])&&v[m.maximumAggregatedSize]<ke&&c("AggregatedMaximumSize: given aggregated size "+ke+" byte doesn't satisfy specified maximum of "+v[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===p.length&&r&&"migrate"===w)for(var $e in r)Object.prototype.hasOwnProperty.call(r,$e)&&!Object.prototype.hasOwnProperty.call(e,$e)&&(p=o.concat($e,"migrate removed property"));return{changedPath:p,newDocument:e}},_=M(e,r);return(!_.newDocument._deleted||r)&&(_.newDocument._deleted&&_.newDocument._deleted!==(null==r?void 0:r._deleted)||_.changedPath.length)||c("NoChange: No new data given. new document: "+P(e)+"; old document: "+P(r)+"."),Object.prototype.hasOwnProperty.call(a,i.property.name.validatedDocumentsCache)?a[i.property.name.validatedDocumentsCache].add(g+"-"+v):a[i.property.name.validatedDocumentsCache]=new Set([g+"-"+v]),_.newDocument},e}();const l=i})(),module.exports=o})();
1
+ (()=>{var e=[(e,t,r)=>{var o=r(1),n=r(2);function a(t,r,i){return n()?(e.exports=a=Reflect.construct,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=a=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},e.exports.__esModule=!0,e.exports.default=e.exports),a.apply(null,arguments)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},e=>{function t(r,o){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,o)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},e=>{e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}],t={};function r(o){var n=t[o];if(void 0!==n)return n.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";r.r(o),r.d(o,{DatabaseHelper:()=>i,default:()=>l});var e=r(0),t=r.n(e);function n(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=Array(t);r<t;r++)o[r]=e[r];return o}var i=function(){function e(){}return e.authenticate=function(e,t,r,o,a,i,l,p,c){var s;void 0===t&&(t=null),void 0===r&&(r={db:"dummy",name:'"unknown"',roles:[]}),void 0===o&&(o={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===i&&(i="_id"),void 0===l&&(l="-type"),void 0===p&&(p="_design/"),void 0===c&&(c=!1);var u=null!==(s=e[l])&&void 0!==s?s:t&&t[l];if(!u)return!0;var y=c?"read":"write",m={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,i)&&e[i].startsWith(p)&&m.read.push("readonlymember");var d="Current user doesn't own any role";if(r)if("name"in r||(r.name='"unknown"'),r.roles.length){if(a&&u&&Object.prototype.hasOwnProperty.call(a,u)){for(var f,h,g=a[u],v=n(["read","write"]);!(f=v()).done;)m[h=f.value]=m[h].concat(g[h]||[]);g.properties&&(m.properties=g.properties)}for(var O,b,w=m[y],P=n(r.roles);!(O=P()).done;)if(b=O.value,w.includes(b))return!0;d='Current user "'+r.name+'" owns the following roles: "'+r.roles.join('", "')+'"'}else d='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 "+y+' action: "'+m[y].join('", "')+'". '+d+"."}},e.validateDocumentUpdate=function(e,r,o,a,i,l,p){void 0===l&&(l={});var c=function(e,t,r){var o;void 0===t&&(t="forbidden"),void 0===r&&(r={});var n=((o={})[t]=e,o.message=e,o.name=t,o);for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(n[a]=r[a]);throw n},s=new Date,u=Date.UTC(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate(),s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds())/1e3,y=!i.dateTimeFormat.startsWith("iso"),m=i.property.name.special,d=m.id,f=m.revision,h=m.type;r&&r[h]&&!e[h]&&(e[h]=r[h]);var g="",v="",O=function(){g=Object.prototype.hasOwnProperty.call(e,d)?e[d]:"",v=Object.prototype.hasOwnProperty.call(e,f)?e[f]:""};if(O(),Object.prototype.hasOwnProperty.call(a,i.property.name.validatedDocumentsCache)&&a[i.property.name.validatedDocumentsCache].has(g+"-"+v))return a[i.property.name.validatedDocumentsCache].delete(g+"-"+v),e;["latest","upsert"].includes(v)&&(r&&Object.prototype.hasOwnProperty.call(r,f)?v=e[f]=r[f]:"latest"===v?c("Revision: No old document available to update."):delete e[f]);var b,w=i.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(w=e[m.strategy],delete e[m.strategy]),p?b=p:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?b=function(e){return JSON.stringify(e,null,4)}:c('Needed "serializer" is not available.');var P=function(e){return e instanceof Error?""+e:b(e)},j={};if("migrate"===w)for(var x in l)if(Object.prototype.hasOwnProperty.call(l,x)&&Object.prototype.hasOwnProperty.call(l[x],m.oldType)&&![null,void 0].includes(l[x][m.oldType]))for(var N,A,C=n([].concat(l[x][m.oldType]));!(N=C()).done;)A=N.value,j[A]=x;var S=function(e){return"string"==typeof e?e.trim():""},T=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},E=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},k=function(t,r){if(r||(r=e[m.attachment]),t){for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o)&&o.startsWith(t))return o}else{var n=Object.keys(r);if(n.length)return n[0]}return null},D=function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var r=e[m.attachment],o=k(t);if(o)return Object.prototype.hasOwnProperty.call(r[o],"stub")&&r[o].stub||Object.prototype.hasOwnProperty.call(r[o],"data")&&![null,void 0].includes(r[o].data)}return!1},M=function(e,r,n){void 0===r&&(r=!1),void 0===n&&(n={});var p=S(e);if(p){var y=(r?"return ":"")+p,g={attachmentWithPrefixExists:D,checkDocument:_,code:y,getFileNameByPrefix:k,idName:d,modelConfiguration:i,models:l,now:s,nowUTCTimestamp:u,revisionName:f,securitySettings:a,serialize:P,specialNames:m,typeName:h,userContext:o};for(var v in n)Object.prototype.hasOwnProperty.call(n,v)&&(g[v]=n[v]);var O,b=Object.keys(g);try{O=t()(Function,b.concat([y]))}catch(e){c(P(e),"compilation",{code:y,error:e,scope:g})}var w={code:y,result:void 0,scope:g};try{w.result=O.apply(void 0,b.map((function(e){return g[e]})))}catch(e){c(P(e),"runtime",{code:y,error:e,scope:g})}return w}c("No expression to evaluate provided.","empty")},_=function(e,r,o){void 0===o&&(o=[]);var a=o.length?" in "+o.join(" -> "):"",p=[],s=function(){Object.prototype.hasOwnProperty.call(e,h)||(r&&Object.prototype.hasOwnProperty.call(r,h)&&["fillUp","migrate"].includes(w)?e[h]=r[h]:c('Type: You have to specify a model type via property "'+h+'"'+a+".")),o.length||new RegExp(i.property.name.typeRegularExpressionPattern.public).test(e[h])||c('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(l,e[h])||(Object.prototype.hasOwnProperty.call(j,e[h])?e[h]=j[e[h]]:c('Model: Given model "'+e[h]+'" is not specified'+a+"."))};s();var u=e[h],v=l[u],b=null;Object.prototype.hasOwnProperty.call(v,m.additional)&&v[m.additional]&&(b=v[m.additional]);var x=function(i,l,p,s,y){void 0===y&&(y=["constraintExecution","constraintExpression"]);for(var m,d,f=n(y);!(m=f()).done;)if(d=m.value,Object.prototype.hasOwnProperty.call(p,d)){var h,g=void 0;try{g=M(p[d].evaluation,d.endsWith("Expression"),{checkPropertyContent:N,code:p[d].evaluation,model:v,modelName:u,name:l,newDocument:e,newValue:i,oldDocument:r,oldValue:s,parentNames:o,pathDescription:a,propertySpecification:p,type:d})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+d+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+d+'" has throw an error with code "'+e.code+'": "'+e.message+'"'+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(null==(h=g)||!h.result){var O=S(p[d].description);c(d.charAt(0).toUpperCase()+(d.substring(1)+": ")+(O?t()(Function,Object.keys(g.scope).concat(["return "+O])).apply(void 0,Object.values(g.scope)):'Property "'+l+'" should satisfy constraint "'+g.code+'" (given "'+P(i)+'")'+a+"."))}}},N=function(e,t,r,i){void 0===i&&(i=null);var p=[],s=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,h)&&1===s.length&&Object.prototype.hasOwnProperty.call(l,s[0])&&(e[h]=s[0]);for(var u,m,f=!1,g=n(s);!(u=g()).done;)if(m=u.value,Object.prototype.hasOwnProperty.call(l,m)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]!==m&&"migrate"===w&&1===s.length&&(e[h]=m,p=o.concat(t,"migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]===m){var v=_(e,i,o.concat(t));if(v.changedPath.length&&(p=v.changedPath),e=v.newDocument,P(e)===P({}))return{newValue:null,changedPath:p};f=!0;break}1===s.length&&c('NestedType: Under key "'+t+'" isn\'t of type "'+m+'" (given "'+P(e)+'" of type '+typeof e+")"+a+".")}else if("DateTime"===m){var O=e;if(e=T(e),!(y&&("number"!=typeof e||isNaN(e))||!y&&"string"!=typeof e)){f=!0;break}1===s.length&&c('PropertyType: Property "'+t+'" isn\'t of (valid) type "DateTime" (given "'+P(O).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof O+'")'+a+".")}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)){f=!0;break}1===s.length&&c('PropertyType: Property "'+t+'" isn\'t of (valid) type "${type}" (given "'+P(e)+'" of type "'+typeof e+'")'+a+".")}else if("string"==typeof m&&m.startsWith("foreignKey:")){var b=l[m.substring(11)][d].type;if(b===typeof e){f=!0;break}1===s.length&&c('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+b+'" (given "'+P(e)+'" of type "'+typeof e+'")'+a+".")}else{if("any"===m||P(e)===P(m)){f=!0;break}1===s.length&&c('PropertyType: Property "'+t+'" isn\'t value "'+m+'" (given "'+P(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+a+".")}if(f||c('PropertyType: None of the specified types "'+s.join('", "')+'" for property "'+t+'" matches value "'+P(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'")'+a+"."),"string"==typeof e&&(![null,void 0].includes(r.minimumLength)&&e.length<r.minimumLength&&c('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&&c('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&&c('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&&c('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+a+".")),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(T)),j.includes(e)||c('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+j.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)&&c('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+r.invertedRegularExpressionPattern+' (given "'+e+'")'+a+"."):c('PatternMatch: Property "'+t+'" should match regular expression pattern '+r.regularExpressionPattern+' (given "'+e+'")'+a+"."),x(e,t,r,i),P(e)!==P(i)&&(p=o.concat(t,"value updated")),{newValue:e,changedPath:p}},A=function(e,t,r,o){if(!r)for(var i,l,p=n(["onCreateExecution","onCreateExpression"]);!(i=p()).done;)if(l=i.value,Object.prototype.hasOwnProperty.call(e,l)){var s=void 0;try{s=M(e[l],l.endsWith("Expression"),{checkPropertyContent:N,code:e[l],model:v,modelName:u,name:o,newDocument:t,oldDocument:r,propertySpecification:e,type:l})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+l+'" has invalid code "'+e.code+'" for property "'+o+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+l+'" has throw an error with code "'+e.code+'" for property "'+o+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}s&&![null,void 0].includes(s.result)&&(t[o]=s.result)}},C=function(e,t,r,i){if(Object.prototype.hasOwnProperty.call(t,i)){e.trim&&"string"==typeof t[i]&&(t[i]=t[i].trim()),e.emptyEqualsToNull&&(""===t[i]||Array.isArray(t[i])&&0===t[i].length||null!==t[i]&&"object"==typeof t[i]&&0===Object.keys(t).length)&&(t[i]=null);for(var l,p,s=n(["onUpdateExecution","onUpdateExpression"]);!(l=s()).done;)if(p=l.value,Object.prototype.hasOwnProperty.call(e,p))try{t[i]=M(e[p],p.endsWith("Expression"),{checkPropertyContent:N,code:e[p],modelName:u,name:i,newDocument:t,oldDocument:r,parentNames:o,pathDescription:a,propertySpecification:e,type:p}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+p+'" has invalid code "'+e.code+'" for property "'+i+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+p+'" has throw an error with code "'+e.code+'" for property "'+i+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}}},k=Object.keys(v).filter((function(e){return![m.additional,m.allowedRole,m.constraint.execution,m.constraint.expression,m.create.execution,m.create.expression,m.extend,m.maximumAggregatedSize,m.minimumAggregatedSize,m.oldType,m.update.execution,m.update.expression].includes(e)}));if("migrate"===w)for(var D,z,R=n(k);!(D=R()).done;)if(z=D.value,![null,void 0].includes(v[z].oldName))for(var U,H,L=n([].concat(v[z].oldName));!(U=L()).done;)H=U.value,Object.prototype.hasOwnProperty.call(e,H)&&(e[z]=e[H],delete e[H]);if(!r)for(var I,W=0,F=[m.create.execution,m.create.expression];W<F.length;W++)if(I=F[W],Object.prototype.hasOwnProperty.call(v,I)){var B=void 0;try{B=M(v[I],I.endsWith("Expression"),{checkPropertyContent:N,code:v[I],id:g,model:v,modelName:u,newDocument:e,oldDocument:r,parentNames:o,pathDescription:a,type:I}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+I+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+I+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(B)||(e=B),s(),u=e[h],0===o.length&&O()}for(var V,$=0,q=[m.update.execution,m.update.expression];$<q.length;$++)if(V=q[$],Object.prototype.hasOwnProperty.call(v,V)){var Y=void 0;try{Y=M(v[V],V.endsWith("Expression"),{checkPropertyContent:N,code:v[V],id:g,model:v,modelName:u,newDocument:e,oldDocument:r,parentNames:o,pathDescription:a,type:V}).result}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+V+'" has invalid code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+V+'" has throw an error with code "'+e.code+'" for document "'+u+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(Y)||(e=Y),s(),u=e[h],0===o.length&&O()}for(var J,G=function(){var t=J.value;if(m.attachment===t){var i=function(i){if(Object.prototype.hasOwnProperty.call(v[t],i)){Object.prototype.hasOwnProperty.call(e,t)&&null!==e[t]||(e[t]={}),r&&!Object.prototype.hasOwnProperty.call(r,t)&&(r[t]={});var l=Object.keys(e[t]).filter((function(r){return null!==e[t][r].data&&E(i,r,v[t][i])})),s=e[t],u=[];if(r){var y=r[t];u=Object.keys(y).filter((function(e){return!(Object.prototype.hasOwnProperty.call(s,e)&&Object.prototype.hasOwnProperty.call(s[e],"data")&&null===s[e].data)&&!!y[e]&&(Object.prototype.hasOwnProperty.call(y[e],"data")&&null!==y[e].data||y[e].stub&&!!y[e].digest)&&!!E(i,e,v[t][i])}))}for(var m,d,f=v[t][i],h=n(l);!(m=h()).done;)d=m.value,A(f,s,r&&r[t]?r[t]:null,d);for(var g,O,b=n(l);!(g=b()).done;)O=g.value,C(f,s,r&&r[t]?r[t]:null,O);if([null,void 0].includes(f.default)){if(f.nullable||0<l.length||0<u.length||c('AttachmentMissing: Missing attachment for type "'+i+'"'+a+"."),"fillUp"===w&&0===l.length&&0<u.length)for(var P,j,x=n(u);!(P=x()).done;)j=P.value,null===s[j]?p=o.concat(t,j,"file removed"):s[j]=r[t][j]}else if(0===l.length)if(0===u.length)for(var N in f.default)Object.prototype.hasOwnProperty.call(f.default,N)&&(s[N]=f.default[N],p=o.concat(t,i,"add default file"));else if("fillUp"===w)for(var S,T,k=n(u);!(S=k()).done;)T=S.value,s[T]=r[t][T]}};for(var l in v[t])i(l)}else{var s=k.includes(t)?v[t]:b;A(s,e,r,t),C(s,e,r,t),[null,void 0].includes(s.default)?(!(s.nullable||Object.prototype.hasOwnProperty.call(e,t)||r&&Object.prototype.hasOwnProperty.call(r,t)&&w)&&c('MissingProperty: Missing property "'+t+'"'+a+"."),!Object.prototype.hasOwnProperty.call(e,t)&&r&&Object.prototype.hasOwnProperty.call(r,t)&&("fillUp"===w?e[t]=r[t]:!w&&(p=o.concat(t,"property removed")))):(!Object.prototype.hasOwnProperty.call(e,t)||null===e[t])&&(r&&Object.prototype.hasOwnProperty.call(r,t)?"fillUp"===w?e[t]=r[t]:"migrate"===w&&(e[t]=s.default,p=o.concat(t,"migrate default value")):(e[t]=s.default,p=p.concat(t,"add default value")))}},K=n(k.concat(b?Object.keys(e).filter((function(e){return!k.includes(e)})):[]));!(J=K()).done;)G();if(r&&"incremental"===w)for(var Z in e)if(Object.prototype.hasOwnProperty.call(e,Z)&&Object.prototype.hasOwnProperty.call(r,Z)&&!i.property.name.reserved.concat(d,f,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,h).includes(Z)&&(r[Z]===e[Z]||P(r[Z])===P(e[Z]))){delete e[Z];continue}for(var Q in e)if(Object.prototype.hasOwnProperty.call(e,Q)&&!i.property.name.reserved.concat(f,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(Q)){var X=void 0;if(Object.prototype.hasOwnProperty.call(v,Q))X=v[Q];else if(b)X=b;else{if("migrate"===w){delete e[Q],p=o.concat(Q,"migrate removed property");continue}c('Property: Given property "'+Q+'" isn\'t specified in model "'+u+'"'+a+".")}if(!X)continue;var ee=function(e,t,r,n){if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,n)&&P(t[n])===P(r[n]))return n!==d&&"incremental"===w&&delete t[n],!0;c('Readonly: Property "'+n+'" is not writable (old document "'+P(r)+'")'+a+".")}else c('Readonly: Property "'+n+'" is not writable'+a+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,n)){if(P(t[n])===P(r[n]))return"incremental"!==w||i.property.name.reserved.concat(m.deleted,d,f).includes(n)||delete t[n],!0;"migrate"!==w&&c('Immutable: Property "'+n+'" is not writable (old document "'+P(r)+'")'+a+".")}if(null===t[n]){if(e.nullable)return delete t[n],r&&Object.prototype.hasOwnProperty.call(r,n)&&(p=o.concat(n,"delete property")),!0;c('NotNull: Property "'+n+'" should not by "null"'+a+".")}return!1};if(m.attachment===Q){var te=e[Q];for(var re in te)if(Object.prototype.hasOwnProperty.call(te,re))for(var oe in v[Q])if(E(oe,re,v[Q][oe])){ee(v[Q][oe],e,r,re);break}continue}if(ee(X,e,r,Q))continue;if("string"==typeof X.type&&X.type.endsWith("[]")||Array.isArray(X.type)&&X.type.length&&Array.isArray(X.type[0])){var ne,ae=e[Q];Array.isArray(ae)?![null,void 0].includes(X.minimumNumber)&&ae.length<X.minimumNumber?c('MinimumArrayLength: Property "'+Q+'" (array of length '+ae.length+") doesn't fullfill minimum array length of "+X.minimumNumber+a+"."):![null,void 0].includes(X.maximumNumber)&&X.maximumNumber<ae.length&&c('MaximumArrayLength: Property "'+Q+'" (array of length '+ae.length+") doesn't fullfill maximum array length of "+X.maximumNumber+a+"."):c('PropertyType: Property "'+Q+'" isn\'t of type "array -> '+X.type+'" (given "'+P(ae)+'")'+a+"."),x(ae,Q,X,r&&Object.prototype.hasOwnProperty.call(r,Q)&&r[Q]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var ie={};for(var le in X)Object.prototype.hasOwnProperty.call(X,le)&&(ie[le]="type"===le?Array.isArray(X[le])?X[le][0]:[X[le].substring(0,X.type.length-2)]:X[le]);if(1===(null==(ne=ie.type)?void 0:ne.length)&&Object.prototype.hasOwnProperty.call(l,ie.type[0]))for(var pe,ce,se=n(ae.slice());!(pe=se()).done;)"object"!=typeof(ce=pe.value)||Object.getPrototypeOf(ce)!==Object.prototype||Object.prototype.hasOwnProperty.call(ce,h)||(ce[h]=ie.type[0]);for(var ue,ye,me=0,de=n(ae.slice());!(ue=de()).done;)ye=ue.value,ae[me]=N(ye,me+1+". value in "+Q,ie).newValue,null===ye&&ae.splice(me,1),me+=1;r&&Object.prototype.hasOwnProperty.call(r,Q)&&Array.isArray(r[Q])&&r[Q].length===ae.length&&P(r[Q])===P(ae)||(p=o.concat(Q,"array updated"))}else{var fe=r&&Object.prototype.hasOwnProperty.call(r,Q)?r[Q]:null,he=N(e[Q],Q,X,fe);e[Q]=he.newValue,he.changedPath.length&&(p=he.changedPath),null===e[Q]&&(null!==fe&&(p=o.concat(Q,"property removed")),delete e[Q])}}for(var ge in m.constraint)if(Object.prototype.hasOwnProperty.call(m.constraint,ge)&&(ge=m.constraint[ge])&&Object.prototype.hasOwnProperty.call(v,ge))for(var ve,Oe=n([].concat(v[ge]));!(ve=Oe()).done;){var be,we=ve.value,Pe=void 0;try{Pe=M(we.evaluation,ge===m.constraint.expression,{checkPropertyContent:N,code:we.evaluation,model:v,modelName:u,newDocument:e,oldDocument:r,parentNames:o,pathDescription:a,type:ge})}catch(e){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&c('Compilation: Hook "'+ge+'" has invalid code "'+e.code+'": "'+e.message+'"'+a+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&c('Runtime: Hook "'+ge+'" has thrown an error with code "'+e.code+'": '+e.message+a+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(null==(be=Pe)||!be.result){var je=ge.replace(/^[^a-zA-Z]+/,"");c(je.charAt(0).toUpperCase()+(je.substring(1)+": ")+(we.description?t()(Function,Object.keys(Pe.scope).concat(["return "+we.description.trim()])).apply(void 0,Object.values(Pe.scope)):'Model "'+u+'" should satisfy constraint "'+Pe.code+'" (given "'+P(e)+'")'+a+"."))}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var xe=e[m.attachment];("object"!=typeof xe||Object.getPrototypeOf(xe)!==Object.prototype)&&c("AttachmentType: given attachment has invalid type"+a+".");var Ne=null;if(r&&Object.prototype.hasOwnProperty.call(r,m.attachment)&&(null!==(Ne=r[m.attachment])&&"object"==typeof Ne))for(var Ae in Ne)Object.prototype.hasOwnProperty.call(Ne,Ae)&&(Object.prototype.hasOwnProperty.call(xe,Ae)?null===xe[Ae]||null===xe[Ae].data||xe[Ae].content_type===Ne[Ae].content_type&&(xe[Ae].data===Ne[Ae].data||xe[Ae].digest===Ne[Ae].digest)?((null===xe[Ae]||null===xe[Ae].data)&&(p=o.concat(m.attachment,Ae,"attachment removed")),"incremental"===w&&delete xe[Ae]):p=o.concat(m.attachment,Ae,"attachment updated"):"fillUp"===w?xe[Ae]=Ne[Ae]:w||(p=o.concat(m.attachment,Ae,"attachment removed")));for(var Ce in xe)Object.prototype.hasOwnProperty.call(xe,Ce)&&([null,void 0].includes(xe[Ce])||null===xe[Ce].data?delete xe[Ce]:Ne&&Object.prototype.hasOwnProperty.call(Ne,Ce)&&xe[Ce].content_type===Ne[Ce].content_type&&(xe[Ce].data===Ne[Ce].data||xe[Ce].digest===Ne[Ce].digest)||(p=o.concat(m.attachment,Ce,"attachment updated")));0===Object.keys(xe).length&&delete e[m.attachment];var Se={};for(var Te in v[m.attachment])Object.prototype.hasOwnProperty.call(v[m.attachment],Te)&&(Se[Te]=[]);for(var Ee in xe)if(Object.prototype.hasOwnProperty.call(xe,Ee)){var ke=!1;for(var De in v[m.attachment])if(E(De,Ee,v[m.attachment][De])){Se[De].push(Ee),ke=!0;break}ke||c('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(v[m.attachment]).join('", "')+'") matches given one ("'+Ee+'")'+a+".")}for(var Me=0,_e=0,ze=Object.keys(Se);_e<ze.length;_e++){var Re=ze[_e],Ue=v[m.attachment][Re];if(Object.prototype.hasOwnProperty.call(Se,Re)){var He=Se[Re].length;null!==Ue.maximumNumber&&He>Ue.maximumNumber&&c("AttachmentMaximum: given number of attachments ("+He+") doesn't satisfy specified maximum of "+Ue.maximumNumber+' from type "'+Re+'"'+a+"."),(!Ue.nullable||0!==He)&&He<Ue.minimumNumber&&c("AttachmentMinimum: given number of attachments ("+He+") doesn't satisfy specified minimum of "+Ue.minimumNumber+' from type "'+Re+'"'+a+".");for(var Le,Ie=0,We=n(Se[Re]);!(Le=We()).done;){var Fe,Be,Ve=Le.value;null!=(Fe=Ue.fileName)&&Fe.regularExpressionPattern&&!new RegExp(Ue.fileName.regularExpressionPattern).test(Ve)?c('AttachmentName: given attachment name "'+Ve+'" doesn\'t satisfy specified regular expression pattern "'+Ue.fileName.regularExpressionPattern+'" from type "'+Re+'"'+a+"."):null!=(Be=Ue.fileName)&&Be.invertedRegularExpressionPattern&&new RegExp(Ue.fileName.invertedRegularExpressionPattern).test(Ve)?c('InvertedAttachmentName: given attachment name "'+Ve+'" does satisfy specified regular expression pattern "'+Ue.fileName.invertedRegularExpressionPattern+'" from type "'+Re+'"'+a+"."):!([null,void 0].includes(Ue.contentTypeRegularExpressionPattern)||xe[Ve].content_type&&new RegExp(Ue.contentTypeRegularExpressionPattern).test(xe[Ve].content_type))&&c('AttachmentContentType: given attachment content type "'+xe[Ve].content_type+'" doesn\'t satisfy specified regular expression pattern "'+Ue.contentTypeRegularExpressionPattern+'" from type "'+Re+'"'+a+".");var $e=Ue.invertedContentTypeRegularExpressionPattern;[null,void 0].includes($e)||xe[Ve].content_type&&!new RegExp($e).test(xe[Ve].content_type)||c('InvertedAttachmentContentType: given attachment content type "'+xe[Ve].content_type+'" does satisfy specified regular expression pattern "'+$e+'" from type "'+Re+'"'+a+".");var qe=0;"length"in xe[Ve]?qe=xe[Ve].length:"data"in xe[Ve]&&(qe=Buffer&&"byteLength"in Buffer?Buffer.byteLength(xe[Ve].data,"base64"):xe[Ve].data.length),![null,void 0].includes(Ue.minimumSize)&&Ue.minimumSize>qe?c("AttachmentMinimumSize: given attachment size "+qe+" byte doesn't satisfy specified minimum of "+Ue.minimumSize+" byte "+a+"."):![null,void 0].includes(Ue.maximumSize)&&Ue.maximumSize<qe&&c("AttachmentMaximumSize: given attachment size "+qe+" byte doesn't satisfy specified maximum of "+Ue.maximumSize+" byte "+a+"."),Ie+=qe}![null,void 0].includes(Ue.minimumAggregatedSize)&&Ue.minimumAggregatedSize>Ie?c('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+Re+'" '+Ie+" byte doesn't satisfy specified minimum of "+Ue.minimumAggregatedSize+" byte "+a+"."):![null,void 0].includes(Ue.maximumAggregatedSize)&&Ue.maximumAggregatedSize<Ie&&c('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+Re+'" '+Ie+" byte doesn't satisfy specified maximum of "+Ue.maximumAggregatedSize+" byte "+a+"."),Me+=Ie}}Object.prototype.hasOwnProperty.call(v,m.minimumAggregatedSize)&&![null,void 0].includes(v[m.minimumAggregatedSize])&&v[m.minimumAggregatedSize]>Me?c("AggregatedMinimumSize: given aggregated size "+Me+" byte doesn't satisfy specified minimum of "+v[m.minimumAggregatedSize]+" byte "+a+"."):![null,void 0].includes(v[m.maximumAggregatedSize])&&v[m.maximumAggregatedSize]<Me&&c("AggregatedMaximumSize: given aggregated size "+Me+" byte doesn't satisfy specified maximum of "+v[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===p.length&&r&&"migrate"===w)for(var Ye in r)Object.prototype.hasOwnProperty.call(r,Ye)&&!Object.prototype.hasOwnProperty.call(e,Ye)&&(p=o.concat(Ye,"migrate removed property"));return{changedPath:p,newDocument:e}},z=_(e,r);return(!z.newDocument._deleted||r)&&(z.newDocument._deleted&&z.newDocument._deleted!==(null==r?void 0:r._deleted)||z.changedPath.length)||c("NoChange: No new data given. new document: "+P(e)+"; old document: "+P(r)+"."),Object.prototype.hasOwnProperty.call(a,i.property.name.validatedDocumentsCache)?a[i.property.name.validatedDocumentsCache].add(g+"-"+v):a[i.property.name.validatedDocumentsCache]=new Set([g+"-"+v]),z.newDocument},e}();const l=i})(),module.exports=o})();
package/helper.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var __webpack_modules__=[e=>{e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{e.exports=require("@babel/runtime/regenerator")},e=>{e.exports=require("clientnode")},e=>{e.exports=require("fs")},e=>{e.exports=require("path")},e=>{e.exports=require("@babel/runtime/helpers/extends")},e=>{e.exports=require("child_process")},e=>{e.exports=require("pouchdb/node_modules/node-fetch/lib/index.js")}],__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var _=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](_,_.exports,__webpack_require__),_.exports}__webpack_require__.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=(e,r)=>{for(var _ in r)__webpack_require__.o(r,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:r[_]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__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__={};(()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Helper:()=>Helper,default:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5),_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__(0),_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__(1),_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__(6),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(2),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(7),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(3),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(4),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__);function _createForOfIteratorHelperLoose(e,r){var _="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(_)return(_=_.call(e)).next.bind(_);if(Array.isArray(e)||(_=_unsupportedIterableToArray(e))||r&&e&&"number"==typeof e.length){_&&(e=_);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}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,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var _=Object.prototype.toString.call(e).slice(8,-1);return"Object"===_&&e.constructor&&(_=e.constructor.name),"Map"===_||"Set"===_?Array.from(e):"Arguments"===_||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var _=0,t=Array(r);_<r;_++)t[_]=e[_];return t}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(r,_){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(r,clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.couchdb.connector.fetch),_||{}))}}:{fetch:function(e,r){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(e,r)}}},Helper.mayStripRepresentation=function(e,r,_){var t=clientnode__WEBPACK_IMPORTED_MODULE_4___default().represent(e);return t.length<=r?t.length>_?t.substring(0,_-3)+"...":t:"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(r,_,t,n,o,a,c){var i,l,s;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===a&&(a="_id"),void 0===c&&(c="_design/"),l=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(((i={})[a]=""+c+_,i.language="javascript",i),t),e.prev=4,e.next=7,r.get(""+c+_);case 7:return s=e.sent,l._rev=s._rev,e.next=11,r.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,r.put(l);case 23:throw e.prev=23,e.t1=e.catch(17),new Error(n+" 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(r,_){var t,n,o,a,c,i;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(_.couchdb.url,_.couchdb.user.name+":"+_.couchdb.user.password+"@")+"/"+_.name,r.couchdb.connection=new r.couchdb.connector(t,Helper.getConnectorOptions(_)),r.couchdb.connection.setMaxListeners(1/0),n=_.couchdb.model.property.name.special.id,o=_.couchdb.model.property.name.special.revision,a=function(){var e=i.value,t=r.couchdb.connection[e].bind(r.couchdb.connection);r.couchdb.connection[e]=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(r){var a,c,i,l,s,u=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,a=u.length,c=Array(1<a?a-1:0),i=1;i<a;i++)c[i-1]=u[i];return e.next=4,t.apply(void 0,[r].concat(c));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!(n in r&&_.couchdb.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(l=e.t0.message)&&l.startsWith("NoChange:"))){e.next=21;break}if(s={id:r[n],ok:!0},!(o in r)||["latest","upsert"].includes(r[o])){e.next=15;break}e.t1=r[o],e.next=19;break;case 15:return e.next=17,this.get(s.id);case 17:e.t2=o,e.t1=e.sent[e.t2];case 19:return s.rev=e.t1,e.abrupt("return",s);case 21:throw e.t0;case 22:case"end":return e.stop()}}),e,this,[[0,7]])})))},c=_createForOfIteratorHelperLoose(["post","put"]);!(i=c()).done;)a();return e.prev=7,e.next=10,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(t);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(t,{method:"PUT"});case 17:return e.abrupt("return",r);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.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,r){for(var _,t,n=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(_=n()).done;)t=_.value,services.couchdb.server.process.on(t,clientnode__WEBPACK_IMPORTED_MODULE_4___default().getProcessCloseHandler(e,r,{process:services.couchdb.server.process,reason:t}))})).then((function(){for(var e,r,_=arguments.length,t=Array(_),n=0;n<_;n++)t[n]=arguments[n];null!=(e=services.couchdb)&&null!=(r=e.server)&&r.resolve&&services.couchdb.server.resolve.apply(_this,t)}),(function(){for(var e,r,_=arguments.length,t=Array(_),n=0;n<_;n++)t[n]=arguments[n];null!=(e=services.couchdb)&&null!=(r=e.server)&&r.resolve&&services.couchdb.server.reject.apply(_this,t)})),_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(r,_,t,n){var o,a;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.couchdb.server.resolve,a=r.couchdb.server.reject,r.couchdb.server.resolve=r.couchdb.server.reject=clientnode__WEBPACK_IMPORTED_MODULE_4___default().noop,e.next=5,Helper.stopServer(r,_);case 5:return r.couchdb.server.resolve=o,r.couchdb.server.reject=a,e.next=9,Helper.startServer(r,_);case 9:return Helper.initializeConnection(r,_),e.next=12,n.callStack("restartCouchdb",t,_,r);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(r,_){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.couchdb.connection&&r.couchdb.connection.close(),r.couchdb.server.process&&r.couchdb.server.process.kill("SIGINT"),e.next=4,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkUnreachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(_.couchdb.url,""),{wait:!0});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Helper.determineAllowedModelRolesMapping=function(e){var r=e.property.name.special.allowedRole,_={},t=Helper.extendModels(e);for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Object.prototype.hasOwnProperty.call(t[n],r))for(var o in _[n]=Helper.normalizeAllowedModelRoles(t[n][r]),_[n].properties={},t[n])Object.prototype.hasOwnProperty.call(t[n],o)&&null!==t[n][o]&&"object"==typeof t[n][o]&&Object.prototype.hasOwnProperty.call(t[n][o],"allowedRoles")&&t[n][o].allowedRoles&&(_[n].properties[o]=Helper.normalizeAllowedModelRoles(t[n][o].allowedRoles));else _[n]={properties:{},read:[],write:[]};return _},Helper.determineGenericIndexablePropertyNames=function(e,r){var _=e.property.name.special;return Object.keys(r).filter((function(t){return null!==r[t]&&"object"==typeof r[t]&&(Object.prototype.hasOwnProperty.call(r[t],"index")&&r[t].index||!(Object.prototype.hasOwnProperty.call(r[t],"index")&&!r[t].index||e.property.name.reserved.concat(_.additional,_.allowedRole,_.attachment,_.conflict,_.constraint.execution,_.constraint.expression,_.deleted,_.deletedConflict,_.extend,_.id,_.maximumAggregatedSize,_.minimumAggregatedSize,_.oldType,_.revision,_.revisions,_.revisionsInformation,_.type).includes(t)||r[t].type&&("string"==typeof r[t].type&&r[t].type.endsWith("[]")||Array.isArray(r[t].type)&&r[t].type.length&&Array.isArray(r[t].type[0])||Object.prototype.hasOwnProperty.call(e.entities,r[t].type))))})).concat(_.id,_.revision).sort()},Helper.extendModel=function(e,r,_){if(void 0===_&&(_="_extends"),"_base"===e)return r[e];if(Object.prototype.hasOwnProperty.call(r,"_base")&&(Object.prototype.hasOwnProperty.call(r[e],_)&&r[e][_]?r[e][_]=["_base"].concat(r[e][_]):r[e][_]="_base"),Object.prototype.hasOwnProperty.call(r[e],_)){for(var t,n,o=_createForOfIteratorHelperLoose([].concat(r[e][_]));!(t=o()).done;)n=t.value,r[e]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(Helper.extendModel(n,r,_)),r[e]);delete r[e][_]}return r[e]},Helper.extendModels=function(e){var r=e.property.name.special,_={};for(var t in e.entities)if(Object.prototype.hasOwnProperty.call(e.entities,t)){if(!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+'").');_[t]=Helper.extendModel(t,e.entities,r.extend)}for(var n in _)if(Object.prototype.hasOwnProperty.call(_,n))for(var o in _[n])if(Object.prototype.hasOwnProperty.call(_[n],o))if(o===r.attachment)for(var a in _[n][o])Object.prototype.hasOwnProperty.call(_[n][o],a)&&(_[n][o][a]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),_[n][o][a]));else[r.allowedRole,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(o)||(_[n][o]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),_[n][o]));return _},Helper.normalizeAllowedModelRoles=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){var r={read:[],write:[]};for(var _ in r)Object.prototype.hasOwnProperty.call(e,_)&&(r[_]=Array.isArray(e[_])?e[_]:[e[_]]);return r}return{read:[e],write:[e]}},Helper}();const __WEBPACK_DEFAULT_EXPORT__=Helper})(),module.exports=__webpack_exports__})();
1
+ (()=>{"use strict";var __webpack_modules__=[e=>{e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{e.exports=require("@babel/runtime/regenerator")},e=>{e.exports=require("clientnode")},e=>{e.exports=require("fs")},e=>{e.exports=require("path")},e=>{e.exports=require("@babel/runtime/helpers/extends")},e=>{e.exports=require("child_process")},e=>{e.exports=require("pouchdb/node_modules/node-fetch/lib/index.js")}],__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var _=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](_,_.exports,__webpack_require__),_.exports}__webpack_require__.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=(e,r)=>{for(var _ in r)__webpack_require__.o(r,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:r[_]})},__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__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__={};(()=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Helper:()=>Helper,default:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(5),_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__(0),_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__(1),_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__(6),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(2),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(7),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(3),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(4),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__);function _createForOfIteratorHelperLoose(e,r){var _="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(_)return(_=_.call(e)).next.bind(_);if(Array.isArray(e)||(_=_unsupportedIterableToArray(e))||r&&e&&"number"==typeof e.length){_&&(e=_);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}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,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var _=Object.prototype.toString.call(e).slice(8,-1);return"Object"===_&&e.constructor&&(_=e.constructor.name),"Map"===_||"Set"===_?Array.from(e):"Arguments"===_||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var _=0,t=Array(r);_<r;_++)t[_]=e[_];return t}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(r,_){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(r,clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.couchdb.connector.fetch),_||{}))}}:{fetch:function(e,r){return clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch(e,r)}}},Helper.mayStripRepresentation=function(e,r,_){var t=clientnode__WEBPACK_IMPORTED_MODULE_4___default().represent(e);return t.length<=r?t.length>_?t.substring(0,_-3)+"...":t:"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(r,_,t,n,o,a,c){var i,l,s;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===a&&(a="_id"),void 0===c&&(c="_design/"),l=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(((i={})[a]=""+c+_,i.language="javascript",i),t),e.prev=4,e.next=7,r.get(""+c+_);case 7:return s=e.sent,l._rev=s._rev,e.next=11,r.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,r.put(l);case 23:throw e.prev=23,e.t1=e.catch(17),new Error(n+" 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(r,_){var t,n,o,a,c,i;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(_.couchdb.url,_.couchdb.user.name+":"+_.couchdb.user.password+"@")+"/"+_.couchdb.databaseName,r.couchdb.connection=new r.couchdb.connector(t,Helper.getConnectorOptions(_)),r.couchdb.connection.setMaxListeners(1/0),n=_.couchdb.model.property.name.special.id,o=_.couchdb.model.property.name.special.revision,a=function(){var e=i.value,t=r.couchdb.connection[e].bind(r.couchdb.connection);r.couchdb.connection[e]=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(r){var a,c,i,l,s,u=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,a=u.length,c=Array(1<a?a-1:0),i=1;i<a;i++)c[i-1]=u[i];return e.next=4,t.apply(void 0,[r].concat(c));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!(n in r&&_.couchdb.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(l=e.t0.message)&&l.startsWith("NoChange:"))){e.next=21;break}if(s={id:r[n],ok:!0},!(o in r)||["latest","upsert"].includes(r[o])){e.next=15;break}e.t1=r[o],e.next=19;break;case 15:return e.next=17,this.get(s.id);case 17:e.t2=o,e.t1=e.sent[e.t2];case 19:return s.rev=e.t1,e.abrupt("return",s);case 21:throw e.t0;case 22:case"end":return e.stop()}}),e,this,[[0,7]])})))},c=_createForOfIteratorHelperLoose(["post","put"]);!(i=c()).done;)a();return e.prev=7,e.next=10,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkReachability(t);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(t,{method:"PUT"});case 17:return e.abrupt("return",r);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,r){for(var _,t,n=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(_=n()).done;)t=_.value,services.couchdb.server.process.on(t,clientnode__WEBPACK_IMPORTED_MODULE_4___default().getProcessCloseHandler(e,r,{process:services.couchdb.server.process,reason:t}))})).then((function(){for(var e,r,_=arguments.length,t=Array(_),n=0;n<_;n++)t[n]=arguments[n];null!=(e=services.couchdb)&&null!=(r=e.server)&&r.resolve&&services.couchdb.server.resolve.apply(_this,t)}),(function(){for(var e,r,_=arguments.length,t=Array(_),n=0;n<_;n++)t[n]=arguments[n];null!=(e=services.couchdb)&&null!=(r=e.server)&&r.resolve&&services.couchdb.server.reject.apply(_this,t)})),_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(r,_,t,n){var o,a;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.couchdb.server.resolve,a=r.couchdb.server.reject,r.couchdb.server.resolve=r.couchdb.server.reject=clientnode__WEBPACK_IMPORTED_MODULE_4___default().noop,e.next=5,Helper.stopServer(r,_);case 5:return r.couchdb.server.resolve=o,r.couchdb.server.reject=a,e.next=9,Helper.startServer(r,_);case 9:return Helper.initializeConnection(r,_),e.next=12,n.callStack("restartCouchdb",t,_,r);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(r,_){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.couchdb.connection&&r.couchdb.connection.close(),r.couchdb.server.process&&r.couchdb.server.process.kill("SIGINT"),e.next=4,clientnode__WEBPACK_IMPORTED_MODULE_4___default().checkUnreachability(clientnode__WEBPACK_IMPORTED_MODULE_4___default().stringFormat(_.couchdb.url,""),{wait:!0});case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Helper.determineAllowedModelRolesMapping=function(e){var r=e.property.name.special.allowedRole,_={},t=Helper.extendModels(e);for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&Object.prototype.hasOwnProperty.call(t[n],r))for(var o in _[n]=Helper.normalizeAllowedModelRoles(t[n][r]),_[n].properties={},t[n])Object.prototype.hasOwnProperty.call(t[n],o)&&null!==t[n][o]&&"object"==typeof t[n][o]&&Object.prototype.hasOwnProperty.call(t[n][o],"allowedRoles")&&t[n][o].allowedRoles&&(_[n].properties[o]=Helper.normalizeAllowedModelRoles(t[n][o].allowedRoles));else _[n]={properties:{},read:[],write:[]};return _},Helper.determineGenericIndexablePropertyNames=function(e,r){var _=e.property.name.special;return Object.keys(r).filter((function(t){return null!==r[t]&&"object"==typeof r[t]&&(Object.prototype.hasOwnProperty.call(r[t],"index")&&r[t].index||!(Object.prototype.hasOwnProperty.call(r[t],"index")&&!r[t].index||e.property.name.reserved.concat(_.additional,_.allowedRole,_.attachment,_.conflict,_.constraint.execution,_.constraint.expression,_.deleted,_.deletedConflict,_.extend,_.id,_.maximumAggregatedSize,_.minimumAggregatedSize,_.oldType,_.revision,_.revisions,_.revisionsInformation,_.type).includes(t)||r[t].type&&("string"==typeof r[t].type&&r[t].type.endsWith("[]")||Array.isArray(r[t].type)&&r[t].type.length&&Array.isArray(r[t].type[0])||Object.prototype.hasOwnProperty.call(e.entities,r[t].type))))})).concat(_.id,_.revision).sort()},Helper.extendModel=function(e,r,_){if(void 0===_&&(_="_extends"),"_base"===e)return r[e];if(Object.prototype.hasOwnProperty.call(r,"_base")&&(Object.prototype.hasOwnProperty.call(r[e],_)&&r[e][_]?r[e][_]=["_base"].concat(r[e][_]):r[e][_]="_base"),Object.prototype.hasOwnProperty.call(r[e],_)){for(var t,n,o=_createForOfIteratorHelperLoose([].concat(r[e][_]));!(t=o()).done;)n=t.value,r[e]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(Helper.extendModel(n,r,_)),r[e]);delete r[e][_]}return r[e]},Helper.extendModels=function(e){var r=e.property.name.special,_={};for(var t in e.entities)if(Object.prototype.hasOwnProperty.call(e.entities,t)){if(!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+'").');_[t]=Helper.extendModel(t,e.entities,r.extend)}for(var n in _)if(Object.prototype.hasOwnProperty.call(_,n))for(var o in _[n])if(Object.prototype.hasOwnProperty.call(_[n],o))if(o===r.attachment)for(var a in _[n][o])Object.prototype.hasOwnProperty.call(_[n][o],a)&&(_[n][o][a]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),_[n][o][a]));else[r.allowedRole,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(o)||(_[n][o]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),_[n][o]));return _},Helper.normalizeAllowedModelRoles=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){var r={read:[],write:[]};for(var _ in r)Object.prototype.hasOwnProperty.call(e,_)&&(r[_]=Array.isArray(e[_])?e[_]:[e[_]]);return r}return{read:[e],write:[e]}},Helper}();const __WEBPACK_DEFAULT_EXPORT__=Helper})(),module.exports=__webpack_exports__})();
package/index.js CHANGED
@@ -1 +1 @@
1
- (()=>{var __webpack_modules__=[e=>{"use strict";e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{"use strict";e.exports=require("@babel/runtime/regenerator")},e=>{"use strict";e.exports=require("clientnode")},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},e=>{"use strict";e.exports=require("@babel/runtime/helpers/extends")},e=>{"use strict";e.exports=require("child_process")},e=>{"use strict";e.exports=require("pouchdb/node_modules/node-fetch/lib/index.js")},(__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__(5),_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__(0),_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__(1),_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__(6),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(2),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(7),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(3),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(4),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,o,a,c,_){var i,s,l;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=!0),void 0===c&&(c="_id"),void 0===_&&(_="_design/"),s=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(((i={})[c]=""+_+r,i.language="javascript",i),n),e.prev=4,e.next=7,t.get(""+_+r);case 7:return l=e.sent,s._rev=l._rev,e.next=11,t.put(s);case 11:case 20:e.next=26;break;case 14:return e.prev=14,e.t0=e.catch(4),a&&e.t0.error,e.prev=17,e.next=20,t.put(s);case 23:throw e.prev=23,e.t1=e.catch(17),new Error(o+" 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,o,a,c,_,i;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.name,t.couchdb.connection=new t.couchdb.connector(n,Helper.getConnectorOptions(r)),t.couchdb.connection.setMaxListeners(1/0),o=r.couchdb.model.property.name.special.id,a=r.couchdb.model.property.name.special.revision,c=function(){var e=i.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=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=u.length,_=Array(1<c?c-1:0),i=1;i<c;i++)_[i-1]=u[i];return e.next=4,n.apply(void 0,[t].concat(_));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!(o in t&&r.couchdb.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(s=e.t0.message)&&s.startsWith("NoChange:"))){e.next=21;break}if(l={id:t[o],ok:!0},!(a in t)||["latest","upsert"].includes(t[a])){e.next=15;break}e.t1=t[a],e.next=19;break;case 15:return e.next=17,this.get(l.id);case 17:e.t2=a,e.t1=e.sent[e.t2];case 19:return l.rev=e.t1,e.abrupt("return",l);case 21:throw e.t0;case 22:case"end":return e.stop()}}),e,this,[[0,7]])})))},_=_createForOfIteratorHelperLoose(["post","put"]);!(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.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,o=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(r=o()).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(){for(var e,t,r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];null!=(e=services.couchdb)&&null!=(t=e.server)&&t.resolve&&services.couchdb.server.resolve.apply(_this,n)}),(function(){for(var e,t,r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];null!=(e=services.couchdb)&&null!=(t=e.server)&&t.resolve&&services.couchdb.server.reject.apply(_this,n)})),_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,o){var a,c;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=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=a,t.couchdb.server.reject=c,e.next=9,Helper.startServer(t,r);case 9:return Helper.initializeConnection(t,r),e.next=12,o.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){var t=e.property.name.special.allowedRole,r={},n=Helper.extendModels(e);for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)&&Object.prototype.hasOwnProperty.call(n[o],t))for(var a in r[o]=Helper.normalizeAllowedModelRoles(n[o][t]),r[o].properties={},n[o])Object.prototype.hasOwnProperty.call(n[o],a)&&null!==n[o][a]&&"object"==typeof n[o][a]&&Object.prototype.hasOwnProperty.call(n[o][a],"allowedRoles")&&n[o][a].allowedRoles&&(r[o].properties[a]=Helper.normalizeAllowedModelRoles(n[o][a].allowedRoles));else r[o]={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.allowedRole,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,o,a=_createForOfIteratorHelperLoose([].concat(t[e][r]));!(n=a()).done;)o=n.value,t[e]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(Helper.extendModel(o,t,r)),t[e]);delete t[e][r]}return t[e]},Helper.extendModels=function(e){var t=e.property.name.special,r={};for(var n in e.entities)if(Object.prototype.hasOwnProperty.call(e.entities,n)){if(!new RegExp(e.property.name.typeRegularExpressionPattern.public).test(n)&&!new RegExp(e.property.name.typeRegularExpressionPattern.private).test(n))throw new Error('Model names have to match "'+e.property.name.typeRegularExpressionPattern.public+'" or "'+e.property.name.typeRegularExpressionPattern.private+'" for private one (given name: "'+n+'").');r[n]=Helper.extendModel(n,e.entities,t.extend)}for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o))for(var a in r[o])if(Object.prototype.hasOwnProperty.call(r[o],a))if(a===t.attachment)for(var c in r[o][a])Object.prototype.hasOwnProperty.call(r[o][a],c)&&(r[o][a][c]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),r[o][a][c]));else[t.allowedRole,t.constraint.execution,t.constraint.expression,t.extend,t.maximumAggregatedSize,t.minimumAggregatedSize,t.oldType].includes(a)||(r[o][a]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),r[o][a]));return r},Helper.normalizeAllowedModelRoles=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){var t={read:[],write:[]};for(var r in t)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=Array.isArray(e[r])?e[r]:[e[r]]);return t}return{read:[e],write:[e]}},Helper}();const __WEBPACK_DEFAULT_EXPORT__=Helper},e=>{!function(){function t(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return r[e](a,a.exports,t),a.exports}var r=[function(e,t,r){function n(){return a()?(e.exports=n=Reflect.construct,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=n=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},e.exports.__esModule=!0,e.exports.default=e.exports),n.apply(null,arguments)}var o=r(1),a=r(2);e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){function t(r,n){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}],n={};t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,{a:r}),r},t.d=function(e,r){for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(function(){"use strict";function e(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}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 r(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}t.r(o),t.d(o,{DatabaseHelper:function(){return c},default:function(){return _}});var n=t(0),a=t.n(n),c=function(){function t(){}return t.authenticate=function(t,r,n,o,a,c,_,i,s){var l;void 0===r&&(r=null),void 0===n&&(n={db:"dummy",name:'"unknown"',roles:[]}),void 0===o&&(o={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===c&&(c="_id"),void 0===_&&(_="-type"),void 0===i&&(i="_design/"),void 0===s&&(s=!1);var u=null!==(l=t[_])&&void 0!==l?l:r&&r[_];if(!u)return!0;var p=s?"read":"write",d={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(t,c)&&t[c].startsWith(i)&&d.read.push("readonlymember");var m="Current user doesn't own any role";if(n)if("name"in n||(n.name='"unknown"'),n.roles.length){if(a&&u&&Object.prototype.hasOwnProperty.call(a,u)){for(var f,b,y=a[u],h=e(["read","write"]);!(f=h()).done;)d[b=f.value]=d[b].concat(y[b]||[]);y.properties&&(d.properties=y.properties)}for(var x,O,E=d[p],P=e(n.roles);!(x=P()).done;)if(O=x.value,E.includes(O))return!0;m='Current user "'+n.name+'" owns the following roles: "'+n.roles.join('", "')+'"'}else m='Current user "'+n.name+"\" doesn't own any role";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+p+' action: "'+d[p].join('", "')+'". '+m+"."}},t.validateDocumentUpdate=function(t,r,n,o,c,_,i){void 0===_&&(_={});var s=function(e,t,r){var n;void 0===t&&(t="forbidden"),void 0===r&&(r={});var o=((n={})[t]=e,n.message=e,n.name=t,n);for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(o[a]=r[a]);throw o},l=new Date,u=Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate(),l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds())/1e3,p=!c.dateTimeFormat.startsWith("iso"),d=c.property.name.special,m=d.id,f=d.revision,b=d.type;r&&r[b]&&!t[b]&&(t[b]=r[b]);var y="",h="",x=function(){y=Object.prototype.hasOwnProperty.call(t,m)?t[m]:"",h=Object.prototype.hasOwnProperty.call(t,f)?t[f]:""};if(x(),Object.prototype.hasOwnProperty.call(o,c.property.name.validatedDocumentsCache)&&o[c.property.name.validatedDocumentsCache].has(y+"-"+h))return o[c.property.name.validatedDocumentsCache].delete(y+"-"+h),t;["latest","upsert"].includes(h)&&(r&&Object.prototype.hasOwnProperty.call(r,f)?h=t[f]=r[f]:"latest"===h?s("Revision: No old document available to update."):delete t[f]);var O,E=c.updateStrategy;Object.prototype.hasOwnProperty.call(t,d.strategy)&&(E=t[d.strategy],delete t[d.strategy]),i?O=i:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?O=function(e){return JSON.stringify(e,null,4)}:s('Needed "serializer" is not available.');var P=function(e){return e instanceof Error?""+e:O(e)},g={};if("migrate"===E)for(var v in _)if(Object.prototype.hasOwnProperty.call(_,v)&&Object.prototype.hasOwnProperty.call(_[v],d.oldType)&&![null,void 0].includes(_[v][d.oldType]))for(var D,M,w=e([].concat(_[v][d.oldType]));!(D=w()).done;)M=D.value,g[M]=v;var C=function(e){return"string"==typeof e?e.trim():""},A=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},k=function(e,r){if(r||(r=t[d.attachment]),e){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&n.startsWith(e))return n}else{var o=Object.keys(r);if(o.length)return o[0]}return null},T=function(e){if(Object.prototype.hasOwnProperty.call(t,d.attachment)){var r=t[d.attachment],n=k(e);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},I=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r={});var i=C(e);if(i){var p=(t?"return ":"")+i,y={attachmentWithPrefixExists:T,checkDocument:R,code:p,getFileNameByPrefix:k,idName:m,modelConfiguration:c,models:_,now:l,nowUTCTimestamp:u,revisionName:f,securitySettings:o,serialize:P,specialNames:d,typeName:b,userContext:n};for(var h in r)Object.prototype.hasOwnProperty.call(r,h)&&(y[h]=r[h]);var x,O=Object.keys(y);try{x=a()(Function,O.concat([p]))}catch(e){s(P(e),"compilation",{code:p,error:e,scope:y})}var E={code:p,result:void 0,scope:y};try{E.result=x.apply(void 0,O.map((function(e){return y[e]})))}catch(e){s(P(e),"runtime",{code:p,error:e,scope:y})}return E}s("No expression to evaluate provided.","empty")},R=function(t,r,n){void 0===n&&(n=[]);var o=n.length?" in "+n.join(" -> "):"",i=[],l=function(){Object.prototype.hasOwnProperty.call(t,b)||(r&&Object.prototype.hasOwnProperty.call(r,b)&&["fillUp","migrate"].includes(E)?t[b]=r[b]:s('Type: You have to specify a model type via property "'+b+'"'+o+".")),n.length||new RegExp(c.property.name.typeRegularExpressionPattern.public).test(t[b])||s('TypeName: You have to specify a model type which matches "'+c.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+t[b]+'")'+o+"."),Object.prototype.hasOwnProperty.call(_,t[b])||(Object.prototype.hasOwnProperty.call(g,t[b])?t[b]=g[t[b]]:s('Model: Given model "'+t[b]+'" is not specified'+o+"."))};l();var u=t[b],h=_[u],O=null;Object.prototype.hasOwnProperty.call(h,d.additional)&&h[d.additional]&&(O=h[d.additional]);var v=function(c,_,i,l,p){void 0===p&&(p=["constraintExecution","constraintExpression"]);for(var d,m,f=e(p);!(d=f()).done;)if(m=d.value,Object.prototype.hasOwnProperty.call(i,m)){var b=void 0;try{b=I(i[m].evaluation,m.endsWith("Expression"),{checkPropertyContent:D,code:i[m].evaluation,model:h,modelName:u,name:_,newDocument:t,newValue:c,oldDocument:r,oldValue:l,parentNames:n,pathDescription:o,propertySpecification:i,type:m})}catch(c){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(c)&&s('Compilation: Hook "'+m+'" has invalid code "'+c.code+'": "'+c.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(c)&&s('Runtime: Hook "'+m+'" has throw an error with code "'+c.code+'": "'+c.message+'"'+o+"."),!Object.prototype.hasOwnProperty.call(c,"empty"))throw c}if(!b.result){var y=C(i[m].description);s(m.charAt(0).toUpperCase()+(m.substring(1)+": ")+(y?a()(Function,Object.keys(b.scope).concat(["return "+y])).apply(void 0,Object.values(b.scope)):'Property "'+_+'" should satisfy constraint "'+b.code+'" (given "'+P(c)+'")'+o+"."))}}},D=function(t,r,a,c){void 0===c&&(c=null);var i=[],l=[].concat(a.type?a.type:[]);"object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype&&!Object.prototype.hasOwnProperty.call(t,b)&&1===l.length&&Object.prototype.hasOwnProperty.call(_,l[0])&&(t[b]=l[0]);for(var u,d,f=!1,y=e(l);!(u=y()).done;)if(d=u.value,Object.prototype.hasOwnProperty.call(_,d)){if("object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype&&Object.prototype.hasOwnProperty.call(t,b)&&t[b]!==d&&"migrate"===E&&1===l.length&&(t[b]=d,i=n.concat(r,"migrate nested object type")),"object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype&&Object.prototype.hasOwnProperty.call(t,b)&&t[b]===d){var h=R(t,c,n.concat(r));if(h.changedPath.length&&(i=h.changedPath),t=h.newDocument,P(t)===P({}))return{newValue:null,changedPath:i};f=!0;break}1===l.length&&s('NestedType: Under key "'+r+'" isn\'t of type "'+d+'" (given "'+P(t)+'" of type '+typeof t+")"+o+".")}else if("DateTime"===d){var x=t;if(p)p&&null!==t&&"number"!=typeof t&&(t=new Date(t),t=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds(),t.getUTCMilliseconds())/1e3);else{t=new Date(t);try{t=t.toISOString()}catch(t){}}if(!(p&&("number"!=typeof t||isNaN(t))||!p&&"string"!=typeof t)){f=!0;break}1===l.length&&s('PropertyType: Property "'+r+'" isn\'t of (valid) type "DateTime" (given "'+P(x).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof x+'")'+o+".")}else if(["boolean","integer","number","string"].includes(d)){if(!("number"==typeof t&&isNaN(t)||"integer"!==d&&typeof t!==d||"integer"===d&&parseInt(t,10)!==t)){f=!0;break}1===l.length&&s('PropertyType: Property "'+r+'" isn\'t of (valid) type "${type}" (given "'+P(t)+'" of type "'+typeof t+'")'+o+".")}else if("string"==typeof d&&d.startsWith("foreignKey:")){var O=_[d.substring(11)][m].type;if(O===typeof t){f=!0;break}1===l.length&&s('PropertyType: Foreign key property "'+r+'" isn\'t of type "'+O+'" (given "'+P(t)+'" of type "'+typeof t+'")'+o+".")}else{if("any"===d||P(t)===P(d)){f=!0;break}1===l.length&&s('PropertyType: Property "'+r+'" isn\'t value "'+d+'" (given "'+P(t).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof t+'")'+o+".")}if(f||s('PropertyType: None of the specified types "'+l.join('", "')+'" for property "'+r+'" matches value "'+P(t).replace(/^"/,"").replace(/"$/,"")+t+'" of type "'+typeof t+'")'+o+"."),"string"==typeof t&&(![null,void 0].includes(a.minimumLength)&&t.length<a.minimumLength&&s('MinimalLength: Property "'+r+'" must have minimal length '+a.minimumLength+" (given "+t+" with length i"+t.length+") "+o+"."),![null,void 0].includes(a.maximumLength)&&t.length>a.maximumLength&&s('MaximalLength: Property "'+r+'" must have maximal length '+a.maximumLength+" (given "+t+" with length "+t.length+")"+o+".")),"number"==typeof t&&(![null,void 0].includes(a.minimum)&&t<a.minimum&&s('Minimum: Property "'+r+'" (type '+a.type+") must satisfy a minimum of "+a.minimum+" (given "+t+" is too low)"+o+"."),![null,void 0].includes(a.maximum)&&t>a.maximum&&s('Maximum: Property "'+r+'" (type '+a.type+") must satisfy a maximum of "+a.maximum+" (given "+t+" is too high)"+o+".")),a.selection){var g=Array.isArray(a.selection)?a.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(a.selection);g.includes(t)||s('Selection: Property "'+r+'" (type '+a.type+') should be one of "'+g.join('", "')+'". But is "'+t+'"'+o+".")}return[null,void 0].includes(a.regularExpressionPattern)||new RegExp(a.regularExpressionPattern).test(t)?![null,void 0].includes(a.invertedRegularExpressionPattern)&&new RegExp(a.invertedRegularExpressionPattern).test(t)&&s('InvertedPatternMatch: Property "'+r+'" should not match regular expression pattern '+a.invertedRegularExpressionPattern+' (given "'+t+'")'+o+"."):s('PatternMatch: Property "'+r+'" should match regular expression pattern '+a.regularExpressionPattern+' (given "'+t+'")'+o+"."),v(t,r,a,c),P(t)!==P(c)&&(i=n.concat(r,"value updated")),{newValue:t,changedPath:i}},M=function(t,r,n,a){if(!n)for(var c,_,i=e(["onCreateExecution","onCreateExpression"]);!(c=i()).done;)if(_=c.value,Object.prototype.hasOwnProperty.call(t,_)){var l=void 0;try{l=I(t[_],_.endsWith("Expression"),{checkPropertyContent:D,code:t[_],model:h,modelName:u,name:a,newDocument:r,oldDocument:n,propertySpecification:t,type:_})}catch(t){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(t)&&s('Compilation: Hook "'+_+'" has invalid code "'+t.code+'" for property "'+a+'": '+t.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(t)&&s('Runtime: Hook "'+_+'" has throw an error with code "'+t.code+'" for property "'+a+'": '+t.message+o+"."),!Object.prototype.hasOwnProperty.call(t,"empty"))throw t}[null,void 0].includes(l.result)||(r[a]=l.result)}},w=function(t,r,a,c){if(Object.prototype.hasOwnProperty.call(r,c)){t.trim&&"string"==typeof r[c]&&(r[c]=r[c].trim()),t.emptyEqualsToNull&&(""===r[c]||Array.isArray(r[c])&&0===r[c].length||null!==r[c]&&"object"==typeof r[c]&&0===Object.keys(r).length)&&(r[c]=null);for(var _,i,l=e(["onUpdateExecution","onUpdateExpression"]);!(_=l()).done;)if(i=_.value,Object.prototype.hasOwnProperty.call(t,i))try{r[c]=I(t[i],i.endsWith("Expression"),{checkPropertyContent:D,code:t[i],modelName:u,name:c,newDocument:r,oldDocument:a,parentNames:n,pathDescription:o,propertySpecification:t,type:i}).result}catch(t){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(t)&&s('Compilation: Hook "'+i+'" has invalid code "'+t.code+'" for property "'+c+'": '+t.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(t)&&s('Runtime: Hook "'+i+'" has throw an error with code "'+t.code+'" for property "'+c+'": '+t.message+o+"."),!Object.prototype.hasOwnProperty.call(t,"empty"))throw t}}},k=Object.keys(h).filter((function(e){return![d.additional,d.allowedRole,d.constraint.execution,d.constraint.expression,d.create.execution,d.create.expression,d.extend,d.maximumAggregatedSize,d.minimumAggregatedSize,d.oldType,d.update.execution,d.update.expression].includes(e)}));if("migrate"===E)for(var T,U,L=e(k);!(T=L()).done;)if(U=T.value,![null,void 0].includes(h[U].oldName))for(var j,W,B=e([].concat(h[U].oldName));!(j=B()).done;)W=j.value,Object.prototype.hasOwnProperty.call(t,W)&&(t[U]=t[W],delete t[W]);if(!r)for(var K,N=0,S=[d.create.execution,d.create.expression];N<S.length;N++)if(K=S[N],Object.prototype.hasOwnProperty.call(h,K)){var H=void 0;try{H=I(h[K],K.endsWith("Expression"),{checkPropertyContent:D,code:h[K],id:y,model:h,modelName:u,newDocument:t,oldDocument:r,parentNames:n,pathDescription:o,type:K}).result}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&s('Compilation: Hook "'+K+'" has invalid code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&s('Runtime: Hook "'+K+'" has throw an error with code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}[null,void 0].includes(H)||(t=H),l(),u=t[b],0===n.length&&x()}for(var q,F=0,z=[d.update.execution,d.update.expression];F<z.length;F++)if(q=z[F],Object.prototype.hasOwnProperty.call(h,q)){var G=void 0;try{G=I(h[q],q.endsWith("Expression"),{checkPropertyContent:D,code:h[q],id:y,model:h,modelName:u,newDocument:t,oldDocument:r,parentNames:n,pathDescription:o,type:q}).result}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&s('Compilation: Hook "'+q+'" has invalid code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&s('Runtime: Hook "'+q+'" has throw an error with code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}[void 0,null].includes(G)||(t=G),l(),u=t[b],0===n.length&&x()}for(var V,J=function(){var a=V.value;if(d.attachment===a){var c=function(c){if(Object.prototype.hasOwnProperty.call(h[a],c)){Object.prototype.hasOwnProperty.call(t,a)&&null!==t[a]||(t[a]={}),r&&!Object.prototype.hasOwnProperty.call(r,a)&&(r[a]={});var _=Object.keys(t[a]).filter((function(e){return null!==t[a][e].data&&A(c,e,h[a][c])})),l=t[a],u=[];if(r){var p=r[a];u=Object.keys(p).filter((function(e){return!(Object.prototype.hasOwnProperty.call(l,e)&&Object.prototype.hasOwnProperty.call(l[e],"data")&&null===l[e].data)&&p[e]&&(Object.prototype.hasOwnProperty.call(p[e],"data")&&null!==p[e].data||p[e].stub&&p[e].digest)&&A(c,e,h[a][c])}))}for(var d,m,f=h[a][c],b=e(_);!(d=b()).done;)m=d.value,M(f,l,r&&r[a]?r[a]:null,m);for(var y,x,O=e(_);!(y=O()).done;)x=y.value,w(f,l,r&&r[a]?r[a]:null,x);if([null,void 0].includes(f.default)){if(f.nullable||0<_.length||0<u.length||s('AttachmentMissing: Missing attachment for type "'+c+'"'+o+"."),"fillUp"===E&&0===_.length&&0<u.length)for(var P,g,v=e(u);!(P=v()).done;)g=P.value,null===l[g]?i=n.concat(a,g,"file removed"):l[g]=r[a][g]}else if(0===_.length)if(0===u.length)for(var D in f.default)Object.prototype.hasOwnProperty.call(f.default,D)&&(l[D]=f.default[D],i=n.concat(a,c,"add default file"));else if("fillUp"===E)for(var C,k,T=e(u);!(C=T()).done;)k=C.value,l[k]=r[a][k]}};for(var _ in h[a])c(_)}else{var l=k.includes(a)?h[a]:O;M(l,t,r,a),w(l,t,r,a),[null,void 0].includes(l.default)?(!(l.nullable||Object.prototype.hasOwnProperty.call(t,a)||r&&Object.prototype.hasOwnProperty.call(r,a)&&E)&&s('MissingProperty: Missing property "'+a+'"'+o+"."),!Object.prototype.hasOwnProperty.call(t,a)&&r&&Object.prototype.hasOwnProperty.call(r,a)&&("fillUp"===E?t[a]=r[a]:!E&&(i=n.concat(a,"property removed")))):(!Object.prototype.hasOwnProperty.call(t,a)||null===t[a])&&(r&&Object.prototype.hasOwnProperty.call(r,a)?"fillUp"===E?t[a]=r[a]:"migrate"===E&&(t[a]=l.default,i=n.concat(a,"migrate default value")):(t[a]=l.default,i=i.concat(a,"add default value")))}},$=e(k.concat(O?Object.keys(t).filter((function(e){return!k.includes(e)})):[]));!(V=$()).done;)J();if(r&&"incremental"===E)for(var X in t)if(Object.prototype.hasOwnProperty.call(t,X)&&Object.prototype.hasOwnProperty.call(r,X)&&!c.property.name.reserved.concat(m,f,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,b).includes(X)&&(r[X]===t[X]||P(r[X])===P(t[X]))){delete t[X];continue}for(var Y in t)if(Object.prototype.hasOwnProperty.call(t,Y)&&!c.property.name.reserved.concat(f,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,d.strategy).includes(Y)){var Z=void 0;if(Object.prototype.hasOwnProperty.call(h,Y))Z=h[Y];else if(O)Z=O;else{if("migrate"===E){delete t[Y],i=n.concat(Y,"migrate removed property");continue}s('Property: Given property "'+Y+'" isn\'t specified in model "'+u+'"'+o+".")}if(!Z)continue;var Q=function(e,t,r,a){if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,a)&&P(t[a])===P(r[a]))return a!==m&&"incremental"===E&&delete t[a],!0;s('Readonly: Property "'+a+'" is not writable (old document "'+P(r)+'")'+o+".")}else s('Readonly: Property "'+a+'" is not writable'+o+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,a)){if(P(t[a])===P(r[a]))return"incremental"!==E||c.property.name.reserved.concat(d.deleted,m,f).includes(a)||delete t[a],!0;"migrate"!==E&&s('Immutable: Property "'+a+'" is not writable (old document "'+P(r)+'")'+o+".")}if(null===t[a]){if(e.nullable)return delete t[a],r&&Object.prototype.hasOwnProperty.call(r,a)&&(i=n.concat(a,"delete property")),!0;s('NotNull: Property "'+a+'" should not by "null"'+o+".")}return!1};if(d.attachment===Y){var ee=t[Y];for(var te in ee)if(Object.prototype.hasOwnProperty.call(ee,te))for(var re in h[Y])if(A(re,te,h[Y][re])){Q(h[Y][re],t,r,te);break}continue}if(Q(Z,t,r,Y))continue;if("string"==typeof Z.type&&Z.type.endsWith("[]")||Array.isArray(Z.type)&&Z.type.length&&Array.isArray(Z.type[0])){var ne,oe=t[Y];Array.isArray(oe)?![null,void 0].includes(Z.minimumNumber)&&oe.length<Z.minimumNumber?s('MinimumArrayLength: Property "'+Y+'" (array of length '+oe.length+") doesn't fullfill minimum array length of "+Z.minimumNumber+o+"."):![null,void 0].includes(Z.maximumNumber)&&Z.maximumNumber<oe.length&&s('MaximumArrayLength: Property "'+Y+'" (array of length '+oe.length+") doesn't fullfill maximum array length of "+Z.maximumNumber+o+"."):s('PropertyType: Property "'+Y+'" isn\'t of type "array -> '+Z.type+'" (given "'+P(oe)+'")'+o+"."),v(oe,Y,Z,r&&Object.prototype.hasOwnProperty.call(r,Y)&&r[Y]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var ae={};for(var ce in Z)Object.prototype.hasOwnProperty.call(Z,ce)&&(ae[ce]="type"===ce?Array.isArray(Z[ce])?Z[ce][0]:[Z[ce].substring(0,Z.type.length-2)]:Z[ce]);if(1===(null==(ne=ae.type)?void 0:ne.length)&&Object.prototype.hasOwnProperty.call(_,ae.type[0]))for(var _e,ie,se=e(oe.slice());!(_e=se()).done;)"object"!=typeof(ie=_e.value)||Object.getPrototypeOf(ie)!==Object.prototype||Object.prototype.hasOwnProperty.call(ie,b)||(ie[b]=ae.type[0]);for(var le,ue,pe=0,de=e(oe.slice());!(le=de()).done;)ue=le.value,oe[pe]=D(ue,pe+1+". value in "+Y,ae).newValue,null===ue&&oe.splice(pe,1),pe+=1;r&&Object.prototype.hasOwnProperty.call(r,Y)&&Array.isArray(r[Y])&&r[Y].length===oe.length&&P(r[Y])===P(oe)||(i=n.concat(Y,"array updated"))}else{var me=r&&Object.prototype.hasOwnProperty.call(r,Y)?r[Y]:null,fe=D(t[Y],Y,Z,me);t[Y]=fe.newValue,fe.changedPath.length&&(i=fe.changedPath),null===t[Y]&&(null!==me&&(i=n.concat(Y,"property removed")),delete t[Y])}}for(var be in d.constraint)if(Object.prototype.hasOwnProperty.call(d.constraint,be)&&(be=d.constraint[be])&&Object.prototype.hasOwnProperty.call(h,be))for(var ye,he=e([].concat(h[be]));!(ye=he()).done;){var xe=ye.value,Oe=void 0;try{Oe=I(xe.evaluation,be===d.constraint.expression,{checkPropertyContent:D,code:xe.evaluation,model:h,modelName:u,newDocument:t,oldDocument:r,parentNames:n,pathDescription:o,type:be})}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&s('Compilation: Hook "'+be+'" has invalid code "'+i.code+'": "'+i.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&s('Runtime: Hook "'+be+'" has thrown an error with code "'+i.code+'": '+i.message+o+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}if(!Oe.result){var Ee=be.replace(/^[^a-zA-Z]+/,"");s(Ee.charAt(0).toUpperCase()+(Ee.substring(1)+": ")+(xe.description?a()(Function,Object.keys(Oe.scope).concat(["return "+xe.description.trim()])).apply(void 0,Object.values(Oe.scope)):'Model "'+u+'" should satisfy constraint "'+Oe.code+'" (given "'+P(t)+'")'+o+"."))}}if(Object.prototype.hasOwnProperty.call(t,d.attachment)){var Pe=t[d.attachment];("object"!=typeof Pe||Object.getPrototypeOf(Pe)!==Object.prototype)&&s("AttachmentType: given attachment has invalid type"+o+".");var ge=null;if(r&&Object.prototype.hasOwnProperty.call(r,d.attachment)&&null!==(ge=r[d.attachment])&&"object"==typeof ge)for(var ve in ge)Object.prototype.hasOwnProperty.call(ge,ve)&&(Object.prototype.hasOwnProperty.call(Pe,ve)?null===Pe[ve]||null===Pe[ve].data||Pe[ve].content_type===ge[ve].content_type&&(Pe[ve].data===ge[ve].data||Pe[ve].digest===ge[ve].digest)?((null===Pe[ve]||null===Pe[ve].data)&&(i=n.concat(d.attachment,ve,"attachment removed")),"incremental"===E&&delete Pe[ve]):i=n.concat(d.attachment,ve,"attachment updated"):"fillUp"===E?Pe[ve]=ge[ve]:E||(i=n.concat(d.attachment,ve,"attachment removed")));for(var De in Pe)Object.prototype.hasOwnProperty.call(Pe,De)&&([null,void 0].includes(Pe[De])||null===Pe[De].data?delete Pe[De]:ge&&Object.prototype.hasOwnProperty.call(ge,De)&&Pe[De].content_type===ge[De].content_type&&(Pe[De].data===ge[De].data||Pe[De].digest===ge[De].digest)||(i=n.concat(d.attachment,De,"attachment updated")));0===Object.keys(Pe).length&&delete t[d.attachment];var Me={};for(var we in h[d.attachment])Object.prototype.hasOwnProperty.call(h[d.attachment],we)&&(Me[we]=[]);for(var Ce in Pe)if(Object.prototype.hasOwnProperty.call(Pe,Ce)){var Ae=!1;for(var ke in h[d.attachment])if(A(ke,Ce,h[d.attachment][ke])){Me[ke].push(Ce),Ae=!0;break}Ae||s('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(h[d.attachment]).join('", "')+'") matches given one ("'+Ce+'")'+o+".")}for(var Te=0,Ie=0,Re=Object.keys(Me);Ie<Re.length;Ie++){var Ue=Re[Ie],Le=h[d.attachment][Ue];if(Object.prototype.hasOwnProperty.call(Me,Ue)){var je=Me[Ue].length;null!==Le.maximumNumber&&je>Le.maximumNumber&&s("AttachmentMaximum: given number of attachments ("+je+") doesn't satisfy specified maximum of "+Le.maximumNumber+' from type "'+Ue+'"'+o+"."),(!Le.nullable||0!==je)&&je<Le.minimumNumber&&s("AttachmentMinimum: given number of attachments ("+je+") doesn't satisfy specified minimum of "+Le.minimumNumber+' from type "'+Ue+'"'+o+".");for(var We,Be=0,Ke=e(Me[Ue]);!(We=Ke()).done;){var Ne,Se,He=We.value;null!=(Ne=Le.fileName)&&Ne.regularExpressionPattern&&!new RegExp(Le.fileName.regularExpressionPattern).test(He)?s('AttachmentName: given attachment name "'+He+'" doesn\'t satisfy specified regular expression pattern "'+Le.fileName.regularExpressionPattern+'" from type "'+Ue+'"'+o+"."):null!=(Se=Le.fileName)&&Se.invertedRegularExpressionPattern&&new RegExp(Le.fileName.invertedRegularExpressionPattern).test(He)?s('InvertedAttachmentName: given attachment name "'+He+'" does satisfy specified regular expression pattern "'+Le.fileName.invertedRegularExpressionPattern+'" from type "'+Ue+'"'+o+"."):!([null,void 0].includes(Le.contentTypeRegularExpressionPattern)||Pe[He].content_type&&new RegExp(Le.contentTypeRegularExpressionPattern).test(Pe[He].content_type))&&s('AttachmentContentType: given attachment content type "'+Pe[He].content_type+'" doesn\'t satisfy specified regular expression pattern "'+Le.contentTypeRegularExpressionPattern+'" from type "'+Ue+'"'+o+".");var qe=Le.invertedContentTypeRegularExpressionPattern;[null,void 0].includes(qe)||Pe[He].content_type&&!new RegExp(qe).test(Pe[He].content_type)||s('InvertedAttachmentContentType: given attachment content type "'+Pe[He].content_type+'" does satisfy specified regular expression pattern "'+qe+'" from type "'+Ue+'"'+o+".");var Fe=0;"length"in Pe[He]?Fe=Pe[He].length:"data"in Pe[He]&&(Fe=Buffer&&"byteLength"in Buffer?Buffer.byteLength(Pe[He].data,"base64"):Pe[He].data.length),![null,void 0].includes(Le.minimumSize)&&Le.minimumSize>Fe?s("AttachmentMinimumSize: given attachment size "+Fe+" byte doesn't satisfy specified minimum of "+Le.minimumSize+" byte "+o+"."):![null,void 0].includes(Le.maximumSize)&&Le.maximumSize<Fe&&s("AttachmentMaximumSize: given attachment size "+Fe+" byte doesn't satisfy specified maximum of "+Le.maximumSize+" byte "+o+"."),Be+=Fe}![null,void 0].includes(Le.minimumAggregatedSize)&&Le.minimumAggregatedSize>Be?s('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+Ue+'" '+Be+" byte doesn't satisfy specified minimum of "+Le.minimumAggregatedSize+" byte "+o+"."):![null,void 0].includes(Le.maximumAggregatedSize)&&Le.maximumAggregatedSize<Be&&s('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+Ue+'" '+Be+" byte doesn't satisfy specified maximum of "+Le.maximumAggregatedSize+" byte "+o+"."),Te+=Be}}Object.prototype.hasOwnProperty.call(h,d.minimumAggregatedSize)&&![null,void 0].includes(h[d.minimumAggregatedSize])&&h[d.minimumAggregatedSize]>Te?s("AggregatedMinimumSize: given aggregated size "+Te+" byte doesn't satisfy specified minimum of "+h[d.minimumAggregatedSize]+" byte "+o+"."):![null,void 0].includes(h[d.maximumAggregatedSize])&&h[d.maximumAggregatedSize]<Te&&s("AggregatedMaximumSize: given aggregated size "+Te+" byte doesn't satisfy specified maximum of "+h[d.maximumAggregatedSize]+" byte "+o+".")}if(r&&Object.prototype.hasOwnProperty.call(r,d.attachment)&&0===Object.keys(r[d.attachment]).length&&delete r[d.attachment],0===i.length&&r&&"migrate"===E)for(var ze in r)Object.prototype.hasOwnProperty.call(r,ze)&&!Object.prototype.hasOwnProperty.call(t,ze)&&(i=n.concat(ze,"migrate removed property"));return{changedPath:i,newDocument:t}},U=R(t,r);return(!U.newDocument._deleted||r)&&(U.newDocument._deleted&&U.newDocument._deleted!==(null==r?void 0:r._deleted)||U.changedPath.length)||s("NoChange: No new data given. new document: "+P(t)+"; old document: "+P(r)+"."),Object.prototype.hasOwnProperty.call(o,c.property.name.validatedDocumentsCache)?o[c.property.name.validatedDocumentsCache].add(y+"-"+h):o[c.property.name.validatedDocumentsCache]=new Set([y+"-"+h]),U.newDocument},t}(),_=c})(),e.exports=o}()},,e=>{"use strict";e.exports=require("pouchdb")},e=>{"use strict";e.exports=require("pouchdb-find")}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Database:()=>Database,default:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__),clientnode__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(2),clientnode__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_2__),fs__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3),fs__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_3__),path__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(4),path__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_4__),pouchdb__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(11),pouchdb__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(pouchdb__WEBPACK_IMPORTED_MODULE_5__),pouchdb_find__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(12),pouchdb_find__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(pouchdb_find__WEBPACK_IMPORTED_MODULE_6__),_databaseHelper__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(9),_databaseHelper__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_8__),_helper__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(8);function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Database=function(){function Database(){}return Database.loadService=function(){function loadService(){return _loadService.apply(this,arguments)}var _loadService=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function _callee(servicePromises,services,configuration){var promise,urlPrefix,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,_i,_arr,type,_iterator,_step,name,userDatabaseConnection,_userDatabaseConnecti,_iterator2,_step2,prefix,subPath,fullPath,url,value,response,changeNeeded,idName,typeName,modelConfiguration,models,databaseHelperCode,_iterator3,_step3,_type2,code,modelName,_name,_iterator4,_step4,constraint,property,_iterator5,_step5,_type,_constraint,migrater,_iterator6,_step6,file,extension,basename,document,_forbidden,_iterator7,_step7,retrievedDocument,_document,newDocument,_iterator8,_step8,_name2,result,indexes,_modelName,_iterator9,_step9,propertyName,_name3,foundPosition,position,_iterator10,_step10,index,_iterator11,_step11,_index,exists,_modelName2,_iterator12,_step12,_name4;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(promise=null,!Object.prototype.hasOwnProperty.call(services.couchdb.server,"runner")){_context.next=8;break}return _context.next=4,_helper__WEBPACK_IMPORTED_MODULE_7__.default.startServer(services,configuration);case 4:services.couchdb.server.restart=_helper__WEBPACK_IMPORTED_MODULE_7__.default.restartServer,services.couchdb.server.start=_helper__WEBPACK_IMPORTED_MODULE_7__.default.startServer,services.couchdb.server.stop=_helper__WEBPACK_IMPORTED_MODULE_7__.default.stopServer,promise=new Promise((function(e,t){services.couchdb.server.resolve=e,services.couchdb.server.reject=t}));case 8:if(!Object.prototype.hasOwnProperty.call(services.couchdb,"connection")){_context.next=10;break}return _context.abrupt("return",{name:"couchdb",promise});case 10:if(urlPrefix=clientnode__WEBPACK_IMPORTED_MODULE_2___default().stringFormat(configuration.couchdb.url,configuration.couchdb.user.name+":"+configuration.couchdb.user.password+"@"),!configuration.couchdb.ensureAdminPresence){_context.next=42;break}return unauthenticatedUserDatabaseConnection=new services.couchdb.connector(clientnode__WEBPACK_IMPORTED_MODULE_2___default().stringFormat(configuration.couchdb.url,"")+"/_users",_helper__WEBPACK_IMPORTED_MODULE_7__.default.getConnectorOptions(configuration)),_context.prev=13,_context.next=16,unauthenticatedUserDatabaseConnection.allDocs();case 16:return _context.next=19,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(clientnode__WEBPACK_IMPORTED_MODULE_2___default().stringFormat(configuration.couchdb.url,"")+"/"+services.couchdb.server.runner.adminUserConfigurationPath+"/"+configuration.couchdb.user.name,{body:'"'+configuration.couchdb.user.password+'"',method:"PUT"});case 19:_context.next=39;break;case 21:if(_context.prev=21,_context.t0=_context.catch(13),"unauthorized"!==_context.t0.name){_context.next=38;break}return authenticatedUserDatabaseConnection=new services.couchdb.connector(urlPrefix+"/_users",_helper__WEBPACK_IMPORTED_MODULE_7__.default.getConnectorOptions(configuration)),_context.prev=25,_context.next=28,authenticatedUserDatabaseConnection.allDocs();case 28:_context.next=33;break;case 30:_context.prev=30,_context.t1=_context.catch(25);case 33:return _context.prev=33,authenticatedUserDatabaseConnection.close(),_context.finish(33);case 36:_context.next=39;break;case 38:case 39:return _context.prev=39,unauthenticatedUserDatabaseConnection.close(),_context.finish(39);case 42:if(!configuration.couchdb.ensureUserPresence){_context.next=77;break}_i=0,_arr=[configuration.couchdb.security.admins,configuration.couchdb.security.members];case 44:if(!(_i<_arr.length)){_context.next=77;break}type=_arr[_i],_iterator=_createForOfIteratorHelperLoose(type.names);case 47:if((_step=_iterator()).done){_context.next=74;break}return name=_step.value,userDatabaseConnection=new services.couchdb.connector(urlPrefix+"/_users",_helper__WEBPACK_IMPORTED_MODULE_7__.default.getConnectorOptions(configuration)),_context.prev=50,_context.next=53,userDatabaseConnection.get("org.couchdb.user:"+name);case 53:_context.next=69;break;case 55:if(_context.prev=55,_context.t2=_context.catch(50),"not_found"!==_context.t2.error){_context.next=68;break}return _context.prev=58,_context.next=61,userDatabaseConnection.put((_userDatabaseConnecti={},_userDatabaseConnecti[configuration.couchdb.model.property.name.special.id]="org.couchdb.user:"+name,_userDatabaseConnecti.name=name,_userDatabaseConnecti.password=name,_userDatabaseConnecti.roles=[].concat(type.roles.includes(name+"s")?name+"s":[]),_userDatabaseConnecti.type="user",_userDatabaseConnecti));case 61:_context.next=66;break;case 63:throw _context.prev=63,_context.t3=_context.catch(58),new Error("Couldn't create missing user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t3));case 66:_context.next=69;break;case 68:throw new Error("Couldn't check for presence of user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t2));case 69:return _context.prev=69,userDatabaseConnection.close(),_context.finish(69);case 72:_context.next=47;break;case 74:_i++,_context.next=44;break;case 77:if(!configuration.couchdb.model.updateConfiguration){_context.next=132;break}_iterator2=_createForOfIteratorHelperLoose(configuration.couchdb.backend.prefixes);case 79:if((_step2=_iterator2()).done){_context.next=132;break}prefix=_step2.value,_context.t4=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(configuration.couchdb.backend.configuration);case 82:if((_context.t5=_context.t4()).done){_context.next=130;break}if(subPath=_context.t5.value,!Object.prototype.hasOwnProperty.call(configuration.couchdb.backend.configuration,subPath)){_context.next=128;break}return fullPath="/"+prefix+(prefix.trim()?"/":"")+subPath,url=""+urlPrefix+fullPath,value=configuration.couchdb.backend.configuration[subPath],response=void 0,_context.prev=89,_context.next=92,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(url);case 92:response=_context.sent,_context.next=98;break;case 95:_context.prev=95,_context.t6=_context.catch(89);case 98:if(!response){_context.next=128;break}if(!response.ok){_context.next=127;break}if(changeNeeded=!0,"function"!=typeof response.text){_context.next=113;break}return _context.prev=102,_context.t7=value,_context.next=106,response["string"==typeof value?"text":"json"]();case 106:_context.t8=_context.sent,changeNeeded=_context.t7===_context.t8,_context.next=113;break;case 110:_context.prev=110,_context.t9=_context.catch(102);case 113:if(!changeNeeded){_context.next=124;break}return _context.prev=114,_context.next=117,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(url,{body:'"'+configuration.couchdb.backend.configuration[subPath]+'"',method:"PUT"});case 117:_context.next=122;break;case 119:_context.prev=119,_context.t10=_context.catch(114);case 122:_context.next=125;break;case 124:case 125:_context.next=128;break;case 127:case 128:_context.next=82;break;case 130:_context.next=79;break;case 132:return _context.next=134,_helper__WEBPACK_IMPORTED_MODULE_7__.default.initializeConnection(services,configuration);case 134:if(idName=configuration.couchdb.model.property.name.special.id,typeName=configuration.couchdb.model.property.name.special.type,!configuration.couchdb.ensureSecuritySettingsPresence){_context.next=145;break}return _context.prev=137,_context.next=140,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(urlPrefix+"/"+configuration.name+"/_security",{body:JSON.stringify(configuration.couchdb.security),method:"PUT"});case 140:_context.next=145;break;case 142:_context.prev=142,_context.t11=_context.catch(137);case 145:if(modelConfiguration=clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(configuration.couchdb.model),delete modelConfiguration.property.defaultSpecification,delete modelConfiguration.entities,models=_helper__WEBPACK_IMPORTED_MODULE_7__.default.extendModels(configuration.couchdb.model),!configuration.couchdb.model.updateValidation){_context.next=213;break}return _context.next=152,fs__WEBPACK_IMPORTED_MODULE_3__.promises.readFile(eval("require.resolve")("./databaseHelper"),{encoding:configuration.encoding,flag:"r"});case 152:databaseHelperCode=_context.sent,_iterator3=_createForOfIteratorHelperLoose([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(modelConfiguration)+", "+JSON.stringify(models)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify(_helper__WEBPACK_IMPORTED_MODULE_7__.default.determineAllowedModelRolesMapping(configuration.couchdb.model))+", '"+idName+"', '"+typeName+"', '"+configuration.couchdb.model.property.name.special.designDocumentNamePrefix+"'"}]);case 154:if((_step3=_iterator3()).done){_context.next=169;break}_type2=_step3.value,code="function(...parameters) {\n return require('helper').default."+_type2.methodName+"(...parameters.concat(["+_type2.serializedParameter+"]))\n}",_context.prev=157,new Function("return "+code),_context.next=164;break;case 161:throw _context.prev=161,_context.t12=_context.catch(157),new Error("Generated "+_type2.name+' code "'+code+"\" doesn't compile: "+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t12));case 164:return configuration.debug,_context.next=167,_helper__WEBPACK_IMPORTED_MODULE_7__.default.ensureValidationDocumentPresence(services.couchdb.connection,_type2.name,{helper:databaseHelperCode,validate_doc_update:code},_type2.description,!0,idName,modelConfiguration.property.name.special.designDocumentNamePrefix);case 167:_context.next=154;break;case 169:_context.t13=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models);case 170:if((_context.t14=_context.t13()).done){_context.next=213;break}if(modelName=_context.t14.value,!Object.prototype.hasOwnProperty.call(models,modelName)){_context.next=211;break}_context.t15=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models[modelName]);case 174:if((_context.t16=_context.t15()).done){_context.next=211;break}if(_name=_context.t16.value,!Object.prototype.hasOwnProperty.call(models[modelName],_name)){_context.next=209;break}if(![modelConfiguration.property.name.special.constraint.execution,modelConfiguration.property.name.special.constraint.expression].includes(_name)){_context.next=193;break}_iterator4=_createForOfIteratorHelperLoose([].concat(models[modelName][_name]));case 179:if((_step4=_iterator4()).done){_context.next=191;break}if(constraint=_step4.value,!constraint.description){_context.next=189;break}_context.prev=182,new Function("return "+constraint.description),_context.next=189;break;case 186:throw _context.prev=186,_context.t17=_context.catch(182),new Error('Specified constraint description "'+constraint.description+'" for model "'+modelName+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t17)+'".');case 189:_context.next=179;break;case 191:_context.next=209;break;case 193:property=models[modelName][_name],_iterator5=_createForOfIteratorHelperLoose(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 195:if((_step5=_iterator5()).done){_context.next=209;break}if(_type=_step5.value,null===property||"object"!=typeof property){_context.next=207;break}if(_constraint=property[_type],null==_constraint||!_constraint.description){_context.next=207;break}_context.prev=200,new Function(_constraint.description),_context.next=207;break;case 204:throw _context.prev=204,_context.t18=_context.catch(200),new Error('Specified constraint description "'+_constraint.description+'" for model "'+modelName+'" in property "'+_name+'" as "'+_type+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t18)+'".');case 207:_context.next=195;break;case 209:_context.next=174;break;case 211:_context.next=170;break;case 213:if(!configuration.couchdb.model.autoMigrationPath){_context.next=305;break}return migrater={},_context.next=217,clientnode__WEBPACK_IMPORTED_MODULE_2___default().isDirectory(path__WEBPACK_IMPORTED_MODULE_4___default().resolve(configuration.couchdb.model.autoMigrationPath));case 217:if(!_context.sent){_context.next=257;break}return _context.t19=_createForOfIteratorHelperLoose,_context.next=221,clientnode__WEBPACK_IMPORTED_MODULE_2___default().walkDirectoryRecursively(path__WEBPACK_IMPORTED_MODULE_4___default().resolve(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_2___default().noop:function(e){return"debug"!==e.name});case 221:_context.t20=_context.sent,_iterator6=(0,_context.t19)(_context.t20);case 223:if((_step6=_iterator6()).done){_context.next=257;break}if(file=_step6.value,extension=path__WEBPACK_IMPORTED_MODULE_4___default().extname(file.name),basename=path__WEBPACK_IMPORTED_MODULE_4___default().basename(file.name,extension),".json"!==extension){_context.next=254;break}return document=void 0,_context.prev=229,_context.t21=JSON,_context.next=233,fs__WEBPACK_IMPORTED_MODULE_3__.promises.readFile(file.path,{encoding:configuration.encoding,flag:"r"});case 233:_context.t22=_context.sent,document=_context.t21.parse.call(_context.t21,_context.t22),_context.next=240;break;case 237:throw _context.prev=237,_context.t23=_context.catch(229),new Error('Parsing document "'+file.path+'" to include by automigration of has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t23));case 240:return document[idName]=basename,document[configuration.couchdb.model.property.name.special.revision]="upsert",_context.prev=242,_context.next=245,services.couchdb.connection.put(document);case 245:_context.next=251;break;case 247:throw _context.prev=247,_context.t24=_context.catch(242),null!=(_forbidden=_context.t24.forbidden)&&_forbidden.startsWith("NoChange:"),new Error('Migrating document "'+document[idName]+'" of type "'+document[typeName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t24));case 251:_context.next=255;break;case 254:".js"===path__WEBPACK_IMPORTED_MODULE_4___default().extname(file.name)&&(migrater[file.path]=eval("require")(file.path).default);case 255:_context.next=223;break;case 257:return _context.t25=_createForOfIteratorHelperLoose,_context.next=260,services.couchdb.connection.allDocs({include_docs:!0});case 260:_context.t26=_context.sent.rows,_iterator7=(0,_context.t25)(_context.t26);case 262:if((_step7=_iterator7()).done){_context.next=305;break}if(retrievedDocument=_step7.value,"string"==typeof retrievedDocument.id&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context.next=303;break}_document=retrievedDocument.doc,newDocument=clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(_document),newDocument[configuration.couchdb.model.property.name.special.strategy]="migrate",_iterator8=_createForOfIteratorHelperLoose(Object.keys(migrater).sort());case 269:if((_step8=_iterator8()).done){_context.next=282;break}_name2=_step8.value,result=null,_context.prev=272,result=migrater[_name2](newDocument,{configuration,databaseHelper:_databaseHelper__WEBPACK_IMPORTED_MODULE_8___default(),idName,migrater,models,modelConfiguration,selfFilePath:_name2,services,tools:clientnode__WEBPACK_IMPORTED_MODULE_2___default(),typeName}),_context.next=279;break;case 276:throw _context.prev=276,_context.t27=_context.catch(272),new Error('Running migrater "'+_name2+'" in document '+_helper__WEBPACK_IMPORTED_MODULE_7__.default.mayStripRepresentation(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+'" failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t27));case 279:result&&(newDocument=result);case 280:_context.next=269;break;case 282:_context.prev=282,_databaseHelper__WEBPACK_IMPORTED_MODULE_8___default().validateDocumentUpdate(clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(newDocument),clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(_document),{db:configuration.name,name:configuration.couchdb.user.name,roles:["_admin"]},clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(configuration.couchdb.security),modelConfiguration,models),_context.next=294;break;case 286:if(_context.prev=286,_context.t28=_context.catch(282),!Object.prototype.hasOwnProperty.call(_context.t28,"forbidden")){_context.next=293;break}return _context.t28.forbidden.startsWith("NoChange:"),_context.abrupt("continue",303);case 293:throw _context.t28;case 294:return _context.prev=294,_context.next=297,services.couchdb.connection.put(newDocument);case 297:_context.next=302;break;case 299:throw _context.prev=299,_context.t29=_context.catch(294),new Error('Replaceing auto migrated document "'+newDocument[idName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t29));case 302:case 303:_context.next=262;break;case 305:if(!configuration.couchdb.createGenericFlatIndex||!configuration.couchdb.model.autoMigrationPath){_context.next=358;break}return _context.next=308,services.couchdb.connection.getIndexes();case 308:indexes=_context.sent.indexes,_context.t30=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models);case 310:if((_context.t31=_context.t30()).done){_context.next=340;break}if(_modelName=_context.t31.value,!Object.prototype.hasOwnProperty.call(models,_modelName)||!new RegExp(configuration.couchdb.model.property.name.typeRegularExpressionPattern.public).test(_modelName)){_context.next=338;break}return _context.next=315,services.couchdb.connection.createIndex({index:{ddoc:_modelName+"-GenericIndex",fields:[typeName],name:_modelName+"-GenericIndex"}});case 315:_iterator9=_createForOfIteratorHelperLoose(_helper__WEBPACK_IMPORTED_MODULE_7__.default.determineGenericIndexablePropertyNames(configuration.couchdb.model,models[_modelName]));case 316:if((_step9=_iterator9()).done){_context.next=338;break}propertyName=_step9.value,_name3=_modelName+"-"+propertyName+"-GenericIndex",foundPosition=-1,position=0,_iterator10=_createForOfIteratorHelperLoose(indexes);case 322:if((_step10=_iterator10()).done){_context.next=330;break}if(index=_step10.value,index.name!==_name3){_context.next=327;break}return foundPosition=position,_context.abrupt("break",330);case 327:position+=1;case 328:_context.next=322;break;case 330:if(-1!==foundPosition){_context.next=335;break}return _context.next=333,services.couchdb.connection.createIndex({index:{ddoc:_name3,fields:[typeName,propertyName],name:_name3}});case 333:_context.next=336;break;case 335:indexes.slice(position,1);case 336:_context.next=316;break;case 338:_context.next=310;break;case 340:_iterator11=_createForOfIteratorHelperLoose(indexes);case 341:if((_step11=_iterator11()).done){_context.next=358;break}if(_index=_step11.value,!_index.name.endsWith("-GenericIndex")){_context.next=356;break}exists=!1,_context.t32=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models);case 346:if((_context.t33=_context.t32()).done){_context.next=353;break}if(_modelName2=_context.t33.value,!_index.name.startsWith(_modelName2+"-")){_context.next=351;break}for(_iterator12=_createForOfIteratorHelperLoose(_helper__WEBPACK_IMPORTED_MODULE_7__.default.determineGenericIndexablePropertyNames(configuration.couchdb.model,models[_modelName2]));!(_step12=_iterator12()).done;)_name4=_step12.value,[_modelName2+"-"+_name4+"-GenericIndex",_modelName2+"-GenericIndex"].includes(_index.name)&&(exists=!0);return _context.abrupt("break",353);case 351:_context.next=346;break;case 353:if(exists){_context.next=356;break}return _context.next=356,services.couchdb.connection.deleteIndex(_index);case 356:_context.next=341;break;case 358:if(!configuration.couchdb.model.triggerInitialCompaction){_context.next=367;break}return _context.prev=359,_context.next=362,services.couchdb.connection.compact();case 362:_context.next=367;break;case 364:_context.prev=364,_context.t34=_context.catch(359);case 367:return _context.abrupt("return",{name:"couchdb",promise});case 368:case"end":return _context.stop()}}),_callee,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],[182,186],[200,204],[229,237],[242,247],[272,276],[282,286],[294,299],[359,364]])})));return loadService}(),Database.postLoadService=function(e,t,r,n,o){var a=0;setInterval((function(){0<a&&(a=0)}),3e4);var c=clientnode__WEBPACK_IMPORTED_MODULE_2___default().debounce(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Database.changesStream&&Database.changesStream.cancel(),Database.changesStream=t.couchdb.connection.changes(clientnode__WEBPACK_IMPORTED_MODULE_2___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(r.couchdb.changesStream),Database.additionalChangesStreamOptions)),Database.changesStream.on("error",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(3<(a+=1))){e.next=9;break}return a=0,Database.changesStream.cancel(),e.next=7,t.couchdb.server.restart(t,r,n,o);case 7:e.next=10;break;case 9:case 10:c();case 11:case"end":return e.stop()}}),e)})))),e.next=5,o.callStack("couchdbInitializeChangesStream",n,r,Database.changesStream,t);case 5:case"end":return e.stop()}}),e)}))));return r.couchdb.attachAutoRestarter&&c(),e},Database.preLoadService=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(t,r){var n,o,a,c,_,i,s,l,u,p,d,m,f,b;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Object.prototype.hasOwnProperty.call(t,"couchdb")||(t.couchdb={}),Object.prototype.hasOwnProperty.call(t.couchdb,"connector")||(n=r.couchdb.model.property.name.special.id,o=r.couchdb.model.property.name.special.revision,t.couchdb.connector=pouchdb__WEBPACK_IMPORTED_MODULE_5___default(),a=t.couchdb.connector.prototype.bulkDocs,t.couchdb.connector.plugin({bulkDocs:function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(t){var c,_,i,s,l,u,p,d,m,f,b,y,h,x,O,E,P,g=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(_=g.length,i=Array(1<_?_-1:0),s=1;s<_;s++)i[s-1]=g[s];return l=0<i.length&&i[i.length-1]===Database.toggleIDDetermining,u=l?!Database.skipIDDetermining:Database.skipIDDetermining,l&&i.pop(),!Array.isArray(t)&&null!==t&&"object"==typeof t&&n in t&&(t=[t]),null!=(c=r.couchdb.connector.fetch)&&c.timeout&&(0===i.length||"object"!=typeof i[0])&&i.unshift({timeout:r.couchdb.connector.fetch.timeout}),e.next=8,a.call.apply(a,[this,t].concat(i));case 8:p=e.sent,d=[],m=[],f=0,b=_createForOfIteratorHelperLoose(p);case 13:if((y=b()).done){e.next=36;break}if(h=y.value,"object"!=typeof t[f]||null===t){e.next=33;break}if(!(o in t[f])||"conflict"!==h.name||!["latest","upsert"].includes(t[f][o])){e.next=21;break}m.push(h),d.push(f),e.next=33;break;case 21:if(!(n in t[f]&&r.couchdb.ignoreNoChangeError&&"name"in h&&"forbidden"===h.name&&"message"in h&&h.message.startsWith("NoChange:"))){e.next=33;break}if(p[f]={id:t[f][n],ok:!0},u){e.next=33;break}if(!(o in t[f])||["latest","upsert"].includes(t[f][o])){e.next=28;break}e.t0=t[f][o],e.next=32;break;case 28:return e.next=30,this.get(p[f].id);case 30:e.t1=o,e.t0=e.sent[e.t1];case 32:p[f].rev=e.t0;case 33:f+=1;case 34:e.next=13;break;case 36:if(!m.length){e.next=43;break}return t=m,l&&i.push(Database.toggleIDDetermining),e.next=41,this.bulkDocs.apply(this,[t].concat(i));case 41:for(x=e.sent,O=_createForOfIteratorHelperLoose(x);!(E=O()).done;)P=E.value,p[d.shift()]=P;case 43:return e.abrupt("return",p);case 44:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}),r.couchdb.debug&&t.couchdb.connector.debug.enable("*"),t.couchdb.connector=t.couchdb.connector.plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_6___default())),Object.prototype.hasOwnProperty.call(t.couchdb,"server")){e.next=34;break}t.couchdb.server={},c=[],_=_createForOfIteratorHelperLoose([].concat(r.couchdb.binary.runner));case 6:if((i=_()).done){e.next=32;break}s=i.value,l=_createForOfIteratorHelperLoose([].concat(s.location));case 9:if((u=l()).done){e.next=28;break}p=u.value,d=_createForOfIteratorHelperLoose([].concat(s.name));case 12:if((m=d()).done){e.next=24;break}return f=m.value,b=path__WEBPACK_IMPORTED_MODULE_4___default().resolve(p,f),c.push(b),e.next=18,clientnode__WEBPACK_IMPORTED_MODULE_2___default().isFile(b);case 18:if(!e.sent){e.next=22;break}return s.binaryFilePath=b,t.couchdb.server.runner=s,e.abrupt("break",24);case 22:e.next=12;break;case 24:if(!Object.prototype.hasOwnProperty.call(t.couchdb.server,"runner")){e.next=26;break}return e.abrupt("break",28);case 26:e.next=9;break;case 28:if(!Object.prototype.hasOwnProperty.call(t.couchdb.server,"runner")){e.next=30;break}return e.abrupt("break",32);case 30:e.next=6;break;case 32:if(Object.prototype.hasOwnProperty.call(t.couchdb.server,"runner")){e.next=34;break}throw new Error('No binary file in one of the following locations found: "'+c.join('", "')+'".');case 34:return e.abrupt("return",t);case 35:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database.shouldExit=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(t,r){var n;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_helper__WEBPACK_IMPORTED_MODULE_7__.default.stopServer(t,r);case 2:return delete t.couchdb,n="log.txt",e.next=6,clientnode__WEBPACK_IMPORTED_MODULE_2___default().isFile(n);case 6:if(!e.sent){e.next=9;break}return e.next=9,fs__WEBPACK_IMPORTED_MODULE_3__.promises.unlink(n);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database}();Database.additionalChangesStreamOptions={},Database.changesStream=void 0,Database.skipIDDetermining=!0,Database.toggleIDDetermining=Symbol("toggleIDDetermining");const __WEBPACK_DEFAULT_EXPORT__=Database})(),module.exports=__webpack_exports__})();
1
+ (()=>{var __webpack_modules__=[e=>{"use strict";e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{"use strict";e.exports=require("@babel/runtime/regenerator")},e=>{"use strict";e.exports=require("clientnode")},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},e=>{"use strict";e.exports=require("@babel/runtime/helpers/extends")},e=>{"use strict";e.exports=require("child_process")},e=>{"use strict";e.exports=require("pouchdb/node_modules/node-fetch/lib/index.js")},(__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__(5),_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__(0),_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__(1),_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__(6),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(2),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(7),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(3),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(4),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,o,a,c,_){var i,s,l;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===a&&(a=!0),void 0===c&&(c="_id"),void 0===_&&(_="_design/"),s=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()(((i={})[c]=""+_+r,i.language="javascript",i),n),e.prev=4,e.next=7,t.get(""+_+r);case 7:return l=e.sent,s._rev=l._rev,e.next=11,t.put(s);case 11:case 20:e.next=26;break;case 14:return e.prev=14,e.t0=e.catch(4),a&&e.t0.error,e.prev=17,e.next=20,t.put(s);case 23:throw e.prev=23,e.t1=e.catch(17),new Error(o+" 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,o,a,c,_,i;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),o=r.couchdb.model.property.name.special.id,a=r.couchdb.model.property.name.special.revision,c=function(){var e=i.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=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=u.length,_=Array(1<c?c-1:0),i=1;i<c;i++)_[i-1]=u[i];return e.next=4,n.apply(void 0,[t].concat(_));case 4:return e.abrupt("return",e.sent);case 7:if(e.prev=7,e.t0=e.catch(0),!(o in t&&r.couchdb.ignoreNoChangeError&&"forbidden"===e.t0.name&&null!=(s=e.t0.message)&&s.startsWith("NoChange:"))){e.next=21;break}if(l={id:t[o],ok:!0},!(a in t)||["latest","upsert"].includes(t[a])){e.next=15;break}e.t1=t[a],e.next=19;break;case 15:return e.next=17,this.get(l.id);case 17:e.t2=a,e.t1=e.sent[e.t2];case 19:return l.rev=e.t1,e.abrupt("return",l);case 21:throw e.t0;case 22:case"end":return e.stop()}}),e,this,[[0,7]])})))},_=_createForOfIteratorHelperLoose(["post","put"]);!(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,o=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CloseEventNames);!(r=o()).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(){for(var e,t,r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];null!=(e=services.couchdb)&&null!=(t=e.server)&&t.resolve&&services.couchdb.server.resolve.apply(_this,n)}),(function(){for(var e,t,r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];null!=(e=services.couchdb)&&null!=(t=e.server)&&t.resolve&&services.couchdb.server.reject.apply(_this,n)})),_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,o){var a,c;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=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=a,t.couchdb.server.reject=c,e.next=9,Helper.startServer(t,r);case 9:return Helper.initializeConnection(t,r),e.next=12,o.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){var t=e.property.name.special.allowedRole,r={},n=Helper.extendModels(e);for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o)&&Object.prototype.hasOwnProperty.call(n[o],t))for(var a in r[o]=Helper.normalizeAllowedModelRoles(n[o][t]),r[o].properties={},n[o])Object.prototype.hasOwnProperty.call(n[o],a)&&null!==n[o][a]&&"object"==typeof n[o][a]&&Object.prototype.hasOwnProperty.call(n[o][a],"allowedRoles")&&n[o][a].allowedRoles&&(r[o].properties[a]=Helper.normalizeAllowedModelRoles(n[o][a].allowedRoles));else r[o]={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.allowedRole,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,o,a=_createForOfIteratorHelperLoose([].concat(t[e][r]));!(n=a()).done;)o=n.value,t[e]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(Helper.extendModel(o,t,r)),t[e]);delete t[e][r]}return t[e]},Helper.extendModels=function(e){var t=e.property.name.special,r={};for(var n in e.entities)if(Object.prototype.hasOwnProperty.call(e.entities,n)){if(!new RegExp(e.property.name.typeRegularExpressionPattern.public).test(n)&&!new RegExp(e.property.name.typeRegularExpressionPattern.private).test(n))throw new Error('Model names have to match "'+e.property.name.typeRegularExpressionPattern.public+'" or "'+e.property.name.typeRegularExpressionPattern.private+'" for private one (given name: "'+n+'").');r[n]=Helper.extendModel(n,e.entities,t.extend)}for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o))for(var a in r[o])if(Object.prototype.hasOwnProperty.call(r[o],a))if(a===t.attachment)for(var c in r[o][a])Object.prototype.hasOwnProperty.call(r[o][a],c)&&(r[o][a][c]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),r[o][a][c]));else[t.allowedRole,t.constraint.execution,t.constraint.expression,t.extend,t.maximumAggregatedSize,t.minimumAggregatedSize,t.oldType].includes(a)||(r[o][a]=clientnode__WEBPACK_IMPORTED_MODULE_4___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_4___default().copy(e.property.defaultSpecification),r[o][a]));return r},Helper.normalizeAllowedModelRoles=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){var t={read:[],write:[]};for(var r in t)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=Array.isArray(e[r])?e[r]:[e[r]]);return t}return{read:[e],write:[e]}},Helper}();const __WEBPACK_DEFAULT_EXPORT__=Helper},e=>{!function(){function t(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return r[e](a,a.exports,t),a.exports}var r=[function(e,t,r){function n(){return a()?(e.exports=n=Reflect.construct,e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=n=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},e.exports.__esModule=!0,e.exports.default=e.exports),n.apply(null,arguments)}var o=r(1),a=r(2);e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){function t(r,n){return e.exports=t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}},e.exports.__esModule=!0,e.exports.default=e.exports}],n={};t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,{a:r}),r},t.d=function(e,r){for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(function(){"use strict";function e(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}}}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 r(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}t.r(o),t.d(o,{DatabaseHelper:function(){return c},default:function(){return _}});var n=t(0),a=t.n(n),c=function(){function t(){}return t.authenticate=function(t,r,n,o,a,c,_,i,s){var l;void 0===r&&(r=null),void 0===n&&(n={db:"dummy",name:'"unknown"',roles:[]}),void 0===o&&(o={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===c&&(c="_id"),void 0===_&&(_="-type"),void 0===i&&(i="_design/"),void 0===s&&(s=!1);var u=null!==(l=t[_])&&void 0!==l?l:r&&r[_];if(!u)return!0;var p=s?"read":"write",d={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(t,c)&&t[c].startsWith(i)&&d.read.push("readonlymember");var m="Current user doesn't own any role";if(n)if("name"in n||(n.name='"unknown"'),n.roles.length){if(a&&u&&Object.prototype.hasOwnProperty.call(a,u)){for(var f,b,y=a[u],h=e(["read","write"]);!(f=h()).done;)d[b=f.value]=d[b].concat(y[b]||[]);y.properties&&(d.properties=y.properties)}for(var x,O,E=d[p],P=e(n.roles);!(x=P()).done;)if(O=x.value,E.includes(O))return!0;m='Current user "'+n.name+'" owns the following roles: "'+n.roles.join('", "')+'"'}else m='Current user "'+n.name+"\" doesn't own any role";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+p+' action: "'+d[p].join('", "')+'". '+m+"."}},t.validateDocumentUpdate=function(t,r,n,o,c,_,i){void 0===_&&(_={});var s=function(e,t,r){var n;void 0===t&&(t="forbidden"),void 0===r&&(r={});var o=((n={})[t]=e,n.message=e,n.name=t,n);for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(o[a]=r[a]);throw o},l=new Date,u=Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate(),l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds())/1e3,p=!c.dateTimeFormat.startsWith("iso"),d=c.property.name.special,m=d.id,f=d.revision,b=d.type;r&&r[b]&&!t[b]&&(t[b]=r[b]);var y="",h="",x=function(){y=Object.prototype.hasOwnProperty.call(t,m)?t[m]:"",h=Object.prototype.hasOwnProperty.call(t,f)?t[f]:""};if(x(),Object.prototype.hasOwnProperty.call(o,c.property.name.validatedDocumentsCache)&&o[c.property.name.validatedDocumentsCache].has(y+"-"+h))return o[c.property.name.validatedDocumentsCache].delete(y+"-"+h),t;["latest","upsert"].includes(h)&&(r&&Object.prototype.hasOwnProperty.call(r,f)?h=t[f]=r[f]:"latest"===h?s("Revision: No old document available to update."):delete t[f]);var O,E=c.updateStrategy;Object.prototype.hasOwnProperty.call(t,d.strategy)&&(E=t[d.strategy],delete t[d.strategy]),i?O=i:JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?O=function(e){return JSON.stringify(e,null,4)}:s('Needed "serializer" is not available.');var P=function(e){return e instanceof Error?""+e:O(e)},g={};if("migrate"===E)for(var v in _)if(Object.prototype.hasOwnProperty.call(_,v)&&Object.prototype.hasOwnProperty.call(_[v],d.oldType)&&![null,void 0].includes(_[v][d.oldType]))for(var D,M,w=e([].concat(_[v][d.oldType]));!(D=w()).done;)M=D.value,g[M]=v;var C=function(e){return"string"==typeof e?e.trim():""},A=function(e){if(p)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},k=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},T=function(e,r){if(r||(r=t[d.attachment]),e){for(var n in r)if(Object.prototype.hasOwnProperty.call(r,n)&&n.startsWith(e))return n}else{var o=Object.keys(r);if(o.length)return o[0]}return null},I=function(e){if(Object.prototype.hasOwnProperty.call(t,d.attachment)){var r=t[d.attachment],n=T(e);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},R=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r={});var i=C(e);if(i){var p=(t?"return ":"")+i,y={attachmentWithPrefixExists:I,checkDocument:U,code:p,getFileNameByPrefix:T,idName:m,modelConfiguration:c,models:_,now:l,nowUTCTimestamp:u,revisionName:f,securitySettings:o,serialize:P,specialNames:d,typeName:b,userContext:n};for(var h in r)Object.prototype.hasOwnProperty.call(r,h)&&(y[h]=r[h]);var x,O=Object.keys(y);try{x=a()(Function,O.concat([p]))}catch(e){s(P(e),"compilation",{code:p,error:e,scope:y})}var E={code:p,result:void 0,scope:y};try{E.result=x.apply(void 0,O.map((function(e){return y[e]})))}catch(e){s(P(e),"runtime",{code:p,error:e,scope:y})}return E}s("No expression to evaluate provided.","empty")},U=function(t,r,n){void 0===n&&(n=[]);var o=n.length?" in "+n.join(" -> "):"",i=[],l=function(){Object.prototype.hasOwnProperty.call(t,b)||(r&&Object.prototype.hasOwnProperty.call(r,b)&&["fillUp","migrate"].includes(E)?t[b]=r[b]:s('Type: You have to specify a model type via property "'+b+'"'+o+".")),n.length||new RegExp(c.property.name.typeRegularExpressionPattern.public).test(t[b])||s('TypeName: You have to specify a model type which matches "'+c.property.name.typeRegularExpressionPattern.public+'" as public type (given "'+t[b]+'")'+o+"."),Object.prototype.hasOwnProperty.call(_,t[b])||(Object.prototype.hasOwnProperty.call(g,t[b])?t[b]=g[t[b]]:s('Model: Given model "'+t[b]+'" is not specified'+o+"."))};l();var u=t[b],h=_[u],O=null;Object.prototype.hasOwnProperty.call(h,d.additional)&&h[d.additional]&&(O=h[d.additional]);var v=function(c,_,i,l,p){void 0===p&&(p=["constraintExecution","constraintExpression"]);for(var d,m,f=e(p);!(d=f()).done;)if(m=d.value,Object.prototype.hasOwnProperty.call(i,m)){var b,y=void 0;try{y=R(i[m].evaluation,m.endsWith("Expression"),{checkPropertyContent:D,code:i[m].evaluation,model:h,modelName:u,name:_,newDocument:t,newValue:c,oldDocument:r,oldValue:l,parentNames:n,pathDescription:o,propertySpecification:i,type:m})}catch(c){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(c)&&s('Compilation: Hook "'+m+'" has invalid code "'+c.code+'": "'+c.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(c)&&s('Runtime: Hook "'+m+'" has throw an error with code "'+c.code+'": "'+c.message+'"'+o+"."),!Object.prototype.hasOwnProperty.call(c,"empty"))throw c}if(null==(b=y)||!b.result){var x=C(i[m].description);s(m.charAt(0).toUpperCase()+(m.substring(1)+": ")+(x?a()(Function,Object.keys(y.scope).concat(["return "+x])).apply(void 0,Object.values(y.scope)):'Property "'+_+'" should satisfy constraint "'+y.code+'" (given "'+P(c)+'")'+o+"."))}}},D=function(t,r,a,c){void 0===c&&(c=null);var i=[],l=[].concat(a.type?a.type:[]);"object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype&&!Object.prototype.hasOwnProperty.call(t,b)&&1===l.length&&Object.prototype.hasOwnProperty.call(_,l[0])&&(t[b]=l[0]);for(var u,d,f=!1,y=e(l);!(u=y()).done;)if(d=u.value,Object.prototype.hasOwnProperty.call(_,d)){if("object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype&&Object.prototype.hasOwnProperty.call(t,b)&&t[b]!==d&&"migrate"===E&&1===l.length&&(t[b]=d,i=n.concat(r,"migrate nested object type")),"object"==typeof t&&Object.getPrototypeOf(t)===Object.prototype&&Object.prototype.hasOwnProperty.call(t,b)&&t[b]===d){var h=U(t,c,n.concat(r));if(h.changedPath.length&&(i=h.changedPath),t=h.newDocument,P(t)===P({}))return{newValue:null,changedPath:i};f=!0;break}1===l.length&&s('NestedType: Under key "'+r+'" isn\'t of type "'+d+'" (given "'+P(t)+'" of type '+typeof t+")"+o+".")}else if("DateTime"===d){var x=t;if(t=A(t),!(p&&("number"!=typeof t||isNaN(t))||!p&&"string"!=typeof t)){f=!0;break}1===l.length&&s('PropertyType: Property "'+r+'" isn\'t of (valid) type "DateTime" (given "'+P(x).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof x+'")'+o+".")}else if(["boolean","integer","number","string"].includes(d)){if(!("number"==typeof t&&isNaN(t)||"integer"!==d&&typeof t!==d||"integer"===d&&parseInt(t,10)!==t)){f=!0;break}1===l.length&&s('PropertyType: Property "'+r+'" isn\'t of (valid) type "${type}" (given "'+P(t)+'" of type "'+typeof t+'")'+o+".")}else if("string"==typeof d&&d.startsWith("foreignKey:")){var O=_[d.substring(11)][m].type;if(O===typeof t){f=!0;break}1===l.length&&s('PropertyType: Foreign key property "'+r+'" isn\'t of type "'+O+'" (given "'+P(t)+'" of type "'+typeof t+'")'+o+".")}else{if("any"===d||P(t)===P(d)){f=!0;break}1===l.length&&s('PropertyType: Property "'+r+'" isn\'t value "'+d+'" (given "'+P(t).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof t+'")'+o+".")}if(f||s('PropertyType: None of the specified types "'+l.join('", "')+'" for property "'+r+'" matches value "'+P(t).replace(/^"/,"").replace(/"$/,"")+t+'" of type "'+typeof t+'")'+o+"."),"string"==typeof t&&(![null,void 0].includes(a.minimumLength)&&t.length<a.minimumLength&&s('MinimalLength: Property "'+r+'" must have minimal length '+a.minimumLength+" (given "+t+" with length i"+t.length+") "+o+"."),![null,void 0].includes(a.maximumLength)&&t.length>a.maximumLength&&s('MaximalLength: Property "'+r+'" must have maximal length '+a.maximumLength+" (given "+t+" with length "+t.length+")"+o+".")),"number"==typeof t&&(![null,void 0].includes(a.minimum)&&t<a.minimum&&s('Minimum: Property "'+r+'" (type '+a.type+") must satisfy a minimum of "+a.minimum+" (given "+t+" is too low)"+o+"."),![null,void 0].includes(a.maximum)&&t>a.maximum&&s('Maximum: Property "'+r+'" (type '+a.type+") must satisfy a maximum of "+a.maximum+" (given "+t+" is too high)"+o+".")),a.selection){var g=Array.isArray(a.selection)?a.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(a.selection);"DateTime"===a.type&&(g=g.map(A)),g.includes(t)||s('Selection: Property "'+r+'" (type '+a.type+') should be one of "'+g.join('", "')+'". But is "'+t+'"'+o+".")}return[null,void 0].includes(a.regularExpressionPattern)||new RegExp(a.regularExpressionPattern).test(t)?![null,void 0].includes(a.invertedRegularExpressionPattern)&&new RegExp(a.invertedRegularExpressionPattern).test(t)&&s('InvertedPatternMatch: Property "'+r+'" should not match regular expression pattern '+a.invertedRegularExpressionPattern+' (given "'+t+'")'+o+"."):s('PatternMatch: Property "'+r+'" should match regular expression pattern '+a.regularExpressionPattern+' (given "'+t+'")'+o+"."),v(t,r,a,c),P(t)!==P(c)&&(i=n.concat(r,"value updated")),{newValue:t,changedPath:i}},M=function(t,r,n,a){if(!n)for(var c,_,i=e(["onCreateExecution","onCreateExpression"]);!(c=i()).done;)if(_=c.value,Object.prototype.hasOwnProperty.call(t,_)){var l=void 0;try{l=R(t[_],_.endsWith("Expression"),{checkPropertyContent:D,code:t[_],model:h,modelName:u,name:a,newDocument:r,oldDocument:n,propertySpecification:t,type:_})}catch(t){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(t)&&s('Compilation: Hook "'+_+'" has invalid code "'+t.code+'" for property "'+a+'": '+t.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(t)&&s('Runtime: Hook "'+_+'" has throw an error with code "'+t.code+'" for property "'+a+'": '+t.message+o+"."),!Object.prototype.hasOwnProperty.call(t,"empty"))throw t}l&&![null,void 0].includes(l.result)&&(r[a]=l.result)}},w=function(t,r,a,c){if(Object.prototype.hasOwnProperty.call(r,c)){t.trim&&"string"==typeof r[c]&&(r[c]=r[c].trim()),t.emptyEqualsToNull&&(""===r[c]||Array.isArray(r[c])&&0===r[c].length||null!==r[c]&&"object"==typeof r[c]&&0===Object.keys(r).length)&&(r[c]=null);for(var _,i,l=e(["onUpdateExecution","onUpdateExpression"]);!(_=l()).done;)if(i=_.value,Object.prototype.hasOwnProperty.call(t,i))try{r[c]=R(t[i],i.endsWith("Expression"),{checkPropertyContent:D,code:t[i],modelName:u,name:c,newDocument:r,oldDocument:a,parentNames:n,pathDescription:o,propertySpecification:t,type:i}).result}catch(t){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(t)&&s('Compilation: Hook "'+i+'" has invalid code "'+t.code+'" for property "'+c+'": '+t.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(t)&&s('Runtime: Hook "'+i+'" has throw an error with code "'+t.code+'" for property "'+c+'": '+t.message+o+"."),!Object.prototype.hasOwnProperty.call(t,"empty"))throw t}}},T=Object.keys(h).filter((function(e){return![d.additional,d.allowedRole,d.constraint.execution,d.constraint.expression,d.create.execution,d.create.expression,d.extend,d.maximumAggregatedSize,d.minimumAggregatedSize,d.oldType,d.update.execution,d.update.expression].includes(e)}));if("migrate"===E)for(var I,L,j=e(T);!(I=j()).done;)if(L=I.value,![null,void 0].includes(h[L].oldName))for(var W,B,K=e([].concat(h[L].oldName));!(W=K()).done;)B=W.value,Object.prototype.hasOwnProperty.call(t,B)&&(t[L]=t[B],delete t[B]);if(!r)for(var N,S=0,H=[d.create.execution,d.create.expression];S<H.length;S++)if(N=H[S],Object.prototype.hasOwnProperty.call(h,N)){var q=void 0;try{q=R(h[N],N.endsWith("Expression"),{checkPropertyContent:D,code:h[N],id:y,model:h,modelName:u,newDocument:t,oldDocument:r,parentNames:n,pathDescription:o,type:N}).result}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&s('Compilation: Hook "'+N+'" has invalid code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&s('Runtime: Hook "'+N+'" has throw an error with code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}[null,void 0].includes(q)||(t=q),l(),u=t[b],0===n.length&&x()}for(var F,z=0,G=[d.update.execution,d.update.expression];z<G.length;z++)if(F=G[z],Object.prototype.hasOwnProperty.call(h,F)){var V=void 0;try{V=R(h[F],F.endsWith("Expression"),{checkPropertyContent:D,code:h[F],id:y,model:h,modelName:u,newDocument:t,oldDocument:r,parentNames:n,pathDescription:o,type:F}).result}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&s('Compilation: Hook "'+F+'" has invalid code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&s('Runtime: Hook "'+F+'" has throw an error with code "'+i.code+'" for document "'+u+'": '+i.message+o+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}[void 0,null].includes(V)||(t=V),l(),u=t[b],0===n.length&&x()}for(var J,$=function(){var a=J.value;if(d.attachment===a){var c=function(c){if(Object.prototype.hasOwnProperty.call(h[a],c)){Object.prototype.hasOwnProperty.call(t,a)&&null!==t[a]||(t[a]={}),r&&!Object.prototype.hasOwnProperty.call(r,a)&&(r[a]={});var _=Object.keys(t[a]).filter((function(e){return null!==t[a][e].data&&k(c,e,h[a][c])})),l=t[a],u=[];if(r){var p=r[a];u=Object.keys(p).filter((function(e){return!(Object.prototype.hasOwnProperty.call(l,e)&&Object.prototype.hasOwnProperty.call(l[e],"data")&&null===l[e].data)&&!!p[e]&&(Object.prototype.hasOwnProperty.call(p[e],"data")&&null!==p[e].data||p[e].stub&&!!p[e].digest)&&!!k(c,e,h[a][c])}))}for(var d,m,f=h[a][c],b=e(_);!(d=b()).done;)m=d.value,M(f,l,r&&r[a]?r[a]:null,m);for(var y,x,O=e(_);!(y=O()).done;)x=y.value,w(f,l,r&&r[a]?r[a]:null,x);if([null,void 0].includes(f.default)){if(f.nullable||0<_.length||0<u.length||s('AttachmentMissing: Missing attachment for type "'+c+'"'+o+"."),"fillUp"===E&&0===_.length&&0<u.length)for(var P,g,v=e(u);!(P=v()).done;)g=P.value,null===l[g]?i=n.concat(a,g,"file removed"):l[g]=r[a][g]}else if(0===_.length)if(0===u.length)for(var D in f.default)Object.prototype.hasOwnProperty.call(f.default,D)&&(l[D]=f.default[D],i=n.concat(a,c,"add default file"));else if("fillUp"===E)for(var C,A,T=e(u);!(C=T()).done;)A=C.value,l[A]=r[a][A]}};for(var _ in h[a])c(_)}else{var l=T.includes(a)?h[a]:O;M(l,t,r,a),w(l,t,r,a),[null,void 0].includes(l.default)?(!(l.nullable||Object.prototype.hasOwnProperty.call(t,a)||r&&Object.prototype.hasOwnProperty.call(r,a)&&E)&&s('MissingProperty: Missing property "'+a+'"'+o+"."),!Object.prototype.hasOwnProperty.call(t,a)&&r&&Object.prototype.hasOwnProperty.call(r,a)&&("fillUp"===E?t[a]=r[a]:!E&&(i=n.concat(a,"property removed")))):(!Object.prototype.hasOwnProperty.call(t,a)||null===t[a])&&(r&&Object.prototype.hasOwnProperty.call(r,a)?"fillUp"===E?t[a]=r[a]:"migrate"===E&&(t[a]=l.default,i=n.concat(a,"migrate default value")):(t[a]=l.default,i=i.concat(a,"add default value")))}},X=e(T.concat(O?Object.keys(t).filter((function(e){return!T.includes(e)})):[]));!(J=X()).done;)$();if(r&&"incremental"===E)for(var Y in t)if(Object.prototype.hasOwnProperty.call(t,Y)&&Object.prototype.hasOwnProperty.call(r,Y)&&!c.property.name.reserved.concat(m,f,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,b).includes(Y)&&(r[Y]===t[Y]||P(r[Y])===P(t[Y]))){delete t[Y];continue}for(var Z in t)if(Object.prototype.hasOwnProperty.call(t,Z)&&!c.property.name.reserved.concat(f,d.conflict,d.deleted,d.deletedConflict,d.localSequence,d.revisions,d.revisionsInformation,d.strategy).includes(Z)){var Q=void 0;if(Object.prototype.hasOwnProperty.call(h,Z))Q=h[Z];else if(O)Q=O;else{if("migrate"===E){delete t[Z],i=n.concat(Z,"migrate removed property");continue}s('Property: Given property "'+Z+'" isn\'t specified in model "'+u+'"'+o+".")}if(!Q)continue;var ee=function(e,t,r,a){if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,a)&&P(t[a])===P(r[a]))return a!==m&&"incremental"===E&&delete t[a],!0;s('Readonly: Property "'+a+'" is not writable (old document "'+P(r)+'")'+o+".")}else s('Readonly: Property "'+a+'" is not writable'+o+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,a)){if(P(t[a])===P(r[a]))return"incremental"!==E||c.property.name.reserved.concat(d.deleted,m,f).includes(a)||delete t[a],!0;"migrate"!==E&&s('Immutable: Property "'+a+'" is not writable (old document "'+P(r)+'")'+o+".")}if(null===t[a]){if(e.nullable)return delete t[a],r&&Object.prototype.hasOwnProperty.call(r,a)&&(i=n.concat(a,"delete property")),!0;s('NotNull: Property "'+a+'" should not by "null"'+o+".")}return!1};if(d.attachment===Z){var te=t[Z];for(var re in te)if(Object.prototype.hasOwnProperty.call(te,re))for(var ne in h[Z])if(k(ne,re,h[Z][ne])){ee(h[Z][ne],t,r,re);break}continue}if(ee(Q,t,r,Z))continue;if("string"==typeof Q.type&&Q.type.endsWith("[]")||Array.isArray(Q.type)&&Q.type.length&&Array.isArray(Q.type[0])){var oe,ae=t[Z];Array.isArray(ae)?![null,void 0].includes(Q.minimumNumber)&&ae.length<Q.minimumNumber?s('MinimumArrayLength: Property "'+Z+'" (array of length '+ae.length+") doesn't fullfill minimum array length of "+Q.minimumNumber+o+"."):![null,void 0].includes(Q.maximumNumber)&&Q.maximumNumber<ae.length&&s('MaximumArrayLength: Property "'+Z+'" (array of length '+ae.length+") doesn't fullfill maximum array length of "+Q.maximumNumber+o+"."):s('PropertyType: Property "'+Z+'" isn\'t of type "array -> '+Q.type+'" (given "'+P(ae)+'")'+o+"."),v(ae,Z,Q,r&&Object.prototype.hasOwnProperty.call(r,Z)&&r[Z]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var ce={};for(var _e in Q)Object.prototype.hasOwnProperty.call(Q,_e)&&(ce[_e]="type"===_e?Array.isArray(Q[_e])?Q[_e][0]:[Q[_e].substring(0,Q.type.length-2)]:Q[_e]);if(1===(null==(oe=ce.type)?void 0:oe.length)&&Object.prototype.hasOwnProperty.call(_,ce.type[0]))for(var ie,se,le=e(ae.slice());!(ie=le()).done;)"object"!=typeof(se=ie.value)||Object.getPrototypeOf(se)!==Object.prototype||Object.prototype.hasOwnProperty.call(se,b)||(se[b]=ce.type[0]);for(var ue,pe,de=0,me=e(ae.slice());!(ue=me()).done;)pe=ue.value,ae[de]=D(pe,de+1+". value in "+Z,ce).newValue,null===pe&&ae.splice(de,1),de+=1;r&&Object.prototype.hasOwnProperty.call(r,Z)&&Array.isArray(r[Z])&&r[Z].length===ae.length&&P(r[Z])===P(ae)||(i=n.concat(Z,"array updated"))}else{var fe=r&&Object.prototype.hasOwnProperty.call(r,Z)?r[Z]:null,be=D(t[Z],Z,Q,fe);t[Z]=be.newValue,be.changedPath.length&&(i=be.changedPath),null===t[Z]&&(null!==fe&&(i=n.concat(Z,"property removed")),delete t[Z])}}for(var ye in d.constraint)if(Object.prototype.hasOwnProperty.call(d.constraint,ye)&&(ye=d.constraint[ye])&&Object.prototype.hasOwnProperty.call(h,ye))for(var he,xe=e([].concat(h[ye]));!(he=xe()).done;){var Oe,Ee=he.value,Pe=void 0;try{Pe=R(Ee.evaluation,ye===d.constraint.expression,{checkPropertyContent:D,code:Ee.evaluation,model:h,modelName:u,newDocument:t,oldDocument:r,parentNames:n,pathDescription:o,type:ye})}catch(i){if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&s('Compilation: Hook "'+ye+'" has invalid code "'+i.code+'": "'+i.message+'"'+o+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&s('Runtime: Hook "'+ye+'" has thrown an error with code "'+i.code+'": '+i.message+o+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}if(null==(Oe=Pe)||!Oe.result){var ge=ye.replace(/^[^a-zA-Z]+/,"");s(ge.charAt(0).toUpperCase()+(ge.substring(1)+": ")+(Ee.description?a()(Function,Object.keys(Pe.scope).concat(["return "+Ee.description.trim()])).apply(void 0,Object.values(Pe.scope)):'Model "'+u+'" should satisfy constraint "'+Pe.code+'" (given "'+P(t)+'")'+o+"."))}}if(Object.prototype.hasOwnProperty.call(t,d.attachment)){var ve=t[d.attachment];("object"!=typeof ve||Object.getPrototypeOf(ve)!==Object.prototype)&&s("AttachmentType: given attachment has invalid type"+o+".");var De=null;if(r&&Object.prototype.hasOwnProperty.call(r,d.attachment)&&null!==(De=r[d.attachment])&&"object"==typeof De)for(var Me in De)Object.prototype.hasOwnProperty.call(De,Me)&&(Object.prototype.hasOwnProperty.call(ve,Me)?null===ve[Me]||null===ve[Me].data||ve[Me].content_type===De[Me].content_type&&(ve[Me].data===De[Me].data||ve[Me].digest===De[Me].digest)?((null===ve[Me]||null===ve[Me].data)&&(i=n.concat(d.attachment,Me,"attachment removed")),"incremental"===E&&delete ve[Me]):i=n.concat(d.attachment,Me,"attachment updated"):"fillUp"===E?ve[Me]=De[Me]:E||(i=n.concat(d.attachment,Me,"attachment removed")));for(var we in ve)Object.prototype.hasOwnProperty.call(ve,we)&&([null,void 0].includes(ve[we])||null===ve[we].data?delete ve[we]:De&&Object.prototype.hasOwnProperty.call(De,we)&&ve[we].content_type===De[we].content_type&&(ve[we].data===De[we].data||ve[we].digest===De[we].digest)||(i=n.concat(d.attachment,we,"attachment updated")));0===Object.keys(ve).length&&delete t[d.attachment];var Ce={};for(var Ae in h[d.attachment])Object.prototype.hasOwnProperty.call(h[d.attachment],Ae)&&(Ce[Ae]=[]);for(var ke in ve)if(Object.prototype.hasOwnProperty.call(ve,ke)){var Te=!1;for(var Ie in h[d.attachment])if(k(Ie,ke,h[d.attachment][Ie])){Ce[Ie].push(ke),Te=!0;break}Te||s('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(h[d.attachment]).join('", "')+'") matches given one ("'+ke+'")'+o+".")}for(var Re=0,Ue=0,Le=Object.keys(Ce);Ue<Le.length;Ue++){var je=Le[Ue],We=h[d.attachment][je];if(Object.prototype.hasOwnProperty.call(Ce,je)){var Be=Ce[je].length;null!==We.maximumNumber&&Be>We.maximumNumber&&s("AttachmentMaximum: given number of attachments ("+Be+") doesn't satisfy specified maximum of "+We.maximumNumber+' from type "'+je+'"'+o+"."),(!We.nullable||0!==Be)&&Be<We.minimumNumber&&s("AttachmentMinimum: given number of attachments ("+Be+") doesn't satisfy specified minimum of "+We.minimumNumber+' from type "'+je+'"'+o+".");for(var Ke,Ne=0,Se=e(Ce[je]);!(Ke=Se()).done;){var He,qe,Fe=Ke.value;null!=(He=We.fileName)&&He.regularExpressionPattern&&!new RegExp(We.fileName.regularExpressionPattern).test(Fe)?s('AttachmentName: given attachment name "'+Fe+'" doesn\'t satisfy specified regular expression pattern "'+We.fileName.regularExpressionPattern+'" from type "'+je+'"'+o+"."):null!=(qe=We.fileName)&&qe.invertedRegularExpressionPattern&&new RegExp(We.fileName.invertedRegularExpressionPattern).test(Fe)?s('InvertedAttachmentName: given attachment name "'+Fe+'" does satisfy specified regular expression pattern "'+We.fileName.invertedRegularExpressionPattern+'" from type "'+je+'"'+o+"."):!([null,void 0].includes(We.contentTypeRegularExpressionPattern)||ve[Fe].content_type&&new RegExp(We.contentTypeRegularExpressionPattern).test(ve[Fe].content_type))&&s('AttachmentContentType: given attachment content type "'+ve[Fe].content_type+'" doesn\'t satisfy specified regular expression pattern "'+We.contentTypeRegularExpressionPattern+'" from type "'+je+'"'+o+".");var ze=We.invertedContentTypeRegularExpressionPattern;[null,void 0].includes(ze)||ve[Fe].content_type&&!new RegExp(ze).test(ve[Fe].content_type)||s('InvertedAttachmentContentType: given attachment content type "'+ve[Fe].content_type+'" does satisfy specified regular expression pattern "'+ze+'" from type "'+je+'"'+o+".");var Ge=0;"length"in ve[Fe]?Ge=ve[Fe].length:"data"in ve[Fe]&&(Ge=Buffer&&"byteLength"in Buffer?Buffer.byteLength(ve[Fe].data,"base64"):ve[Fe].data.length),![null,void 0].includes(We.minimumSize)&&We.minimumSize>Ge?s("AttachmentMinimumSize: given attachment size "+Ge+" byte doesn't satisfy specified minimum of "+We.minimumSize+" byte "+o+"."):![null,void 0].includes(We.maximumSize)&&We.maximumSize<Ge&&s("AttachmentMaximumSize: given attachment size "+Ge+" byte doesn't satisfy specified maximum of "+We.maximumSize+" byte "+o+"."),Ne+=Ge}![null,void 0].includes(We.minimumAggregatedSize)&&We.minimumAggregatedSize>Ne?s('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+je+'" '+Ne+" byte doesn't satisfy specified minimum of "+We.minimumAggregatedSize+" byte "+o+"."):![null,void 0].includes(We.maximumAggregatedSize)&&We.maximumAggregatedSize<Ne&&s('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+je+'" '+Ne+" byte doesn't satisfy specified maximum of "+We.maximumAggregatedSize+" byte "+o+"."),Re+=Ne}}Object.prototype.hasOwnProperty.call(h,d.minimumAggregatedSize)&&![null,void 0].includes(h[d.minimumAggregatedSize])&&h[d.minimumAggregatedSize]>Re?s("AggregatedMinimumSize: given aggregated size "+Re+" byte doesn't satisfy specified minimum of "+h[d.minimumAggregatedSize]+" byte "+o+"."):![null,void 0].includes(h[d.maximumAggregatedSize])&&h[d.maximumAggregatedSize]<Re&&s("AggregatedMaximumSize: given aggregated size "+Re+" byte doesn't satisfy specified maximum of "+h[d.maximumAggregatedSize]+" byte "+o+".")}if(r&&Object.prototype.hasOwnProperty.call(r,d.attachment)&&0===Object.keys(r[d.attachment]).length&&delete r[d.attachment],0===i.length&&r&&"migrate"===E)for(var Ve in r)Object.prototype.hasOwnProperty.call(r,Ve)&&!Object.prototype.hasOwnProperty.call(t,Ve)&&(i=n.concat(Ve,"migrate removed property"));return{changedPath:i,newDocument:t}},L=U(t,r);return(!L.newDocument._deleted||r)&&(L.newDocument._deleted&&L.newDocument._deleted!==(null==r?void 0:r._deleted)||L.changedPath.length)||s("NoChange: No new data given. new document: "+P(t)+"; old document: "+P(r)+"."),Object.prototype.hasOwnProperty.call(o,c.property.name.validatedDocumentsCache)?o[c.property.name.validatedDocumentsCache].add(y+"-"+h):o[c.property.name.validatedDocumentsCache]=new Set([y+"-"+h]),L.newDocument},t}(),_=c})(),e.exports=o}()},,e=>{"use strict";e.exports=require("pouchdb")},e=>{"use strict";e.exports=require("pouchdb-find")}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{Database:()=>Database,default:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(0),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(1),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1__),clientnode__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(2),clientnode__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_2__),fs__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(3),fs__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_3__),path__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(4),path__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_4__),pouchdb__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(11),pouchdb__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(pouchdb__WEBPACK_IMPORTED_MODULE_5__),pouchdb_find__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(12),pouchdb_find__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(pouchdb_find__WEBPACK_IMPORTED_MODULE_6__),_databaseHelper__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(9),_databaseHelper__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_8__),_helper__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(8);function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Database=function(){function Database(){}return Database.loadService=function(){function loadService(){return _loadService.apply(this,arguments)}var _loadService=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function _callee(servicePromises,services,configuration){var promise,urlPrefix,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,_i,_arr,type,_iterator,_step,name,userDatabaseConnection,_userDatabaseConnecti,_iterator2,_step2,prefix,subPath,fullPath,url,value,response,changeNeeded,idName,typeName,modelConfiguration,models,databaseHelperCode,_iterator3,_step3,_type2,code,modelName,_name,_iterator4,_step4,constraint,property,_iterator5,_step5,_type,_constraint,migrater,_iterator6,_step6,file,extension,basename,document,_forbidden,_iterator7,_step7,retrievedDocument,_document,newDocument,_iterator8,_step8,_name2,result,indexes,_modelName,_iterator9,_step9,propertyName,_name3,foundPosition,position,_iterator10,_step10,index,_iterator11,_step11,_index,exists,_modelName2,_iterator12,_step12,_name4;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(promise=null,!Object.prototype.hasOwnProperty.call(services.couchdb.server,"runner")){_context.next=8;break}return _context.next=4,_helper__WEBPACK_IMPORTED_MODULE_7__.default.startServer(services,configuration);case 4:services.couchdb.server.restart=_helper__WEBPACK_IMPORTED_MODULE_7__.default.restartServer,services.couchdb.server.start=_helper__WEBPACK_IMPORTED_MODULE_7__.default.startServer,services.couchdb.server.stop=_helper__WEBPACK_IMPORTED_MODULE_7__.default.stopServer,promise=new Promise((function(e,t){services.couchdb.server.resolve=e,services.couchdb.server.reject=t}));case 8:if(!Object.prototype.hasOwnProperty.call(services.couchdb,"connection")){_context.next=10;break}return _context.abrupt("return",{name:"couchdb",promise});case 10:if(urlPrefix=clientnode__WEBPACK_IMPORTED_MODULE_2___default().stringFormat(configuration.couchdb.url,configuration.couchdb.user.name+":"+configuration.couchdb.user.password+"@"),!configuration.couchdb.ensureAdminPresence){_context.next=42;break}return unauthenticatedUserDatabaseConnection=new services.couchdb.connector(clientnode__WEBPACK_IMPORTED_MODULE_2___default().stringFormat(configuration.couchdb.url,"")+"/_users",_helper__WEBPACK_IMPORTED_MODULE_7__.default.getConnectorOptions(configuration)),_context.prev=13,_context.next=16,unauthenticatedUserDatabaseConnection.allDocs();case 16:return _context.next=19,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(clientnode__WEBPACK_IMPORTED_MODULE_2___default().stringFormat(configuration.couchdb.url,"")+"/"+services.couchdb.server.runner.adminUserConfigurationPath+"/"+configuration.couchdb.user.name,{body:'"'+configuration.couchdb.user.password+'"',method:"PUT"});case 19:_context.next=39;break;case 21:if(_context.prev=21,_context.t0=_context.catch(13),"unauthorized"!==_context.t0.name){_context.next=38;break}return authenticatedUserDatabaseConnection=new services.couchdb.connector(urlPrefix+"/_users",_helper__WEBPACK_IMPORTED_MODULE_7__.default.getConnectorOptions(configuration)),_context.prev=25,_context.next=28,authenticatedUserDatabaseConnection.allDocs();case 28:_context.next=33;break;case 30:_context.prev=30,_context.t1=_context.catch(25);case 33:return _context.prev=33,authenticatedUserDatabaseConnection.close(),_context.finish(33);case 36:_context.next=39;break;case 38:case 39:return _context.prev=39,unauthenticatedUserDatabaseConnection.close(),_context.finish(39);case 42:if(!configuration.couchdb.ensureUserPresence){_context.next=77;break}_i=0,_arr=[configuration.couchdb.security.admins,configuration.couchdb.security.members];case 44:if(!(_i<_arr.length)){_context.next=77;break}type=_arr[_i],_iterator=_createForOfIteratorHelperLoose(type.names);case 47:if((_step=_iterator()).done){_context.next=74;break}return name=_step.value,userDatabaseConnection=new services.couchdb.connector(urlPrefix+"/_users",_helper__WEBPACK_IMPORTED_MODULE_7__.default.getConnectorOptions(configuration)),_context.prev=50,_context.next=53,userDatabaseConnection.get("org.couchdb.user:"+name);case 53:_context.next=69;break;case 55:if(_context.prev=55,_context.t2=_context.catch(50),"not_found"!==_context.t2.error){_context.next=68;break}return _context.prev=58,_context.next=61,userDatabaseConnection.put((_userDatabaseConnecti={},_userDatabaseConnecti[configuration.couchdb.model.property.name.special.id]="org.couchdb.user:"+name,_userDatabaseConnecti.name=name,_userDatabaseConnecti.password=name,_userDatabaseConnecti.roles=[].concat(type.roles.includes(name+"s")?name+"s":[]),_userDatabaseConnecti.type="user",_userDatabaseConnecti));case 61:_context.next=66;break;case 63:throw _context.prev=63,_context.t3=_context.catch(58),new Error("Couldn't create missing user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t3));case 66:_context.next=69;break;case 68:throw new Error("Couldn't check for presence of user \""+name+'": '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t2));case 69:return _context.prev=69,userDatabaseConnection.close(),_context.finish(69);case 72:_context.next=47;break;case 74:_i++,_context.next=44;break;case 77:if(!configuration.couchdb.model.updateConfiguration){_context.next=132;break}_iterator2=_createForOfIteratorHelperLoose(configuration.couchdb.backend.prefixes);case 79:if((_step2=_iterator2()).done){_context.next=132;break}prefix=_step2.value,_context.t4=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(configuration.couchdb.backend.configuration);case 82:if((_context.t5=_context.t4()).done){_context.next=130;break}if(subPath=_context.t5.value,!Object.prototype.hasOwnProperty.call(configuration.couchdb.backend.configuration,subPath)){_context.next=128;break}return fullPath="/"+prefix+(prefix.trim()?"/":"")+subPath,url=""+urlPrefix+fullPath,value=configuration.couchdb.backend.configuration[subPath],response=void 0,_context.prev=89,_context.next=92,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(url);case 92:response=_context.sent,_context.next=98;break;case 95:_context.prev=95,_context.t6=_context.catch(89);case 98:if(!response){_context.next=128;break}if(!response.ok){_context.next=127;break}if(changeNeeded=!0,"function"!=typeof response.text){_context.next=113;break}return _context.prev=102,_context.t7=value,_context.next=106,response["string"==typeof value?"text":"json"]();case 106:_context.t8=_context.sent,changeNeeded=_context.t7===_context.t8,_context.next=113;break;case 110:_context.prev=110,_context.t9=_context.catch(102);case 113:if(!changeNeeded){_context.next=124;break}return _context.prev=114,_context.next=117,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(url,{body:'"'+configuration.couchdb.backend.configuration[subPath]+'"',method:"PUT"});case 117:_context.next=122;break;case 119:_context.prev=119,_context.t10=_context.catch(114);case 122:_context.next=125;break;case 124:case 125:_context.next=128;break;case 127:case 128:_context.next=82;break;case 130:_context.next=79;break;case 132:return _context.next=134,_helper__WEBPACK_IMPORTED_MODULE_7__.default.initializeConnection(services,configuration);case 134:if(idName=configuration.couchdb.model.property.name.special.id,typeName=configuration.couchdb.model.property.name.special.type,!configuration.couchdb.ensureSecuritySettingsPresence){_context.next=145;break}return _context.prev=137,_context.next=140,clientnode__WEBPACK_IMPORTED_MODULE_2__.globalContext.fetch(urlPrefix+"/"+configuration.couchdb.databaseName+"/_security",{body:JSON.stringify(configuration.couchdb.security),method:"PUT"});case 140:_context.next=145;break;case 142:_context.prev=142,_context.t11=_context.catch(137);case 145:if(modelConfiguration=clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(configuration.couchdb.model),delete modelConfiguration.property.defaultSpecification,delete modelConfiguration.entities,models=_helper__WEBPACK_IMPORTED_MODULE_7__.default.extendModels(configuration.couchdb.model),!configuration.couchdb.model.updateValidation){_context.next=213;break}return _context.next=152,fs__WEBPACK_IMPORTED_MODULE_3__.promises.readFile(eval("require.resolve")("./databaseHelper"),{encoding:configuration.core.encoding,flag:"r"});case 152:databaseHelperCode=_context.sent,_iterator3=_createForOfIteratorHelperLoose([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(modelConfiguration)+", "+JSON.stringify(models)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify(_helper__WEBPACK_IMPORTED_MODULE_7__.default.determineAllowedModelRolesMapping(configuration.couchdb.model))+", '"+idName+"', '"+typeName+"', '"+configuration.couchdb.model.property.name.special.designDocumentNamePrefix+"'"}]);case 154:if((_step3=_iterator3()).done){_context.next=169;break}_type2=_step3.value,code="function(...parameters) {\n return require('helper').default."+_type2.methodName+"(...parameters.concat(["+_type2.serializedParameter+"]))\n}",_context.prev=157,new Function("return "+code),_context.next=164;break;case 161:throw _context.prev=161,_context.t12=_context.catch(157),new Error("Generated "+_type2.name+' code "'+code+"\" doesn't compile: "+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t12));case 164:return configuration.core.debug,_context.next=167,_helper__WEBPACK_IMPORTED_MODULE_7__.default.ensureValidationDocumentPresence(services.couchdb.connection,_type2.name,{helper:databaseHelperCode,validate_doc_update:code},_type2.description,!0,idName,modelConfiguration.property.name.special.designDocumentNamePrefix);case 167:_context.next=154;break;case 169:_context.t13=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models);case 170:if((_context.t14=_context.t13()).done){_context.next=213;break}if(modelName=_context.t14.value,!Object.prototype.hasOwnProperty.call(models,modelName)){_context.next=211;break}_context.t15=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models[modelName]);case 174:if((_context.t16=_context.t15()).done){_context.next=211;break}if(_name=_context.t16.value,!Object.prototype.hasOwnProperty.call(models[modelName],_name)){_context.next=209;break}if(![modelConfiguration.property.name.special.constraint.execution,modelConfiguration.property.name.special.constraint.expression].includes(_name)){_context.next=193;break}_iterator4=_createForOfIteratorHelperLoose([].concat(models[modelName][_name]));case 179:if((_step4=_iterator4()).done){_context.next=191;break}if(constraint=_step4.value,!constraint.description){_context.next=189;break}_context.prev=182,new Function("return "+constraint.description),_context.next=189;break;case 186:throw _context.prev=186,_context.t17=_context.catch(182),new Error('Specified constraint description "'+constraint.description+'" for model "'+modelName+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t17)+'".');case 189:_context.next=179;break;case 191:_context.next=209;break;case 193:property=models[modelName][_name],_iterator5=_createForOfIteratorHelperLoose(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 195:if((_step5=_iterator5()).done){_context.next=209;break}if(_type=_step5.value,null===property||"object"!=typeof property){_context.next=207;break}if(_constraint=property[_type],null==_constraint||!_constraint.description){_context.next=207;break}_context.prev=200,new Function(_constraint.description),_context.next=207;break;case 204:throw _context.prev=204,_context.t18=_context.catch(200),new Error('Specified constraint description "'+_constraint.description+'" for model "'+modelName+'" in property "'+_name+'" as "'+_type+'" doesn\'t compile: "'+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t18)+'".');case 207:_context.next=195;break;case 209:_context.next=174;break;case 211:_context.next=170;break;case 213:if(!configuration.couchdb.model.autoMigrationPath){_context.next=305;break}return migrater={},_context.next=217,clientnode__WEBPACK_IMPORTED_MODULE_2___default().isDirectory(path__WEBPACK_IMPORTED_MODULE_4___default().resolve(configuration.couchdb.model.autoMigrationPath));case 217:if(!_context.sent){_context.next=257;break}return _context.t19=_createForOfIteratorHelperLoose,_context.next=221,clientnode__WEBPACK_IMPORTED_MODULE_2___default().walkDirectoryRecursively(path__WEBPACK_IMPORTED_MODULE_4___default().resolve(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_2___default().noop:function(e){return"debug"!==e.name});case 221:_context.t20=_context.sent,_iterator6=(0,_context.t19)(_context.t20);case 223:if((_step6=_iterator6()).done){_context.next=257;break}if(file=_step6.value,extension=path__WEBPACK_IMPORTED_MODULE_4___default().extname(file.name),basename=path__WEBPACK_IMPORTED_MODULE_4___default().basename(file.name,extension),".json"!==extension){_context.next=254;break}return document=void 0,_context.prev=229,_context.t21=JSON,_context.next=233,fs__WEBPACK_IMPORTED_MODULE_3__.promises.readFile(file.path,{encoding:configuration.core.encoding,flag:"r"});case 233:_context.t22=_context.sent,document=_context.t21.parse.call(_context.t21,_context.t22),_context.next=240;break;case 237:throw _context.prev=237,_context.t23=_context.catch(229),new Error('Parsing document "'+file.path+'" to include by automigration of has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t23));case 240:return document[idName]=basename,document[configuration.couchdb.model.property.name.special.revision]="upsert",_context.prev=242,_context.next=245,services.couchdb.connection.put(document);case 245:_context.next=251;break;case 247:throw _context.prev=247,_context.t24=_context.catch(242),null!=(_forbidden=_context.t24.forbidden)&&_forbidden.startsWith("NoChange:"),new Error('Migrating document "'+document[idName]+'" of type "'+document[typeName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t24));case 251:_context.next=255;break;case 254:".js"===path__WEBPACK_IMPORTED_MODULE_4___default().extname(file.name)&&(migrater[file.path]=eval("require")(file.path).default);case 255:_context.next=223;break;case 257:return _context.t25=_createForOfIteratorHelperLoose,_context.next=260,services.couchdb.connection.allDocs({include_docs:!0});case 260:_context.t26=_context.sent.rows,_iterator7=(0,_context.t25)(_context.t26);case 262:if((_step7=_iterator7()).done){_context.next=305;break}if(retrievedDocument=_step7.value,"string"==typeof retrievedDocument.id&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context.next=303;break}_document=retrievedDocument.doc,newDocument=clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(_document),newDocument[configuration.couchdb.model.property.name.special.strategy]="migrate",_iterator8=_createForOfIteratorHelperLoose(Object.keys(migrater).sort());case 269:if((_step8=_iterator8()).done){_context.next=282;break}_name2=_step8.value,result=null,_context.prev=272,result=migrater[_name2](newDocument,{configuration,databaseHelper:_databaseHelper__WEBPACK_IMPORTED_MODULE_8___default(),idName,migrater,models,modelConfiguration,selfFilePath:_name2,services,tools:clientnode__WEBPACK_IMPORTED_MODULE_2___default(),typeName}),_context.next=279;break;case 276:throw _context.prev=276,_context.t27=_context.catch(272),new Error('Running migrater "'+_name2+'" in document '+_helper__WEBPACK_IMPORTED_MODULE_7__.default.mayStripRepresentation(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+'" failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t27));case 279:result&&(newDocument=result);case 280:_context.next=269;break;case 282:_context.prev=282,_databaseHelper__WEBPACK_IMPORTED_MODULE_8___default().validateDocumentUpdate(clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(newDocument),clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(_document),{db:configuration.couchdb.databaseName,name:configuration.couchdb.user.name,roles:["_admin"]},clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(configuration.couchdb.security),modelConfiguration,models),_context.next=294;break;case 286:if(_context.prev=286,_context.t28=_context.catch(282),!Object.prototype.hasOwnProperty.call(_context.t28,"forbidden")){_context.next=293;break}return _context.t28.forbidden.startsWith("NoChange:"),_context.abrupt("continue",303);case 293:throw _context.t28;case 294:return _context.prev=294,_context.next=297,services.couchdb.connection.put(newDocument);case 297:_context.next=302;break;case 299:throw _context.prev=299,_context.t29=_context.catch(294),new Error('Replaceing auto migrated document "'+newDocument[idName]+'" has failed: '+clientnode__WEBPACK_IMPORTED_MODULE_2___default().represent(_context.t29));case 302:case 303:_context.next=262;break;case 305:if(!configuration.couchdb.createGenericFlatIndex||!configuration.couchdb.model.autoMigrationPath){_context.next=358;break}return _context.next=308,services.couchdb.connection.getIndexes();case 308:indexes=_context.sent.indexes,_context.t30=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models);case 310:if((_context.t31=_context.t30()).done){_context.next=340;break}if(_modelName=_context.t31.value,!Object.prototype.hasOwnProperty.call(models,_modelName)||!new RegExp(configuration.couchdb.model.property.name.typeRegularExpressionPattern.public).test(_modelName)){_context.next=338;break}return _context.next=315,services.couchdb.connection.createIndex({index:{ddoc:_modelName+"-GenericIndex",fields:[typeName],name:_modelName+"-GenericIndex"}});case 315:_iterator9=_createForOfIteratorHelperLoose(_helper__WEBPACK_IMPORTED_MODULE_7__.default.determineGenericIndexablePropertyNames(configuration.couchdb.model,models[_modelName]));case 316:if((_step9=_iterator9()).done){_context.next=338;break}propertyName=_step9.value,_name3=_modelName+"-"+propertyName+"-GenericIndex",foundPosition=-1,position=0,_iterator10=_createForOfIteratorHelperLoose(indexes);case 322:if((_step10=_iterator10()).done){_context.next=330;break}if(index=_step10.value,index.name!==_name3){_context.next=327;break}return foundPosition=position,_context.abrupt("break",330);case 327:position+=1;case 328:_context.next=322;break;case 330:if(-1!==foundPosition){_context.next=335;break}return _context.next=333,services.couchdb.connection.createIndex({index:{ddoc:_name3,fields:[typeName,propertyName],name:_name3}});case 333:_context.next=336;break;case 335:indexes.slice(position,1);case 336:_context.next=316;break;case 338:_context.next=310;break;case 340:_iterator11=_createForOfIteratorHelperLoose(indexes);case 341:if((_step11=_iterator11()).done){_context.next=358;break}if(_index=_step11.value,!_index.name.endsWith("-GenericIndex")){_context.next=356;break}exists=!1,_context.t32=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().keys(models);case 346:if((_context.t33=_context.t32()).done){_context.next=353;break}if(_modelName2=_context.t33.value,!_index.name.startsWith(_modelName2+"-")){_context.next=351;break}for(_iterator12=_createForOfIteratorHelperLoose(_helper__WEBPACK_IMPORTED_MODULE_7__.default.determineGenericIndexablePropertyNames(configuration.couchdb.model,models[_modelName2]));!(_step12=_iterator12()).done;)_name4=_step12.value,[_modelName2+"-"+_name4+"-GenericIndex",_modelName2+"-GenericIndex"].includes(_index.name)&&(exists=!0);return _context.abrupt("break",353);case 351:_context.next=346;break;case 353:if(exists){_context.next=356;break}return _context.next=356,services.couchdb.connection.deleteIndex(_index);case 356:_context.next=341;break;case 358:if(!configuration.couchdb.model.triggerInitialCompaction){_context.next=367;break}return _context.prev=359,_context.next=362,services.couchdb.connection.compact();case 362:_context.next=367;break;case 364:_context.prev=364,_context.t34=_context.catch(359);case 367:return _context.abrupt("return",{name:"couchdb",promise});case 368:case"end":return _context.stop()}}),_callee,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],[182,186],[200,204],[229,237],[242,247],[272,276],[282,286],[294,299],[359,364]])})));return loadService}(),Database.postLoadService=function(e,t,r,n,o){var a=0;setInterval((function(){0<a&&(a=0)}),3e4);var c=clientnode__WEBPACK_IMPORTED_MODULE_2___default().debounce(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Database.changesStream&&Database.changesStream.cancel(),Database.changesStream=t.couchdb.connection.changes(clientnode__WEBPACK_IMPORTED_MODULE_2___default().extend(!0,clientnode__WEBPACK_IMPORTED_MODULE_2___default().copy(r.couchdb.changesStream),Database.additionalChangesStreamOptions)),Database.changesStream.on("error",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(3<(a+=1))){e.next=9;break}return a=0,Database.changesStream.cancel(),e.next=7,t.couchdb.server.restart(t,r,n,o);case 7:e.next=10;break;case 9:case 10:c();case 11:case"end":return e.stop()}}),e)})))),e.next=5,o.callStack("couchdbInitializeChangesStream",n,r,Database.changesStream,t);case 5:case"end":return e.stop()}}),e)}))));return r.couchdb.attachAutoRestarter&&c(),e},Database.preLoadService=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(t,r){var n,o,a,c,_,i,s,l,u,p,d,m,f,b;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Object.prototype.hasOwnProperty.call(t,"couchdb")||(t.couchdb={}),Object.prototype.hasOwnProperty.call(t.couchdb,"connector")||(n=r.couchdb.model.property.name.special.id,o=r.couchdb.model.property.name.special.revision,t.couchdb.connector=pouchdb__WEBPACK_IMPORTED_MODULE_5___default(),a=t.couchdb.connector.prototype.bulkDocs,t.couchdb.connector.plugin({bulkDocs:function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(t){var c,_,i,s,l,u,p,d,m,f,b,y,h,x,O,E,P,g=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(_=g.length,i=Array(1<_?_-1:0),s=1;s<_;s++)i[s-1]=g[s];return l=0<i.length&&i[i.length-1]===Database.toggleIDDetermining,u=l?!Database.skipIDDetermining:Database.skipIDDetermining,l&&i.pop(),!Array.isArray(t)&&null!==t&&"object"==typeof t&&n in t&&(t=[t]),null!=(c=r.couchdb.connector.fetch)&&c.timeout&&(0===i.length||"object"!=typeof i[0])&&i.unshift({timeout:r.couchdb.connector.fetch.timeout}),e.next=8,a.call.apply(a,[this,t].concat(i));case 8:p=e.sent,d=[],m=[],f=0,b=_createForOfIteratorHelperLoose(p);case 13:if((y=b()).done){e.next=36;break}if(h=y.value,"object"!=typeof t[f]||null===t){e.next=33;break}if(!(o in t[f])||"conflict"!==h.name||!["latest","upsert"].includes(t[f][o])){e.next=21;break}m.push(h),d.push(f),e.next=33;break;case 21:if(!(n in t[f]&&r.couchdb.ignoreNoChangeError&&"name"in h&&"forbidden"===h.name&&"message"in h&&h.message.startsWith("NoChange:"))){e.next=33;break}if(p[f]={id:t[f][n],ok:!0},u){e.next=33;break}if(!(o in t[f])||["latest","upsert"].includes(t[f][o])){e.next=28;break}e.t0=t[f][o],e.next=32;break;case 28:return e.next=30,this.get(p[f].id);case 30:e.t1=o,e.t0=e.sent[e.t1];case 32:p[f].rev=e.t0;case 33:f+=1;case 34:e.next=13;break;case 36:if(!m.length){e.next=43;break}return t=m,l&&i.push(Database.toggleIDDetermining),e.next=41,this.bulkDocs.apply(this,[t].concat(i));case 41:for(x=e.sent,O=_createForOfIteratorHelperLoose(x);!(E=O()).done;)P=E.value,p[d.shift()]=P;case 43:return e.abrupt("return",p);case 44:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}),r.couchdb.debug&&t.couchdb.connector.debug.enable("*"),t.couchdb.connector=t.couchdb.connector.plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_6___default())),Object.prototype.hasOwnProperty.call(t.couchdb,"server")){e.next=34;break}t.couchdb.server={},c=[],_=_createForOfIteratorHelperLoose([].concat(r.couchdb.binary.runner));case 6:if((i=_()).done){e.next=32;break}s=i.value,l=_createForOfIteratorHelperLoose([].concat(s.location));case 9:if((u=l()).done){e.next=28;break}p=u.value,d=_createForOfIteratorHelperLoose([].concat(s.name));case 12:if((m=d()).done){e.next=24;break}return f=m.value,b=path__WEBPACK_IMPORTED_MODULE_4___default().resolve(p,f),c.push(b),e.next=18,clientnode__WEBPACK_IMPORTED_MODULE_2___default().isFile(b);case 18:if(!e.sent){e.next=22;break}return s.binaryFilePath=b,t.couchdb.server.runner=s,e.abrupt("break",24);case 22:e.next=12;break;case 24:if(!Object.prototype.hasOwnProperty.call(t.couchdb.server,"runner")){e.next=26;break}return e.abrupt("break",28);case 26:e.next=9;break;case 28:if(!Object.prototype.hasOwnProperty.call(t.couchdb.server,"runner")){e.next=30;break}return e.abrupt("break",32);case 30:e.next=6;break;case 32:if(Object.prototype.hasOwnProperty.call(t.couchdb.server,"runner")){e.next=34;break}throw new Error('No binary file in one of the following locations found: "'+c.join('", "')+'".');case 34:return e.abrupt("return",t);case 35:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database.shouldExit=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_0___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().mark((function e(t,r){var n;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_1___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_helper__WEBPACK_IMPORTED_MODULE_7__.default.stopServer(t,r);case 2:return delete t.couchdb,n="log.txt",e.next=6,clientnode__WEBPACK_IMPORTED_MODULE_2___default().isFile(n);case 6:if(!e.sent){e.next=9;break}return e.next=9,fs__WEBPACK_IMPORTED_MODULE_3__.promises.unlink(n);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Database}();Database.additionalChangesStreamOptions={},Database.changesStream=void 0,Database.skipIDDetermining=!0,Database.toggleIDDetermining=Symbol("toggleIDDetermining");const __WEBPACK_DEFAULT_EXPORT__=Database})(),module.exports=__webpack_exports__})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "couchdb-web-node-plugin",
3
- "version": "1.0.509",
3
+ "version": "1.0.513",
4
4
  "license": "CC-BY-3.0",
5
5
  "description": "A couchdb server, model instance conflict handler, rest api, authentication, session management, schema validator and model relation guarantee for webNode.",
6
6
  "homepage": "https://torben.website/couchdb-web-node-plugin",
@@ -54,6 +54,7 @@
54
54
  "watch": "weboptimizer build --watch"
55
55
  },
56
56
  "dependencies": {
57
+ "@types/buffer": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz",
57
58
  "@types/webpack": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz",
58
59
  "pouchdb": "*",
59
60
  "pouchdb-find": "*",
@@ -93,6 +94,7 @@
93
94
  }
94
95
  },
95
96
  "resolutions": {
97
+ "@types/buffer": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz",
96
98
  "@types/webpack": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz",
97
99
  "colors": "1.4.0"
98
100
  },
@@ -191,6 +193,7 @@
191
193
  }
192
194
  },
193
195
  "createGenericFlatIndex": true,
196
+ "databaseName": "main",
194
197
  "debug": false,
195
198
  "ensureAdminPresence": true,
196
199
  "ensureSecuritySettingsPresence": true,