couchdb-web-node-plugin 1.0.682 → 1.0.684
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/helper.d.ts +1 -1
- package/helper.js +1 -1
- package/index.js +1 -1
- package/package.json +13 -13
- package/type.d.ts +3 -3
package/helper.d.ts
CHANGED
|
@@ -78,7 +78,7 @@ export declare const extendModel: (modelName: string, models: Mapping<Partial<Mo
|
|
|
78
78
|
export declare const extendModels: (modelConfiguration: ModelConfiguration) => Models;
|
|
79
79
|
/**
|
|
80
80
|
* Convert given roles to its normalized representation.
|
|
81
|
-
* @param roles - Unstructured role'
|
|
81
|
+
* @param roles - Unstructured role's description.
|
|
82
82
|
* @returns Normalized roles representation.
|
|
83
83
|
*/
|
|
84
84
|
export declare const normalizeAllowedRoles: (roles: AllowedRoles) => NormalizedAllowedRoles;
|
package/helper.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e=[,e=>{e.exports=require("@babel/runtime/helpers/extends")},e=>{e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{e.exports=require("@babel/runtime/regenerator")},e=>{e.exports=require("clientnode")}],t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{determineAllowedModelRolesMapping:()=>m,determineGenericIndexablePropertyNames:()=>x,ensureValidationDocumentPresence:()=>v,extendModel:()=>w,extendModels:()=>O,getConnectorOptions:()=>b,initializeConnection:()=>h,isPropertySpecification:()=>g,mayStripRepresentation:()=>y,normalizeAllowedRoles:()=>j});var o=r(1),a=r.n(o),i=r(2),c=r.n(i),s=r(3),l=r.n(s),p=r(4);const u="1.0.
|
|
1
|
+
(()=>{"use strict";var e=[,e=>{e.exports=require("@babel/runtime/helpers/extends")},e=>{e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{e.exports=require("@babel/runtime/regenerator")},e=>{e.exports=require("clientnode")}],t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n](a,a.exports,r),a.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{determineAllowedModelRolesMapping:()=>m,determineGenericIndexablePropertyNames:()=>x,ensureValidationDocumentPresence:()=>v,extendModel:()=>w,extendModels:()=>O,getConnectorOptions:()=>b,initializeConnection:()=>h,isPropertySpecification:()=>g,mayStripRepresentation:()=>y,normalizeAllowedRoles:()=>j});var o=r(1),a=r.n(o),i=r(2),c=r.n(i),s=r(3),l=r.n(s),p=r(4);const u="1.0.683";function d(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 f(e,t);var r={}.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)?f(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(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 b=function(e){return e.couchdb.connector.fetch?{fetch:function(t,r){if(!p.globalContext.fetch)throw new Error("Missing fetch implementation.");return p.globalContext.fetch(t,(0,p.extend)(!0,(0,p.copy)(e.couchdb.connector.fetch),r||{}))}}:{fetch:function(e,t){if(!p.globalContext.fetch)throw new Error("Missing fetch implementation.");return p.globalContext.fetch(e,t)}}},y=function(e,t,r){var n=(0,p.represent)(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},v=function(){var e=c()(l().mark((function e(t,r,n,o,i,c,s,d){var f,b,y;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===i&&(i=!0),void 0===c&&(c="_id"),void 0===s&&(s="_rev"),void 0===d&&(d="_design/"),b=a()(((f={})[c]=""+d+r,f.language="javascript",f.version=u,f),n),e.prev=5,e.next=8,t.get(""+d+r);case 8:return y=e.sent,b[s]=y[s],e.next=12,t.put(b);case 12:i&&console.info(o+" updated."),e.next=27;break;case 15:return e.prev=15,e.t0=e.catch(5),i&&("not_found"===e.t0.error?console.info(o+" not available: create new one."):console.info(o+" couldn't be updated: \""+(0,p.represent)(e.t0)+'" create new one.')),e.prev=18,e.next=21,t.put(b);case 21:i&&console.info(o+" installed/updated."),e.next=27;break;case 24:throw e.prev=24,e.t1=e.catch(18),new Error(o+" couldn't be installed/updated: \""+(0,p.represent)(e.t1)+'".');case 27:case"end":return e.stop()}}),e,null,[[5,15],[18,24]])})));return function(){return e.apply(this,arguments)}}(),h=function(){var e=c()(l().mark((function e(t,r){var n,o,a,i,s,u,f,y;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=r.couchdb,o=(0,p.format)(n.url,n.user.name+":"+n.user.password+"@")+"/"+n.databaseName,t.couchdb.connection=new t.couchdb.connector(o,b(r)),(a=t.couchdb.connection).setMaxListeners(1/0),i=n.model.property.name.special.id,s=n.model.property.name.special.revision,u=l().mark((function e(){var t,r;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=y.value,r=a[t].bind(a),a[t]=c()(l().mark((function e(t){var o,a,c,p,u,d,f,b=arguments;return l().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o=b.length,a=Array(1<o?o-1:0),c=1;c<o;c++)a[c-1]=b[c];return p=a.length&&"object"==typeof a[0]?a[0]:{},e.prev=2,e.next=5,r.apply(void 0,[t].concat(a));case 5:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e.catch(2),u=t[i],d=e.t0,!(u&&n.ignoreNoChangeError&&"name"in d&&"forbidden"===d.name&&"message"in d&&d.message.startsWith("NoChange:"))){e.next=25;break}if(f=s in p?p[s]:t[s],e.t1=u,!(s in t)||["0-latest","0-upsert"].includes(f)){e.next=19;break}e.t2=f,e.next=23;break;case 19:return e.next=21,this.get(u);case 21:e.t3=s,e.t2=e.sent[e.t3];case 23:return e.t4=e.t2,e.abrupt("return",{id:e.t1,rev:e.t4,ok:!0});case 25:throw d;case 26:case"end":return e.stop()}}),e,this,[[2,8]])})));case 3:case"end":return e.stop()}}),e)})),f=d(["post","put"]);case 9:if((y=f()).done){e.next=13;break}return e.delegateYield(u(),"t0",11);case 11:e.next=9;break;case 13:return e.prev=13,e.next=16,(0,p.checkReachability)(o);case 16:e.next=25;break;case 18:if(e.prev=18,e.t1=e.catch(13),console.info("Database could not be retrieved yet: Creating it."),p.globalContext.fetch){e.next=23;break}throw new Error("Missing fetch implementation.");case 23:return e.next=25,p.globalContext.fetch(o,{method:"PUT"});case 25:return e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,null,[[13,18]])})));return function(){return e.apply(this,arguments)}}(),m=function(e){for(var t=e.property.name.special.allowedRole,r={},n=O(e),o=0,i=Object.entries(n);o<i.length;o++){var c=i[o],s=c[0],l=c[1];if(l[t]){r[s]=a()({properties:{}},j(l[t]));for(var u=0,d=Object.entries(l);u<d.length;u++){var f=d[u],b=f[0],y=f[1];(0,p.isObject)(y)&&y.allowedRoles&&(r[s].properties[b]=j(y.allowedRoles))}}else r[s]={properties:{},read:[],write:[]}}return r},g=function(e){return(0,p.isObject)(e)},x=function(e,t){var r=e.property.name.special;return Object.keys(t).filter((function(n){var o=t[n];return g(o)&&Object.prototype.hasOwnProperty.call(o,"index")&&o.index||g(o)&&!(Object.prototype.hasOwnProperty.call(o,"index")&&!o.index||e.property.name.reserved.concat(r.additional,r.allowedRole,r.attachment,r.conflict,r.constraint.execution,r.constraint.expression,r.deleted,r.deletedConflict,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType,r.id,r.revision,r.revisions,r.revisionsInformation,r.type).includes(n)||o.type&&("string"==typeof o.type&&o.type.endsWith("[]")||Array.isArray(o.type)&&o.type.length&&Array.isArray(o.type[0])||Object.prototype.hasOwnProperty.call(e.entities,o.type)))})).concat([r.id,r.revision]).sort()},w=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=d([].concat(t[e][r]));!(n=a()).done;)o=n.value,t[e]=(0,p.extend)(!0,(0,p.copy)(w(o,t,r)),t[e]);delete t[e][r]}return t[e]},O=function(e){for(var t,r=e.property.name.special,n={},o=e.property.name.typePattern,a=0,i=Object.keys(e.entities);a<i.length;a++){if(t=i[a],!new RegExp(o.public).test(t)&&!new RegExp(o.private).test(t))throw new Error('Model names have to match "'+o.public+'" or "'+o.private+'" for private one (given name: "'+t+'").');n[t]=w(t,e.entities,r.extend)}for(var c,s=0,l=Object.values(n);s<l.length;s++){c=l[s];for(var u=0,d=Object.entries(c);u<d.length;u++){var f=d[u],b=f[0],y=f[1];if(b===r.attachment)for(var v=y,h=0,m=Object.entries(v);h<m.length;h++){var g=m[h],x=g[0],O=g[1];v[x]=(0,p.extend)(!0,(0,p.copy)(e.property.defaultSpecification),O)}else[r.allowedRole,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(b)||(c[b]=(0,p.extend)(!0,(0,p.copy)(e.property.defaultSpecification),y))}}return n},j=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,r={read:[],write:[]},n=0,o=Object.keys(r);n<o.length;n++)t=o[n],Object.prototype.hasOwnProperty.call(e,t)&&(Array.isArray(e[t])?r[t]=e[t]:r[t]=[e[t]]);return r}return{read:[e],write:[e]}};module.exports=n})();
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var __webpack_modules__=[(e,t,n)=>{"use strict";n.d(t,{determineAllowedModelRolesMapping:()=>h,determineGenericIndexablePropertyNames:()=>O,ensureValidationDocumentPresence:()=>f,extendModels:()=>g,getConnectorOptions:()=>d,initializeConnection:()=>b,mayStripRepresentation:()=>m});var r=n(1),o=n.n(r),a=n(2),c=n.n(a),_=n(3),i=n.n(_),s=n(4);const l="1.0.681";function u(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 p(e,t);var n={}.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)?p(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var d=function(e){return e.couchdb.connector.fetch?{fetch:function(t,n){if(!s.globalContext.fetch)throw new Error("Missing fetch implementation.");return s.globalContext.fetch(t,(0,s.extend)(!0,(0,s.copy)(e.couchdb.connector.fetch),n||{}))}}:{fetch:function(e,t){if(!s.globalContext.fetch)throw new Error("Missing fetch implementation.");return s.globalContext.fetch(e,t)}}},m=function(e,t,n){var r=(0,s.represent)(e);return r.length<=t?r.length>n?r.substring(0,n-3)+"...":r:"DOCUMENT IS TOO BIG TO REPRESENT"},f=function(){var e=c()(i().mark((function e(t,n,r,a,c,_,u,p){var d,m,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===c&&(c=!0),void 0===_&&(_="_id"),void 0===u&&(u="_rev"),void 0===p&&(p="_design/"),m=o()(((d={})[_]=""+p+n,d.language="javascript",d.version=l,d),r),e.prev=5,e.next=8,t.get(""+p+n);case 8:return f=e.sent,m[u]=f[u],e.next=12,t.put(m);case 12:c&&console.info(a+" updated."),e.next=27;break;case 15:return e.prev=15,e.t0=e.catch(5),c&&("not_found"===e.t0.error?console.info(a+" not available: create new one."):console.info(a+" couldn't be updated: \""+(0,s.represent)(e.t0)+'" create new one.')),e.prev=18,e.next=21,t.put(m);case 21:c&&console.info(a+" installed/updated."),e.next=27;break;case 24:throw e.prev=24,e.t1=e.catch(18),new Error(a+" couldn't be installed/updated: \""+(0,s.represent)(e.t1)+'".');case 27:case"end":return e.stop()}}),e,null,[[5,15],[18,24]])})));return function(){return e.apply(this,arguments)}}(),b=function(){var e=c()(i().mark((function e(t,n){var r,o,a,_,l,p,m,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.couchdb,o=(0,s.format)(r.url,r.user.name+":"+r.user.password+"@")+"/"+r.databaseName,t.couchdb.connection=new t.couchdb.connector(o,d(n)),(a=t.couchdb.connection).setMaxListeners(1/0),_=r.model.property.name.special.id,l=r.model.property.name.special.revision,p=i().mark((function e(){var t,n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=f.value,n=a[t].bind(a),a[t]=c()(i().mark((function e(t){var o,a,c,s,u,p,d,m=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o=m.length,a=Array(1<o?o-1:0),c=1;c<o;c++)a[c-1]=m[c];return s=a.length&&"object"==typeof a[0]?a[0]:{},e.prev=2,e.next=5,n.apply(void 0,[t].concat(a));case 5:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e.catch(2),u=t[_],p=e.t0,!(u&&r.ignoreNoChangeError&&"name"in p&&"forbidden"===p.name&&"message"in p&&p.message.startsWith("NoChange:"))){e.next=25;break}if(d=l in s?s[l]:t[l],e.t1=u,!(l in t)||["0-latest","0-upsert"].includes(d)){e.next=19;break}e.t2=d,e.next=23;break;case 19:return e.next=21,this.get(u);case 21:e.t3=l,e.t2=e.sent[e.t3];case 23:return e.t4=e.t2,e.abrupt("return",{id:e.t1,rev:e.t4,ok:!0});case 25:throw p;case 26:case"end":return e.stop()}}),e,this,[[2,8]])})));case 3:case"end":return e.stop()}}),e)})),m=u(["post","put"]);case 9:if((f=m()).done){e.next=13;break}return e.delegateYield(p(),"t0",11);case 11:e.next=9;break;case 13:return e.prev=13,e.next=16,(0,s.checkReachability)(o);case 16:e.next=25;break;case 18:if(e.prev=18,e.t1=e.catch(13),console.info("Database could not be retrieved yet: Creating it."),s.globalContext.fetch){e.next=23;break}throw new Error("Missing fetch implementation.");case 23:return e.next=25,s.globalContext.fetch(o,{method:"PUT"});case 25:return e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,null,[[13,18]])})));return function(){return e.apply(this,arguments)}}(),h=function(e){for(var t=e.property.name.special.allowedRole,n={},r=g(e),a=0,c=Object.entries(r);a<c.length;a++){var _=c[a],i=_[0],l=_[1];if(l[t]){n[i]=o()({properties:{}},v(l[t]));for(var u=0,p=Object.entries(l);u<p.length;u++){var d=p[u],m=d[0],f=d[1];(0,s.isObject)(f)&&f.allowedRoles&&(n[i].properties[m]=v(f.allowedRoles))}}else n[i]={properties:{},read:[],write:[]}}return n},y=function(e){return(0,s.isObject)(e)},O=function(e,t){var n=e.property.name.special;return Object.keys(t).filter((function(r){var o=t[r];return y(o)&&Object.prototype.hasOwnProperty.call(o,"index")&&o.index||y(o)&&!(Object.prototype.hasOwnProperty.call(o,"index")&&!o.index||e.property.name.reserved.concat(n.additional,n.allowedRole,n.attachment,n.conflict,n.constraint.execution,n.constraint.expression,n.deleted,n.deletedConflict,n.extend,n.maximumAggregatedSize,n.minimumAggregatedSize,n.oldType,n.id,n.revision,n.revisions,n.revisionsInformation,n.type).includes(r)||o.type&&("string"==typeof o.type&&o.type.endsWith("[]")||Array.isArray(o.type)&&o.type.length&&Array.isArray(o.type[0])||Object.prototype.hasOwnProperty.call(e.entities,o.type)))})).concat([n.id,n.revision]).sort()},x=function(e,t,n){if(void 0===n&&(n="_extends"),"_base"===e)return t[e];if(Object.prototype.hasOwnProperty.call(t,"_base")&&(Object.prototype.hasOwnProperty.call(t[e],n)&&t[e][n]?t[e][n]=["_base"].concat(t[e][n]):t[e][n]="_base"),Object.prototype.hasOwnProperty.call(t[e],n)){for(var r,o,a=u([].concat(t[e][n]));!(r=a()).done;)o=r.value,t[e]=(0,s.extend)(!0,(0,s.copy)(x(o,t,n)),t[e]);delete t[e][n]}return t[e]},g=function(e){for(var t,n=e.property.name.special,r={},o=e.property.name.typePattern,a=0,c=Object.keys(e.entities);a<c.length;a++){if(t=c[a],!new RegExp(o.public).test(t)&&!new RegExp(o.private).test(t))throw new Error('Model names have to match "'+o.public+'" or "'+o.private+'" for private one (given name: "'+t+'").');r[t]=x(t,e.entities,n.extend)}for(var _,i=0,l=Object.values(r);i<l.length;i++){_=l[i];for(var u=0,p=Object.entries(_);u<p.length;u++){var d=p[u],m=d[0],f=d[1];if(m===n.attachment)for(var b=f,h=0,y=Object.entries(b);h<y.length;h++){var O=y[h],g=O[0],v=O[1];b[g]=(0,s.extend)(!0,(0,s.copy)(e.property.defaultSpecification),v)}else[n.allowedRole,n.constraint.execution,n.constraint.expression,n.extend,n.maximumAggregatedSize,n.minimumAggregatedSize,n.oldType].includes(m)||(_[m]=(0,s.extend)(!0,(0,s.copy)(e.property.defaultSpecification),f))}}return r},v=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,n={read:[],write:[]},r=0,o=Object.keys(n);r<o.length;r++)t=o[r],Object.prototype.hasOwnProperty.call(e,t)&&(Array.isArray(e[t])?n[t]=e[t]:n[t]=[e[t]]);return n}return{read:[e],write:[e]}}},e=>{"use strict";e.exports=require("@babel/runtime/helpers/extends")},e=>{"use strict";e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{"use strict";e.exports=require("@babel/runtime/regenerator")},e=>{"use strict";e.exports=require("clientnode")},(module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{TOGGLE_LATEST_REVISION_DETERMINING:()=>TOGGLE_LATEST_REVISION_DETERMINING,database:()=>database,default:()=>__WEBPACK_DEFAULT_EXPORT__,loadService:()=>loadService,postLoadService:()=>postLoadService,preLoadService:()=>preLoadService,shouldExit:()=>shouldExit});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1),_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__(2),_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__(3),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),clientnode__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_3__),fs__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(6),fs__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_4__),path__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(7),path__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_5__),pouchdb_node__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9),pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(pouchdb_node__WEBPACK_IMPORTED_MODULE_6__),pouchdb_find__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(10),pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(pouchdb_find__WEBPACK_IMPORTED_MODULE_7__),_databaseHelper__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(8),_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_10__),_helper__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(0),_server__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(14);function _createForOfIteratorHelperLoose(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=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 n={}.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)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}module=__webpack_require__.hmd(module);var TOGGLE_LATEST_REVISION_DETERMINING=Symbol("toggleLatestRevisionDetermining"),preLoadService=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,r,o,a,c,_,i,s,l,u,p,d,m,f,b,h,y;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.configuration.couchdb,r=t.services,Object.prototype.hasOwnProperty.call(r,"couchdb")||(r.couchdb={}),o=r.couchdb,Object.prototype.hasOwnProperty.call(o,"connector")||(a=n.model.property.name.special.id,c=n.model.property.name.special.revision,o.connector=pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default(),_=o.connector.prototype.bulkDocs,o.connector.plugin({bulkDocs:function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,o,i,s,l,u,p,d,m,f,b,h,y,O,x,g,v,E,P=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o=P.length,i=Array(1<o?o-1:0),s=1;s<o;s++)i[s-1]=P[s];return l=0<i.length&&i[i.length-1]===TOGGLE_LATEST_REVISION_DETERMINING,u=l?!n.skipLatestRevisionDetermining:n.skipLatestRevisionDetermining,l&&i.pop(),p=!Array.isArray(t)&&(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isObject)(t)&&a in t?[t]:t,null!=(r=n.connector.fetch)&&r.timeout&&(0===i.length||"object"!=typeof i[0])&&i.unshift({timeout:n.connector.fetch.timeout}),e.next=8,_.call.apply(_,[this,p].concat(i));case 8:d=e.sent,m=[],f=[],b=0,h=_createForOfIteratorHelperLoose(d);case 13:if((y=h()).done){e.next=36;break}if(O=y.value,"object"!=typeof p[b]){e.next=33;break}if(!(c in p[b])||"conflict"!==O.name||!["0-latest","0-upsert"].includes(p[b][c])){e.next=21;break}f.push(p[b]),m.push(b),e.next=33;break;case 21:if(!(a in p[b]&&n.ignoreNoChangeError&&"name"in O&&"forbidden"===O.name&&"message"in O&&O.message.startsWith("NoChange:"))){e.next=33;break}if(d[b]={id:p[b][a],ok:!0},u){e.next=33;break}if(!(c in p[b])||["0-latest","0-upsert"].includes(p[b][c])){e.next=28;break}e.t0=p[b][c],e.next=32;break;case 28:return e.next=30,this.get(d[b].id);case 30:e.t1=c,e.t0=e.sent[e.t1];case 32:d[b].rev=e.t0;case 33:b+=1;case 34:e.next=13;break;case 36:if(!f.length){e.next=43;break}return p=f,l&&i.push(TOGGLE_LATEST_REVISION_DETERMINING),e.next=41,this.bulkDocs.apply(this,[p].concat(i));case 41:for(x=e.sent,g=_createForOfIteratorHelperLoose(x);!(v=g()).done;)E=v.value,d[m.shift()]=E;case 43:return e.abrupt("return",d);case 44:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}),n.debug&&o.connector.debug.enable("*"),o.connector=o.connector.plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default())),Object.prototype.hasOwnProperty.call(o,"server")){e.next=36;break}o.server={},i=[],s=_createForOfIteratorHelperLoose([].concat(n.binary.runner));case 8:if((l=s()).done){e.next=34;break}u=l.value,p=_createForOfIteratorHelperLoose([].concat(u.location));case 11:if((d=p()).done){e.next=30;break}m=d.value,f=_createForOfIteratorHelperLoose([].concat(u.name));case 14:if((b=f()).done){e.next=26;break}return h=b.value,y=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(m,h),i.push(y),e.next=20,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isFile)(y);case 20:if(!e.sent){e.next=24;break}return u.binaryFilePath=y,o.server.runner=u,e.abrupt("break",26);case 24:e.next=14;break;case 26:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=28;break}return e.abrupt("break",30);case 28:e.next=11;break;case 30:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=32;break}return e.abrupt("break",34);case 32:e.next=8;break;case 34:if(Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=36;break}throw new Error('No binary file in one of the following locations found: "'+i.join('", "')+'".');case 36:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),loadService=function(){var _ref5=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee3(_ref4){var configuration,services,promise,couchdb,urlPrefix,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,_i,_arr,type,_iterator6,_step6,name,userDatabaseConnection,_userDatabaseConnecti,_iterator7,_step7,prefix,subPath,fullPath,url,value,response,changeNeeded,modelConfiguration,specialNames,idName,revisionName,typeName,models,databaseHelperCode,_iterator8,_step8,_type2,code,_i2,_Object$entries,_Object$entries$_i,modelName,model,_i3,_Object$entries2,_Object$entries2$_i,_name,specification,_iterator9,_step9,constraint,_iterator10,_step10,_type,_constraint,migrators,_iterator11,_step11,file,extension,_name2,documents,_iterator12,_step12,document,_forbidden,_iterator13,_step13,retrievedDocument,_document,newDocument,_iterator14,_step14,_name3,result,genericIndexes,_i4,_Object$entries3,_Object$entries3$_i,_modelName,_model,_iterator15,_step15,propertyName,_name4,foundPosition,position,_iterator16,_step16,index,_iterator17,_step17,_index,exists,_i5,_Object$entries4,_Object$entries4$_i,_modelName2,_model2,_iterator18,_step18,_name5;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:if(configuration=_ref4.configuration,services=_ref4.services,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch){_context3.next=3;break}throw new Error("Missing fetch implementation.");case 3:if(promise=null,couchdb=services.couchdb,!Object.prototype.hasOwnProperty.call(couchdb.server,"runner")){_context3.next=12;break}return _context3.next=8,(0,_server__WEBPACK_IMPORTED_MODULE_8__.ni)(services,configuration);case 8:couchdb.server.restart=_server__WEBPACK_IMPORTED_MODULE_8__.S8,couchdb.server.start=_server__WEBPACK_IMPORTED_MODULE_8__.ni,couchdb.server.stop=_server__WEBPACK_IMPORTED_MODULE_8__.ds,promise=new Promise((function(e,t){couchdb.server.resolve=e,couchdb.server.reject=t}));case 12:if(!Object.prototype.hasOwnProperty.call(couchdb,"connection")){_context3.next=14;break}return _context3.abrupt("return",{couchdb:promise});case 14:if(urlPrefix=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.format)(configuration.couchdb.url,configuration.couchdb.user.name+":"+configuration.couchdb.user.password+"@"),!configuration.couchdb.ensureAdminPresence){_context3.next=46;break}return unauthenticatedUserDatabaseConnection=new couchdb.connector((0,clientnode__WEBPACK_IMPORTED_MODULE_3__.format)(configuration.couchdb.url,"")+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=17,_context3.next=20,unauthenticatedUserDatabaseConnection.allDocs();case 20:return console.info('No admin user available. Automatically creating admin user" '+configuration.couchdb.user.name+'".'),_context3.next=23,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch((0,clientnode__WEBPACK_IMPORTED_MODULE_3__.format)(configuration.couchdb.url,"")+"/"+couchdb.server.runner.adminUserConfigurationPath+"/"+configuration.couchdb.user.name,{body:'"'+configuration.couchdb.user.password+'"',method:"PUT"});case 23:_context3.next=43;break;case 25:if(_context3.prev=25,_context3.t0=_context3.catch(17),"unauthorized"!==_context3.t0.name){_context3.next=42;break}return authenticatedUserDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=29,_context3.next=32,authenticatedUserDatabaseConnection.allDocs();case 32:_context3.next=37;break;case 34:_context3.prev=34,_context3.t1=_context3.catch(29),console.error("Can't login as existing admin user \""+configuration.couchdb.user.name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t1));case 37:return _context3.prev=37,authenticatedUserDatabaseConnection.close(),_context3.finish(37);case 40:_context3.next=43;break;case 42:console.error("Can't create new admin user \""+configuration.couchdb.user.name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t0));case 43:return _context3.prev=43,unauthenticatedUserDatabaseConnection.close(),_context3.finish(43);case 46:if(!configuration.couchdb.ensureUserPresence){_context3.next=81;break}_i=0,_arr=[configuration.couchdb.security.admins,configuration.couchdb.security.members];case 48:if(!(_i<_arr.length)){_context3.next=81;break}type=_arr[_i],_iterator6=_createForOfIteratorHelperLoose(type.names);case 51:if((_step6=_iterator6()).done){_context3.next=78;break}return name=_step6.value,userDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=54,_context3.next=57,userDatabaseConnection.get("org.couchdb.user:"+name);case 57:_context3.next=73;break;case 59:if(_context3.prev=59,_context3.t2=_context3.catch(54),"not_found"!==_context3.t2.error){_context3.next=72;break}return _context3.prev=62,_context3.next=65,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 65:_context3.next=70;break;case 67:throw _context3.prev=67,_context3.t3=_context3.catch(62),new Error("Couldn't create missing user \""+name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t3));case 70:_context3.next=73;break;case 72:throw new Error("Couldn't check for presence of user \""+name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t2));case 73:return _context3.prev=73,userDatabaseConnection.close(),_context3.finish(73);case 76:_context3.next=51;break;case 78:_i++,_context3.next=48;break;case 81:if(!configuration.couchdb.model.updateConfiguration){_context3.next=136;break}_iterator7=_createForOfIteratorHelperLoose(configuration.couchdb.backend.prefixes);case 83:if((_step7=_iterator7()).done){_context3.next=136;break}prefix=_step7.value,_context3.t4=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().keys(configuration.couchdb.backend.configuration);case 86:if((_context3.t5=_context3.t4()).done){_context3.next=134;break}if(subPath=_context3.t5.value,!Object.prototype.hasOwnProperty.call(configuration.couchdb.backend.configuration,subPath)){_context3.next=132;break}return fullPath="/"+prefix+(prefix.trim()?"/":"")+subPath,url=""+urlPrefix+fullPath,value=configuration.couchdb.backend.configuration[subPath],response=void 0,_context3.prev=93,_context3.next=96,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url);case 96:response=_context3.sent,_context3.next=102;break;case 99:_context3.prev=99,_context3.t6=_context3.catch(93),console.warn('Configuration "'+fullPath+'" (with desired value ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]) couldn't be determined: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t6));case 102:if(!response){_context3.next=132;break}if(!response.ok){_context3.next=131;break}if(changeNeeded=!0,"function"!=typeof response.text){_context3.next=117;break}return _context3.prev=106,_context3.t7=value,_context3.next=110,response["string"==typeof value?"text":"json"]();case 110:_context3.t8=_context3.sent,changeNeeded=_context3.t7===_context3.t8,_context3.next=117;break;case 114:_context3.prev=114,_context3.t9=_context3.catch(106),console.warn('Error checking curent value of "'+fullPath+'" to be ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t9));case 117:if(!changeNeeded){_context3.next=128;break}return _context3.prev=118,_context3.next=121,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url,{body:'"'+configuration.couchdb.backend.configuration[subPath]+'"',method:"PUT"});case 121:_context3.next=126;break;case 123:_context3.prev=123,_context3.t10=_context3.catch(118),console.error('Configuration "'+fullPath+"\" couldn't be applied to ["+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t10));case 126:_context3.next=129;break;case 128:console.info('Configuration "'+fullPath+'" is already set to desired value ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"].");case 129:_context3.next=132;break;case 131:console.info('Configuration "'+fullPath+'" does not exist (desired value ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]). Response code is "+response.status+".");case 132:_context3.next=86;break;case 134:_context3.next=83;break;case 136:return _context3.next=138,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.initializeConnection)(services,configuration);case 138:if(!configuration.couchdb.ensureSecuritySettingsPresence){_context3.next=147;break}return _context3.prev=139,_context3.next=142,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(urlPrefix+"/"+configuration.couchdb.databaseName+"/_security",{body:JSON.stringify(configuration.couchdb.security),method:"PUT"});case 142:_context3.next=147;break;case 144:_context3.prev=144,_context3.t11=_context3.catch(139),console.error("Security object couldn't be applied: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t11));case 147:if(modelConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(configuration.couchdb.model),delete modelConfiguration.property.defaultSpecification,delete modelConfiguration.entities,specialNames=modelConfiguration.property.name.special,idName=specialNames.id,revisionName=specialNames.revision,typeName=specialNames.type,models=(0,_helper__WEBPACK_IMPORTED_MODULE_9__.extendModels)(configuration.couchdb.model),!configuration.couchdb.model.updateValidation){_context3.next=216;break}return _context3.next=156,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(eval("require.resolve('./databaseHelper')"),{encoding:configuration.core.encoding,flag:"r"});case 156:databaseHelperCode=_context3.sent,_iterator8=_createForOfIteratorHelperLoose([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(modelConfiguration)+", "+JSON.stringify(models)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineAllowedModelRolesMapping)(configuration.couchdb.model))+", '"+idName+"', '"+typeName+"', '"+specialNames.designDocumentNamePrefix+"'"}]);case 158:if((_step8=_iterator8()).done){_context3.next=173;break}_type2=_step8.value,code="function(...parameters) {\n return require('helper')."+_type2.methodName+"(...parameters.concat(["+_type2.serializedParameter+"]))\n}",_context3.prev=161,new Function("return "+code),_context3.next=168;break;case 165:throw _context3.prev=165,_context3.t12=_context3.catch(161),new Error("Generated "+_type2.name+' code "'+code+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t12));case 168:return configuration.core.debug&&console.debug(_type2.name+' code: \n\n"'+code+'" integrated.'),_context3.next=171,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.ensureValidationDocumentPresence)(couchdb.connection,_type2.name,{helper:databaseHelperCode,validate_doc_update:code},_type2.description,!0,idName,revisionName,specialNames.designDocumentNamePrefix);case 171:_context3.next=158;break;case 173:_i2=0,_Object$entries=Object.entries(models);case 174:if(!(_i2<_Object$entries.length)){_context3.next=216;break}_Object$entries$_i=_Object$entries[_i2],modelName=_Object$entries$_i[0],model=_Object$entries$_i[1],_i3=0,_Object$entries2=Object.entries(model);case 177:if(!(_i3<_Object$entries2.length)){_context3.next=213;break}if(_Object$entries2$_i=_Object$entries2[_i3],_name=_Object$entries2$_i[0],specification=_Object$entries2$_i[1],![specialNames.constraint.execution,specialNames.constraint.expression].includes(_name)){_context3.next=195;break}_iterator9=_createForOfIteratorHelperLoose([].concat(specification));case 181:if((_step9=_iterator9()).done){_context3.next=193;break}if(constraint=_step9.value,!constraint.description){_context3.next=191;break}_context3.prev=184,new Function("return "+constraint.description),_context3.next=191;break;case 188:throw _context3.prev=188,_context3.t13=_context3.catch(184),new Error('Specified constraint description "'+constraint.description+'" for model "'+modelName+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t13));case 191:_context3.next=181;break;case 193:_context3.next=210;break;case 195:_iterator10=_createForOfIteratorHelperLoose(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 196:if((_step10=_iterator10()).done){_context3.next=210;break}if(_type=_step10.value,!(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isObject)(specification)){_context3.next=208;break}if(_constraint=specification[_type],null==_constraint||!_constraint.description){_context3.next=208;break}_context3.prev=201,new Function(_constraint.description),_context3.next=208;break;case 205:throw _context3.prev=205,_context3.t14=_context3.catch(201),new Error('Specified constraint description "'+_constraint.description+'" for model "'+modelName+'" in property "'+_name+'" as "'+_type+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t14));case 208:_context3.next=196;break;case 210:_i3++,_context3.next=177;break;case 213:_i2++,_context3.next=174;break;case 216:if(!configuration.couchdb.model.autoMigrationPath){_context3.next=321;break}return migrators={},_context3.next=220,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isDirectory)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath));case 220:if(!_context3.sent){_context3.next=273;break}return _context3.t15=_createForOfIteratorHelperLoose,_context3.next=224,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.walkDirectoryRecursively)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_3__.NOOP:function(e){return!["debug","deprecated"].includes(e.name)});case 224:_context3.t16=_context3.sent,_iterator11=(0,_context3.t15)(_context3.t16);case 226:if((_step11=_iterator11()).done){_context3.next=273;break}if(file=_step11.value,extension=(0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name),_name2=(0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(file.name,extension),".json"!==extension){_context3.next=263;break}return documents=void 0,_context3.prev=232,_context3.t17=[],_context3.t18=JSON,_context3.next=237,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(file.path,{encoding:configuration.core.encoding,flag:"r"});case 237:_context3.t19=_context3.sent,_context3.t20=_context3.t18.parse.call(_context3.t18,_context3.t19),documents=_context3.t17.concat.call(_context3.t17,_context3.t20),_context3.next=245;break;case 242:throw _context3.prev=242,_context3.t21=_context3.catch(232),new Error('Parsing document "'+file.path+'" to include by automigration of has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t21));case 245:1===documents.length&&(!documents[0][idName]&&(documents[0][idName]=_name2),!documents[0][revisionName]&&(documents[0][revisionName]="0-upsert")),_iterator12=_createForOfIteratorHelperLoose(documents);case 247:if((_step12=_iterator12()).done){_context3.next=261;break}return document=_step12.value,_context3.prev=249,_context3.next=252,couchdb.connection.put(document);case 252:_context3.next=258;break;case 254:throw _context3.prev=254,_context3.t22=_context3.catch(249),null!=(_forbidden=_context3.t22.forbidden)&&_forbidden.startsWith("NoChange:")&&console.info('Including document "'+document[idName]+'" of type "'+document[typeName]+"\" hasn't changed existing document."),new Error('Migrating document "'+document[idName]+'" of type "'+document[typeName]+'" has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t22));case 258:console.info('Including document "'+document[idName]+'" of type "'+document[typeName]+'" was successful.');case 259:_context3.next=247;break;case 261:_context3.next=271;break;case 263:if(![".js"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=267;break}migrators[file.path]=eval("require('"+file.path+"')").default,_context3.next=271;break;case 267:if(![".mjs"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=271;break}return _context3.next=270,eval("import('"+file.path+"')");case 270:migrators[file.path]=_context3.sent.default;case 271:_context3.next=226;break;case 273:return _context3.t23=_createForOfIteratorHelperLoose,_context3.next=276,couchdb.connection.allDocs({include_docs:!0});case 276:_context3.t24=_context3.sent.rows,_iterator13=(0,_context3.t23)(_context3.t24);case 278:if((_step13=_iterator13()).done){_context3.next=321;break}if(retrievedDocument=_step13.value,"string"==typeof retrievedDocument.id&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context3.next=319;break}_document=retrievedDocument.doc,newDocument=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(_document),newDocument[configuration.couchdb.model.property.name.special.strategy]="migrate",_iterator14=_createForOfIteratorHelperLoose(Object.keys(migrators).sort());case 285:if((_step14=_iterator14()).done){_context3.next=298;break}_name3=_step14.value,result=null,_context3.prev=288,result=migrators[_name3](newDocument,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},clientnode__WEBPACK_IMPORTED_MODULE_3__.UTILITY_SCOPE,{configuration,databaseHelper:_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default(),idName,typeName,migrators,models,modelConfiguration,selfFilePath:_name3,services})),_context3.next=295;break;case 292:throw _context3.prev=292,_context3.t25=_context3.catch(288),new Error('Running migrater "'+_name3+'" in document '+(0,_helper__WEBPACK_IMPORTED_MODULE_9__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+'" failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t25));case 295:result&&(newDocument=result,console.info('Running migrater "'+_name3+'" for document "'+newDocument[idName]+'" (of type "'+newDocument[typeName]+'") was successful.'));case 296:_context3.next=285;break;case 298:_context3.prev=298,(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.validateDocumentUpdate)((0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(newDocument),(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(_document),{db:configuration.couchdb.databaseName,name:configuration.couchdb.user.name,roles:["_admin"]},(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(configuration.couchdb.security),modelConfiguration,models),_context3.next=310;break;case 302:if(_context3.prev=302,_context3.t26=_context3.catch(298),!Object.prototype.hasOwnProperty.call(_context3.t26,"forbidden")){_context3.next=309;break}return _context3.t26.forbidden.startsWith("NoChange:")||console.warn('Document "'+(0,_helper__WEBPACK_IMPORTED_MODULE_9__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+"\" doesn't satisfy its schema (and can not be migrated automatically): "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t26)),_context3.abrupt("continue",319);case 309:throw _context3.t26;case 310:return _context3.prev=310,_context3.next=313,couchdb.connection.put(newDocument);case 313:_context3.next=318;break;case 315:throw _context3.prev=315,_context3.t27=_context3.catch(310),new Error('Replacing auto migrated document "'+newDocument[idName]+'" has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t27));case 318:console.info('Auto migrating document "'+newDocument[idName]+'" was successful.');case 319:_context3.next=278;break;case 321:return _context3.next=323,couchdb.connection.getIndexes();case 323:if(genericIndexes=_context3.sent.indexes.filter((function(e){return e.name.endsWith("-GenericIndex")})),!configuration.couchdb.createGenericFlatIndex||!configuration.couchdb.model.autoMigrationPath&&0!==genericIndexes.length){_context3.next=375;break}_i4=0,_Object$entries3=Object.entries(models);case 326:if(!(_i4<_Object$entries3.length)){_context3.next=357;break}if(_Object$entries3$_i=_Object$entries3[_i4],_modelName=_Object$entries3$_i[0],_model=_Object$entries3$_i[1],!new RegExp(configuration.couchdb.model.property.name.typePattern.public).test(_modelName)){_context3.next=354;break}return _context3.next=331,couchdb.connection.createIndex({index:{ddoc:_modelName+"-GenericIndex",fields:[typeName],name:_modelName+"-GenericIndex"}});case 331:_iterator15=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model));case 332:if((_step15=_iterator15()).done){_context3.next=354;break}propertyName=_step15.value,_name4=_modelName+"-"+propertyName+"-GenericIndex",foundPosition=-1,position=0,_iterator16=_createForOfIteratorHelperLoose(genericIndexes);case 338:if((_step16=_iterator16()).done){_context3.next=346;break}if(index=_step16.value,index.name!==_name4){_context3.next=343;break}return foundPosition=position,_context3.abrupt("break",346);case 343:position+=1;case 344:_context3.next=338;break;case 346:if(-1!==foundPosition){_context3.next=351;break}return _context3.next=349,couchdb.connection.createIndex({index:{ddoc:_name4,fields:[typeName,propertyName],name:_name4}});case 349:_context3.next=352;break;case 351:genericIndexes.slice(position,1);case 352:_context3.next=332;break;case 354:_i4++,_context3.next=326;break;case 357:_iterator17=_createForOfIteratorHelperLoose(genericIndexes);case 358:if((_step17=_iterator17()).done){_context3.next=375;break}_index=_step17.value,exists=!1,_i5=0,_Object$entries4=Object.entries(models);case 362:if(!(_i5<_Object$entries4.length)){_context3.next=370;break}if(_Object$entries4$_i=_Object$entries4[_i5],_modelName2=_Object$entries4$_i[0],_model2=_Object$entries4$_i[1],!_index.name.startsWith(_modelName2+"-")){_context3.next=367;break}for(_iterator18=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model2));!(_step18=_iterator18()).done;)_name5=_step18.value,[_modelName2+"-"+_name5+"-GenericIndex",_modelName2+"-GenericIndex"].includes(_index.name)&&(exists=!0);return _context3.abrupt("break",370);case 367:_i5++,_context3.next=362;break;case 370:if(exists){_context3.next=373;break}return _context3.next=373,couchdb.connection.deleteIndex(_index);case 373:_context3.next=358;break;case 375:if(!configuration.couchdb.model.triggerInitialCompaction){_context3.next=384;break}return _context3.prev=376,_context3.next=379,couchdb.connection.compact();case 379:_context3.next=384;break;case 381:_context3.prev=381,_context3.t28=_context3.catch(376),console.warn("Initial database compaction has failed: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t28));case 384:return _context3.abrupt("return",{couchdb:promise});case 385:case"end":return _context3.stop()}}),_callee3,null,[[17,25,43,46],[29,34,37,40],[54,59,73,76],[62,67],[93,99],[106,114],[118,123],[139,144],[161,165],[184,188],[201,205],[232,242],[249,254],[288,292],[298,302],[310,315],[376,381]])})));return function(){return _ref5.apply(this,arguments)}}(),postLoadService=function(e){var t=e.configuration.couchdb,n=e.pluginAPI,r=e.services.couchdb,o=0;setInterval((function(){0<o&&(console.info("No additional errors (initially got "+o+" errors through) occurred during observing changes stream for 30 seconds. Clearing saved number of errors through."),o=0)}),3e4);var a=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.debounce)(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function c(){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(c){for(;;)switch(c.prev=c.next){case 0:return r.changesStream&&r.changesStream.cancel(),console.info("Initialize changes stream."),r.changesStream=r.connection.changes(t.changesStream),r.changesStream.on("error",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function t(n){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(3<(o+=1))){t.next=9;break}return console.warn("Observing changes feed throws an error for "+o+" times through: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(n)+" Restarting database server and reinitialize changes stream..."),o=0,r.changesStream.cancel(),t.next=7,r.server.restart(e);case 7:t.next=10;break;case 9:console.warn("Observing changes feed throws an error for "+o+" times through: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(n)+" Reinitializing changes stream...");case 10:a();case 11:case"end":return t.stop()}}),t)})))),c.next=6,n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,{data:r.changesStream,hook:"couchdbInitializeChangesStream"}));case 6:console.info("Changes stream initialized."),r.changesStream.on("change",(function(t){return n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,{data:t,hook:"couchdbChange"}))}));case 8:case"end":return c.stop()}}),c)}))));return t.attachAutoRestarter&&a(),Promise.resolve()},shouldExit=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,r,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.configuration,r=t.services,e.next=3,(0,_server__WEBPACK_IMPORTED_MODULE_8__.ds)(r,n);case 3:return delete r.couchdb,o="log.txt",e.next=7,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isFile)(o);case 7:if(!e.sent){e.next=10;break}return e.next=10,fs__WEBPACK_IMPORTED_MODULE_4__.promises.unlink(o);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),database=module.exports;const __WEBPACK_DEFAULT_EXPORT__=database},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},e=>{!function(){"use strict";function t(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={id:e,loaded:!1,exports:{}};return n[e](a,a.exports,t),a.loaded=!0,a.exports}var n=[function(e,t,n){function r(e,t,n){if(a())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var c=new(e.bind.apply(e,r));return n&&o(c,n.prototype),c}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(a=function(){return!!e})()}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t,n=1;n<arguments.length;n++)for(var r in t=arguments[n])({}).hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},c.apply(null,arguments)}function _(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 i(e,t);var n={}.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)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}n.r(t),n.d(t,{authenticate:function(){return s},databaseHelper:function(){return u},default:function(){return p},validateDocumentUpdate:function(){return l}}),e=n.hmd(e);var s=function(e,t,n,r,o,a,c,i,s){var l,u,p;void 0===t&&(t=null),void 0===n&&(n={}),void 0===r&&(r={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===a&&(a="_id"),void 0===c&&(c="-type"),void 0===i&&(i="_design/"),void 0===s&&(s=!1);var d=null!==(l=e[c])&&void 0!==l?l:t&&t[c];if(!d)return!0;var m=s?"read":"write",f={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,a)&&e[a].startsWith(i)&&f.read.push("readonlymember");var b="Current user doesn't own any role";if("name"in n||(n.name='"unknown"'),null!=(u=n.roles)&&u.length){var h;if(o&&d&&Object.prototype.hasOwnProperty.call(o,d)){for(var y,O,x=o[d],g=_(["read","write"]);!(y=g()).done;)f[O=y.value]=f[O].concat(x[O]||[]);f.properties=x.properties}for(var v,E,P=f[m],D=_(n.roles);!(v=D()).done;)if(E=v.value,P.includes(E))return!0;b='Current user "'+(null!==(h=n.name)&&void 0!==h?h:"unknown")+'" owns the following roles: "'+n.roles.join('", "')+'"'}else b='Current user "'+(null!==(p=n.name)&&void 0!==p?p:"unknown")+"\" doesn't own anyrole";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+m+' action: "'+[].concat(f[m]).join('", "')+'". '+b+"."}},l=function(e,t,n,o,a,i,s){void 0===i&&(i={});var l=function(e,t,n){var r;throw void 0===t&&(t="forbidden"),void 0===n&&(n={}),c(((r={})[t]=e,r.message=e,r.name=t,r),n)},u=new Date,p=Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate(),u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds())/1e3,d=!a.dateTimeFormat.startsWith("iso"),m=a.property.name.special,f=m.id,b=m.revision,h=m.type;t&&t[h]&&!e[h]&&(e[h]=t[h]);var y="",O="",x=function(){y=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",O=Object.prototype.hasOwnProperty.call(e,b)?e[b]:""};if(x(),Object.prototype.hasOwnProperty.call(o,a.property.name.validatedDocumentsCache)&&o[a.property.name.validatedDocumentsCache].has(y+"-"+O))return o[a.property.name.validatedDocumentsCache].delete(y+"-"+O),e;["0-latest","0-upsert"].includes(O)&&(t&&Object.prototype.hasOwnProperty.call(t,b)?O=e[b]=t[b]:"0-latest"===O?l("Revision: No old document available to update."):delete e[b]);var g=a.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(g=e[m.strategy],delete e[m.strategy]);var v,E={};if("migrate"===g)for(var P=0,D=Object.entries(i);P<D.length;P++){var M=D[P],w=M[0],k=M[1];if(Object.prototype.hasOwnProperty.call(k,m.oldType)&&k[m.oldType])for(var C,T,A=_([].concat(k[m.oldType]));!(C=A()).done;)T=C.value,E[T]=w}s?v=s:"undefined"!=typeof JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?v=function(e){return JSON.stringify(e,null,4)}:l('Needed "serializer" is not available.');var I=[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],j=function(e){return e instanceof Error?e+"":v(e)},L=function(e){return"string"==typeof e?e.trim():""},R=function(e){if(d)null!==e&&"number"!=typeof e&&(e=new Date(e),e=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())/1e3);else if(null!==e){e=new Date("number"!=typeof e||isNaN(e)?e:1e3*e);try{e=e.toISOString()}catch(e){}}return e},U=function(e,t,n){if(n.fileName){if(n.fileName.value)return n.fileName.value===t;if(n.fileName.pattern)return[].concat(n.fileName.pattern).some((function(e){return new RegExp(e).test(t)}))}return e===t},W=function(t,n){if(n||(n=e[m.attachment]),t){for(var r,o=0,a=Object.keys(n);o<a.length;o++)if((r=a[o]).startsWith(t))return r}else{var c=Object.keys(n);if(c.length)return c[0]}return null},B=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var o=c({},N,{code:""},n),a=L(e);if(a){var _=(t?"return ":"")+a;o.code=_;var i,s=Object.keys(o);try{i=r(Function,s.concat([_]))}catch(e){l(j(e),"compilation",{code:_,error:e,scope:o})}var u={code:_,result:void 0,scope:o};try{u.result=i.apply(void 0,s.map((function(e){return o[e]})))}catch(e){l(j(e),"runtime",{code:_,error:e,scope:o})}return u}return l("No expression to evaluate provided.","empty"),{code:o.code,result:void 0,scope:o}},K=function(e,t,n,o){void 0===n&&(n=[]),void 0===o&&(o=!1);var c=n.length?" in "+n.join(" -> "):"",s=[],u=function(){Object.prototype.hasOwnProperty.call(e,h)||(t&&Object.prototype.hasOwnProperty.call(t,h)&&["fillUp","migrate"].includes(g)?e[h]=t[h]:l('Type: You have to specify a model type via property "'+h+'"'+c+".")),n.length||new RegExp(a.property.name.typePattern.public).test(e[h])||l('TypeName: You have to specify a model type which matches "'+a.property.name.typePattern.public+'" as public type (given "'+e[h]+'")'+c+"."),Object.prototype.hasOwnProperty.call(i,e[h])||(Object.prototype.hasOwnProperty.call(E,e[h])?e[h]=E[e[h]]:l('Model: Given model "'+e[h]+'" is not specified'+c+"."))};u();var p,y=e[h],O=i[y];Object.prototype.hasOwnProperty.call(O,m.additional)&&O[m.additional]&&(p=O[m.additional]);var v=function(o,a,i,s,u){void 0===u&&(u=["constraintExecution","constraintExpression"]);for(var p,d,m=_(u);!(p=m()).done;)if(d=p.value,Object.prototype.hasOwnProperty.call(i,d)){var f=void 0;try{f=B(i[d].evaluation,d.endsWith("Expression"),{checkPropertyContent:P,model:O,modelName:y,name:a,type:d,newDocument:e,newValue:o,oldDocument:t,oldValue:s,parentNames:n,pathDescription:c,propertySpecification:i})}catch(i){var b,h;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&l('Compilation: Hook "'+d+'" has invalid code "'+i.code+'": "'+(null!==(b=i.message)&&void 0!==b?b:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&l('Runtime: Hook "'+d+'" has throw an error with code "'+i.code+'": "'+(null!==(h=i.message)&&void 0!==h?h:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}if(f&&!f.result){var x,g=L(null==(x=i[d])?void 0:x.description);l(d.charAt(0).toUpperCase()+(d.substring(1)+": ")+(g?r(Function,Object.keys(f.scope).concat(["return "+g])).apply(void 0,Object.values(f.scope)):'Property "'+a+'" should satisfy constraint "'+f.code+'" (given "'+j(o)+'")'+c+"."))}}},P=function(e,t,r,o,a){void 0===a&&(a=!1);var s=[],u=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,h)&&1===u.length&&"string"==typeof u[0]&&Object.prototype.hasOwnProperty.call(i,u[0])&&(e[h]=u[0]);for(var p,m,b=!1,y=_(u);!(p=y()).done;)if("string"==typeof(m=p.value)&&Object.prototype.hasOwnProperty.call(i,m)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]!==m&&"migrate"===g&&1===u.length&&(e[h]=m,s=n.concat(t+"","migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]===m){var O=K(e,o,n.concat(t+""),a||r.computed);if(O.changedPath.length&&(s=O.changedPath),e=O.newDocument,j(e)===j({}))return{newValue:void 0,changedPath:s};b=!0;break}1===u.length&&l('NestedType: Under key "'+t+'" isn\'t of type "'+m+'" (given "'+j(e)+'" of type '+typeof e+")"+c+".")}else if("DateTime"===m){var x=e;if(e=R(e),!(d&&("number"!=typeof e||isNaN(e))||!d&&"string"!=typeof e)){b=!0;break}1===u.length&&l('PropertyType: Property "'+t+'" isn\'t of (valid) type "DateTime" (given"'+j(x).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof x+'")'+c+".")}else if("string"==typeof m&&["boolean","integer","number","string"].includes(m)){if(!("number"==typeof e&&isNaN(e)||"integer"!==m&&typeof e!==m||"integer"===m&&parseInt(e,10)!==e)){b=!0;break}1===u.length&&l('PropertyType: Property "'+t+'" isn\'t of (valid) type "'+m+'" (given "'+j(e)+'" of type "'+typeof e+'")'+c+".")}else if("string"==typeof m&&m.startsWith("foreignKey:")){var E=i[m.substring(11)][f].type;if(E===typeof e){b=!0;break}1===u.length&&l('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+E+'" (given "'+j(e)+'" of type "'+typeof e+'")'+c+".")}else{if("any"===m||j(e)===j(m)){b=!0;break}1===u.length&&l('PropertyType: Property "'+t+'" isn\'t value "'+m+'" (given "'+j(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+c+".")}if(b||l('PropertyType: None of the specified types "'+u.join('", "')+'" for property "'+t+'" matches value "'+j(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'"'+c+"."),"string"==typeof e&&("number"==typeof r.minimumLength&&e.length<r.minimumLength&&l('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length "+e.length+")"+c+"."),"number"==typeof r.maximumLength&&e.length>r.maximumLength&&l('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+c+".")),"number"==typeof e&&("number"==typeof r.minimum&&e<r.minimum&&l('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+c+"."),"number"==typeof r.maximum&&e>r.maximum&&l('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+c+".")),r.selection){var P=Array.isArray(r.selection)?r.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(r.selection);"DateTime"===r.type&&(P=P.map(R)),P.includes(e)||l('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+P.join('", "')+'". But is "'+e+'"'+c+".")}if(r.pattern){for(var D,M,w=[].concat(r.pattern),k=!1,C=_(w);!(D=C()).done;)if(M=D.value,new RegExp(M).test(e)){k=!0;break}k||l('PatternMatch: Property "'+t+'" should match regular expression pattern "'+w.join('", "')+'" (given "'+e+'")'+c+".")}if(r.invertedPattern)for(var T,A,I=_([].concat(r.invertedPattern));!(T=I()).done;)A=T.value,new RegExp(A).test(e)&&l('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+A+' (given "'+e+'")'+c+".");return v(e,t,r,o),j(e)!==j(o)&&(s=n.concat(t+"","value updated")),{newValue:e,changedPath:s}},D=function(e,t,r,o,c){var _=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&j(_)===j(r[o]))return o!==f&&"incremental"===g&&delete t[o],!0;l("Readonly: Property "+o+'" isnot writable (old document "'+j(r)+'")'+c+".")}else l('Readonly: Property "'+o+'" is not writable'+c+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(j(_)===j(r[o]))return"incremental"!==g||a.property.name.reserved.concat(m.deleted,f,b).includes(o+"")||delete t[o],!0;"migrate"!==g&&l('Immutable: Property "'+o+'"is not writable (old document "'+j(r)+'")'+c+".")}if(null===_){if(e.nullable)return"incremental"===g&&r&&void 0!==r[o]||delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(s=n.concat(o+"","delete property")),!0;l('NotNull: Property "'+o+'" should not be "null"'+c+".")}return!1},M=function(e,t,r,o,a){if(!r)for(var i,s,u=_(["onCreateExecution","onCreateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s)){var p=void 0;try{p=B(e[s],s.endsWith("Expression"),{attachmentsTarget:a,checkPropertyContent:P,model:O,modelName:y,name:o+"",type:s,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:c,propertySpecification:e})}catch(i){var d,m;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&l('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+o+'": "'+(null!==(d=i.message)&&void 0!==d?d:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+o+'": "'+(null!==(m=i.message)&&void 0!==m?m:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}p&&![null,void 0].includes(p.result)&&(a?a[o]=p.result:t[o]=p.result)}},w=function(e,t,r,o,a){if(!a){if(!Object.prototype.hasOwnProperty.call(t,o))return;e.trim&&"string"==typeof t[o]&&(t[o]=t[o].trim()),e.emptyEqualsNull&&(""===t[o]||Array.isArray(t[o])&&0===t[o].length||null!==t[o]&&"object"==typeof t[o]&&0===Object.keys(t).length)&&(t[o]=null)}for(var i,s,u=_(["onUpdateExecution","onUpdateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s))try{var p=B(e[s],s.endsWith("Expression"),{attachmentsTarget:a,checkPropertyContent:P,model:O,modelName:y,name:o+"",type:s,newDocument:t,oldDocument:r,newValue:t[o],oldValue:r&&r[o]||void 0,parentNames:n,pathDescription:c,propertySpecification:e});a?a[o]=p.result:void 0!==p.result&&(t[o]=p.result)}catch(i){var d,m;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&l('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+o+'": "'+(null!==(d=i.message)&&void 0!==d?d:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+o+'": "'+(null!==(m=i.message)&&void 0!==m?m:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}},k=Object.keys(O).filter((function(e){return!I.includes(e)}));if("migrate"===g)for(var C,T,A=_(k);!(C=A()).done;)if(T=C.value,O[T].oldName)for(var W,N,S=_([].concat(O[T].oldName));!(W=S()).done;)N=W.value,Object.prototype.hasOwnProperty.call(e,N)&&(e[T]=e[N],delete e[N]);if(!t)for(var q,$=0,z=[m.create.execution,m.create.expression];$<z.length;$++)if(q=z[$],Object.prototype.hasOwnProperty.call(O,q)){var F=void 0;try{F=B(O[q],q.endsWith("Expression"),{checkPropertyContent:P,model:O,modelName:y,type:q,newDocument:e,oldDocument:t,parentNames:n,pathDescription:c}).result}catch(o){var H,G;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(o)&&l('Compilation: Hook "'+q+'" has invalid code "'+o.code+'" for document "'+y+'": "'+(null!==(H=o.message)&&void 0!==H?H:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(o)&&l('Runtime: Hook "'+q+'" has throw an error with code "'+o.code+'" for document "'+y+'": "'+(null!==(G=o.message)&&void 0!==G?G:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(o,"empty"))throw o}[null,void 0].includes(F)||(e=F),u(),y=e[h],0===n.length&&x()}for(var V,J=0,Y=[m.update.execution,m.update.expression];J<Y.length;J++)if(V=Y[J],Object.prototype.hasOwnProperty.call(O,V)){var X=void 0;try{X=B(O[V],V.endsWith("Expression"),{checkPropertyContent:P,model:O,modelName:y,type:V,newDocument:e,oldDocument:t,parentNames:n,pathDescription:c}).result}catch(o){var Z,Q;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(o)&&l('Compilation: Hook "'+V+'" has invalid code "'+o.code+'" for document "'+y+'": "'+(null!==(Z=o.message)&&void 0!==Z?Z:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(o)&&l('Runtime: Hook "'+V+'" has throw an error with code "'+o.code+'" for document "'+y+'": "'+(null!==(Q=o.message)&&void 0!==Q?Q:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(o,"empty"))throw o}[void 0,null].includes(X)||(e=X),u(),y=e[h],0===n.length&&x()}for(var ee,te,ne=p?Object.keys(e).filter((function(e){return!k.includes(e)})):[],re=_(k.concat(ne));!(ee=re()).done;)if(te=ee.value,m.attachment===te)for(var oe=function(){var r=ce[ae],o=r[0],a=r[1];e[m.attachment]||(e[m.attachment]={}),t&&!Object.prototype.hasOwnProperty.call(t,te)&&(t[m.attachment]={});var i=e[m.attachment],u=Object.keys(i).filter((function(e){return null!==i[e].data&&U(o,e,a)})),p=[];if(t){var d=t[te];p=Object.keys(d).filter((function(e){return!(Object.prototype.hasOwnProperty.call(i,e)&&Object.prototype.hasOwnProperty.call(i[e],"data")&&null===i[e].data)&&!!d[e]&&(Object.prototype.hasOwnProperty.call(d[e],"data")&&null!==d[e].data||Object.prototype.hasOwnProperty.call(d[e],"stub")&&!!d[e].digest)&&!!U(o,e,a)}))}for(var f,b,h=a,y=_(u);!(f=y()).done;)b=f.value,M(h,e,t&&t[te]?t[te]:null,b,i);for(var O,x,v=_(u);!(O=v()).done;)x=O.value,w(h,e,t&&t[te]?t[te]:null,x,i);if(void 0===h.default){if(h.nullable||0<u.length||0<p.length||l('AttachmentMissing: Missing attachment for type "'+o+'"'+c+"."),"fillUp"===g&&0===u.length&&0<p.length)for(var E,P,D=_(p);!(E=D()).done;)P=E.value,null===i[P]?s=n.concat(te,P,"file removed"):i[P]=t[te][P]}else if(0===u.length)if(0===p.length)for(var k in h.default)Object.prototype.hasOwnProperty.call(h.default,k)&&(i[k]=h.default[k],s=n.concat(te,o,"add default file"));else if("fillUp"===g)for(var C,T,A=_(p);!(C=A()).done;)T=C.value,i[T]=t[te][T]},ae=0,ce=Object.entries(O[m.attachment]);ae<ce.length;ae++)oe();else{var _e=k.includes(te)?O[te]:p;M(_e,e,t,te),w(_e,e,t,te),[null,void 0].includes(_e.default)?(!(_e.nullable||Object.prototype.hasOwnProperty.call(e,te)&&void 0!==e[te]||t&&Object.prototype.hasOwnProperty.call(t,te)&&"replace"!==g)&&l('MissingProperty: Missing property "'+te+'"'+c+"."),!o&&!_e.computed&&(!Object.prototype.hasOwnProperty.call(e,te)||void 0===e[te])&&t&&Object.prototype.hasOwnProperty.call(t,te)&&("fillUp"===g?e[te]=t[te]:"replace"===g&&(s=n.concat(te+"","property removed")))):(!Object.prototype.hasOwnProperty.call(e,te)||[null,void 0].includes(e[te]))&&(t?o||_e.computed||null===e[te]||"fillUp"!==g?"migrate"===g&&(e[te]=_e.default,s=n.concat(te+"","migrate default value")):e[te]=t[te]:(e[te]=_e.default,s=s.concat(te+"","add default value")))}if(t&&"incremental"===g)for(var ie=0,se=Object.entries(e);ie<se.length;ie++){var le=se[ie],ue=le[0],pe=le[1];Object.prototype.hasOwnProperty.call(t,ue)&&!a.property.name.reserved.concat(f,b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,h).includes(ue)&&(t[ue]===pe||j(t[ue])===j(pe))&&delete e[ue]}for(var de=0,me=Object.entries(e);de<me.length;de++){var fe=me[de],be=fe[0],he=fe[1];if(!a.property.name.reserved.concat(b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(be)){var ye=void 0;if(Object.prototype.hasOwnProperty.call(O,be))ye=O[be];else if(p)ye=p;else{if("migrate"===g){delete e[be],s=n.concat(be+"","migrate removed property");continue}l('Property: Given property "'+be+'" isn\'t specified in model "'+y+'"'+c+".")}if(!ye)continue;if(m.attachment===be){var Oe=he;for(var xe in Oe)if(Object.prototype.hasOwnProperty.call(Oe,xe))for(var ge=0,ve=Object.keys(O[be]);ge<ve.length;ge++){var Ee=ve[ge],Pe=O[m.attachment][Ee];if(U(Ee,xe,Pe)){D(Pe,e,t,xe,c);break}}continue}if(D(ye,e,t,be,c))continue;var De="string"==typeof ye.type&&ye.type.endsWith("[]")||Array.isArray(ye.type)&&ye.type.length&&Array.isArray(ye.type[0]);if(De&&![null,void 0].includes(he)){var Me=he;Array.isArray(Me)?"number"==typeof ye.minimumNumber&&Me.length<ye.minimumNumber?l('MinimumArrayLength: Property "'+be+'" (array of length '+Me.length+") doesn't fulfill minimum array length of "+ye.minimumNumber+c+"."):"number"==typeof ye.maximumNumber&&ye.maximumNumber<Me.length&&l('MaximumArrayLength: Property "'+be+'" (array of length '+Me.length+") doesn't fulfill maximum array length of "+ye.maximumNumber+c+"."):l('PropertyType: Property "'+be+'" isn\'t of type "array -> '+ye.type+'" (given"'+j(Me)+'")'+c+"."),v(Me,be+"",ye,t&&Object.prototype.hasOwnProperty.call(t,be)&&t[be]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var we={};for(var ke in ye)if(Object.prototype.hasOwnProperty.call(ye,ke))if("type"===ke){var Ce=ye[ke];we[ke]=Array.isArray(ye[ke])?Ce[0]:[Ce.substring(0,Ce.length-2)]}else we[ke]=ye[ke];if(Array.isArray(we.type)&&1===we.type.length&&"string"==typeof we.type[0]&&Object.prototype.hasOwnProperty.call(i,we.type[0]))for(var Te,Ae,Ie=_(Me.slice());!(Te=Ie()).done;)"object"!=typeof(Ae=Te.value)||Object.getPrototypeOf(Ae)!==Object.prototype||Object.prototype.hasOwnProperty.call(Ae,h)||(Ae[h]=we.type[0]);for(var je,Le,Re=0,Ue=_(Me.slice());!(je=Ue()).done;)Le=je.value,Me[Re]=P(Le,Re+1+". value in "+be,we,void 0,o||we.computed).newValue,[null,void 0].includes(Me[Re])&&Me.splice(Re,1),Re+=1;t&&Object.prototype.hasOwnProperty.call(t,be)&&Array.isArray(t[be])&&t[be].length===Me.length&&j(t[be])===j(Me)||(s=n.concat(be+"","array updated"))}else{var We=t&&Object.prototype.hasOwnProperty.call(t,be)?t[be]:void 0,Be=De?{newValue:null,changedPath:[]}:P(he,be+"",ye,We,o||ye.computed);e[be]=Be.newValue,Be.changedPath.length&&(s=Be.changedPath),null===e[be]&&(void 0===We?"fillUp"===g&&delete e[be]:s=n.concat(be+"","property removed")),void 0===e[be]&&"incremental"===g&&delete e[be]}}}for(var Ke=0,Ne=Object.keys(m.constraint);Ke<Ne.length;Ke++){var Se=Ne[Ke],qe=m.constraint[Se];if(Object.prototype.hasOwnProperty.call(O,qe))for(var $e,ze=O[qe],Fe=_([].concat(ze));!($e=Fe()).done;){var He=$e.value,Ge=void 0;try{Ge=B(He.evaluation,qe===m.constraint.expression,{checkPropertyContent:P,model:O,modelName:y,type:qe,newDocument:e,oldDocument:t,parentNames:n,pathDescription:c})}catch(o){var Ve,Je;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(o)&&l('Compilation: Hook "'+qe+'" has invalid code "'+o.code+'": "'+(null!==(Ve=o.message)&&void 0!==Ve?Ve:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(o)&&l('Runtime: Hook "'+qe+'" has thrown an error with code "'+o.code+'": "'+(null!==(Je=o.message)&&void 0!==Je?Je:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(o,"empty"))throw o}if(Ge&&!Ge.result){var Ye=qe.replace(/^[^a-zA-Z]+/,"");l(Ye.charAt(0).toUpperCase()+(Ye.substring(1)+": ")+(He.description?r(Function,Object.keys(Ge.scope).concat(["return "+He.description.trim()])).apply(void 0,Object.values(Ge.scope)):'Model "'+y+'" should satisfy constraint "'+Ge.code+'" (given "'+j(e)+'")'+c+"."))}}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var Xe,Ze,Qe=e[m.attachment];("object"!=typeof Qe||Object.getPrototypeOf(Qe)!==Object.prototype)&&l("AttachmentType: given attachment has invalid type"+c+".");var et=null;if(t&&Object.prototype.hasOwnProperty.call(t,m.attachment)&&null!==(et=t[m.attachment])&&"object"==typeof et)for(var tt=0,nt=Object.entries(et);tt<nt.length;tt++){var rt=nt[tt],ot=rt[0],at=rt[1];if(at&&Object.prototype.hasOwnProperty.call(Qe,ot)){var ct=Qe[ot];null===ct||null===ct.data||ct.content_type===at.content_type&&(ct.data===at.data||ct.digest===at.digest)?((null===ct||null===ct.data)&&(s=n.concat(m.attachment,ot,"attachment removed")),"incremental"===g&&delete Qe[ot]):s=n.concat(m.attachment,ot,"attachment updated")}else"fillUp"===g?Qe[ot]=at:"replace"===g&&(s=n.concat(m.attachment,ot,"attachment removed"))}for(var _t=0,it=Object.entries(Qe);_t<it.length;_t++){var st,lt=it[_t],ut=lt[0],pt=lt[1];if(!pt)break;null===pt.data?delete Qe[ut]:(!et||!Object.prototype.hasOwnProperty.call(et,ut)||pt.content_type!==(null==(st=et[ut])?void 0:st.content_type)||pt.data!==et[ut].data&&pt.digest!==et[ut].digest)&&(s=n.concat(m.attachment,ut,"attachment updated"))}0===Object.keys(Qe).length&&delete e[m.attachment];for(var dt=O[m.attachment],mt={},ft=0,bt=Object.keys(dt);ft<bt.length;ft++)mt[bt[ft]]=[];for(var ht=0,yt=Object.keys(Qe);ht<yt.length;ht++){for(var Ot=yt[ht],xt=!1,gt=0,vt=Object.entries(dt);gt<vt.length;gt++){var Et=vt[gt],Pt=Et[0],Dt=Et[1];if(U(Pt,Ot,Dt)){mt[Pt].push(Ot),xt=!0;break}}xt||l('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(dt).join('", "')+'") matches given one ("'+Ot+'")'+c+".")}for(var Mt=0,wt=0,kt=Object.keys(mt);wt<kt.length;wt++){var Ct=kt[wt],Tt=dt[Ct];if(Object.prototype.hasOwnProperty.call(mt,Ct)){var At=mt[Ct].length;"number"==typeof Tt.maximumNumber&&At>Tt.maximumNumber&&l("AttachmentMaximum: given number of attachments ("+At+") doesn't satisfy specified maximum of "+Tt.maximumNumber+' from type "'+Ct+'"'+c+"."),(!Tt.nullable||0!==At)&&"number"==typeof Tt.minimumNumber&&At<Tt.minimumNumber&&l("AttachmentMinimum: given number of attachments ("+At+") doesn't satisfy specified minimum of "+Tt.minimumNumber+' from type "'+Ct+'"'+c+".");for(var It,jt=0,Lt=_(mt[Ct]);!(It=Lt()).done;){var Rt,Ut,Wt,Bt=It.value;if(null!=(Rt=Tt.fileName)&&Rt.pattern){for(var Kt,Nt,St=[].concat(Tt.fileName.pattern),qt=!1,$t=_(St);!(Kt=$t()).done;)if(Nt=Kt.value,new RegExp(Nt).test(Bt)){qt=!0;break}qt||l('AttachmentName: given attachment name "'+Bt+'" doesn\'t satisfy one of specified regular expression patterns "'+St.join('", "')+'" from type "'+Ct+'"'+c+".")}if(null!=(Ut=Tt.fileName)&&Ut.invertedPattern)for(var zt,Ft,Ht=_([].concat(Tt.fileName.invertedPattern));!(zt=Ht()).done;)Ft=zt.value,new RegExp(Ft).test(Bt)&&l('InvertedAttachmentName: given attachment name "'+Bt+'" does satisfy specified regular expression pattern "'+Ft.toString()+'" from type "'+Ct+'"'+c+".");if(null!=(Wt=Qe[Bt])&&Wt.content_type){if(Tt.contentTypePattern){for(var Gt,Vt,Jt=[].concat(Tt.contentTypePattern),Yt=!1,Xt=_(Jt);!(Gt=Xt()).done;)if(Vt=Gt.value,new RegExp(Vt).test(Qe[Bt].content_type)){Yt=!0;break}Yt||l('AttachmentContentType: given attachment content type "'+Qe[Bt].content_type+'" doesn\'t satisfy specified regular expression pattern "'+Jt.join('", "')+'" from type "'+Ct+'"'+c+".")}var Zt=Tt.invertedContentTypePattern;if(Zt)for(var Qt,en,tn=_([].concat(Zt));!(Qt=tn()).done;)en=Qt.value,new RegExp(en).test(Qe[Bt].content_type)&&l('InvertedAttachmentContentType: given attachment content type "'+Qe[Bt].content_type+'" does satisfy specified regular expression pattern "'+en.toString()+'" from type "'+Ct+'"'+c+".")}var nn=0;Qe[Bt]&&"length"in Qe[Bt]?nn=Qe[Bt].length:Qe[Bt]&&"data"in Qe[Bt]&&(nn="undefined"!=typeof Buffer&&"byteLength"in Buffer?Buffer.byteLength(Qe[Bt].data,"base64"):Qe[Bt].data.length),"number"==typeof Tt.minimumSize&&Tt.minimumSize>nn?l("AttachmentMinimumSize: given attachment size "+nn+" byte doesn't satisfy specified minimum of "+Tt.minimumSize+" byte "+c+"."):"number"==typeof Tt.maximumSize&&Tt.maximumSize<nn&&l("AttachmentMaximumSize: given attachment size "+nn+" byte doesn't satisfy specified maximum of "+Tt.maximumSize+" byte "+c+"."),jt+=nn}"number"==typeof Tt.minimumAggregatedSize&&Tt.minimumAggregatedSize>jt?l('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+Ct+'" '+jt+" byte doesn't satisfy specified minimum of "+Tt.minimumAggregatedSize+" byte "+c+"."):"number"==typeof Tt.maximumAggregatedSize&&Tt.maximumAggregatedSize<jt&&l('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+Ct+'" '+jt+" byte doesn't satisfy specified maximum of "+Tt.maximumAggregatedSize+" byte "+c+"."),Mt+=jt}}(null!==(Xe=O[m.minimumAggregatedSize])&&void 0!==Xe?Xe:0)>Mt?l("AggregatedMinimumSize: given aggregated size "+Mt+" byte doesn't satisfy specified minimum of "+O[m.minimumAggregatedSize]+" byte "+c+"."):(null!==(Ze=O[m.maximumAggregatedSize])&&void 0!==Ze?Ze:1/0)<Mt&&l("AggregatedMaximumSize: given aggregated size "+Mt+" byte doesn't satisfy specified maximum of "+O[m.maximumAggregatedSize]+" byte "+c+".")}if(t&&Object.prototype.hasOwnProperty.call(t,m.attachment)&&0===Object.keys(t[m.attachment]).length&&delete t[m.attachment],0===s.length&&t&&"migrate"===g)for(var rn,on=0,an=Object.keys(t);on<an.length;on++)rn=an[on],Object.prototype.hasOwnProperty.call(e,rn)||(s=n.concat(rn,"migrate removed property"));return{changedPath:s,newDocument:e}},N={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var n=e[m.attachment],r=W(t);if(r)return Object.prototype.hasOwnProperty.call(n[r],"stub")&&n[r].stub||Object.prototype.hasOwnProperty.call(n[r],"data")&&![null,void 0].includes(n[r].data)}return!1},checkDocument:K,getFileNameByPrefix:W,serialize:j,id:y,revision:O,idName:f,revisionName:b,specialNames:m,typeName:h,modelConfiguration:a,models:i,now:u,nowUTCTimestamp:p,securitySettings:o,userContext:n},S=e[m.attachment];if(e[m.attachment])for(var q,$=0,z=Object.values(S);$<z.length;$++)null!=(q=z[$])&&q.contentType&&(q.content_type=q.contentType,delete q.contentType);var F=K(e,t);return(!F.newDocument._deleted||t)&&(F.newDocument._deleted&&F.newDocument._deleted!==(null==t?void 0:t._deleted)||F.changedPath.length)||l("NoChange: No new data given. new document: "+j(e)+"; old document: "+j(t)+"."),Object.prototype.hasOwnProperty.call(o,a.property.name.validatedDocumentsCache)?o[a.property.name.validatedDocumentsCache].add(y+"-"+O):o[a.property.name.validatedDocumentsCache]=new Set([y+"-"+O]),F.newDocument},u=e.exports,p=u}],r={};t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:function(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e},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=t(0);e.exports=o}()},e=>{"use strict";e.exports=require("pouchdb-node")},e=>{"use strict";e.exports=require("pouchdb-find")},e=>{"use strict";e.exports=require("child_process")},e=>{"use strict";e.exports=require("pouchdb-node/node_modules/node-fetch/lib/index.js")},,(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{S8:()=>restart,ds:()=>stop,ni:()=>start});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1),_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__(2),_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__(3),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),child_process__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(11),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(12),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(6),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__),_helper__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(0),_this=void 0;function _createForOfIteratorHelperLoose(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=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 n={}.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)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch=node_fetch__WEBPACK_IMPORTED_MODULE_5___default();var start=function(){var _ref=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee(services,configuration){var server,runner,binary;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(server=services.couchdb.server,runner=server.runner,binary=configuration.couchdb.binary,!runner.configurationFile){_context.next=15;break}return _context.prev=4,_context.next=7,fs__WEBPACK_IMPORTED_MODULE_6__.promises.mkdir((0,path__WEBPACK_IMPORTED_MODULE_7__.dirname)(runner.configurationFile.path),{recursive:!0});case 7:_context.next=13;break;case 9:if(_context.prev=9,_context.t0=_context.catch(4),"EEXIST"===_context.t0.code){_context.next=13;break}throw _context.t0;case 13:return _context.next=15,fs__WEBPACK_IMPORTED_MODULE_6__.promises.writeFile(runner.configurationFile.path,runner.configurationFile.content,{encoding:configuration.core.encoding});case 15:return server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_3__.spawn)("default"===binary.memoryInMegaByte?runner.binaryFilePath:binary.nodePath,("default"===binary.memoryInMegaByte?[]:["--max-old-space-size="+binary.memoryInMegaByte,runner.binaryFilePath]).concat(runner.arguments?runner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(runner,"environment")?_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},eval("process").env,runner.environment):eval("process").env,shell:!0,stdio:"inherit"}),new Promise((function(e,t){for(var n,r=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CLOSE_EVENT_NAMES);!(n=r()).done;){var o,a=n.value;null==(o=server.process)||o.on(a,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.getProcessCloseHandler)(e,t,{process:server.process,reason:a}))}})).then((function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.resolve&&services.couchdb.server.resolve.call(_this,e)}),(function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.reject&&services.couchdb.server.reject.call(_this,e)})),_context.next=19,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.checkReachability)((0,clientnode__WEBPACK_IMPORTED_MODULE_4__.format)(configuration.couchdb.url,""),{wait:!0});case 19:case"end":return _context.stop()}}),_callee,null,[[4,9]])})));return function(){return _ref.apply(this,arguments)}}(),restart=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,r,o,a,c,_;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.configuration,r=t.pluginAPI,o=t.services,a=o.couchdb.server,c=a.resolve,_=a.reject,a.resolve=a.reject=clientnode__WEBPACK_IMPORTED_MODULE_4__.NOOP,e.next=7,stop(o,n);case 7:return a.resolve=c,a.reject=_,e.next=11,start(o,n);case 11:return(0,_helper__WEBPACK_IMPORTED_MODULE_8__.initializeConnection)(o,n),e.next=14,r.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},t,{hook:"restartCouchdb"}));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),stop=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,n){var r,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.couchdb,o=n.couchdb,r.connection.close(),r.server.process&&r.server.process.kill("SIGINT"),e.next=6,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.checkUnreachability)((0,clientnode__WEBPACK_IMPORTED_MODULE_4__.format)(o.url,""),{wait:!0});case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.loaded=!0,n.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 n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),__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__=__webpack_require__(5);module.exports=__webpack_exports__})();
|
|
1
|
+
(()=>{var __webpack_modules__=[(e,t,n)=>{"use strict";n.d(t,{determineAllowedModelRolesMapping:()=>h,determineGenericIndexablePropertyNames:()=>O,ensureValidationDocumentPresence:()=>f,extendModels:()=>g,getConnectorOptions:()=>d,initializeConnection:()=>b,mayStripRepresentation:()=>m});var r=n(1),o=n.n(r),a=n(2),c=n.n(a),_=n(3),i=n.n(_),s=n(4);const l="1.0.683";function u(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 p(e,t);var n={}.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)?p(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var d=function(e){return e.couchdb.connector.fetch?{fetch:function(t,n){if(!s.globalContext.fetch)throw new Error("Missing fetch implementation.");return s.globalContext.fetch(t,(0,s.extend)(!0,(0,s.copy)(e.couchdb.connector.fetch),n||{}))}}:{fetch:function(e,t){if(!s.globalContext.fetch)throw new Error("Missing fetch implementation.");return s.globalContext.fetch(e,t)}}},m=function(e,t,n){var r=(0,s.represent)(e);return r.length<=t?r.length>n?r.substring(0,n-3)+"...":r:"DOCUMENT IS TOO BIG TO REPRESENT"},f=function(){var e=c()(i().mark((function e(t,n,r,a,c,_,u,p){var d,m,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===c&&(c=!0),void 0===_&&(_="_id"),void 0===u&&(u="_rev"),void 0===p&&(p="_design/"),m=o()(((d={})[_]=""+p+n,d.language="javascript",d.version=l,d),r),e.prev=5,e.next=8,t.get(""+p+n);case 8:return f=e.sent,m[u]=f[u],e.next=12,t.put(m);case 12:c&&console.info(a+" updated."),e.next=27;break;case 15:return e.prev=15,e.t0=e.catch(5),c&&("not_found"===e.t0.error?console.info(a+" not available: create new one."):console.info(a+" couldn't be updated: \""+(0,s.represent)(e.t0)+'" create new one.')),e.prev=18,e.next=21,t.put(m);case 21:c&&console.info(a+" installed/updated."),e.next=27;break;case 24:throw e.prev=24,e.t1=e.catch(18),new Error(a+" couldn't be installed/updated: \""+(0,s.represent)(e.t1)+'".');case 27:case"end":return e.stop()}}),e,null,[[5,15],[18,24]])})));return function(){return e.apply(this,arguments)}}(),b=function(){var e=c()(i().mark((function e(t,n){var r,o,a,_,l,p,m,f;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.couchdb,o=(0,s.format)(r.url,r.user.name+":"+r.user.password+"@")+"/"+r.databaseName,t.couchdb.connection=new t.couchdb.connector(o,d(n)),(a=t.couchdb.connection).setMaxListeners(1/0),_=r.model.property.name.special.id,l=r.model.property.name.special.revision,p=i().mark((function e(){var t,n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=f.value,n=a[t].bind(a),a[t]=c()(i().mark((function e(t){var o,a,c,s,u,p,d,m=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o=m.length,a=Array(1<o?o-1:0),c=1;c<o;c++)a[c-1]=m[c];return s=a.length&&"object"==typeof a[0]?a[0]:{},e.prev=2,e.next=5,n.apply(void 0,[t].concat(a));case 5:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e.catch(2),u=t[_],p=e.t0,!(u&&r.ignoreNoChangeError&&"name"in p&&"forbidden"===p.name&&"message"in p&&p.message.startsWith("NoChange:"))){e.next=25;break}if(d=l in s?s[l]:t[l],e.t1=u,!(l in t)||["0-latest","0-upsert"].includes(d)){e.next=19;break}e.t2=d,e.next=23;break;case 19:return e.next=21,this.get(u);case 21:e.t3=l,e.t2=e.sent[e.t3];case 23:return e.t4=e.t2,e.abrupt("return",{id:e.t1,rev:e.t4,ok:!0});case 25:throw p;case 26:case"end":return e.stop()}}),e,this,[[2,8]])})));case 3:case"end":return e.stop()}}),e)})),m=u(["post","put"]);case 9:if((f=m()).done){e.next=13;break}return e.delegateYield(p(),"t0",11);case 11:e.next=9;break;case 13:return e.prev=13,e.next=16,(0,s.checkReachability)(o);case 16:e.next=25;break;case 18:if(e.prev=18,e.t1=e.catch(13),console.info("Database could not be retrieved yet: Creating it."),s.globalContext.fetch){e.next=23;break}throw new Error("Missing fetch implementation.");case 23:return e.next=25,s.globalContext.fetch(o,{method:"PUT"});case 25:return e.abrupt("return",t);case 26:case"end":return e.stop()}}),e,null,[[13,18]])})));return function(){return e.apply(this,arguments)}}(),h=function(e){for(var t=e.property.name.special.allowedRole,n={},r=g(e),a=0,c=Object.entries(r);a<c.length;a++){var _=c[a],i=_[0],l=_[1];if(l[t]){n[i]=o()({properties:{}},v(l[t]));for(var u=0,p=Object.entries(l);u<p.length;u++){var d=p[u],m=d[0],f=d[1];(0,s.isObject)(f)&&f.allowedRoles&&(n[i].properties[m]=v(f.allowedRoles))}}else n[i]={properties:{},read:[],write:[]}}return n},y=function(e){return(0,s.isObject)(e)},O=function(e,t){var n=e.property.name.special;return Object.keys(t).filter((function(r){var o=t[r];return y(o)&&Object.prototype.hasOwnProperty.call(o,"index")&&o.index||y(o)&&!(Object.prototype.hasOwnProperty.call(o,"index")&&!o.index||e.property.name.reserved.concat(n.additional,n.allowedRole,n.attachment,n.conflict,n.constraint.execution,n.constraint.expression,n.deleted,n.deletedConflict,n.extend,n.maximumAggregatedSize,n.minimumAggregatedSize,n.oldType,n.id,n.revision,n.revisions,n.revisionsInformation,n.type).includes(r)||o.type&&("string"==typeof o.type&&o.type.endsWith("[]")||Array.isArray(o.type)&&o.type.length&&Array.isArray(o.type[0])||Object.prototype.hasOwnProperty.call(e.entities,o.type)))})).concat([n.id,n.revision]).sort()},x=function(e,t,n){if(void 0===n&&(n="_extends"),"_base"===e)return t[e];if(Object.prototype.hasOwnProperty.call(t,"_base")&&(Object.prototype.hasOwnProperty.call(t[e],n)&&t[e][n]?t[e][n]=["_base"].concat(t[e][n]):t[e][n]="_base"),Object.prototype.hasOwnProperty.call(t[e],n)){for(var r,o,a=u([].concat(t[e][n]));!(r=a()).done;)o=r.value,t[e]=(0,s.extend)(!0,(0,s.copy)(x(o,t,n)),t[e]);delete t[e][n]}return t[e]},g=function(e){for(var t,n=e.property.name.special,r={},o=e.property.name.typePattern,a=0,c=Object.keys(e.entities);a<c.length;a++){if(t=c[a],!new RegExp(o.public).test(t)&&!new RegExp(o.private).test(t))throw new Error('Model names have to match "'+o.public+'" or "'+o.private+'" for private one (given name: "'+t+'").');r[t]=x(t,e.entities,n.extend)}for(var _,i=0,l=Object.values(r);i<l.length;i++){_=l[i];for(var u=0,p=Object.entries(_);u<p.length;u++){var d=p[u],m=d[0],f=d[1];if(m===n.attachment)for(var b=f,h=0,y=Object.entries(b);h<y.length;h++){var O=y[h],g=O[0],v=O[1];b[g]=(0,s.extend)(!0,(0,s.copy)(e.property.defaultSpecification),v)}else[n.allowedRole,n.constraint.execution,n.constraint.expression,n.extend,n.maximumAggregatedSize,n.minimumAggregatedSize,n.oldType].includes(m)||(_[m]=(0,s.extend)(!0,(0,s.copy)(e.property.defaultSpecification),f))}}return r},v=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t,n={read:[],write:[]},r=0,o=Object.keys(n);r<o.length;r++)t=o[r],Object.prototype.hasOwnProperty.call(e,t)&&(Array.isArray(e[t])?n[t]=e[t]:n[t]=[e[t]]);return n}return{read:[e],write:[e]}}},e=>{"use strict";e.exports=require("@babel/runtime/helpers/extends")},e=>{"use strict";e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{"use strict";e.exports=require("@babel/runtime/regenerator")},e=>{"use strict";e.exports=require("clientnode")},(module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{TOGGLE_LATEST_REVISION_DETERMINING:()=>TOGGLE_LATEST_REVISION_DETERMINING,database:()=>database,default:()=>__WEBPACK_DEFAULT_EXPORT__,loadService:()=>loadService,postLoadService:()=>postLoadService,preLoadService:()=>preLoadService,shouldExit:()=>shouldExit});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1),_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__(2),_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__(3),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),clientnode__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_3__),fs__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(6),fs__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_4__),path__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(7),path__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_5__),pouchdb_node__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9),pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(pouchdb_node__WEBPACK_IMPORTED_MODULE_6__),pouchdb_find__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(10),pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(pouchdb_find__WEBPACK_IMPORTED_MODULE_7__),_databaseHelper__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(8),_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_10__),_helper__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(0),_server__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(14);function _createForOfIteratorHelperLoose(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=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 n={}.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)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}module=__webpack_require__.hmd(module);var TOGGLE_LATEST_REVISION_DETERMINING=Symbol("toggleLatestRevisionDetermining"),preLoadService=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,r,o,a,c,_,i,s,l,u,p,d,m,f,b,h,y;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.configuration.couchdb,r=t.services,Object.prototype.hasOwnProperty.call(r,"couchdb")||(r.couchdb={}),o=r.couchdb,Object.prototype.hasOwnProperty.call(o,"connector")||(a=n.model.property.name.special.id,c=n.model.property.name.special.revision,o.connector=pouchdb_node__WEBPACK_IMPORTED_MODULE_6___default(),_=o.connector.prototype.bulkDocs,o.connector.plugin({bulkDocs:function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,o,i,s,l,u,p,d,m,f,b,h,y,O,x,g,v,E,P=arguments;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(o=P.length,i=Array(1<o?o-1:0),s=1;s<o;s++)i[s-1]=P[s];return l=0<i.length&&i[i.length-1]===TOGGLE_LATEST_REVISION_DETERMINING,u=l?!n.skipLatestRevisionDetermining:n.skipLatestRevisionDetermining,l&&i.pop(),p=!Array.isArray(t)&&(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isObject)(t)&&a in t?[t]:t,null!=(r=n.connector.fetch)&&r.timeout&&(0===i.length||"object"!=typeof i[0])&&i.unshift({timeout:n.connector.fetch.timeout}),e.next=8,_.call.apply(_,[this,p].concat(i));case 8:d=e.sent,m=[],f=[],b=0,h=_createForOfIteratorHelperLoose(d);case 13:if((y=h()).done){e.next=36;break}if(O=y.value,"object"!=typeof p[b]){e.next=33;break}if(!(c in p[b])||"conflict"!==O.name||!["0-latest","0-upsert"].includes(p[b][c])){e.next=21;break}f.push(p[b]),m.push(b),e.next=33;break;case 21:if(!(a in p[b]&&n.ignoreNoChangeError&&"name"in O&&"forbidden"===O.name&&"message"in O&&O.message.startsWith("NoChange:"))){e.next=33;break}if(d[b]={id:p[b][a],ok:!0},u){e.next=33;break}if(!(c in p[b])||["0-latest","0-upsert"].includes(p[b][c])){e.next=28;break}e.t0=p[b][c],e.next=32;break;case 28:return e.next=30,this.get(d[b].id);case 30:e.t1=c,e.t0=e.sent[e.t1];case 32:d[b].rev=e.t0;case 33:b+=1;case 34:e.next=13;break;case 36:if(!f.length){e.next=43;break}return p=f,l&&i.push(TOGGLE_LATEST_REVISION_DETERMINING),e.next=41,this.bulkDocs.apply(this,[p].concat(i));case 41:for(x=e.sent,g=_createForOfIteratorHelperLoose(x);!(v=g()).done;)E=v.value,d[m.shift()]=E;case 43:return e.abrupt("return",d);case 44:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()}),n.debug&&o.connector.debug.enable("*"),o.connector=o.connector.plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default())),Object.prototype.hasOwnProperty.call(o,"server")){e.next=36;break}o.server={},i=[],s=_createForOfIteratorHelperLoose([].concat(n.binary.runner));case 8:if((l=s()).done){e.next=34;break}u=l.value,p=_createForOfIteratorHelperLoose([].concat(u.location));case 11:if((d=p()).done){e.next=30;break}m=d.value,f=_createForOfIteratorHelperLoose([].concat(u.name));case 14:if((b=f()).done){e.next=26;break}return h=b.value,y=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(m,h),i.push(y),e.next=20,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isFile)(y);case 20:if(!e.sent){e.next=24;break}return u.binaryFilePath=y,o.server.runner=u,e.abrupt("break",26);case 24:e.next=14;break;case 26:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=28;break}return e.abrupt("break",30);case 28:e.next=11;break;case 30:if(!Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=32;break}return e.abrupt("break",34);case 32:e.next=8;break;case 34:if(Object.prototype.hasOwnProperty.call(o.server,"runner")){e.next=36;break}throw new Error('No binary file in one of the following locations found: "'+i.join('", "')+'".');case 36:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),loadService=function(){var _ref5=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee3(_ref4){var configuration,services,promise,couchdb,urlPrefix,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,_i,_arr,type,_iterator6,_step6,name,userDatabaseConnection,_userDatabaseConnecti,_iterator7,_step7,prefix,subPath,fullPath,url,value,response,changeNeeded,modelConfiguration,specialNames,idName,revisionName,typeName,models,databaseHelperCode,_iterator8,_step8,_type2,code,_i2,_Object$entries,_Object$entries$_i,modelName,model,_i3,_Object$entries2,_Object$entries2$_i,_name,specification,_iterator9,_step9,constraint,_iterator10,_step10,_type,_constraint,migrators,_iterator11,_step11,file,extension,_name2,documents,_iterator12,_step12,document,_forbidden,_iterator13,_step13,retrievedDocument,_document,newDocument,_iterator14,_step14,_name3,result,genericIndexes,_i4,_Object$entries3,_Object$entries3$_i,_modelName,_model,_iterator15,_step15,propertyName,_name4,foundPosition,position,_iterator16,_step16,index,_iterator17,_step17,_index,exists,_i5,_Object$entries4,_Object$entries4$_i,_modelName2,_model2,_iterator18,_step18,_name5;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context3){for(;;)switch(_context3.prev=_context3.next){case 0:if(configuration=_ref4.configuration,services=_ref4.services,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch){_context3.next=3;break}throw new Error("Missing fetch implementation.");case 3:if(promise=null,couchdb=services.couchdb,!Object.prototype.hasOwnProperty.call(couchdb.server,"runner")){_context3.next=12;break}return _context3.next=8,(0,_server__WEBPACK_IMPORTED_MODULE_8__.ni)(services,configuration);case 8:couchdb.server.restart=_server__WEBPACK_IMPORTED_MODULE_8__.S8,couchdb.server.start=_server__WEBPACK_IMPORTED_MODULE_8__.ni,couchdb.server.stop=_server__WEBPACK_IMPORTED_MODULE_8__.ds,promise=new Promise((function(e,t){couchdb.server.resolve=e,couchdb.server.reject=t}));case 12:if(!Object.prototype.hasOwnProperty.call(couchdb,"connection")){_context3.next=14;break}return _context3.abrupt("return",{couchdb:promise});case 14:if(urlPrefix=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.format)(configuration.couchdb.url,configuration.couchdb.user.name+":"+configuration.couchdb.user.password+"@"),!configuration.couchdb.ensureAdminPresence){_context3.next=46;break}return unauthenticatedUserDatabaseConnection=new couchdb.connector((0,clientnode__WEBPACK_IMPORTED_MODULE_3__.format)(configuration.couchdb.url,"")+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=17,_context3.next=20,unauthenticatedUserDatabaseConnection.allDocs();case 20:return console.info('No admin user available. Automatically creating admin user" '+configuration.couchdb.user.name+'".'),_context3.next=23,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch((0,clientnode__WEBPACK_IMPORTED_MODULE_3__.format)(configuration.couchdb.url,"")+"/"+couchdb.server.runner.adminUserConfigurationPath+"/"+configuration.couchdb.user.name,{body:'"'+configuration.couchdb.user.password+'"',method:"PUT"});case 23:_context3.next=43;break;case 25:if(_context3.prev=25,_context3.t0=_context3.catch(17),"unauthorized"!==_context3.t0.name){_context3.next=42;break}return authenticatedUserDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=29,_context3.next=32,authenticatedUserDatabaseConnection.allDocs();case 32:_context3.next=37;break;case 34:_context3.prev=34,_context3.t1=_context3.catch(29),console.error("Can't login as existing admin user \""+configuration.couchdb.user.name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t1));case 37:return _context3.prev=37,authenticatedUserDatabaseConnection.close(),_context3.finish(37);case 40:_context3.next=43;break;case 42:console.error("Can't create new admin user \""+configuration.couchdb.user.name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t0));case 43:return _context3.prev=43,unauthenticatedUserDatabaseConnection.close(),_context3.finish(43);case 46:if(!configuration.couchdb.ensureUserPresence){_context3.next=81;break}_i=0,_arr=[configuration.couchdb.security.admins,configuration.couchdb.security.members];case 48:if(!(_i<_arr.length)){_context3.next=81;break}type=_arr[_i],_iterator6=_createForOfIteratorHelperLoose(type.names);case 51:if((_step6=_iterator6()).done){_context3.next=78;break}return name=_step6.value,userDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_9__.getConnectorOptions)(configuration)),_context3.prev=54,_context3.next=57,userDatabaseConnection.get("org.couchdb.user:"+name);case 57:_context3.next=73;break;case 59:if(_context3.prev=59,_context3.t2=_context3.catch(54),"not_found"!==_context3.t2.error){_context3.next=72;break}return _context3.prev=62,_context3.next=65,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 65:_context3.next=70;break;case 67:throw _context3.prev=67,_context3.t3=_context3.catch(62),new Error("Couldn't create missing user \""+name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t3));case 70:_context3.next=73;break;case 72:throw new Error("Couldn't check for presence of user \""+name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t2));case 73:return _context3.prev=73,userDatabaseConnection.close(),_context3.finish(73);case 76:_context3.next=51;break;case 78:_i++,_context3.next=48;break;case 81:if(!configuration.couchdb.model.updateConfiguration){_context3.next=136;break}_iterator7=_createForOfIteratorHelperLoose(configuration.couchdb.backend.prefixes);case 83:if((_step7=_iterator7()).done){_context3.next=136;break}prefix=_step7.value,_context3.t4=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().keys(configuration.couchdb.backend.configuration);case 86:if((_context3.t5=_context3.t4()).done){_context3.next=134;break}if(subPath=_context3.t5.value,!Object.prototype.hasOwnProperty.call(configuration.couchdb.backend.configuration,subPath)){_context3.next=132;break}return fullPath="/"+prefix+(prefix.trim()?"/":"")+subPath,url=""+urlPrefix+fullPath,value=configuration.couchdb.backend.configuration[subPath],response=void 0,_context3.prev=93,_context3.next=96,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url);case 96:response=_context3.sent,_context3.next=102;break;case 99:_context3.prev=99,_context3.t6=_context3.catch(93),console.warn('Configuration "'+fullPath+'" (with desired value ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]) couldn't be determined: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t6));case 102:if(!response){_context3.next=132;break}if(!response.ok){_context3.next=131;break}if(changeNeeded=!0,"function"!=typeof response.text){_context3.next=117;break}return _context3.prev=106,_context3.t7=value,_context3.next=110,response["string"==typeof value?"text":"json"]();case 110:_context3.t8=_context3.sent,changeNeeded=_context3.t7===_context3.t8,_context3.next=117;break;case 114:_context3.prev=114,_context3.t9=_context3.catch(106),console.warn('Error checking curent value of "'+fullPath+'" to be ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t9));case 117:if(!changeNeeded){_context3.next=128;break}return _context3.prev=118,_context3.next=121,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url,{body:'"'+configuration.couchdb.backend.configuration[subPath]+'"',method:"PUT"});case 121:_context3.next=126;break;case 123:_context3.prev=123,_context3.t10=_context3.catch(118),console.error('Configuration "'+fullPath+"\" couldn't be applied to ["+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t10));case 126:_context3.next=129;break;case 128:console.info('Configuration "'+fullPath+'" is already set to desired value ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"].");case 129:_context3.next=132;break;case 131:console.info('Configuration "'+fullPath+'" does not exist (desired value ['+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]). Response code is "+response.status+".");case 132:_context3.next=86;break;case 134:_context3.next=83;break;case 136:return _context3.next=138,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.initializeConnection)(services,configuration);case 138:if(!configuration.couchdb.ensureSecuritySettingsPresence){_context3.next=147;break}return _context3.prev=139,_context3.next=142,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(urlPrefix+"/"+configuration.couchdb.databaseName+"/_security",{body:JSON.stringify(configuration.couchdb.security),method:"PUT"});case 142:_context3.next=147;break;case 144:_context3.prev=144,_context3.t11=_context3.catch(139),console.error("Security object couldn't be applied: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t11));case 147:if(modelConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(configuration.couchdb.model),delete modelConfiguration.property.defaultSpecification,delete modelConfiguration.entities,specialNames=modelConfiguration.property.name.special,idName=specialNames.id,revisionName=specialNames.revision,typeName=specialNames.type,models=(0,_helper__WEBPACK_IMPORTED_MODULE_9__.extendModels)(configuration.couchdb.model),!configuration.couchdb.model.updateValidation){_context3.next=216;break}return _context3.next=156,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(eval("require.resolve('./databaseHelper')"),{encoding:configuration.core.encoding,flag:"r"});case 156:databaseHelperCode=_context3.sent,_iterator8=_createForOfIteratorHelperLoose([{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(modelConfiguration)+", "+JSON.stringify(models)},{description:"Authorisation",methodName:"authenticate",name:"authentication",serializedParameter:JSON.stringify((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineAllowedModelRolesMapping)(configuration.couchdb.model))+", '"+idName+"', '"+typeName+"', '"+specialNames.designDocumentNamePrefix+"'"}]);case 158:if((_step8=_iterator8()).done){_context3.next=173;break}_type2=_step8.value,code="function(...parameters) {\n return require('helper')."+_type2.methodName+"(...parameters.concat(["+_type2.serializedParameter+"]))\n}",_context3.prev=161,new Function("return "+code),_context3.next=168;break;case 165:throw _context3.prev=165,_context3.t12=_context3.catch(161),new Error("Generated "+_type2.name+' code "'+code+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t12));case 168:return configuration.core.debug&&console.debug(_type2.name+' code: \n\n"'+code+'" integrated.'),_context3.next=171,(0,_helper__WEBPACK_IMPORTED_MODULE_9__.ensureValidationDocumentPresence)(couchdb.connection,_type2.name,{helper:databaseHelperCode,validate_doc_update:code},_type2.description,!0,idName,revisionName,specialNames.designDocumentNamePrefix);case 171:_context3.next=158;break;case 173:_i2=0,_Object$entries=Object.entries(models);case 174:if(!(_i2<_Object$entries.length)){_context3.next=216;break}_Object$entries$_i=_Object$entries[_i2],modelName=_Object$entries$_i[0],model=_Object$entries$_i[1],_i3=0,_Object$entries2=Object.entries(model);case 177:if(!(_i3<_Object$entries2.length)){_context3.next=213;break}if(_Object$entries2$_i=_Object$entries2[_i3],_name=_Object$entries2$_i[0],specification=_Object$entries2$_i[1],![specialNames.constraint.execution,specialNames.constraint.expression].includes(_name)){_context3.next=195;break}_iterator9=_createForOfIteratorHelperLoose([].concat(specification));case 181:if((_step9=_iterator9()).done){_context3.next=193;break}if(constraint=_step9.value,!constraint.description){_context3.next=191;break}_context3.prev=184,new Function("return "+constraint.description),_context3.next=191;break;case 188:throw _context3.prev=188,_context3.t13=_context3.catch(184),new Error('Specified constraint description "'+constraint.description+'" for model "'+modelName+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t13));case 191:_context3.next=181;break;case 193:_context3.next=210;break;case 195:_iterator10=_createForOfIteratorHelperLoose(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 196:if((_step10=_iterator10()).done){_context3.next=210;break}if(_type=_step10.value,!(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isObject)(specification)){_context3.next=208;break}if(_constraint=specification[_type],null==_constraint||!_constraint.description){_context3.next=208;break}_context3.prev=201,new Function(_constraint.description),_context3.next=208;break;case 205:throw _context3.prev=205,_context3.t14=_context3.catch(201),new Error('Specified constraint description "'+_constraint.description+'" for model "'+modelName+'" in property "'+_name+'" as "'+_type+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t14));case 208:_context3.next=196;break;case 210:_i3++,_context3.next=177;break;case 213:_i2++,_context3.next=174;break;case 216:if(!configuration.couchdb.model.autoMigrationPath){_context3.next=321;break}return migrators={},_context3.next=220,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isDirectory)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath));case 220:if(!_context3.sent){_context3.next=273;break}return _context3.t15=_createForOfIteratorHelperLoose,_context3.next=224,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.walkDirectoryRecursively)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_3__.NOOP:function(e){return!["debug","deprecated"].includes(e.name)});case 224:_context3.t16=_context3.sent,_iterator11=(0,_context3.t15)(_context3.t16);case 226:if((_step11=_iterator11()).done){_context3.next=273;break}if(file=_step11.value,extension=(0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name),_name2=(0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(file.name,extension),".json"!==extension){_context3.next=263;break}return documents=void 0,_context3.prev=232,_context3.t17=[],_context3.t18=JSON,_context3.next=237,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(file.path,{encoding:configuration.core.encoding,flag:"r"});case 237:_context3.t19=_context3.sent,_context3.t20=_context3.t18.parse.call(_context3.t18,_context3.t19),documents=_context3.t17.concat.call(_context3.t17,_context3.t20),_context3.next=245;break;case 242:throw _context3.prev=242,_context3.t21=_context3.catch(232),new Error('Parsing document "'+file.path+'" to include by automigration of has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t21));case 245:1===documents.length&&(!documents[0][idName]&&(documents[0][idName]=_name2),!documents[0][revisionName]&&(documents[0][revisionName]="0-upsert")),_iterator12=_createForOfIteratorHelperLoose(documents);case 247:if((_step12=_iterator12()).done){_context3.next=261;break}return document=_step12.value,_context3.prev=249,_context3.next=252,couchdb.connection.put(document);case 252:_context3.next=258;break;case 254:throw _context3.prev=254,_context3.t22=_context3.catch(249),null!=(_forbidden=_context3.t22.forbidden)&&_forbidden.startsWith("NoChange:")&&console.info('Including document "'+document[idName]+'" of type "'+document[typeName]+"\" hasn't changed existing document."),new Error('Migrating document "'+document[idName]+'" of type "'+document[typeName]+'" has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t22));case 258:console.info('Including document "'+document[idName]+'" of type "'+document[typeName]+'" was successful.');case 259:_context3.next=247;break;case 261:_context3.next=271;break;case 263:if(![".js"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=267;break}migrators[file.path]=eval("require('"+file.path+"')").default,_context3.next=271;break;case 267:if(![".mjs"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context3.next=271;break}return _context3.next=270,eval("import('"+file.path+"')");case 270:migrators[file.path]=_context3.sent.default;case 271:_context3.next=226;break;case 273:return _context3.t23=_createForOfIteratorHelperLoose,_context3.next=276,couchdb.connection.allDocs({include_docs:!0});case 276:_context3.t24=_context3.sent.rows,_iterator13=(0,_context3.t23)(_context3.t24);case 278:if((_step13=_iterator13()).done){_context3.next=321;break}if(retrievedDocument=_step13.value,"string"==typeof retrievedDocument.id&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context3.next=319;break}_document=retrievedDocument.doc,newDocument=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(_document),newDocument[configuration.couchdb.model.property.name.special.strategy]="migrate",_iterator14=_createForOfIteratorHelperLoose(Object.keys(migrators).sort());case 285:if((_step14=_iterator14()).done){_context3.next=298;break}_name3=_step14.value,result=null,_context3.prev=288,result=migrators[_name3](newDocument,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},clientnode__WEBPACK_IMPORTED_MODULE_3__.UTILITY_SCOPE,{configuration,databaseHelper:_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default(),idName,typeName,migrators,models,modelConfiguration,selfFilePath:_name3,services})),_context3.next=295;break;case 292:throw _context3.prev=292,_context3.t25=_context3.catch(288),new Error('Running migrater "'+_name3+'" in document '+(0,_helper__WEBPACK_IMPORTED_MODULE_9__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+'" failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t25));case 295:result&&(newDocument=result,console.info('Running migrater "'+_name3+'" for document "'+newDocument[idName]+'" (of type "'+newDocument[typeName]+'") was successful.'));case 296:_context3.next=285;break;case 298:_context3.prev=298,(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.validateDocumentUpdate)((0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(newDocument),(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(_document),{db:configuration.couchdb.databaseName,name:configuration.couchdb.user.name,roles:["_admin"]},(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(configuration.couchdb.security),modelConfiguration,models),_context3.next=310;break;case 302:if(_context3.prev=302,_context3.t26=_context3.catch(298),!Object.prototype.hasOwnProperty.call(_context3.t26,"forbidden")){_context3.next=309;break}return _context3.t26.forbidden.startsWith("NoChange:")||console.warn('Document "'+(0,_helper__WEBPACK_IMPORTED_MODULE_9__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+"\" doesn't satisfy its schema (and can not be migrated automatically): "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t26)),_context3.abrupt("continue",319);case 309:throw _context3.t26;case 310:return _context3.prev=310,_context3.next=313,couchdb.connection.put(newDocument);case 313:_context3.next=318;break;case 315:throw _context3.prev=315,_context3.t27=_context3.catch(310),new Error('Replacing auto migrated document "'+newDocument[idName]+'" has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t27));case 318:console.info('Auto migrating document "'+newDocument[idName]+'" was successful.');case 319:_context3.next=278;break;case 321:return _context3.next=323,couchdb.connection.getIndexes();case 323:if(genericIndexes=_context3.sent.indexes.filter((function(e){return e.name.endsWith("-GenericIndex")})),!configuration.couchdb.createGenericFlatIndex||!configuration.couchdb.model.autoMigrationPath&&0!==genericIndexes.length){_context3.next=375;break}_i4=0,_Object$entries3=Object.entries(models);case 326:if(!(_i4<_Object$entries3.length)){_context3.next=357;break}if(_Object$entries3$_i=_Object$entries3[_i4],_modelName=_Object$entries3$_i[0],_model=_Object$entries3$_i[1],!new RegExp(configuration.couchdb.model.property.name.typePattern.public).test(_modelName)){_context3.next=354;break}return _context3.next=331,couchdb.connection.createIndex({index:{ddoc:_modelName+"-GenericIndex",fields:[typeName],name:_modelName+"-GenericIndex"}});case 331:_iterator15=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model));case 332:if((_step15=_iterator15()).done){_context3.next=354;break}propertyName=_step15.value,_name4=_modelName+"-"+propertyName+"-GenericIndex",foundPosition=-1,position=0,_iterator16=_createForOfIteratorHelperLoose(genericIndexes);case 338:if((_step16=_iterator16()).done){_context3.next=346;break}if(index=_step16.value,index.name!==_name4){_context3.next=343;break}return foundPosition=position,_context3.abrupt("break",346);case 343:position+=1;case 344:_context3.next=338;break;case 346:if(-1!==foundPosition){_context3.next=351;break}return _context3.next=349,couchdb.connection.createIndex({index:{ddoc:_name4,fields:[typeName,propertyName],name:_name4}});case 349:_context3.next=352;break;case 351:genericIndexes.slice(position,1);case 352:_context3.next=332;break;case 354:_i4++,_context3.next=326;break;case 357:_iterator17=_createForOfIteratorHelperLoose(genericIndexes);case 358:if((_step17=_iterator17()).done){_context3.next=375;break}_index=_step17.value,exists=!1,_i5=0,_Object$entries4=Object.entries(models);case 362:if(!(_i5<_Object$entries4.length)){_context3.next=370;break}if(_Object$entries4$_i=_Object$entries4[_i5],_modelName2=_Object$entries4$_i[0],_model2=_Object$entries4$_i[1],!_index.name.startsWith(_modelName2+"-")){_context3.next=367;break}for(_iterator18=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_9__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model2));!(_step18=_iterator18()).done;)_name5=_step18.value,[_modelName2+"-"+_name5+"-GenericIndex",_modelName2+"-GenericIndex"].includes(_index.name)&&(exists=!0);return _context3.abrupt("break",370);case 367:_i5++,_context3.next=362;break;case 370:if(exists){_context3.next=373;break}return _context3.next=373,couchdb.connection.deleteIndex(_index);case 373:_context3.next=358;break;case 375:if(!configuration.couchdb.model.triggerInitialCompaction){_context3.next=384;break}return _context3.prev=376,_context3.next=379,couchdb.connection.compact();case 379:_context3.next=384;break;case 381:_context3.prev=381,_context3.t28=_context3.catch(376),console.warn("Initial database compaction has failed: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_context3.t28));case 384:return _context3.abrupt("return",{couchdb:promise});case 385:case"end":return _context3.stop()}}),_callee3,null,[[17,25,43,46],[29,34,37,40],[54,59,73,76],[62,67],[93,99],[106,114],[118,123],[139,144],[161,165],[184,188],[201,205],[232,242],[249,254],[288,292],[298,302],[310,315],[376,381]])})));return function(){return _ref5.apply(this,arguments)}}(),postLoadService=function(e){var t=e.configuration.couchdb,n=e.pluginAPI,r=e.services,o=r.couchdb,a=0;setInterval((function(){0<a&&(console.info("No additional errors (initially got "+a+" errors through) occurred during observing changes stream for 30 seconds. Clearing saved number of errors through."),a=0)}),3e4);var c=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.debounce)(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _(){var i;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_){for(;;)switch(_.prev=_.next){case 0:return o.changesStream&&o.changesStream.cancel(),i=t.changesStream,void 0!==r.couchdbLastChangesSequenceIdentifier&&(i.since=r.couchdbLastChangesSequenceIdentifier),console.info('Initialize changes stream since "'+i.since+'".'),o.changesStream=o.connection.changes(i),o.changesStream.on("error",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function t(n){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(3<(a+=1))){t.next=9;break}return console.warn("Observing changes feed throws an error for "+a+" times through: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(n)+" Restarting database server and reinitialize changes stream..."),a=0,o.changesStream.cancel(),t.next=7,o.server.restart(e);case 7:t.next=10;break;case 9:console.warn("Observing changes feed throws an error for "+a+" times through: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(n)+" Reinitializing changes stream...");case 10:c();case 11:case"end":return t.stop()}}),t)})))),_.next=8,n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,{data:o.changesStream,hook:"couchdbInitializeChangesStream"}));case 8:console.info("Changes stream initialized."),o.changesStream.on("change",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function t(o){return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=0,t.prev=1,t.next=4,n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,{data:o,hook:"couchdbChange"}));case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),console.error("An error occured durring on change database hook:",t.t0);case 9:r.couchdbLastChangesSequenceIdentifier=o.seq;case 10:case"end":return t.stop()}}),t,null,[[1,6]])}))));case 10:case"end":return _.stop()}}),_)}))));return t.attachAutoRestarter&&c(),Promise.resolve()},shouldExit=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,r,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.configuration,r=t.services,e.next=3,(0,_server__WEBPACK_IMPORTED_MODULE_8__.ds)(r,n);case 3:return delete r.couchdb,o="log.txt",e.next=7,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isFile)(o);case 7:if(!e.sent){e.next=10;break}return e.next=10,fs__WEBPACK_IMPORTED_MODULE_4__.promises.unlink(o);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),database=module.exports;const __WEBPACK_DEFAULT_EXPORT__=database},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},e=>{!function(){"use strict";function t(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={id:e,loaded:!1,exports:{}};return n[e](a,a.exports,t),a.loaded=!0,a.exports}var n=[function(e,t,n){function r(e,t,n){if(a())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var c=new(e.bind.apply(e,r));return n&&o(c,n.prototype),c}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(a=function(){return!!e})()}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t,n=1;n<arguments.length;n++)for(var r in t=arguments[n])({}).hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},c.apply(null,arguments)}function _(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 i(e,t);var n={}.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)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}n.r(t),n.d(t,{authenticate:function(){return s},databaseHelper:function(){return u},default:function(){return p},validateDocumentUpdate:function(){return l}}),e=n.hmd(e);var s=function(e,t,n,r,o,a,c,i,s){var l,u,p;void 0===t&&(t=null),void 0===n&&(n={}),void 0===r&&(r={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===a&&(a="_id"),void 0===c&&(c="-type"),void 0===i&&(i="_design/"),void 0===s&&(s=!1);var d=null!==(l=e[c])&&void 0!==l?l:t&&t[c];if(!d)return!0;var m=s?"read":"write",f={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,a)&&e[a].startsWith(i)&&f.read.push("readonlymember");var b="Current user doesn't own any role";if("name"in n||(n.name='"unknown"'),null!=(u=n.roles)&&u.length){var h;if(o&&d&&Object.prototype.hasOwnProperty.call(o,d)){for(var y,O,x=o[d],g=_(["read","write"]);!(y=g()).done;)f[O=y.value]=f[O].concat(x[O]||[]);f.properties=x.properties}for(var v,E,P=f[m],D=_(n.roles);!(v=D()).done;)if(E=v.value,P.includes(E))return!0;b='Current user "'+(null!==(h=n.name)&&void 0!==h?h:"unknown")+'" owns the following roles: "'+n.roles.join('", "')+'"'}else b='Current user "'+(null!==(p=n.name)&&void 0!==p?p:"unknown")+"\" doesn't own anyrole";throw{unauthorized:"Only users with a least on of these roles are allowed to perform requested "+m+' action: "'+[].concat(f[m]).join('", "')+'". '+b+"."}},l=function(e,t,n,o,a,i,s){void 0===i&&(i={});var l=function(e,t,n){var r;throw void 0===t&&(t="forbidden"),void 0===n&&(n={}),c(((r={})[t]=e,r.message=e,r.name=t,r),n)},u=new Date,p=Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate(),u.getUTCHours(),u.getUTCMinutes(),u.getUTCSeconds(),u.getUTCMilliseconds())/1e3,d=!a.dateTimeFormat.startsWith("iso"),m=a.property.name.special,f=m.id,b=m.revision,h=m.type;t&&t[h]&&!e[h]&&(e[h]=t[h]);var y="",O="",x=function(){y=Object.prototype.hasOwnProperty.call(e,f)?e[f]:"",O=Object.prototype.hasOwnProperty.call(e,b)?e[b]:""};if(x(),Object.prototype.hasOwnProperty.call(o,a.property.name.validatedDocumentsCache)&&o[a.property.name.validatedDocumentsCache].has(y+"-"+O))return o[a.property.name.validatedDocumentsCache].delete(y+"-"+O),e;["0-latest","0-upsert"].includes(O)&&(t&&Object.prototype.hasOwnProperty.call(t,b)?O=e[b]=t[b]:"0-latest"===O?l("Revision: No old document available to update."):delete e[b]);var g=a.updateStrategy;Object.prototype.hasOwnProperty.call(e,m.strategy)&&(g=e[m.strategy],delete e[m.strategy]);var v,E={};if("migrate"===g)for(var P=0,D=Object.entries(i);P<D.length;P++){var M=D[P],w=M[0],k=M[1];if(Object.prototype.hasOwnProperty.call(k,m.oldType)&&k[m.oldType])for(var C,T,A=_([].concat(k[m.oldType]));!(C=A()).done;)T=C.value,E[T]=w}s?v=s:"undefined"!=typeof JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?v=function(e){return JSON.stringify(e,null,4)}:l('Needed "serializer" is not available.');var I=[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],L=function(e){return e instanceof Error?e+"":v(e)},j=function(e){return"string"==typeof e?e.trim():""},R=function(e){if(d)null!==e&&"number"!=typeof e&&(e=new Date(e),e=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())/1e3);else if(null!==e){e=new Date("number"!=typeof e||isNaN(e)?e:1e3*e);try{e=e.toISOString()}catch(e){}}return e},U=function(e,t,n){if(n.fileName){if(n.fileName.value)return n.fileName.value===t;if(n.fileName.pattern)return[].concat(n.fileName.pattern).some((function(e){return new RegExp(e).test(t)}))}return e===t},W=function(t,n){if(n||(n=e[m.attachment]),t){for(var r,o=0,a=Object.keys(n);o<a.length;o++)if((r=a[o]).startsWith(t))return r}else{var c=Object.keys(n);if(c.length)return c[0]}return null},B=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n={});var o=c({},N,{code:""},n),a=j(e);if(a){var _=(t?"return ":"")+a;o.code=_;var i,s=Object.keys(o);try{i=r(Function,s.concat([_]))}catch(e){l(L(e),"compilation",{code:_,error:e,scope:o})}var u={code:_,result:void 0,scope:o};try{u.result=i.apply(void 0,s.map((function(e){return o[e]})))}catch(e){l(L(e),"runtime",{code:_,error:e,scope:o})}return u}return l("No expression to evaluate provided.","empty"),{code:o.code,result:void 0,scope:o}},K=function(e,t,n,o){void 0===n&&(n=[]),void 0===o&&(o=!1);var c=n.length?" in "+n.join(" -> "):"",s=[],u=function(){Object.prototype.hasOwnProperty.call(e,h)||(t&&Object.prototype.hasOwnProperty.call(t,h)&&["fillUp","migrate"].includes(g)?e[h]=t[h]:l('Type: You have to specify a model type via property "'+h+'"'+c+".")),n.length||new RegExp(a.property.name.typePattern.public).test(e[h])||l('TypeName: You have to specify a model type which matches "'+a.property.name.typePattern.public+'" as public type (given "'+e[h]+'")'+c+"."),Object.prototype.hasOwnProperty.call(i,e[h])||(Object.prototype.hasOwnProperty.call(E,e[h])?e[h]=E[e[h]]:l('Model: Given model "'+e[h]+'" is not specified'+c+"."))};u();var p,y=e[h],O=i[y];Object.prototype.hasOwnProperty.call(O,m.additional)&&O[m.additional]&&(p=O[m.additional]);var v=function(o,a,i,s,u){void 0===u&&(u=["constraintExecution","constraintExpression"]);for(var p,d,m=_(u);!(p=m()).done;)if(d=p.value,Object.prototype.hasOwnProperty.call(i,d)){var f=void 0;try{f=B(i[d].evaluation,d.endsWith("Expression"),{checkPropertyContent:P,model:O,modelName:y,name:a,type:d,newDocument:e,newValue:o,oldDocument:t,oldValue:s,parentNames:n,pathDescription:c,propertySpecification:i})}catch(i){var b,h;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&l('Compilation: Hook "'+d+'" has invalid code "'+i.code+'": "'+(null!==(b=i.message)&&void 0!==b?b:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&l('Runtime: Hook "'+d+'" has throw an error with code "'+i.code+'": "'+(null!==(h=i.message)&&void 0!==h?h:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}if(f&&!f.result){var x,g=j(null==(x=i[d])?void 0:x.description);l(d.charAt(0).toUpperCase()+(d.substring(1)+": ")+(g?r(Function,Object.keys(f.scope).concat(["return "+g])).apply(void 0,Object.values(f.scope)):'Property "'+a+'" should satisfy constraint "'+f.code+'" (given "'+L(o)+'")'+c+"."))}}},P=function(e,t,r,o,a){void 0===a&&(a=!1);var s=[],u=[].concat(r.type?r.type:[]);"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&!Object.prototype.hasOwnProperty.call(e,h)&&1===u.length&&"string"==typeof u[0]&&Object.prototype.hasOwnProperty.call(i,u[0])&&(e[h]=u[0]);for(var p,m,b=!1,y=_(u);!(p=y()).done;)if("string"==typeof(m=p.value)&&Object.prototype.hasOwnProperty.call(i,m)){if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]!==m&&"migrate"===g&&1===u.length&&(e[h]=m,s=n.concat(t+"","migrate nested object type")),"object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype&&Object.prototype.hasOwnProperty.call(e,h)&&e[h]===m){var O=K(e,o,n.concat(t+""),a||r.computed);if(O.changedPath.length&&(s=O.changedPath),e=O.newDocument,L(e)===L({}))return{newValue:void 0,changedPath:s};b=!0;break}1===u.length&&l('NestedType: Under key "'+t+'" isn\'t of type "'+m+'" (given "'+L(e)+'" of type '+typeof e+")"+c+".")}else if("DateTime"===m){var x=e;if(e=R(e),!(d&&("number"!=typeof e||isNaN(e))||!d&&"string"!=typeof e)){b=!0;break}1===u.length&&l('PropertyType: Property "'+t+'" isn\'t of (valid) type "DateTime" (given"'+L(x).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof x+'")'+c+".")}else if("string"==typeof m&&["boolean","integer","number","string"].includes(m)){if(!("number"==typeof e&&isNaN(e)||"integer"!==m&&typeof e!==m||"integer"===m&&parseInt(e,10)!==e)){b=!0;break}1===u.length&&l('PropertyType: Property "'+t+'" isn\'t of (valid) type "'+m+'" (given "'+L(e)+'" of type "'+typeof e+'")'+c+".")}else if("string"==typeof m&&m.startsWith("foreignKey:")){var E=i[m.substring(11)][f].type;if(E===typeof e){b=!0;break}1===u.length&&l('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+E+'" (given "'+L(e)+'" of type "'+typeof e+'")'+c+".")}else{if("any"===m||L(e)===L(m)){b=!0;break}1===u.length&&l('PropertyType: Property "'+t+'" isn\'t value "'+m+'" (given "'+L(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+c+".")}if(b||l('PropertyType: None of the specified types "'+u.join('", "')+'" for property "'+t+'" matches value "'+L(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'"'+c+"."),"string"==typeof e&&("number"==typeof r.minimumLength&&e.length<r.minimumLength&&l('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length "+e.length+")"+c+"."),"number"==typeof r.maximumLength&&e.length>r.maximumLength&&l('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+e.length+")"+c+".")),"number"==typeof e&&("number"==typeof r.minimum&&e<r.minimum&&l('Minimum: Property "'+t+'" (type '+r.type+") must satisfy a minimum of "+r.minimum+" (given "+e+" is too low)"+c+"."),"number"==typeof r.maximum&&e>r.maximum&&l('Maximum: Property "'+t+'" (type '+r.type+") must satisfy a maximum of "+r.maximum+" (given "+e+" is too high)"+c+".")),r.selection){var P=Array.isArray(r.selection)?r.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(r.selection);"DateTime"===r.type&&(P=P.map(R)),P.includes(e)||l('Selection: Property "'+t+'" (type '+r.type+') should be one of "'+P.join('", "')+'". But is "'+e+'"'+c+".")}if(r.pattern){for(var D,M,w=[].concat(r.pattern),k=!1,C=_(w);!(D=C()).done;)if(M=D.value,new RegExp(M).test(e)){k=!0;break}k||l('PatternMatch: Property "'+t+'" should match regular expression pattern "'+w.join('", "')+'" (given "'+e+'")'+c+".")}if(r.invertedPattern)for(var T,A,I=_([].concat(r.invertedPattern));!(T=I()).done;)A=T.value,new RegExp(A).test(e)&&l('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+A+' (given "'+e+'")'+c+".");return v(e,t,r,o),L(e)!==L(o)&&(s=n.concat(t+"","value updated")),{newValue:e,changedPath:s}},D=function(e,t,r,o,c){var _=t[o];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,o)&&L(_)===L(r[o]))return o!==f&&"incremental"===g&&delete t[o],!0;l("Readonly: Property "+o+'" isnot writable (old document "'+L(r)+'")'+c+".")}else l('Readonly: Property "'+o+'" is not writable'+c+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,o)){if(L(_)===L(r[o]))return"incremental"!==g||a.property.name.reserved.concat(m.deleted,f,b).includes(o+"")||delete t[o],!0;"migrate"!==g&&l('Immutable: Property "'+o+'"is not writable (old document "'+L(r)+'")'+c+".")}if(null===_){if(e.nullable)return"incremental"===g&&r&&void 0!==r[o]||delete t[o],r&&Object.prototype.hasOwnProperty.call(r,o)&&(s=n.concat(o+"","delete property")),!0;l('NotNull: Property "'+o+'" should not be "null"'+c+".")}return!1},M=function(e,t,r,o,a){if(!r)for(var i,s,u=_(["onCreateExecution","onCreateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s)){var p=void 0;try{p=B(e[s],s.endsWith("Expression"),{attachmentsTarget:a,checkPropertyContent:P,model:O,modelName:y,name:o+"",type:s,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:n,pathDescription:c,propertySpecification:e})}catch(i){var d,m;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&l('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+o+'": "'+(null!==(d=i.message)&&void 0!==d?d:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+o+'": "'+(null!==(m=i.message)&&void 0!==m?m:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}p&&![null,void 0].includes(p.result)&&(a?a[o]=p.result:t[o]=p.result)}},w=function(e,t,r,o,a){if(!a){if(!Object.prototype.hasOwnProperty.call(t,o))return;e.trim&&"string"==typeof t[o]&&(t[o]=t[o].trim()),e.emptyEqualsNull&&(""===t[o]||Array.isArray(t[o])&&0===t[o].length||null!==t[o]&&"object"==typeof t[o]&&0===Object.keys(t).length)&&(t[o]=null)}for(var i,s,u=_(["onUpdateExecution","onUpdateExpression"]);!(i=u()).done;)if(s=i.value,Object.prototype.hasOwnProperty.call(e,s))try{var p=B(e[s],s.endsWith("Expression"),{attachmentsTarget:a,checkPropertyContent:P,model:O,modelName:y,name:o+"",type:s,newDocument:t,oldDocument:r,newValue:t[o],oldValue:r&&r[o]||void 0,parentNames:n,pathDescription:c,propertySpecification:e});a?a[o]=p.result:void 0!==p.result&&(t[o]=p.result)}catch(i){var d,m;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(i)&&l('Compilation: Hook "'+s+'" has invalid code "'+i.code+'" for property "'+o+'": "'+(null!==(d=i.message)&&void 0!==d?d:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(i)&&l('Runtime: Hook "'+s+'" has throw an error with code "'+i.code+'" for property "'+o+'": "'+(null!==(m=i.message)&&void 0!==m?m:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(i,"empty"))throw i}},k=Object.keys(O).filter((function(e){return!I.includes(e)}));if("migrate"===g)for(var C,T,A=_(k);!(C=A()).done;)if(T=C.value,O[T].oldName)for(var W,N,S=_([].concat(O[T].oldName));!(W=S()).done;)N=W.value,Object.prototype.hasOwnProperty.call(e,N)&&(e[T]=e[N],delete e[N]);if(!t)for(var q,$=0,z=[m.create.execution,m.create.expression];$<z.length;$++)if(q=z[$],Object.prototype.hasOwnProperty.call(O,q)){var F=void 0;try{F=B(O[q],q.endsWith("Expression"),{checkPropertyContent:P,model:O,modelName:y,type:q,newDocument:e,oldDocument:t,parentNames:n,pathDescription:c}).result}catch(o){var G,H;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(o)&&l('Compilation: Hook "'+q+'" has invalid code "'+o.code+'" for document "'+y+'": "'+(null!==(G=o.message)&&void 0!==G?G:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(o)&&l('Runtime: Hook "'+q+'" has throw an error with code "'+o.code+'" for document "'+y+'": "'+(null!==(H=o.message)&&void 0!==H?H:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(o,"empty"))throw o}[null,void 0].includes(F)||(e=F),u(),y=e[h],0===n.length&&x()}for(var V,J=0,Y=[m.update.execution,m.update.expression];J<Y.length;J++)if(V=Y[J],Object.prototype.hasOwnProperty.call(O,V)){var X=void 0;try{X=B(O[V],V.endsWith("Expression"),{checkPropertyContent:P,model:O,modelName:y,type:V,newDocument:e,oldDocument:t,parentNames:n,pathDescription:c}).result}catch(o){var Z,Q;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(o)&&l('Compilation: Hook "'+V+'" has invalid code "'+o.code+'" for document "'+y+'": "'+(null!==(Z=o.message)&&void 0!==Z?Z:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(o)&&l('Runtime: Hook "'+V+'" has throw an error with code "'+o.code+'" for document "'+y+'": "'+(null!==(Q=o.message)&&void 0!==Q?Q:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(o,"empty"))throw o}[void 0,null].includes(X)||(e=X),u(),y=e[h],0===n.length&&x()}for(var ee,te,ne=p?Object.keys(e).filter((function(e){return!k.includes(e)})):[],re=_(k.concat(ne));!(ee=re()).done;)if(te=ee.value,m.attachment===te)for(var oe=function(){var r=ce[ae],o=r[0],a=r[1];e[m.attachment]||(e[m.attachment]={}),t&&!Object.prototype.hasOwnProperty.call(t,te)&&(t[m.attachment]={});var i=e[m.attachment],u=Object.keys(i).filter((function(e){return null!==i[e].data&&U(o,e,a)})),p=[];if(t){var d=t[te];p=Object.keys(d).filter((function(e){return!(Object.prototype.hasOwnProperty.call(i,e)&&Object.prototype.hasOwnProperty.call(i[e],"data")&&null===i[e].data)&&!!d[e]&&(Object.prototype.hasOwnProperty.call(d[e],"data")&&null!==d[e].data||Object.prototype.hasOwnProperty.call(d[e],"stub")&&!!d[e].digest)&&!!U(o,e,a)}))}for(var f,b,h=a,y=_(u);!(f=y()).done;)b=f.value,M(h,e,t&&t[te]?t[te]:null,b,i);for(var O,x,v=_(u);!(O=v()).done;)x=O.value,w(h,e,t&&t[te]?t[te]:null,x,i);if(void 0===h.default){if(h.nullable||0<u.length||0<p.length||l('AttachmentMissing: Missing attachment for type "'+o+'"'+c+"."),"fillUp"===g&&0===u.length&&0<p.length)for(var E,P,D=_(p);!(E=D()).done;)P=E.value,null===i[P]?s=n.concat(te,P,"file removed"):i[P]=t[te][P]}else if(0===u.length)if(0===p.length)for(var k in h.default)Object.prototype.hasOwnProperty.call(h.default,k)&&(i[k]=h.default[k],s=n.concat(te,o,"add default file"));else if("fillUp"===g)for(var C,T,A=_(p);!(C=A()).done;)T=C.value,i[T]=t[te][T]},ae=0,ce=Object.entries(O[m.attachment]);ae<ce.length;ae++)oe();else{var _e=k.includes(te)?O[te]:p;M(_e,e,t,te),w(_e,e,t,te),[null,void 0].includes(_e.default)?(!(_e.nullable||Object.prototype.hasOwnProperty.call(e,te)&&void 0!==e[te]||t&&Object.prototype.hasOwnProperty.call(t,te)&&"replace"!==g)&&l('MissingProperty: Missing property "'+te+'"'+c+"."),!o&&!_e.computed&&(!Object.prototype.hasOwnProperty.call(e,te)||void 0===e[te])&&t&&Object.prototype.hasOwnProperty.call(t,te)&&("fillUp"===g?e[te]=t[te]:"replace"===g&&(s=n.concat(te+"","property removed")))):(!Object.prototype.hasOwnProperty.call(e,te)||[null,void 0].includes(e[te]))&&(t?o||_e.computed||null===e[te]||"fillUp"!==g?"migrate"===g&&(e[te]=_e.default,s=n.concat(te+"","migrate default value")):e[te]=t[te]:(e[te]=_e.default,s=s.concat(te+"","add default value")))}if(t&&"incremental"===g)for(var ie=0,se=Object.entries(e);ie<se.length;ie++){var le=se[ie],ue=le[0],pe=le[1];Object.prototype.hasOwnProperty.call(t,ue)&&!a.property.name.reserved.concat(f,b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,h).includes(ue)&&(t[ue]===pe||L(t[ue])===L(pe))&&delete e[ue]}for(var de=0,me=Object.entries(e);de<me.length;de++){var fe=me[de],be=fe[0],he=fe[1];if(!a.property.name.reserved.concat(b,m.conflict,m.deleted,m.deletedConflict,m.localSequence,m.revisions,m.revisionsInformation,m.strategy).includes(be)){var ye=void 0;if(Object.prototype.hasOwnProperty.call(O,be))ye=O[be];else if(p)ye=p;else{if("migrate"===g){delete e[be],s=n.concat(be+"","migrate removed property");continue}l('Property: Given property "'+be+'" isn\'t specified in model "'+y+'"'+c+".")}if(!ye)continue;if(m.attachment===be){var Oe=he;for(var xe in Oe)if(Object.prototype.hasOwnProperty.call(Oe,xe))for(var ge=0,ve=Object.keys(O[be]);ge<ve.length;ge++){var Ee=ve[ge],Pe=O[m.attachment][Ee];if(U(Ee,xe,Pe)){D(Pe,e,t,xe,c);break}}continue}if(D(ye,e,t,be,c))continue;var De="string"==typeof ye.type&&ye.type.endsWith("[]")||Array.isArray(ye.type)&&ye.type.length&&Array.isArray(ye.type[0]);if(De&&![null,void 0].includes(he)){var Me=he;Array.isArray(Me)?"number"==typeof ye.minimumNumber&&Me.length<ye.minimumNumber?l('MinimumArrayLength: Property "'+be+'" (array of length '+Me.length+") doesn't fulfill minimum array length of "+ye.minimumNumber+c+"."):"number"==typeof ye.maximumNumber&&ye.maximumNumber<Me.length&&l('MaximumArrayLength: Property "'+be+'" (array of length '+Me.length+") doesn't fulfill maximum array length of "+ye.maximumNumber+c+"."):l('PropertyType: Property "'+be+'" isn\'t of type "array -> '+ye.type+'" (given"'+L(Me)+'")'+c+"."),v(Me,be+"",ye,t&&Object.prototype.hasOwnProperty.call(t,be)&&t[be]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var we={};for(var ke in ye)if(Object.prototype.hasOwnProperty.call(ye,ke))if("type"===ke){var Ce=ye[ke];we[ke]=Array.isArray(ye[ke])?Ce[0]:[Ce.substring(0,Ce.length-2)]}else we[ke]=ye[ke];if(Array.isArray(we.type)&&1===we.type.length&&"string"==typeof we.type[0]&&Object.prototype.hasOwnProperty.call(i,we.type[0]))for(var Te,Ae,Ie=_(Me.slice());!(Te=Ie()).done;)"object"!=typeof(Ae=Te.value)||Object.getPrototypeOf(Ae)!==Object.prototype||Object.prototype.hasOwnProperty.call(Ae,h)||(Ae[h]=we.type[0]);for(var Le,je,Re=0,Ue=_(Me.slice());!(Le=Ue()).done;)je=Le.value,Me[Re]=P(je,Re+1+". value in "+be,we,void 0,o||we.computed).newValue,[null,void 0].includes(Me[Re])&&Me.splice(Re,1),Re+=1;t&&Object.prototype.hasOwnProperty.call(t,be)&&Array.isArray(t[be])&&t[be].length===Me.length&&L(t[be])===L(Me)||(s=n.concat(be+"","array updated"))}else{var We=t&&Object.prototype.hasOwnProperty.call(t,be)?t[be]:void 0,Be=De?{newValue:null,changedPath:[]}:P(he,be+"",ye,We,o||ye.computed);e[be]=Be.newValue,Be.changedPath.length&&(s=Be.changedPath),null===e[be]&&(void 0===We?"fillUp"===g&&delete e[be]:s=n.concat(be+"","property removed")),void 0===e[be]&&"incremental"===g&&delete e[be]}}}for(var Ke=0,Ne=Object.keys(m.constraint);Ke<Ne.length;Ke++){var Se=Ne[Ke],qe=m.constraint[Se];if(Object.prototype.hasOwnProperty.call(O,qe))for(var $e,ze=O[qe],Fe=_([].concat(ze));!($e=Fe()).done;){var Ge=$e.value,He=void 0;try{He=B(Ge.evaluation,qe===m.constraint.expression,{checkPropertyContent:P,model:O,modelName:y,type:qe,newDocument:e,oldDocument:t,parentNames:n,pathDescription:c})}catch(o){var Ve,Je;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(o)&&l('Compilation: Hook "'+qe+'" has invalid code "'+o.code+'": "'+(null!==(Ve=o.message)&&void 0!==Ve?Ve:"unknown")+'"'+c+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(o)&&l('Runtime: Hook "'+qe+'" has thrown an error with code "'+o.code+'": "'+(null!==(Je=o.message)&&void 0!==Je?Je:"unknown")+'"'+c+"."),!Object.prototype.hasOwnProperty.call(o,"empty"))throw o}if(He&&!He.result){var Ye=qe.replace(/^[^a-zA-Z]+/,"");l(Ye.charAt(0).toUpperCase()+(Ye.substring(1)+": ")+(Ge.description?r(Function,Object.keys(He.scope).concat(["return "+Ge.description.trim()])).apply(void 0,Object.values(He.scope)):'Model "'+y+'" should satisfy constraint "'+He.code+'" (given "'+L(e)+'")'+c+"."))}}}if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var Xe,Ze,Qe=e[m.attachment];("object"!=typeof Qe||Object.getPrototypeOf(Qe)!==Object.prototype)&&l("AttachmentType: given attachment has invalid type"+c+".");var et=null;if(t&&Object.prototype.hasOwnProperty.call(t,m.attachment)&&null!==(et=t[m.attachment])&&"object"==typeof et)for(var tt=0,nt=Object.entries(et);tt<nt.length;tt++){var rt=nt[tt],ot=rt[0],at=rt[1];if(at&&Object.prototype.hasOwnProperty.call(Qe,ot)){var ct=Qe[ot];null===ct||null===ct.data||ct.content_type===at.content_type&&(ct.data===at.data||ct.digest===at.digest)?((null===ct||null===ct.data)&&(s=n.concat(m.attachment,ot,"attachment removed")),"incremental"===g&&delete Qe[ot]):s=n.concat(m.attachment,ot,"attachment updated")}else"fillUp"===g?Qe[ot]=at:"replace"===g&&(s=n.concat(m.attachment,ot,"attachment removed"))}for(var _t=0,it=Object.entries(Qe);_t<it.length;_t++){var st,lt=it[_t],ut=lt[0],pt=lt[1];if(!pt)break;null===pt.data?delete Qe[ut]:(!et||!Object.prototype.hasOwnProperty.call(et,ut)||pt.content_type!==(null==(st=et[ut])?void 0:st.content_type)||pt.data!==et[ut].data&&pt.digest!==et[ut].digest)&&(s=n.concat(m.attachment,ut,"attachment updated"))}0===Object.keys(Qe).length&&delete e[m.attachment];for(var dt=O[m.attachment],mt={},ft=0,bt=Object.keys(dt);ft<bt.length;ft++)mt[bt[ft]]=[];for(var ht=0,yt=Object.keys(Qe);ht<yt.length;ht++){for(var Ot=yt[ht],xt=!1,gt=0,vt=Object.entries(dt);gt<vt.length;gt++){var Et=vt[gt],Pt=Et[0],Dt=Et[1];if(U(Pt,Ot,Dt)){mt[Pt].push(Ot),xt=!0;break}}xt||l('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(dt).join('", "')+'") matches given one ("'+Ot+'")'+c+".")}for(var Mt=0,wt=0,kt=Object.keys(mt);wt<kt.length;wt++){var Ct=kt[wt],Tt=dt[Ct];if(Object.prototype.hasOwnProperty.call(mt,Ct)){var At=mt[Ct].length;"number"==typeof Tt.maximumNumber&&At>Tt.maximumNumber&&l("AttachmentMaximum: given number of attachments ("+At+") doesn't satisfy specified maximum of "+Tt.maximumNumber+' from type "'+Ct+'"'+c+"."),(!Tt.nullable||0!==At)&&"number"==typeof Tt.minimumNumber&&At<Tt.minimumNumber&&l("AttachmentMinimum: given number of attachments ("+At+") doesn't satisfy specified minimum of "+Tt.minimumNumber+' from type "'+Ct+'"'+c+".");for(var It,Lt=0,jt=_(mt[Ct]);!(It=jt()).done;){var Rt,Ut,Wt,Bt=It.value;if(null!=(Rt=Tt.fileName)&&Rt.pattern){for(var Kt,Nt,St=[].concat(Tt.fileName.pattern),qt=!1,$t=_(St);!(Kt=$t()).done;)if(Nt=Kt.value,new RegExp(Nt).test(Bt)){qt=!0;break}qt||l('AttachmentName: given attachment name "'+Bt+'" doesn\'t satisfy one of specified regular expression patterns "'+St.join('", "')+'" from type "'+Ct+'"'+c+".")}if(null!=(Ut=Tt.fileName)&&Ut.invertedPattern)for(var zt,Ft,Gt=_([].concat(Tt.fileName.invertedPattern));!(zt=Gt()).done;)Ft=zt.value,new RegExp(Ft).test(Bt)&&l('InvertedAttachmentName: given attachment name "'+Bt+'" does satisfy specified regular expression pattern "'+Ft.toString()+'" from type "'+Ct+'"'+c+".");if(null!=(Wt=Qe[Bt])&&Wt.content_type){if(Tt.contentTypePattern){for(var Ht,Vt,Jt=[].concat(Tt.contentTypePattern),Yt=!1,Xt=_(Jt);!(Ht=Xt()).done;)if(Vt=Ht.value,new RegExp(Vt).test(Qe[Bt].content_type)){Yt=!0;break}Yt||l('AttachmentContentType: given attachment content type "'+Qe[Bt].content_type+'" doesn\'t satisfy specified regular expression pattern "'+Jt.join('", "')+'" from type "'+Ct+'"'+c+".")}var Zt=Tt.invertedContentTypePattern;if(Zt)for(var Qt,en,tn=_([].concat(Zt));!(Qt=tn()).done;)en=Qt.value,new RegExp(en).test(Qe[Bt].content_type)&&l('InvertedAttachmentContentType: given attachment content type "'+Qe[Bt].content_type+'" does satisfy specified regular expression pattern "'+en.toString()+'" from type "'+Ct+'"'+c+".")}var nn=0;Qe[Bt]&&"length"in Qe[Bt]?nn=Qe[Bt].length:Qe[Bt]&&"data"in Qe[Bt]&&(nn="undefined"!=typeof Buffer&&"byteLength"in Buffer?Buffer.byteLength(Qe[Bt].data,"base64"):Qe[Bt].data.length),"number"==typeof Tt.minimumSize&&Tt.minimumSize>nn?l("AttachmentMinimumSize: given attachment size "+nn+" byte doesn't satisfy specified minimum of "+Tt.minimumSize+" byte "+c+"."):"number"==typeof Tt.maximumSize&&Tt.maximumSize<nn&&l("AttachmentMaximumSize: given attachment size "+nn+" byte doesn't satisfy specified maximum of "+Tt.maximumSize+" byte "+c+"."),Lt+=nn}"number"==typeof Tt.minimumAggregatedSize&&Tt.minimumAggregatedSize>Lt?l('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+Ct+'" '+Lt+" byte doesn't satisfy specified minimum of "+Tt.minimumAggregatedSize+" byte "+c+"."):"number"==typeof Tt.maximumAggregatedSize&&Tt.maximumAggregatedSize<Lt&&l('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+Ct+'" '+Lt+" byte doesn't satisfy specified maximum of "+Tt.maximumAggregatedSize+" byte "+c+"."),Mt+=Lt}}(null!==(Xe=O[m.minimumAggregatedSize])&&void 0!==Xe?Xe:0)>Mt?l("AggregatedMinimumSize: given aggregated size "+Mt+" byte doesn't satisfy specified minimum of "+O[m.minimumAggregatedSize]+" byte "+c+"."):(null!==(Ze=O[m.maximumAggregatedSize])&&void 0!==Ze?Ze:1/0)<Mt&&l("AggregatedMaximumSize: given aggregated size "+Mt+" byte doesn't satisfy specified maximum of "+O[m.maximumAggregatedSize]+" byte "+c+".")}if(t&&Object.prototype.hasOwnProperty.call(t,m.attachment)&&0===Object.keys(t[m.attachment]).length&&delete t[m.attachment],0===s.length&&t&&"migrate"===g)for(var rn,on=0,an=Object.keys(t);on<an.length;on++)rn=an[on],Object.prototype.hasOwnProperty.call(e,rn)||(s=n.concat(rn,"migrate removed property"));return{changedPath:s,newDocument:e}},N={attachmentWithPrefixExists:function(t){if(Object.prototype.hasOwnProperty.call(e,m.attachment)){var n=e[m.attachment],r=W(t);if(r)return Object.prototype.hasOwnProperty.call(n[r],"stub")&&n[r].stub||Object.prototype.hasOwnProperty.call(n[r],"data")&&![null,void 0].includes(n[r].data)}return!1},checkDocument:K,getFileNameByPrefix:W,serialize:L,id:y,revision:O,idName:f,revisionName:b,specialNames:m,typeName:h,modelConfiguration:a,models:i,now:u,nowUTCTimestamp:p,securitySettings:o,userContext:n},S=e[m.attachment];if(e[m.attachment])for(var q,$=0,z=Object.values(S);$<z.length;$++)null!=(q=z[$])&&q.contentType&&(q.content_type=q.contentType,delete q.contentType);var F=K(e,t);return(!F.newDocument._deleted||t)&&(F.newDocument._deleted&&F.newDocument._deleted!==(null==t?void 0:t._deleted)||F.changedPath.length)||l("NoChange: No new data given. new document: "+L(e)+"; old document: "+L(t)+"."),Object.prototype.hasOwnProperty.call(o,a.property.name.validatedDocumentsCache)?o[a.property.name.validatedDocumentsCache].add(y+"-"+O):o[a.property.name.validatedDocumentsCache]=new Set([y+"-"+O]),F.newDocument},u=e.exports,p=u}],r={};t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:function(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e},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=t(0);e.exports=o}()},e=>{"use strict";e.exports=require("pouchdb-node")},e=>{"use strict";e.exports=require("pouchdb-find")},e=>{"use strict";e.exports=require("child_process")},e=>{"use strict";e.exports=require("pouchdb-node/node_modules/node-fetch/lib/index.js")},,(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{S8:()=>restart,ds:()=>stop,ni:()=>start});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1),_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__(2),_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__(3),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),child_process__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(11),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),node_fetch__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(12),node_fetch__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_5__),fs__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(6),fs__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(7),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__),_helper__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(0),_this=void 0;function _createForOfIteratorHelperLoose(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=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 n={}.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)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch=node_fetch__WEBPACK_IMPORTED_MODULE_5___default();var start=function(){var _ref=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee(services,configuration){var server,runner,binary;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(server=services.couchdb.server,runner=server.runner,binary=configuration.couchdb.binary,!runner.configurationFile){_context.next=15;break}return _context.prev=4,_context.next=7,fs__WEBPACK_IMPORTED_MODULE_6__.promises.mkdir((0,path__WEBPACK_IMPORTED_MODULE_7__.dirname)(runner.configurationFile.path),{recursive:!0});case 7:_context.next=13;break;case 9:if(_context.prev=9,_context.t0=_context.catch(4),"EEXIST"===_context.t0.code){_context.next=13;break}throw _context.t0;case 13:return _context.next=15,fs__WEBPACK_IMPORTED_MODULE_6__.promises.writeFile(runner.configurationFile.path,runner.configurationFile.content,{encoding:configuration.core.encoding});case 15:return server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_3__.spawn)("default"===binary.memoryInMegaByte?runner.binaryFilePath:binary.nodePath,("default"===binary.memoryInMegaByte?[]:["--max-old-space-size="+binary.memoryInMegaByte,runner.binaryFilePath]).concat(runner.arguments?runner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(runner,"environment")?_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},eval("process").env,runner.environment):eval("process").env,shell:!0,stdio:"inherit"}),new Promise((function(e,t){for(var n,r=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CLOSE_EVENT_NAMES);!(n=r()).done;){var o,a=n.value;null==(o=server.process)||o.on(a,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.getProcessCloseHandler)(e,t,{process:server.process,reason:a}))}})).then((function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.resolve&&services.couchdb.server.resolve.call(_this,e)}),(function(e){var t;null!=(t=services.couchdb)&&null!=(t=t.server)&&t.reject&&services.couchdb.server.reject.call(_this,e)})),_context.next=19,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.checkReachability)((0,clientnode__WEBPACK_IMPORTED_MODULE_4__.format)(configuration.couchdb.url,""),{wait:!0});case 19:case"end":return _context.stop()}}),_callee,null,[[4,9]])})));return function(){return _ref.apply(this,arguments)}}(),restart=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,r,o,a,c,_;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.configuration,r=t.pluginAPI,o=t.services,a=o.couchdb.server,c=a.resolve,_=a.reject,a.resolve=a.reject=clientnode__WEBPACK_IMPORTED_MODULE_4__.NOOP,e.next=7,stop(o,n);case 7:return a.resolve=c,a.reject=_,e.next=11,start(o,n);case 11:return(0,_helper__WEBPACK_IMPORTED_MODULE_8__.initializeConnection)(o,n),e.next=14,r.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},t,{hook:"restartCouchdb"}));case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),stop=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,n){var r,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.couchdb,o=n.couchdb,r.connection.close(),r.server.process&&r.server.process.kill("SIGINT"),e.next=6,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.checkUnreachability)((0,clientnode__WEBPACK_IMPORTED_MODULE_4__.format)(o.url,""),{wait:!0});case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e](n,n.exports,__webpack_require__),n.loaded=!0,n.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 n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),__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__=__webpack_require__(5);module.exports=__webpack_exports__})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "couchdb-web-node-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.684",
|
|
4
4
|
"description": "A couchdb server, model instance conflict handler, rest api, authentication, session management, schema validator and model relation guarantee for webNode.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -66,26 +66,26 @@
|
|
|
66
66
|
"pouchdb-server": "^4.2.0"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@babel/eslint-parser": "^7.
|
|
69
|
+
"@babel/eslint-parser": "^7.26.5",
|
|
70
70
|
"@babel/runtime": "^7.26.0",
|
|
71
|
-
"@stylistic/eslint-plugin-ts": "^2.
|
|
71
|
+
"@stylistic/eslint-plugin-ts": "^2.13.0",
|
|
72
72
|
"@types/ejs": "^3.1.5",
|
|
73
|
-
"@types/node": "^22.10.
|
|
73
|
+
"@types/node": "^22.10.6",
|
|
74
74
|
"@types/pouchdb-node": "^6.1.7",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
76
|
-
"@typescript-eslint/parser": "^8.
|
|
77
|
-
"clientnode": "^3.0.
|
|
78
|
-
"documentation-website": "^1.0.
|
|
79
|
-
"eslint": "^9.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.20.0",
|
|
76
|
+
"@typescript-eslint/parser": "^8.20.0",
|
|
77
|
+
"clientnode": "^3.0.1256",
|
|
78
|
+
"documentation-website": "^1.0.342",
|
|
79
|
+
"eslint": "^9.18.0",
|
|
80
80
|
"eslint-config-google": "^0.14.0",
|
|
81
81
|
"eslint-plugin-jsdoc": "^50.6.1",
|
|
82
82
|
"jest": "^29.7.0",
|
|
83
83
|
"jsdoc": "^4.0.4",
|
|
84
84
|
"node-fetch": "^3.3.2",
|
|
85
85
|
"rimraf": "^6.0.1",
|
|
86
|
-
"typescript-eslint": "^8.
|
|
87
|
-
"web-node": "^1.0.
|
|
88
|
-
"weboptimizer": "^2.0.
|
|
86
|
+
"typescript-eslint": "^8.20.0",
|
|
87
|
+
"web-node": "^1.0.539",
|
|
88
|
+
"weboptimizer": "^2.0.1553"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"@babel/runtime": "*",
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
]
|
|
200
200
|
},
|
|
201
201
|
"changesStream": {
|
|
202
|
-
"include_docs":
|
|
202
|
+
"include_docs": false,
|
|
203
203
|
"live": true,
|
|
204
204
|
"since": "now",
|
|
205
205
|
"timeout": false
|
package/type.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ChildProcess } from 'child_process';
|
|
2
2
|
import { AnyFunction, Mapping, PlainObject, Primitive, ProcessCloseReason, UTILITY_SCOPE } from 'clientnode';
|
|
3
3
|
import { Configuration as BaseConfiguration, PluginHandler as BasePluginHandler, ServicePromises as BaseServicePromises, Services as BaseServices, ServicePromisesState as BaseServicePromisesState, ServicesState as BaseServicesState } from 'web-node/type';
|
|
4
|
-
import databaseHelper from './databaseHelper';
|
|
5
4
|
export type Attachment = PouchDB.Core.Attachment & {
|
|
6
5
|
content_type?: PouchDB.Core.Attachment['content_type'];
|
|
7
6
|
contentType?: PouchDB.Core.Attachment['content_type'];
|
|
@@ -61,7 +60,7 @@ export interface Constraint {
|
|
|
61
60
|
export declare const PrimitiveTypes: readonly ["boolean", "DateTime", "integer", "number", "string"];
|
|
62
61
|
export type PrimitiveType = typeof PrimitiveTypes[number];
|
|
63
62
|
export type Type = boolean | number | string;
|
|
64
|
-
export type TypeSpecification = Array<
|
|
63
|
+
export type TypeSpecification = Array<Type> | Array<Array<Type>> | Type;
|
|
65
64
|
export type ConstraintKey = 'arrayConstraintExecution' | 'arrayConstraintExpression' | 'conflictingConstraintExecution' | 'conflictingConstraintExpression' | 'constraintExecution' | 'constraintExpression';
|
|
66
65
|
export interface SelectionMapping {
|
|
67
66
|
label: string;
|
|
@@ -294,6 +293,7 @@ export type ServicePromises<Type = Mapping<unknown>> = BaseServicePromises<{
|
|
|
294
293
|
}> & Type;
|
|
295
294
|
export type Services<Type = Mapping<unknown>> = BaseServices<{
|
|
296
295
|
couchdb: CouchDB;
|
|
296
|
+
couchdbLastChangesSequenceIdentifier?: number | string;
|
|
297
297
|
}> & Type;
|
|
298
298
|
export type ServicesState<Type = undefined> = BaseServicesState<Type, Configuration, Services>;
|
|
299
299
|
export type State<Type = undefined> = BaseServicePromisesState<Type, Configuration, Services, ServicePromises>;
|
|
@@ -384,7 +384,7 @@ export interface CheckedDocumentResult<ObjectType extends object, AdditionalProp
|
|
|
384
384
|
}
|
|
385
385
|
export type Migrator<Type extends object = object, AttachmentType extends Attachment = Attachment, AdditionalSpecifications extends object = object, AdditionalPropertiesType = unknown> = (document: Document, scope: (typeof UTILITY_SCOPE & {
|
|
386
386
|
configuration: Configuration;
|
|
387
|
-
databaseHelper:
|
|
387
|
+
databaseHelper: object;
|
|
388
388
|
idName: string;
|
|
389
389
|
typeName: string;
|
|
390
390
|
migrators: Mapping<Migrator<Type, AttachmentType, AdditionalSpecifications, AdditionalPropertiesType>>;
|