@nmshd/consumption 1.0.9 → 1.0.13

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.
@@ -1,2 +1,2 @@
1
- var NMSHDConsumption;(()=>{"use strict";var e={500:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildInformation=void 0;const i=r(194),o=r(30),n=r(890),a=r(663);t.buildInformation={version:"1.0.9",build:"11",date:"2021-12-21T13:20:41+00:00",commit:"8c9ee503dff9ab6d92e5c9316a2e1bc94308a719",dependencies:{},libraries:{transport:a.buildInformation,crypto:n.buildInformation,serval:i.buildInformation,content:o.buildInformation}}},136:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionBaseController=void 0;const i=r(194),o=r(663);t.ConsumptionBaseController=class ConsumptionBaseController{constructor(e,t){this._parent=t,this._log=o.TransportLoggerFactory.getLogger(e)}get log(){return this._log}get parent(){return this._parent}init(){return Promise.resolve(this)}async parseObject(e,t){return await i.SerializableAsync.fromT(e,t)}async parseArray(e,t,r){const i=[];for(let n=0,a=e.length;n<a;n++)if(r){const a=e[n];if(!a[r]){const e=o.TransportErrors.controller.contentPropertyUndefined(r);throw this._log.error(e),e}i.push(this.parseObject(a[r],t))}else i.push(this.parseObject(e[n],t));return await Promise.all(i)}}},793:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionController=void 0;const i=r(662);t.ConsumptionController=class ConsumptionController{constructor(e,t){this.transport=e,this.accountController=t}get attributes(){return this._attributes}get drafts(){return this._drafts}get requests(){return this._requests}get settings(){return this._settings}get sharedItems(){return this._sharedItems}get relationshipInfo(){return this._relationshipInfo}async init(){return this._attributes=await new i.ConsumptionAttributesController(this).init(),this._drafts=await new i.DraftsController(this).init(),this._requests=await new i.RequestsController(this).init(),this._settings=await new i.SettingsController(this).init(),this._sharedItems=await new i.SharedItemsController(this).init(),this._relationshipInfo=await new i.RelationshipInfoController(this).init(),this}}},47:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionControllerName=void 0,function(e){e.ConsumptionAttributesController="ConsumptionAttributesController",e.DraftsController="DraftsController",e.RelationshipInfoController="RelationshipInfoController",e.SingleRelationshipController="SingleRelationshipController",e.OnboardingFlowController="OnboardingFlowController",e.OffboardingFlowController="OffboardingFlowController",e.RequestsController="Requestsontroller",e.SettingsController="SettingsController",e.SharedItemsController="SharedItemsController"}(t.ConsumptionControllerName||(t.ConsumptionControllerName={}))},926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionErrors=void 0;const i=r(663);class ConsumptionErrors{}t.ConsumptionErrors=ConsumptionErrors,ConsumptionErrors.attributes=new class Attributes{attributeExists(e){return new i.CoreError("error.consumption.attributes.attributeExists",`Attribute with name ${e} already exists. Please use succeed instead.`)}},ConsumptionErrors.requests=new class Requests{requestsExists(e){return new i.CoreError("error.consumption.requests.requestExists",`Request with id ${e} already exists and can't be created.`)}},ConsumptionErrors.relationshipInfo=new class RelationshipInfo{relationshipInfoExists(e){return new i.CoreError("error.consumption.relationshipInfos.relationshipInfoExists",`RelationshipInfo for Relationship ${e} already exists.`)}},ConsumptionErrors.onboarding=new class Onboarding{attributeNotSet(e){return new i.CoreError("error.consumption.onboarding.attributeNotSet",`No attribute with name ${e} set but was required to be shared.`)}wrongTemplate(){return new i.CoreError("error.consumption.onboarding.wrongTemplate","The given template is in the wrong format.")}}},265:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionIds=void 0;const i=r(663);class ConsumptionIds{}t.ConsumptionIds=ConsumptionIds,ConsumptionIds.attribute=new i.CoreIdHelper("CNSATT"),ConsumptionIds.draft=new i.CoreIdHelper("CNSDRF"),ConsumptionIds.relationshipInfo=new i.CoreIdHelper("CNSRIN"),ConsumptionIds.sharedItem=new i.CoreIdHelper("CNSSIT"),ConsumptionIds.response=new i.CoreIdHelper("CNSRES"),ConsumptionIds.request=new i.CoreIdHelper("CNSREQ"),ConsumptionIds.setting=new i.CoreIdHelper("CNSSET")},997:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(136),t),o(r(47),t),o(r(926),t),o(r(265),t)},590:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(500),t),o(r(793),t),o(r(265),t),o(r(662),t)},896:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttributesController=void 0;const i=r(663),o=r(714),n=r(997),a=r(192);class ConsumptionAttributesController extends n.ConsumptionBaseController{constructor(e){super(n.ConsumptionControllerName.ConsumptionAttributesController,e)}async init(){return await super.init(),this.attributes=await this.parent.accountController.getSynchronizedCollection("Attributes"),this}checkValid(e){const t=i.CoreDate.utc();return!e.content.validFrom&&!e.content.validTo||(!(!e.content.validFrom||e.content.validTo||!e.content.validFrom.isSameOrBefore(t))||(!(e.content.validFrom||!e.content.validTo||!e.content.validTo.isAfter(t))||!!(e.content.validFrom&&e.content.validTo&&e.content.validFrom.isSameOrBefore(t)&&e.content.validTo.isAfter(t))))}findCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt)));let r;for(const e of t)this.checkValid(e)&&(r=e);return r}filterCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt))),r=[];for(const e of t)this.checkValid(e)&&r.push(e);return r}async getAttribute(e){const t=await this.attributes.find({[(0,o.nameof)((e=>e.id))]:e.toString()}),r=await this.parseArray(t,a.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeByName(e){const t=await this.attributes.find({[`${(0,o.nameof)((e=>e.content))}.${(0,o.nameof)((e=>e.name))}`]:e}),r=await this.parseArray(t,a.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeHistoryByName(e){const t=await this.attributes.find({[`${(0,o.nameof)((e=>e.content))}.${(0,o.nameof)((e=>e.name))}`]:e});return(await this.parseArray(t,a.ConsumptionAttribute)).sort(((e,t)=>e.createdAt.compare(t.createdAt)))}async getAttributes(e){const t=await this.attributes.find(e);return await this.parseArray(t,a.ConsumptionAttribute)}async getValidAttributes(e){const t=await this.attributes.find(e),r=await this.parseArray(t,a.ConsumptionAttribute);return this.filterCurrent(r)}async getAttributesByName(e){return(await this.getValidAttributes(e)).reduce(((e,t)=>(e[t.content.name]=t,e)),{})}async createAttribute(e){if(await this.getAttributeByName(e.content.name))throw n.ConsumptionErrors.attributes.attributeExists(e.content.name);return await this.attributes.create(e),e}async succeedAttribute(e,t){const r=await this.getAttributeByName(e.content.name);return r&&!t&&(t=i.CoreDate.utc()),r&&(e.content.validFrom=t,r.content.validTo=t,await this.updateAttribute(r)),await this.attributes.create(e),e}async updateAttribute(e){const t=await this.attributes.findOne({[(0,o.nameof)((e=>e.id))]:e.id.toString()});if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionAttribute,e.id.toString());return await this.attributes.update(t,e),e}async deleteAttribute(e){await this.attributes.delete(e)}}t.ConsumptionAttributesController=ConsumptionAttributesController},192:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttribute=void 0;const a=r(194),s=r(30),l=r(663),d=r(714),c=r(997);let u=i=class ConsumptionAttribute extends l.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,d.nameof)((e=>e.createdAt))],this.userdataProperties=[(0,d.nameof)((e=>e.content))],this.metadataProperties=[(0,d.nameof)((e=>e.metadata)),(0,d.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,i)}static async fromAttribute(e){return await this.from({content:s.Attribute.from(e),id:await c.ConsumptionIds.attribute.generate(),createdAt:l.CoreDate.utc()})}};o([(0,a.validate)(),(0,a.serialize)({type:s.Attribute}),n("design:type",s.Attribute)],u.prototype,"content",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",l.CoreDate)],u.prototype,"createdAt",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),n("design:type",Object)],u.prototype,"metadata",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",l.CoreDate)],u.prototype,"metadataModifiedAt",void 0),u=i=o([(0,a.type)("ConsumptionAttribute")],u),t.ConsumptionAttribute=u},574:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DraftsController=void 0;const i=r(663),o=r(997),n=r(535);class DraftsController extends o.ConsumptionBaseController{constructor(e){super(o.ConsumptionControllerName.DraftsController,e)}async init(){return await super.init(),this.drafts=await this.parent.accountController.getSynchronizedCollection("Drafts"),this}async getDraft(e){const t=await this.drafts.read(e.toString());return t?await n.Draft.from(t):void 0}async getDrafts(e){const t=await this.drafts.find(e);return await this.parseArray(t,n.Draft)}async createDraft(e,t=""){const r=await n.Draft.from({id:await o.ConsumptionIds.draft.generate(),content:e,createdAt:new i.CoreDate,lastModifiedAt:new i.CoreDate,type:t});return await this.drafts.create(r),r}async updateDraft(e){const t=await this.drafts.read(e.id.toString());if(!t)throw new Error("Draft Not Found");await this.drafts.update(t,e)}async deleteDraft(e){await this.drafts.delete(e)}}t.DraftsController=DraftsController},535:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Draft=void 0;const a=r(194),s=r(663),l=r(714);let d=i=class Draft extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.type)),(0,l.nameof)((e=>e.createdAt)),(0,l.nameof)((e=>e.lastModifiedAt))],this.userdataProperties=[(0,l.nameof)((e=>e.content))],this.metadataProperties=[(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,i)}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],d.prototype,"type",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"createdAt",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"lastModifiedAt",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",a.SerializableAsync)],d.prototype,"content",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),n("design:type",Object)],d.prototype,"metadata",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"metadataModifiedAt",void 0),d=i=o([(0,a.type)("Draft")],d),t.Draft=d},662:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),o=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),o(r(896),t),o(r(192),t),o(r(574),t),o(r(535),t),o(r(880),t),o(r(447),t),o(r(155),t),o(r(58),t),o(r(137),t),o(r(637),t),o(r(660),t),o(r(672),t),o(r(943),t),o(r(826),t),o(r(245),t),o(r(750),t)},58:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoController=void 0;const i=r(997),o=r(447),n=r(657);class RelationshipInfoController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.RelationshipInfoController,e)}async init(){return await super.init(),this.relationshipInfo=await this.parent.accountController.getSynchronizedCollection("RelationshipInfo"),this}async getRelationshipInfo(e){const t=await this.relationshipInfo.read(e.toString());return t?await o.RelationshipInfo.from(t):void 0}async getRelationshipInfoByRelationship(e){const t=await this.relationshipInfo.findOne({relationshipId:e.toString()});if(t)return await o.RelationshipInfo.from(t);const r=await new n.RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(e);return await this.relationshipInfo.create(r),r}async getRelationshipInfos(e){const t=await this.relationshipInfo.find(e);return await this.parseArray(t,o.RelationshipInfo)}async createRelationshipInfo(e){if(await this.relationshipInfo.exists({relationshipId:e.relationshipId}))throw i.ConsumptionErrors.relationshipInfo.relationshipInfoExists(e.relationshipId.toString());return await this.relationshipInfo.create(e),e}async updateRelationshipInfo(e){const t=await this.relationshipInfo.read(e.id.toString());if(!t)throw new Error("RelationshipInfo Not Found");await this.relationshipInfo.update(t,e)}async deleteRelationshipInfo(e){await this.relationshipInfo.delete(e)}}t.RelationshipInfoController=RelationshipInfoController},657:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoUtil=void 0;const i=r(30),o=r(663),n=r(997),a=r(943),s=r(880),l=r(447);class RelationshipInfoUtil{constructor(e){this.parent=e,this._log=o.TransportLoggerFactory.getLogger(RelationshipInfoUtil)}get log(){return this._log}async createInitialRelationshipInfo(e){const t=await this.parent.accountController.relationships.getRelationship(e);if(!t)throw o.TransportErrors.general.recordNotFound(o.Relationship,e.toString()).logWith(this._log);const r=await this.parent.accountController.relationshipTemplates.getRelationshipTemplate(t.cache.template.id);if(!r)throw o.TransportErrors.general.recordNotFound(o.RelationshipTemplate,t.cache.template.id.toString()).logWith(this._log);return await this.parseTemplateBody(t,r),await this.parseCreationRequest(t),await this.createRelationshipInfo(t)}getTitle(e,t){var r,i,o,n,a,s;let l=e.peer.address.toString().substring(3,9);const d=null===(r=t.get("Thing.name"))||void 0===r?void 0:r.content.value,c=null===(i=t.get("Person.givenName"))||void 0===i?void 0:i.content.value,u=null===(o=t.get("Person.familyName"))||void 0===o?void 0:o.content.value,p=null===(n=t.get("Person.gender"))||void 0===n?void 0:n.content.value,f=null===(a=t.get("Organization.name"))||void 0===a?void 0:a.content.value,h=null===(s=t.get("Organization.legalname"))||void 0===s?void 0:s.content.value;return d?l=d:c&&u?l=`${c} ${u}`:c?l=c:u&&p?l=`i18n://salutation.gender.${p} ${u}`:f?l=f:h&&(l=h),l}async createRelationshipInfo(e){const t=e.peer.address.address.substring(3,9);let r=await l.RelationshipInfo.from({attributes:[],id:await n.ConsumptionIds.relationshipInfo.generate(),isPinned:!1,relationshipId:e.id,title:t});r=await this.parent.relationshipInfo.createRelationshipInfo(r);const o=await this.parent.sharedItems.getSharedItems({sharedBy:e.peer.address.toString()}),a=[],d=new Map;for(const e of o)if(e.content instanceof i.Attribute){const t=await s.RelationshipAttribute.from({name:e.content.name,sharedItem:e.id,content:e.content});a.push(t),d.set(t.name,t)}r.attributes=a;const c=this.getTitle(e,d);return r.title=c,await this.parent.relationshipInfo.updateRelationshipInfo(r),r}async parseTemplateBody(e,t){if(!t.cache)throw o.TransportErrors.general.cacheEmpty(o.RelationshipTemplate,t.id.toString()).logWith(this._log);const r=this.parent.accountController.identity.isMe(t.cache.createdBy);if(t.cache.content instanceof i.RelationshipTemplateBody){const i=t.cache.content.sharedAttributes;if(i){const o=t.cache.createdAt,s=r?this.parent.accountController.identity.address:e.peer.address,l=r?e.peer.address:this.parent.accountController.identity.address;for(const e of i){const r=await a.SharedItem.from({id:await n.ConsumptionIds.sharedItem.generate(),content:e,sharedAt:o,sharedBy:s,sharedWith:l,reference:t.id,expiresAt:e.validTo});await this.parent.sharedItems.createSharedItem(r)}}}}async parseCreationRequest(e){const t=e.cache.creationChange.request;if(!t.content){const e=new Error("error.consumption.noRequestContent");throw this._log.error(e),e}const r=this.parent.accountController.identity.isMe(t.createdBy);if(!(t.content instanceof i.RelationshipCreationChangeRequestBody))throw new Error("Request.content.content is no RelationshipCreationChangeRequestBody");{const i=t.content.sharedAttributes;if(i){const o=t.createdAt,s=r?this.parent.accountController.identity.address:e.peer.address,l=r?e.peer.address:this.parent.accountController.identity.address;for(const t of i){const r=await a.SharedItem.from({id:await n.ConsumptionIds.sharedItem.generate(),content:t,sharedAt:o,sharedBy:s,sharedWith:l,reference:e.id,expiresAt:t.validTo});await this.parent.sharedItems.createSharedItem(r)}}}}}t.RelationshipInfoUtil=RelationshipInfoUtil},880:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipAttribute=void 0;const a=r(194),s=r(30),l=r(663);let d=i=class RelationshipAttribute extends a.SerializableAsync{static async from(e){return await super.fromT(e,i)}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],d.prototype,"name",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.Attribute)],d.prototype,"content",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",l.CoreId)],d.prototype,"sharedItem",void 0),d=i=o([(0,a.type)("RelationshipAttribute")],d),t.RelationshipAttribute=d},447:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfo=void 0;const a=r(194),s=r(663),l=r(714),d=r(997),c=r(880),u=r(155);let p=i=class RelationshipInfo extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.relationshipId)),(0,l.nameof)((e=>e.title)),(0,l.nameof)((e=>e.description)),(0,l.nameof)((e=>e.theme))],this.userdataProperties=[(0,l.nameof)((e=>e.isPinned)),(0,l.nameof)((e=>e.userTitle)),(0,l.nameof)((e=>e.userDescription))]}static async fromRelationship(e){return void 0===e.metadata?await i.from({id:await d.ConsumptionIds.relationshipInfo.generate(),relationshipId:e.id,attributes:[],isPinned:!1,title:e.peer.address.address.substring(3,9)}):await i.from(e.metadata)}static async from(e){return await super.fromT(e,i)}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreId)],p.prototype,"relationshipId",void 0),o([(0,a.validate)(),(0,a.serialize)({type:c.RelationshipAttribute}),n("design:type",Array)],p.prototype,"attributes",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",Boolean)],p.prototype,"isPinned",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",String)],p.prototype,"userTitle",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],p.prototype,"title",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",String)],p.prototype,"userDescription",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",String)],p.prototype,"description",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",u.RelationshipTheme)],p.prototype,"theme",void 0),p=i=o([(0,a.type)("RelationshipInfo")],p),t.RelationshipInfo=p},155:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipTheme=void 0;const a=r(194);let s=i=class RelationshipTheme extends a.SerializableAsync{static async from(e){return await super.fromT(e,i)}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],s.prototype,"image",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],s.prototype,"imageBar",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],s.prototype,"backgroundColor",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],s.prototype,"foregroundColor",void 0),s=i=o([(0,a.type)("RelationshipTheme")],s),t.RelationshipTheme=s},637:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RequestsController=void 0;const i=r(663),o=r(997),n=r(137);class RequestsController extends o.ConsumptionBaseController{constructor(e){super(o.ConsumptionControllerName.RequestsController,e)}async init(){return await super.init(),this.requests=await this.parent.accountController.getSynchronizedCollection("Requests"),this}async getRequest(e){const t=await this.requests.findOne({id:e.toString()});return t?await n.ConsumptionRequest.from(t):void 0}async getRequests(e){const t=await this.requests.find(e);return await this.parseArray(t,n.ConsumptionRequest)}async getPendingRequests(e){return e.isProcessed=!1,await this.getRequests(e)}async createRequest(e,t){if(e.id){if(await this.getRequest(e.id))throw o.ConsumptionErrors.requests.requestsExists(e.id.toString()).logWith(this._log)}else e.id=await o.ConsumptionIds.request.generate();const r=this.parent.accountController.identity.isMe(t.cache.createdBy);return await n.ConsumptionRequest.from({id:e.id,isOwn:r,isPending:!1,requestMessage:t.id,status:n.ConsumptionRequestStatus.Pending})}async updateRequestWithStatus(e,t,r){const o=await this.requests.findOne({id:e.toString()});if(!o)throw i.TransportErrors.general.recordNotFound(n.ConsumptionRequest,e.toString());const a=await n.ConsumptionRequest.from(o);return a.responseMessage=t,a.isPending=!1,a.status=r,await this.requests.update(o,a),a}async acceptRequest(e,t){return await this.updateRequestWithStatus(e,t,n.ConsumptionRequestStatus.Accepted)}async rejectRequest(e,t){return await this.updateRequestWithStatus(e,t,n.ConsumptionRequestStatus.Rejected)}async revokeRequest(e,t){return await this.updateRequestWithStatus(e,t,n.ConsumptionRequestStatus.Revoked)}async updateRequest(e){const t=await this.requests.findOne({id:e.id.toString()});if(!t)throw i.TransportErrors.general.recordNotFound(n.ConsumptionRequest,e.id.toString());return await this.requests.update(t,e),e}async deleteRequest(e){await this.requests.delete(e)}}t.RequestsController=RequestsController},137:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequest=t.ConsumptionRequestStatus=void 0;const a=r(194),s=r(663),l=r(714);var d;!function(e){e.Pending="Pending",e.Accepted="Accepted",e.Rejected="Rejected",e.Revoked="Revoked"}(d=t.ConsumptionRequestStatus||(t.ConsumptionRequestStatus={}));let c=i=class ConsumptionRequest extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.isOwn)),(0,l.nameof)((e=>e.requestMessage)),(0,l.nameof)((e=>e.responseMessage)),(0,l.nameof)((e=>e.isPending)),(0,l.nameof)((e=>e.status))],this.metadataProperties=[(0,l.nameof)((e=>e.processingMetadata)),(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,i)}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",Boolean)],c.prototype,"isOwn",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreId)],c.prototype,"requestMessage",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreId)],c.prototype,"responseMessage",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",Boolean)],c.prototype,"isPending",void 0),o([(0,a.validate)({allowedValues:[d.Pending,d.Accepted,d.Rejected,d.Revoked]}),(0,a.serialize)(),n("design:type",String)],c.prototype,"status",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),n("design:type",Object)],c.prototype,"processingMetadata",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),n("design:type",Object)],c.prototype,"metadata",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],c.prototype,"metadataModifiedAt",void 0),c=i=o([(0,a.type)("ConsumptionRequest")],c),t.ConsumptionRequest=c},672:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsController=void 0;const i=r(663),o=r(997),n=r(660);class SettingsController extends o.ConsumptionBaseController{constructor(e){super(o.ConsumptionControllerName.SettingsController,e)}async init(){return await super.init(),this.settings=await this.parent.accountController.getSynchronizedCollection("Settings"),this}async getSetting(e){const t=await this.settings.read(e.toString());return t?await n.Setting.from(t):void 0}async getSettings(e){const t=await this.settings.find(e);return await this.parseArray(t,n.Setting)}async createSetting(e){var t;const r=await n.Setting.from({id:await o.ConsumptionIds.setting.generate(),createdAt:i.CoreDate.utc(),key:e.key,scope:null!==(t=e.scope)&&void 0!==t?t:n.SettingScope.Identity,value:e.value,reference:e.reference,succeedsAt:e.succeedsAt,succeedsItem:e.succeedsItem});return await this.settings.create(r),r}async updateSetting(e){const t=await this.settings.read(e.id.toString());if(!t)throw i.TransportErrors.general.recordNotFound(n.Setting,e.id.toString()).logWith(this._log);await this.settings.update(t,e)}async deleteSetting(e){await this.settings.delete(e)}}t.SettingsController=SettingsController},660:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.SettingScope=void 0;const a=r(194),s=r(663),l=r(714);!function(e){e.Identity="Identity",e.Device="Device",e.Relationship="Relationship"}(t.SettingScope||(t.SettingScope={}));let d=i=class Setting extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.key)),(0,l.nameof)((e=>e.scope)),(0,l.nameof)((e=>e.reference)),(0,l.nameof)((e=>e.createdAt)),(0,l.nameof)((e=>e.deletedAt)),(0,l.nameof)((e=>e.succeedsItem)),(0,l.nameof)((e=>e.succeedsAt))],this.userdataProperties=[(0,l.nameof)((e=>e.value))],this.metadataProperties=[(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.fromT(e,i)}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],d.prototype,"key",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",String)],d.prototype,"scope",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreId)],d.prototype,"reference",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",a.SerializableAsync)],d.prototype,"value",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"createdAt",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"deletedAt",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreId)],d.prototype,"succeedsItem",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"succeedsAt",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),n("design:type",Object)],d.prototype,"metadata",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"metadataModifiedAt",void 0),d=i=o([(0,a.type)("Setting")],d),t.Setting=d},826:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItemsController=void 0;const i=r(663),o=r(997),n=r(943);class SharedItemsController extends o.ConsumptionBaseController{constructor(e){super(o.ConsumptionControllerName.SharedItemsController,e)}async init(){return await super.init(),this.sharedItems=await this.parent.accountController.getSynchronizedCollection("SharedItems"),this}async getSharedItem(e){const t=await this.sharedItems.read(e.toString());return t?await n.SharedItem.from(t):void 0}async getSharedItems(e){const t=await this.sharedItems.find(e);return await this.parseArray(t,n.SharedItem)}async createSharedItem(e){return await this.sharedItems.create(e),e}async updateSharedItem(e){const t=await this.sharedItems.read(e.id.toString());if(!t)throw i.TransportErrors.general.recordNotFound(n.SharedItem,e.id.toString());return await this.sharedItems.update(t,e)}async deleteSharedItem(e){await this.sharedItems.delete(e)}}t.SharedItemsController=SharedItemsController},943:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItem=void 0;const a=r(194),s=r(663),l=r(714);let d=i=class SharedItem extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.tags)),(0,l.nameof)((e=>e.sharedBy)),(0,l.nameof)((e=>e.sharedWith)),(0,l.nameof)((e=>e.sharedAt)),(0,l.nameof)((e=>e.reference)),(0,l.nameof)((e=>e.content)),(0,l.nameof)((e=>e.succeedsItem)),(0,l.nameof)((e=>e.succeedsAt)),(0,l.nameof)((e=>e.expiresAt))],this.metadataProperties=[(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.fromT(e,i)}};o([(0,a.validate)({nullable:!0}),(0,a.serialize)({type:String}),n("design:type",Array)],d.prototype,"tags",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreAddress)],d.prototype,"sharedBy",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreAddress)],d.prototype,"sharedWith",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"sharedAt",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreId)],d.prototype,"reference",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",a.Serializable)],d.prototype,"content",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreId)],d.prototype,"succeedsItem",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"succeedsAt",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"expiresAt",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),n("design:type",Object)],d.prototype,"metadata",void 0),o([(0,a.validate)({nullable:!0}),(0,a.serialize)(),n("design:type",s.CoreDate)],d.prototype,"metadataModifiedAt",void 0),d=i=o([(0,a.type)("SharedItem")],d),t.SharedItem=d},245:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Signature=void 0;const a=r(194),s=r(890),l=r(663),d=r(750);let c=i=class Signature extends l.CoreSerializableAsync{static async from(e){const t=await s.CryptoSignature.fromBase64(e.signature);return await super.fromT({content:e.content,signature:t},i)}static async deserialize(e){return await super.deserializeT(e,i)}async verify(e,t){if((await s.CryptoHash.hash(s.CoreBuffer.fromUtf8(e),this.content.hashAlgorithm)).toBase64()!==this.content.hash.hash)return!1;const r=this.content.serialize();return await l.CoreCrypto.verify(s.CoreBuffer.fromUtf8(r),this.signature,t)}toJSON(){return{content:this.content.toJSON(),signature:this.signature.toBase64()}}serialize(){return JSON.stringify(this.toJSON())}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",d.SignatureContent)],c.prototype,"content",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CryptoSignature)],c.prototype,"signature",void 0),c=i=o([(0,a.type)("Signature")],c),t.Signature=c},750:function(e,t,r){var i,o=this&&this.__decorate||function(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a},n=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SignatureContent=void 0;const a=r(194),s=r(663);let l=i=class SignatureContent extends s.CoreSerializable{static from(e){return super.from(e,i)}static deserialize(e){return super.deserializeT(e,i)}};o([(0,a.validate)(),(0,a.serialize)(),n("design:type",Number)],l.prototype,"version",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",Number)],l.prototype,"signatureAlgorithm",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",Number)],l.prototype,"hashAlgorithm",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreDate)],l.prototype,"signedAt",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreAddress)],l.prototype,"signer",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreId)],l.prototype,"keyId",void 0),o([(0,a.validate)(),(0,a.serialize)(),n("design:type",s.CoreHash)],l.prototype,"hash",void 0),l=i=o([(0,a.type)("SignatureContent")],l),t.SignatureContent=l},714:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0;var i=r(898);Object.defineProperty(t,"nameof",{enumerable:!0,get:function(){return i.nameof}})},898:(e,t)=>{function cleanseAssertionOperators(e){return e.replace(/[?!]/g,"")}Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0,t.nameof=function nameof(e,t){var r=e.toString();if(r.startsWith("class ")&&!r.startsWith("class =>"))return cleanseAssertionOperators(r.substring("class ".length,r.indexOf(" {")));if(r.includes("=>"))return cleanseAssertionOperators(r.substring(r.indexOf(".")+1));var i=r.match(/function\s*\(\w+\)\s*\{[\r\n\s]*return\s+\w+\.((\w+\.)*(\w+))/i);if(i)return t&&t.lastProp?i[3]:i[1];if(r.startsWith("function "))return cleanseAssertionOperators(r.substring("function ".length,r.indexOf("(")));throw new Error("ts-simple-nameof: Invalid function.")}},30:e=>{e.exports=NMSHDContent},890:e=>{e.exports=NMSHDCrypto},663:e=>{e.exports=NMSHDTransport},194:e=>{e.exports=TSServal}},t={};var r=function __webpack_require__(r){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,__webpack_require__),o.exports}(590);NMSHDConsumption=r})();
1
+ var NMSHDConsumption;(()=>{"use strict";var e={500:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildInformation=void 0;const i=r(194),n=r(30),o=r(890),a=r(663);t.buildInformation={version:"1.0.13",build:"15",date:"2022-01-25T16:43:54+00:00",commit:"156f0241ed8ffd6909131950abd43936f263fa62",dependencies:{},libraries:{transport:a.buildInformation,crypto:o.buildInformation,serval:i.buildInformation,content:n.buildInformation}}},136:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionBaseController=void 0;const i=r(194),n=r(663);t.ConsumptionBaseController=class ConsumptionBaseController{constructor(e,t){this._parent=t,this._log=n.TransportLoggerFactory.getLogger(e)}get log(){return this._log}get parent(){return this._parent}init(){return Promise.resolve(this)}async parseObject(e,t){return await i.SerializableAsync.fromT(e,t)}async parseArray(e,t,r){const i=[];for(let o=0,a=e.length;o<a;o++)if(r){const a=e[o];if(!a[r]){const e=n.TransportErrors.controller.contentPropertyUndefined(r);throw this._log.error(e),e}i.push(this.parseObject(a[r],t))}else i.push(this.parseObject(e[o],t));return await Promise.all(i)}}},793:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionController=void 0;const i=r(662);t.ConsumptionController=class ConsumptionController{constructor(e,t){this.transport=e,this.accountController=t}get attributes(){return this._attributes}get drafts(){return this._drafts}get requests(){return this._requests}get settings(){return this._settings}get sharedItems(){return this._sharedItems}get relationshipInfo(){return this._relationshipInfo}async init(){return this._attributes=await new i.ConsumptionAttributesController(this).init(),this._drafts=await new i.DraftsController(this).init(),this._requests=await new i.RequestsController(this).init(),this._settings=await new i.SettingsController(this).init(),this._sharedItems=await new i.SharedItemsController(this).init(),this._relationshipInfo=await new i.RelationshipInfoController(this).init(),this}}},47:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionControllerName=void 0,function(e){e.ConsumptionAttributesController="ConsumptionAttributesController",e.DraftsController="DraftsController",e.RelationshipInfoController="RelationshipInfoController",e.SingleRelationshipController="SingleRelationshipController",e.OnboardingFlowController="OnboardingFlowController",e.OffboardingFlowController="OffboardingFlowController",e.RequestsController="Requestsontroller",e.SettingsController="SettingsController",e.SharedItemsController="SharedItemsController"}(t.ConsumptionControllerName||(t.ConsumptionControllerName={}))},926:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionErrors=void 0;const i=r(663);class ConsumptionErrors{}t.ConsumptionErrors=ConsumptionErrors,ConsumptionErrors.attributes=new class Attributes{attributeExists(e){return new i.CoreError("error.consumption.attributes.attributeExists",`Attribute with name ${e} already exists. Please use succeed instead.`)}},ConsumptionErrors.requests=new class Requests{requestsExists(e){return new i.CoreError("error.consumption.requests.requestExists",`Request with id ${e} already exists and can't be created.`)}},ConsumptionErrors.relationshipInfo=new class RelationshipInfo{relationshipInfoExists(e){return new i.CoreError("error.consumption.relationshipInfos.relationshipInfoExists",`RelationshipInfo for Relationship ${e} already exists.`)}},ConsumptionErrors.onboarding=new class Onboarding{attributeNotSet(e){return new i.CoreError("error.consumption.onboarding.attributeNotSet",`No attribute with name ${e} set but was required to be shared.`)}wrongTemplate(){return new i.CoreError("error.consumption.onboarding.wrongTemplate","The given template is in the wrong format.")}}},265:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionIds=void 0;const i=r(663);class ConsumptionIds{}t.ConsumptionIds=ConsumptionIds,ConsumptionIds.attribute=new i.CoreIdHelper("CNSATT"),ConsumptionIds.draft=new i.CoreIdHelper("CNSDRF"),ConsumptionIds.relationshipInfo=new i.CoreIdHelper("CNSRIN"),ConsumptionIds.sharedItem=new i.CoreIdHelper("CNSSIT"),ConsumptionIds.response=new i.CoreIdHelper("CNSRES"),ConsumptionIds.request=new i.CoreIdHelper("CNSREQ"),ConsumptionIds.setting=new i.CoreIdHelper("CNSSET")},997:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),n(r(136),t),n(r(47),t),n(r(926),t),n(r(265),t)},590:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),n(r(500),t),n(r(793),t),n(r(265),t),n(r(662),t)},896:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttributesController=void 0;const i=r(663),n=r(714),o=r(997),a=r(192);class ConsumptionAttributesController extends o.ConsumptionBaseController{constructor(e){super(o.ConsumptionControllerName.ConsumptionAttributesController,e)}async init(){return await super.init(),this.attributes=await this.parent.accountController.getSynchronizedCollection("Attributes"),this}checkValid(e){const t=i.CoreDate.utc();return!e.content.validFrom&&!e.content.validTo||(!(!e.content.validFrom||e.content.validTo||!e.content.validFrom.isSameOrBefore(t))||(!(e.content.validFrom||!e.content.validTo||!e.content.validTo.isAfter(t))||!!(e.content.validFrom&&e.content.validTo&&e.content.validFrom.isSameOrBefore(t)&&e.content.validTo.isAfter(t))))}findCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt)));let r;for(const e of t)this.checkValid(e)&&(r=e);return r}filterCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt))),r=[];for(const e of t)this.checkValid(e)&&r.push(e);return r}async getAttribute(e){const t=await this.attributes.find({[(0,n.nameof)((e=>e.id))]:e.toString()}),r=await this.parseArray(t,a.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeByName(e){const t=await this.attributes.find({[`${(0,n.nameof)((e=>e.content))}.${(0,n.nameof)((e=>e.name))}`]:e}),r=await this.parseArray(t,a.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeHistoryByName(e){const t=await this.attributes.find({[`${(0,n.nameof)((e=>e.content))}.${(0,n.nameof)((e=>e.name))}`]:e});return(await this.parseArray(t,a.ConsumptionAttribute)).sort(((e,t)=>e.createdAt.compare(t.createdAt)))}async getAttributes(e){const t=await this.attributes.find(e);return await this.parseArray(t,a.ConsumptionAttribute)}async getValidAttributes(e){const t=await this.attributes.find(e),r=await this.parseArray(t,a.ConsumptionAttribute);return this.filterCurrent(r)}async getAttributesByName(e){return(await this.getValidAttributes(e)).reduce(((e,t)=>(e[t.content.name]=t,e)),{})}async createAttribute(e){if(await this.getAttributeByName(e.content.name))throw o.ConsumptionErrors.attributes.attributeExists(e.content.name);return await this.attributes.create(e),e}async succeedAttribute(e,t){const r=await this.getAttributeByName(e.content.name);return r&&!t&&(t=i.CoreDate.utc()),r&&(e.content.validFrom=t,r.content.validTo=t,await this.updateAttribute(r)),await this.attributes.create(e),e}async updateAttribute(e){const t=await this.attributes.findOne({[(0,n.nameof)((e=>e.id))]:e.id.toString()});if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionAttribute,e.id.toString());return await this.attributes.update(t,e),e}async deleteAttribute(e){await this.attributes.delete(e)}}t.ConsumptionAttributesController=ConsumptionAttributesController},192:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttribute=void 0;const a=r(194),s=r(30),l=r(663),d=r(714),c=r(997);let u=i=class ConsumptionAttribute extends l.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,d.nameof)((e=>e.createdAt))],this.userdataProperties=[(0,d.nameof)((e=>e.content))],this.metadataProperties=[(0,d.nameof)((e=>e.metadata)),(0,d.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,i)}static async fromAttribute(e){return await this.from({content:s.Attribute.from(e),id:await c.ConsumptionIds.attribute.generate(),createdAt:l.CoreDate.utc()})}};n([(0,a.validate)(),(0,a.serialize)({type:s.Attribute}),o("design:type",s.Attribute)],u.prototype,"content",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",l.CoreDate)],u.prototype,"createdAt",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),o("design:type",Object)],u.prototype,"metadata",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",l.CoreDate)],u.prototype,"metadataModifiedAt",void 0),u=i=n([(0,a.type)("ConsumptionAttribute")],u),t.ConsumptionAttribute=u},574:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DraftsController=void 0;const i=r(663),n=r(997),o=r(535);class DraftsController extends n.ConsumptionBaseController{constructor(e){super(n.ConsumptionControllerName.DraftsController,e)}async init(){return await super.init(),this.drafts=await this.parent.accountController.getSynchronizedCollection("Drafts"),this}async getDraft(e){const t=await this.drafts.read(e.toString());return t?await o.Draft.from(t):void 0}async getDrafts(e){const t=await this.drafts.find(e);return await this.parseArray(t,o.Draft)}async createDraft(e,t=""){const r=await o.Draft.from({id:await n.ConsumptionIds.draft.generate(),content:e,createdAt:new i.CoreDate,lastModifiedAt:new i.CoreDate,type:t});return await this.drafts.create(r),r}async updateDraft(e){const t=await this.drafts.read(e.id.toString());if(!t)throw new Error("Draft Not Found");await this.drafts.update(t,e)}async deleteDraft(e){await this.drafts.delete(e)}}t.DraftsController=DraftsController},535:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Draft=void 0;const a=r(194),s=r(663),l=r(714);let d=i=class Draft extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.type)),(0,l.nameof)((e=>e.createdAt)),(0,l.nameof)((e=>e.lastModifiedAt))],this.userdataProperties=[(0,l.nameof)((e=>e.content))],this.metadataProperties=[(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,i)}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],d.prototype,"type",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"createdAt",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"lastModifiedAt",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",a.SerializableAsync)],d.prototype,"content",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),o("design:type",Object)],d.prototype,"metadata",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"metadataModifiedAt",void 0),d=i=n([(0,a.type)("Draft")],d),t.Draft=d},662:function(e,t,r){var i=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||i(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),n(r(896),t),n(r(192),t),n(r(574),t),n(r(535),t),n(r(880),t),n(r(447),t),n(r(155),t),n(r(58),t),n(r(137),t),n(r(637),t),n(r(660),t),n(r(672),t),n(r(943),t),n(r(826),t),n(r(245),t),n(r(750),t)},58:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoController=void 0;const i=r(997),n=r(447),o=r(657);class RelationshipInfoController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.RelationshipInfoController,e)}async init(){return await super.init(),this.relationshipInfo=await this.parent.accountController.getSynchronizedCollection("RelationshipInfo"),this}async getRelationshipInfo(e){const t=await this.relationshipInfo.read(e.toString());return t?await n.RelationshipInfo.from(t):void 0}async getRelationshipInfoByRelationship(e){return await new o.RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(e)}async getRelationshipInfos(e){const t=await this.relationshipInfo.find(e);return await this.parseArray(t,n.RelationshipInfo)}async createRelationshipInfo(e){if(await this.relationshipInfo.exists({relationshipId:e.relationshipId}))throw i.ConsumptionErrors.relationshipInfo.relationshipInfoExists(e.relationshipId.toString());return await this.relationshipInfo.create(e),e}async updateRelationshipInfo(e){const t=await this.relationshipInfo.read(e.id.toString());if(!t)throw new Error("RelationshipInfo Not Found");await this.relationshipInfo.update(t,e)}async deleteRelationshipInfo(e){await this.relationshipInfo.delete(e)}}t.RelationshipInfoController=RelationshipInfoController},657:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoUtil=void 0;const i=r(194),n=r(30),o=r(663),a=r(997),s=r(943),l=r(880),d=r(447);class RelationshipInfoUtil{constructor(e){this.parent=e,this._log=o.TransportLoggerFactory.getLogger(RelationshipInfoUtil)}get log(){return this._log}async createInitialRelationshipInfo(e){const t=await this.parent.accountController.relationships.getRelationship(e);if(!t)throw o.TransportErrors.general.recordNotFound(o.Relationship,e.toString()).logWith(this._log);return await this.parseTemplateBody(t),await this.parseCreationRequest(t),await this.createRelationshipInfo(t)}getTitle(e,t){var r,i,n,o,a,s;let l=e.peer.address.toString().substring(3,9);const d=null===(r=t.get("Thing.name"))||void 0===r?void 0:r.content.value,c=null===(i=t.get("Person.givenName"))||void 0===i?void 0:i.content.value,u=null===(n=t.get("Person.familyName"))||void 0===n?void 0:n.content.value,p=null===(o=t.get("Person.gender"))||void 0===o?void 0:o.content.value,f=null===(a=t.get("Organization.name"))||void 0===a?void 0:a.content.value,h=null===(s=t.get("Organization.legalname"))||void 0===s?void 0:s.content.value;return d?l=d:c&&u?l=`${c} ${u}`:c?l=c:u&&p?l=`i18n://salutation.gender.${p} ${u}`:f?l=f:h&&(l=h),l}async createRelationshipInfo(e){const t=e.peer.address.address.substring(3,9),r=await d.RelationshipInfo.from({attributes:[],id:await a.ConsumptionIds.relationshipInfo.generate(),isPinned:!1,relationshipId:e.id,title:t}),i=await this.parent.sharedItems.getSharedItems({sharedBy:e.peer.address.toString()}),o=[],s=new Map;for(const e of i)if(e.content instanceof n.Attribute){const t=await l.RelationshipAttribute.from({name:e.content.name,sharedItem:e.id,content:e.content});o.push(t),s.set(t.name,t)}r.attributes=o;const c=this.getTitle(e,s);return r.title=c,r}async parseTemplateBody(e){const t=e.cache.template;if(!t.cache)throw o.TransportErrors.general.cacheEmpty(o.RelationshipTemplate,t.id.toString()).logWith(this._log);const r=t.cache.content,l=this.parent.accountController.identity.isMe(t.cache.createdBy),d=t.cache.createdAt,c=l?this.parent.accountController.identity.address:e.peer.address,u=l?e.peer.address:this.parent.accountController.identity.address,p=await this.parent.sharedItems.getSharedItems({reference:t.id.toString()}),f=[];if(r instanceof n.RelationshipTemplateBody){const e=r.sharedAttributes;e&&p.length!==e.length&&e.forEach((e=>{p.find((function(t){return t.content.name===e.name}))||f.push(e)}))}else{let e=r;(r instanceof i.JSONWrapper||r instanceof i.JSONWrapperAsync)&&(e=e.value),(null==e?void 0:e.attributes)&&Array.isArray(e.attributes)&&p.length!==e.attributes.length&&e.attributes.forEach((e=>{p.find((function(t){return t.content.name===e.name}))||f.push(n.Attribute.from({name:e.name,value:e.value}))}))}for(const e of f){const r=await s.SharedItem.from({id:await a.ConsumptionIds.sharedItem.generate(),content:e,sharedAt:d,sharedBy:c,sharedWith:u,reference:t.id,expiresAt:e.validTo});await this.parent.sharedItems.createSharedItem(r)}}async parseCreationRequest(e){const t=e.cache.creationChange,r=t.request,o=r.content,l=this.parent.accountController.identity.isMe(r.createdBy),d=r.createdAt,c=l?this.parent.accountController.identity.address:e.peer.address,u=l?e.peer.address:this.parent.accountController.identity.address,p=await this.parent.sharedItems.getSharedItems({reference:t.id.toString()}),f=[];if(o instanceof n.RelationshipCreationChangeRequestBody){const e=o.sharedAttributes;e&&e.length>0&&p.length!==e.length&&e.forEach((e=>{p.find((function(t){return t.content.name===e.name}))||f.push(e)}))}else{let e=o;if((o instanceof i.JSONWrapper||o instanceof i.JSONWrapperAsync)&&(e=e.value),null==e?void 0:e.attributes){const t=Object.keys(e.attributes);p.length!==t.length&&t.forEach((t=>{const r=e.attributes[t];p.find((function(e){return e.content.name===r.name}))||f.push(n.Attribute.from({name:r.name,value:r.value}))}))}}for(const e of f){const r=await s.SharedItem.from({id:await a.ConsumptionIds.sharedItem.generate(),content:e,sharedAt:d,sharedBy:c,sharedWith:u,reference:t.id,expiresAt:e.validTo});await this.parent.sharedItems.createSharedItem(r)}}}t.RelationshipInfoUtil=RelationshipInfoUtil},880:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipAttribute=void 0;const a=r(194),s=r(30),l=r(663);let d=i=class RelationshipAttribute extends a.SerializableAsync{static async from(e){return await super.fromT(e,i)}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],d.prototype,"name",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.Attribute)],d.prototype,"content",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",l.CoreId)],d.prototype,"sharedItem",void 0),d=i=n([(0,a.type)("RelationshipAttribute")],d),t.RelationshipAttribute=d},447:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfo=void 0;const a=r(194),s=r(663),l=r(714),d=r(997),c=r(880),u=r(155);let p=i=class RelationshipInfo extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.relationshipId)),(0,l.nameof)((e=>e.title)),(0,l.nameof)((e=>e.description)),(0,l.nameof)((e=>e.theme))],this.userdataProperties=[(0,l.nameof)((e=>e.isPinned)),(0,l.nameof)((e=>e.userTitle)),(0,l.nameof)((e=>e.userDescription))]}static async fromRelationship(e){return void 0===e.metadata?await i.from({id:await d.ConsumptionIds.relationshipInfo.generate(),relationshipId:e.id,attributes:[],isPinned:!1,title:e.peer.address.address.substring(3,9)}):await i.from(e.metadata)}static async from(e){return await super.fromT(e,i)}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreId)],p.prototype,"relationshipId",void 0),n([(0,a.validate)(),(0,a.serialize)({type:c.RelationshipAttribute}),o("design:type",Array)],p.prototype,"attributes",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",Boolean)],p.prototype,"isPinned",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",String)],p.prototype,"userTitle",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],p.prototype,"title",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",String)],p.prototype,"userDescription",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",String)],p.prototype,"description",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",u.RelationshipTheme)],p.prototype,"theme",void 0),p=i=n([(0,a.type)("RelationshipInfo")],p),t.RelationshipInfo=p},155:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipTheme=void 0;const a=r(194);let s=i=class RelationshipTheme extends a.SerializableAsync{static async from(e){return await super.fromT(e,i)}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],s.prototype,"image",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],s.prototype,"imageBar",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],s.prototype,"backgroundColor",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],s.prototype,"foregroundColor",void 0),s=i=n([(0,a.type)("RelationshipTheme")],s),t.RelationshipTheme=s},637:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RequestsController=void 0;const i=r(663),n=r(997),o=r(137);class RequestsController extends n.ConsumptionBaseController{constructor(e){super(n.ConsumptionControllerName.RequestsController,e)}async init(){return await super.init(),this.requests=await this.parent.accountController.getSynchronizedCollection("Requests"),this}async getRequest(e){const t=await this.requests.findOne({id:e.toString()});return t?await o.ConsumptionRequest.from(t):void 0}async getRequests(e){const t=await this.requests.find(e);return await this.parseArray(t,o.ConsumptionRequest)}async getPendingRequests(e){return e.isProcessed=!1,await this.getRequests(e)}async createRequest(e,t){if(e.id){if(await this.getRequest(e.id))throw n.ConsumptionErrors.requests.requestsExists(e.id.toString()).logWith(this._log)}else e.id=await n.ConsumptionIds.request.generate();const r=this.parent.accountController.identity.isMe(t.cache.createdBy);return await o.ConsumptionRequest.from({id:e.id,isOwn:r,isPending:!1,requestMessage:t.id,status:o.ConsumptionRequestStatus.Pending})}async updateRequestWithStatus(e,t,r){const n=await this.requests.findOne({id:e.toString()});if(!n)throw i.TransportErrors.general.recordNotFound(o.ConsumptionRequest,e.toString());const a=await o.ConsumptionRequest.from(n);return a.responseMessage=t,a.isPending=!1,a.status=r,await this.requests.update(n,a),a}async acceptRequest(e,t){return await this.updateRequestWithStatus(e,t,o.ConsumptionRequestStatus.Accepted)}async rejectRequest(e,t){return await this.updateRequestWithStatus(e,t,o.ConsumptionRequestStatus.Rejected)}async revokeRequest(e,t){return await this.updateRequestWithStatus(e,t,o.ConsumptionRequestStatus.Revoked)}async updateRequest(e){const t=await this.requests.findOne({id:e.id.toString()});if(!t)throw i.TransportErrors.general.recordNotFound(o.ConsumptionRequest,e.id.toString());return await this.requests.update(t,e),e}async deleteRequest(e){await this.requests.delete(e)}}t.RequestsController=RequestsController},137:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequest=t.ConsumptionRequestStatus=void 0;const a=r(194),s=r(663),l=r(714);var d;!function(e){e.Pending="Pending",e.Accepted="Accepted",e.Rejected="Rejected",e.Revoked="Revoked"}(d=t.ConsumptionRequestStatus||(t.ConsumptionRequestStatus={}));let c=i=class ConsumptionRequest extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.isOwn)),(0,l.nameof)((e=>e.requestMessage)),(0,l.nameof)((e=>e.responseMessage)),(0,l.nameof)((e=>e.isPending)),(0,l.nameof)((e=>e.status))],this.metadataProperties=[(0,l.nameof)((e=>e.processingMetadata)),(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,i)}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",Boolean)],c.prototype,"isOwn",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreId)],c.prototype,"requestMessage",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreId)],c.prototype,"responseMessage",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",Boolean)],c.prototype,"isPending",void 0),n([(0,a.validate)({allowedValues:[d.Pending,d.Accepted,d.Rejected,d.Revoked]}),(0,a.serialize)(),o("design:type",String)],c.prototype,"status",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),o("design:type",Object)],c.prototype,"processingMetadata",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),o("design:type",Object)],c.prototype,"metadata",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],c.prototype,"metadataModifiedAt",void 0),c=i=n([(0,a.type)("ConsumptionRequest")],c),t.ConsumptionRequest=c},672:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsController=void 0;const i=r(663),n=r(997),o=r(660);class SettingsController extends n.ConsumptionBaseController{constructor(e){super(n.ConsumptionControllerName.SettingsController,e)}async init(){return await super.init(),this.settings=await this.parent.accountController.getSynchronizedCollection("Settings"),this}async getSetting(e){const t=await this.settings.read(e.toString());return t?await o.Setting.from(t):void 0}async getSettings(e){const t=await this.settings.find(e);return await this.parseArray(t,o.Setting)}async createSetting(e){var t;const r=await o.Setting.from({id:await n.ConsumptionIds.setting.generate(),createdAt:i.CoreDate.utc(),key:e.key,scope:null!==(t=e.scope)&&void 0!==t?t:o.SettingScope.Identity,value:e.value,reference:e.reference,succeedsAt:e.succeedsAt,succeedsItem:e.succeedsItem});return await this.settings.create(r),r}async updateSetting(e){const t=await this.settings.read(e.id.toString());if(!t)throw i.TransportErrors.general.recordNotFound(o.Setting,e.id.toString()).logWith(this._log);await this.settings.update(t,e)}async deleteSetting(e){await this.settings.delete(e)}}t.SettingsController=SettingsController},660:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.SettingScope=void 0;const a=r(194),s=r(663),l=r(714);!function(e){e.Identity="Identity",e.Device="Device",e.Relationship="Relationship"}(t.SettingScope||(t.SettingScope={}));let d=i=class Setting extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.key)),(0,l.nameof)((e=>e.scope)),(0,l.nameof)((e=>e.reference)),(0,l.nameof)((e=>e.createdAt)),(0,l.nameof)((e=>e.deletedAt)),(0,l.nameof)((e=>e.succeedsItem)),(0,l.nameof)((e=>e.succeedsAt))],this.userdataProperties=[(0,l.nameof)((e=>e.value))],this.metadataProperties=[(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.fromT(e,i)}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],d.prototype,"key",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",String)],d.prototype,"scope",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreId)],d.prototype,"reference",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",a.SerializableAsync)],d.prototype,"value",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"createdAt",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"deletedAt",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreId)],d.prototype,"succeedsItem",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"succeedsAt",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),o("design:type",Object)],d.prototype,"metadata",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"metadataModifiedAt",void 0),d=i=n([(0,a.type)("Setting")],d),t.Setting=d},826:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItemsController=void 0;const i=r(663),n=r(997),o=r(943);class SharedItemsController extends n.ConsumptionBaseController{constructor(e){super(n.ConsumptionControllerName.SharedItemsController,e)}async init(){return await super.init(),this.sharedItems=await this.parent.accountController.getSynchronizedCollection("SharedItems"),this}async getSharedItem(e){const t=await this.sharedItems.read(e.toString());return t?await o.SharedItem.from(t):void 0}async getSharedItems(e){const t=await this.sharedItems.find(e);return await this.parseArray(t,o.SharedItem)}async createSharedItem(e){return await this.sharedItems.create(e),e}async updateSharedItem(e){const t=await this.sharedItems.read(e.id.toString());if(!t)throw i.TransportErrors.general.recordNotFound(o.SharedItem,e.id.toString());return await this.sharedItems.update(t,e)}async deleteSharedItem(e){await this.sharedItems.delete(e)}}t.SharedItemsController=SharedItemsController},943:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItem=void 0;const a=r(194),s=r(663),l=r(714);let d=i=class SharedItem extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,l.nameof)((e=>e.tags)),(0,l.nameof)((e=>e.sharedBy)),(0,l.nameof)((e=>e.sharedWith)),(0,l.nameof)((e=>e.sharedAt)),(0,l.nameof)((e=>e.reference)),(0,l.nameof)((e=>e.content)),(0,l.nameof)((e=>e.succeedsItem)),(0,l.nameof)((e=>e.succeedsAt)),(0,l.nameof)((e=>e.expiresAt))],this.metadataProperties=[(0,l.nameof)((e=>e.metadata)),(0,l.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.fromT(e,i)}};n([(0,a.validate)({nullable:!0}),(0,a.serialize)({type:String}),o("design:type",Array)],d.prototype,"tags",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreAddress)],d.prototype,"sharedBy",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreAddress)],d.prototype,"sharedWith",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"sharedAt",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreId)],d.prototype,"reference",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",a.Serializable)],d.prototype,"content",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreId)],d.prototype,"succeedsItem",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"succeedsAt",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"expiresAt",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)({any:!0}),o("design:type",Object)],d.prototype,"metadata",void 0),n([(0,a.validate)({nullable:!0}),(0,a.serialize)(),o("design:type",s.CoreDate)],d.prototype,"metadataModifiedAt",void 0),d=i=n([(0,a.type)("SharedItem")],d),t.SharedItem=d},245:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Signature=void 0;const a=r(194),s=r(890),l=r(663),d=r(750);let c=i=class Signature extends l.CoreSerializableAsync{static async from(e){const t=await s.CryptoSignature.fromBase64(e.signature);return await super.fromT({content:e.content,signature:t},i)}static async deserialize(e){return await super.deserializeT(e,i)}async verify(e,t){if((await s.CryptoHash.hash(s.CoreBuffer.fromUtf8(e),this.content.hashAlgorithm)).toBase64()!==this.content.hash.hash)return!1;const r=this.content.serialize();return await l.CoreCrypto.verify(s.CoreBuffer.fromUtf8(r),this.signature,t)}toJSON(){return{content:this.content.toJSON(),signature:this.signature.toBase64()}}serialize(){return JSON.stringify(this.toJSON())}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",d.SignatureContent)],c.prototype,"content",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CryptoSignature)],c.prototype,"signature",void 0),c=i=n([(0,a.type)("Signature")],c),t.Signature=c},750:function(e,t,r){var i,n=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SignatureContent=void 0;const a=r(194),s=r(663);let l=i=class SignatureContent extends s.CoreSerializable{static from(e){return super.from(e,i)}static deserialize(e){return super.deserializeT(e,i)}};n([(0,a.validate)(),(0,a.serialize)(),o("design:type",Number)],l.prototype,"version",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",Number)],l.prototype,"signatureAlgorithm",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",Number)],l.prototype,"hashAlgorithm",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreDate)],l.prototype,"signedAt",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreAddress)],l.prototype,"signer",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreId)],l.prototype,"keyId",void 0),n([(0,a.validate)(),(0,a.serialize)(),o("design:type",s.CoreHash)],l.prototype,"hash",void 0),l=i=n([(0,a.type)("SignatureContent")],l),t.SignatureContent=l},714:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0;var i=r(898);Object.defineProperty(t,"nameof",{enumerable:!0,get:function(){return i.nameof}})},898:(e,t)=>{function cleanseAssertionOperators(e){return e.replace(/[?!]/g,"")}Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0,t.nameof=function nameof(e,t){var r=e.toString();if(r.startsWith("class ")&&!r.startsWith("class =>"))return cleanseAssertionOperators(r.substring("class ".length,r.indexOf(" {")));if(r.includes("=>"))return cleanseAssertionOperators(r.substring(r.indexOf(".")+1));var i=r.match(/function\s*\(\w+\)\s*\{[\r\n\s]*return\s+\w+\.((\w+\.)*(\w+))/i);if(i)return t&&t.lastProp?i[3]:i[1];if(r.startsWith("function "))return cleanseAssertionOperators(r.substring("function ".length,r.indexOf("(")));throw new Error("ts-simple-nameof: Invalid function.")}},30:e=>{e.exports=NMSHDContent},890:e=>{e.exports=NMSHDCrypto},663:e=>{e.exports=NMSHDTransport},194:e=>{e.exports=TSServal}},t={};var r=function __webpack_require__(r){var i=t[r];if(void 0!==i)return i.exports;var n=t[r]={exports:{}};return e[r].call(n.exports,n,n.exports,__webpack_require__),n.exports}(590);NMSHDConsumption=r})();
2
2
  //# sourceMappingURL=nmshd.consumption.min.js.map