@elyx-code/project-logic-tree 0.0.6644 → 0.0.6645
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/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -188663,7 +188663,7 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
188663
188663
|
this.id
|
|
188664
188664
|
), this;
|
|
188665
188665
|
const l = this.foreignKeyRef;
|
|
188666
|
-
return (l == null ? void 0 : l.id) !== (i == null ? void 0 : i.id) && (this.foreignKeyRef = i, n == null || n.add(this, H.
|
|
188666
|
+
return (l == null ? void 0 : l.id) !== (i == null ? void 0 : i.id) && (this.foreignKeyRef = i, n == null || n.add(this, H.Updated)), n == null || n.attemptAutoclose(
|
|
188667
188667
|
V.SetDataTypeForeignKeyRef,
|
|
188668
188668
|
this.id
|
|
188669
188669
|
), this;
|
package/dist/index.umd.cjs
CHANGED
|
@@ -384,7 +384,7 @@ ${Ap}`}))}}}const y=l.parent&&r.get(l.parent)||r.getBuiltIn(l.parent),v=y?Op(y):
|
|
|
384
384
|
The entitities of type '${Dt(E,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property so no 'parentRelationType' is needed.`})),y.dataType)){const w=(b=y.dataType)==null?void 0:b.id;c.push(new Oe({id:`${i.id}--${re.NewEntityWouldOverriteExisting}`,code:re.NewEntityWouldOverriteExisting,severity:ce.Error,message:`The entity with id '${i.id}' and type '${i.type}', cannot be added as a child to the entity with id '${l.parent}' and type '${A}', because it already has a 'data-type' child with id '${w}'.
|
|
385
385
|
The entitities of type '${Dt(E,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property. You can inspect the existing data-type entity with the 'describe_entity' action. Like so:
|
|
386
386
|
${No({describe_entity:w})}
|
|
387
|
-
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`}))}A===o.DataType&&(!l.parentRelationType||!(l.parentRelationType===Fe.AndDataTypeGroup||l.parentRelationType===Fe.OrDataTypeGroup))&&c.push(new Oe({id:`${i.id}--${re.InvalidParentRelationType}`,code:re.InvalidParentRelationType,severity:ce.Error,message:`The entity with id '${i.id}' and type '${i.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`}))}return{errors:c,modifiedData:l}}get isGroup(){const i=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(i.length>1){let r=0;for(const l of i)if(l.isResolved&&(r++,r>1))return!0}return!1}get isResolved(){return[o.BuiltInBaseEntity,o.ActionDescriptor].includes(this.parent.type)||Op(this.parent)?!0:!(!this.entity&&!this.isGroup&&!this.foreignKeyRef&&!this.foreignKeyAllowed)}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],l=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);r.push(...v.updated),l.push(...v.added),c.push(...v.removed),e.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}onDetachedDependencyRemoved(i,r,l){const c=[],e=[],y=[],v=[];return r==="entity-field"&&this.setEntity(null,l),r==="foreign-key-ref-field"&&this.setForeignKeyRef(null,l),{updated:O(c),added:O(e),removed:O(y),affected:O(v),self:this}}onDetachedDependencyRestored(i,r,l){const c=[],e=[],y=[],v=[];return r==="entity-field"&&this.setEntity(i,l),r==="foreign-key-ref-field"&&this.setForeignKeyRef(i,l),{updated:O(c),added:O(e),removed:O(y),affected:O(v),self:this}}unsubscribeFromDependencies(){var i,r,l,c;return(r=(i=this.entity)==null?void 0:i.unsubscribeDependents)==null||r.call(i,[{entity:this,field:"entity-field"}]),(c=(l=this.foreignKeyRef)==null?void 0:l.unsubscribeDependents)==null||c.call(l,[{entity:this,field:"foreign-key-ref-field"}]),this}subscribeToDependencies(){var i,r,l,c;return(r=(i=this.entity)==null?void 0:i.subscribeDependents)==null||r.call(i,[{entity:this,field:"entity-field"}]),(c=(l=this.foreignKeyRef)==null?void 0:l.subscribeDependents)==null||c.call(l,[{entity:this,field:"foreign-key-ref-field"}]),this}increaseVersion(i){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=L.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this)}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new vi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.entity=this.entity,i.foreignKeyRef=this.foreignKeyRef,i.andChildrenGroup=this.andChildrenGroup?[...this.andChildrenGroup]:this.andChildrenGroup,i.orChildrenGroup=this.orChildrenGroup?[...this.orChildrenGroup]:this.orChildrenGroup,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const r=[],l=[],c=[],e=[];if(this.parent&&this.parent.type!==o.BuiltInBaseEntity){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...y.updated),l.push(...y.added),c.push(...y.removed)}return{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}async restoreVersion(i){var v;const r=[],l=[],c=[],e=[];if(this.version===i)return{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this};if(!this.knownVersions){const b=new Map;for(const[A,E]of this.knownVersions||new Map){if(b.set(A,E),E.activeVersion=!1,E.knownVersions)for(const[w,P]of E.knownVersions)b.set(w,P);E.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const b=await this.APILoadVersion({},i);if(!b)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new vi(b,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.entity=y.entity,this.foreignKeyRef=y.foreignKeyRef,this.andChildrenGroup=y.andChildrenGroup?[...y.andChildrenGroup]:null,this.orChildrenGroup=y.orChildrenGroup?[...y.orChildrenGroup]:null,this.parent=y.parent,{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.UpdateWithShallowTransfer))){var l,c;if(!this.checkCanEdit(this,r))return ae.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const e=ye(i.parent),y=this.project.get(e),v=this.parent;if(v&&v.id!==(y==null?void 0:y.id)&&this.removeFromParent(r),y)this.setParent(y,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.entity){const e=ye(i.entity),y=this.project.get(e);y&&(y.type===o.DefinitionEntity&&y.parent===this||this.setEntity(y,null))}if(i.foreignKeyRef){const e=ye(i.foreignKeyRef),y=this.project.get(e);y&&this.setForeignKeyRef(y,null)}return(l=i.andChildrenGroup)==null||l.forEach(e=>{const y=ye(e),v=this.project.get(y);v&&(this.addToAndGroup(v,r),v.setParent(this,r))}),[...this.andChildrenGroup||[]].forEach(e=>{var v;((v=i.andChildrenGroup)==null?void 0:v.find(b=>ye(b)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),(c=i.orChildrenGroup)==null||c.forEach(e=>{const y=ye(e),v=this.project.get(y);v&&(this.addToOrGroup(v,r),v.setParent(this,r))}),[...this.orChildrenGroup||[]].forEach(e=>{var v;((v=i.orChildrenGroup)==null?void 0:v.find(b=>ye(b)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],r=[],l=[],c=[];if(this.initialData.parent){const e=ye(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.entity){const e=ye(this.initialData.entity),y=this.project.get(e);y&&(y.type===o.DefinitionEntity&&y.parent===this||(this.setEntity(y,null),y.type!==o.BuiltInBaseEntity&&y.type!==o.PrimitiveEntity&&i.push(y)))}if(this.initialData.foreignKeyRef){const e=ye(this.initialData.foreignKeyRef),y=this.project.get(e);y&&this.setForeignKeyRef(y,null)}return{updated:O(i),added:O(r),removed:O(l),affected:O(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AfterAllChildrenInitialized))){var y,v,b;if(!this.checkCanEdit(this,i))return ae.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(this.initialized=!0,((y=this.parent)==null?void 0:y.type)===o.DataType){let A=this.index||0;const E=(this.parentRelationType===Fe.AndDataTypeGroup?this.parent.andChildrenGroup||[]:this.parent.orChildrenGroup||[]).filter(P=>!P.deleted&&P.id!==this.id);E.length&&(A>E.length+1?A=E.length:A<0&&(A=0)),E.find(P=>(P.index||0)===A&&!P.deleted)&&E.filter(P=>(P.index||0)>=A&&!P.deleted).forEach(P=>{P.metaSync({index:(P.index||0)+1},i),i==null||i.add(P,W.Updated),r.push(P)}),this.metaSync({index:A},i)}return(v=this.andChildrenGroup)!=null&&v.length&&this.andChildrenGroup.sort((A,E)=>(A.index||0)-(E.index||0)),(b=this.orChildrenGroup)!=null&&b.length&&this.orChildrenGroup.sort((A,E)=>(A.index||0)-(E.index||0)),this.captureVersion(),i==null||i.attemptAutoclose(V.AfterAllChildrenInitialized,this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],l=[],c=[],e=[];return this.parent.type===o.DataType?(this.parentRelationType===Fe.AndDataTypeGroup?this.parent.addToAndGroup(this,i):this.parentRelationType===Fe.OrDataTypeGroup&&this.parent.addToOrGroup(this,i),e.push(this.parent)):this.parent.type===o.DefinitionEntity?(this.parent.setAdditionalPropertiesDataType(this,i),e.push(this.parent)):this.parent.type!==o.BuiltInBaseEntity&&this.parent.setDataType(this,i),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}setParent(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetParent))){var l;return this.checkCanEditWithCounterpartAndSideEffects(this,i,V.SetParent,r)?(((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(V.SetParent,this.id),this):this}removeChildGroup(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveChildGroup))){if(!this.checkCanEdit(this,r))return ae.warn(`[removeChildGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.RemoveChildGroup,this.id),this;if(this.andChildrenGroup){const l=this.andChildrenGroup.findIndex(c=>c.id===i.id);l!==-1&&(this.andChildrenGroup.splice(l,1),r==null||r.add(this,W.Updated))}if(this.orChildrenGroup){const l=this.orChildrenGroup.findIndex(c=>c.id===i.id);l!==-1&&(this.orChildrenGroup.splice(l,1),r==null||r.add(this,W.Updated))}return r==null||r.attemptAutoclose(V.RemoveChildGroup,this.id),this}initChildren(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"init-children"))){var r,l,c,e,y,v,b,A,E,w;if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.entity)if(this.initialData.entity.type===o.GenericReference){const P=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=P}else this.entity=me(this.initialData.entity,this.project),(((l=(r=this.initialData.entity)==null?void 0:r.parent)==null?void 0:l.id)===this.id||((e=(c=this.initialData.entity)==null?void 0:c.parent)==null?void 0:e.type)===o.GenericReference&&((v=(y=this.initialData.entity)==null?void 0:y.parent)==null?void 0:v.entityId)==this.id)&&this.entity.setParent(this,null),(A=(b=this.entity).initChildren)==null||A.call(b,i);if(this.initialData.foreignKeyRef)if(this.initialData.foreignKeyRef.type===o.GenericReference){const P=this.project.findSubscribedInstanceFromReference(this.initialData.foreignKeyRef);this.foreignKeyRef=P}else this.foreignKeyRef=me(this.initialData.foreignKeyRef,this.project),(w=(E=this.foreignKeyRef).initChildren)==null||w.call(E,i);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(P=>{const x=me(P,this.project);return x.setParent(this,null),x.initChildren(i),x})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(P=>{const x=me(P,this.project);return x.setParent(this,null),x.initChildren(i),x})),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const l=$n(this,i,r),c=Nn(this,l),e=this.toMeta();return this.options=l.options||e.options,this.parentRelationType=l.parentRelationType||e.parentRelationType,this.isList=l.isList!==void 0?l.isList:e.isList,this.inferred=l.inferred!==void 0?l.inferred:e.inferred,this.like=l.like!==void 0?l.like:e.like,this.asType=l.asType!==void 0?l.asType:e.asType,this.index=l.index!==void 0?l.index:e.index,this.implementationChooseOne=l.implementationChooseOne!==void 0?l.implementationChooseOne:e.implementationChooseOne,this.staticEntities=l.staticEntities!==void 0?l.staticEntities:e.staticEntities,this.interactiveEntities=l.interactiveEntities!==void 0?l.interactiveEntities:e.interactiveEntities,this.actionEntities=l.actionEntities!==void 0?l.actionEntities:e.actionEntities,super.baseMetaSync(l,this,r),l.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):l.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Be,...r){return await vi.repository.APILoad(this.id,...r),this}async APICreate(i=Be,...r){return await vi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Be,...r){return await vi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Be,...r){return await vi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Be,...r){return await vi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Be,r,...l){return await vi.repository.APILoadVersion(this.id,r,...l)}removeFromParent(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveFromParent))){var y,v;if(!this.checkCanEdit(this,i))return ae.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(((y=this.parent)==null?void 0:y.type)===o.DataType)this.parent.removeChildGroup(this,i);else if(((v=this.parent)==null?void 0:v.type)===o.DefinitionEntity)this.parent.removeAdditionalPropertiesDataType(i);else{const b=this.parent;b==null||b.removeDataType(i)}return this.parent&&this.parent.type!==o.BuiltInBaseEntity&&r.push(this.parent),i==null||i.attemptAutoclose(V.RemoveFromParent,this.id),{added:O(c),updated:O(r),removed:O(l),affected:O(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveEntity))){const l=[],c=[],e=[],y=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(V.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(v=>{const{updated:b,removed:A,added:E}=v.entity.onDetachedDependencyRemoved(this,v.field,r);l.push(...b),c.push(...A),e.push(...E)}),this.entity&&this.entity.type===o.DefinitionEntity&&this.entity.parent===this){const{updated:v,removed:b}=this.entity.remove({ignoreUpstream:!0},r);l.push(...v),c.push(...b)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(v=>{const{removed:b,updated:A}=v.remove({ignoreUpstream:!0},r);c.push(...b),l.push(...A)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(v=>{const{removed:b,updated:A}=v.remove({ignoreUpstream:!0},r);c.push(...b),l.push(...A)}),!i){const v=this.removeFromParent(r);e.push(...v.added),l.push(...v.updated),c.push(...v.removed),y.push(...v.affected)}return r==null||r.attemptAutoclose(V.RemoveEntity,this.id),{added:O(e),updated:O(l),removed:O(c),affected:O(y),self:this}}restore({}={},i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RestoreEntity))){if(!this.checkCanEdit(this,i))return ae.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:b,added:A}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),c.push(...b),r.push(...A)}),this.entity&&this.entity.type===o.DefinitionEntity&&this.entity.parent===this){const{updated:y}=this.entity.restore({},i);l.push(...y)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(y=>{const{updated:v,added:b}=y.restore({},i);l.push(...v),r.push(...b)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(y=>{const{updated:v,added:b}=y.restore({},i);l.push(...v),r.push(...b)}),this.parent.type===o.DataType){const y=this.parent;Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this)}if(this.parent.type===o.DataType){const y=this.parent;this.parentRelationType===Fe.AndDataTypeGroup?Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this):this.parentRelationType===Fe.OrDataTypeGroup&&Array.isArray(y.orChildrenGroup)&&y.orChildrenGroup.push(this)}else if(this.parent.type===o.DefinitionEntity){const y=this.parent;y.setAdditionalPropertiesDataType(this,i),l.push(y)}else{const y=this.parent;y.setDataType(this,i),l.push(y)}return i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:O(r),updated:O(l),removed:O(c),affected:O(e),self:this}}toFlat(i=new Set){var l,c,e,y;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(v=>v.toFlat(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(v=>v.toFlat(i)))||[],...((e=this.entity)==null?void 0:e.toFlat(i))||[],...((y=this.foreignKeyRef)==null?void 0:y.toFlat(i))||[]])}toFlatIds(i=new Set){var l,c,e,y;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(v=>v.toFlatIds(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(v=>v.toFlatIds(i)))||[],...((e=this.entity)==null?void 0:e.toFlatIds(i))||[],...((y=this.foreignKeyRef)==null?void 0:y.toFlatIds(i))||[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,like:this.like,isList:this.isList,inferred:this.inferred,index:this.index,foreignKeyAllowed:this.foreignKeyAllowed,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,options:this.options,asType:this.asType,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var r,l,c,e,y;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,options:this.options,isList:this.isList,asType:this.asType,index:this.index,like:this.like,foreignKeyAllowed:this.foreignKeyAllowed,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,foreignKeyRef:((r=this.foreignKeyRef)==null?void 0:r.toJSON(i))||null,andChildrenGroup:((l=this.andChildrenGroup)==null?void 0:l.map(v=>v.toJSON(i)))||null,orChildrenGroup:((c=this.orChildrenGroup)==null?void 0:c.map(v=>v.toJSON(i)))||null,entity:((e=this.entity)==null?void 0:e.parent)===this?this.entity.toJSON(i):((y=this.entity)==null?void 0:y.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=dt){var l,c,e,y,v,b,A,E,w,P;let r;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||jn(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(r),(v=i.seenEntities)==null||v.add(this.id),{id:r,version:L.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,options:this.options,isList:this.isList,asType:this.asType,like:this.like,index:this.index,inferred:this.inferred,foreignKeyAllowed:this.foreignKeyAllowed,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,foreignKeyRef:((b=this.foreignKeyRef)==null?void 0:b.toJSONClone({...i,newId:null}))||null,andChildrenGroup:((A=this.andChildrenGroup)==null?void 0:A.map(x=>x.toJSONClone({...i,newId:null})))||null,orChildrenGroup:((E=this.orChildrenGroup)==null?void 0:E.map(x=>x.toJSONClone({...i,newId:null})))||null,entity:((w=this.entity)==null?void 0:w.parent)===this?this.entity.toJSONClone({...i,newId:null}):((P=this.entity)==null?void 0:P.toReference({seenEntityMaps:i.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=dt){var l;let r=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+L.UUID.uuid()+"--ref",type:o.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=dt){var l,c,e,y,v;let r=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,isList:this.isList,options:this.options,asType:this.asType,index:this.index,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,foreignKeyAllowed:this.foreignKeyAllowed,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,foreignKeyRef:((c=this.foreignKeyRef)==null?void 0:c.toReference(i))||null,andChildrenGroup:((e=this.andChildrenGroup)==null?void 0:e.map(b=>b.toReference(i)))||null,orChildrenGroup:((y=this.orChildrenGroup)==null?void 0:y.map(b=>b.toReference(i)))||null,entity:((v=this.entity)==null?void 0:v.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var l,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatJSON(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(y=>y.toFlatJSON(i)))||[],...((e=this.entity)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(){var i,r;return{id:this.id,type:this.type,options:this.options||void 0,isList:this.isList,like:this.like,parentRelationType:this.parentRelationType||void 0,foreignKeyRef:((i=this.foreignKeyRef)==null?void 0:i.id)||null,asType:this.asType,entity:((r=this.entity)==null?void 0:r.id)||null,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var l,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...this.entity&&this.entity.type==o.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(i)||[]])}clearErrors(){var i,r,l,c;return this.errors=[],(i=this.andChildrenGroup)==null||i.forEach(e=>e.clearErrors()),(r=this.orChildrenGroup)==null||r.forEach(e=>e.clearErrors()),this.inferred&&this.entity&&this.entity.type===o.DefinitionEntity&&((l=this.entity)==null?void 0:l.parent)===this&&((c=this.entity)==null||c.clearErrors()),this}validate(){const i=hxe(this);return this.errors=i,{success:!0}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.CloneEntity)),r=null,l=null,c=!0){var x,M,k,q;const e=Vn(r,this),y=r||this.parent,v=l||L.UUID.uuid(),b=new Set([...this.project.getAllBuiltInIds(),...rn()]),A={id:v,version:L.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||"1",previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:o.DataType,isList:this.isList,asType:this.asType,options:this.options,index:this.index,parentRelationType:this.parentRelationType,staticEntities:this.staticEntities,foreignKeyAllowed:this.foreignKeyAllowed,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,foreignKeyRef:((x=this.foreignKeyRef)==null?void 0:x.toReference())||null,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:y.toReference()},E=Ui(A,e);E.hydrateAncestors(),E.setParent(y,null),c&&(E.subscribe(),E.addSelfToProject(i)),E.initChildren(i),i==null||i.add(E,W.Added);const w=(M=this.andChildrenGroup)==null?void 0:M.map(Z=>b.has(Z.id)?e.getBuiltIn(Z.id):Z.clone(i,E,L.UUID.uuid(),c)),P=(k=this.orChildrenGroup)==null?void 0:k.map(Z=>b.has(Z.id)?e.getBuiltIn(Z.id):Z.clone(i,E,L.UUID.uuid(),c));if(E.andChildrenGroup=w||null,E.orChildrenGroup=P||null,this.entity&&this.entity.type===o.DefinitionEntity&&((q=this.entity)==null?void 0:q.parent)===this)if(b.has(this.entity.id))E.setEntity(e.getBuiltIn(this.entity.id),i);else{const Z=this.entity.clone(i,E,L.UUID.uuid(),c);E.setEntity(Z,i)}else if(this.entity){const Z=e.get(this.entity.id)||e.getBuiltIn(this.entity.id);E.setEntity(Z,i)}return i==null||i.attemptAutoclose(V.CloneEntity,this.id),E}merge(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.MergeDataTypes))){var v,b,A;const l=[],c=[],e=[],y=[];if(!this.checkCanEdit(this,r))return ae.warn(`[${V.MergeDataTypes}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.MergeDataTypes,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.asType!==(i==null?void 0:i.asType)&&(this.metaSync({asType:i==null?void 0:i.asType},r),r==null||r.add(this,W.Updated),l.push(this)),this.index!==(i==null?void 0:i.index)&&(this.metaSync({index:i==null?void 0:i.index},r),r==null||r.add(this,W.Updated),l.push(this)),this.foreignKeyAllowed!==(i==null?void 0:i.foreignKeyAllowed)&&(this.metaSync({foreignKeyAllowed:i==null?void 0:i.foreignKeyAllowed},r),r==null||r.add(this,W.Updated),l.push(this)),this.isList!==(i==null?void 0:i.isList)&&(this.metaSync({isList:i==null?void 0:i.isList},r),r==null||r.add(this,W.Updated),l.push(this)),this.like!==(i==null?void 0:i.like)&&(this.metaSync({like:i==null?void 0:i.like},r),r==null||r.add(this,W.Updated),l.push(this)),((v=i==null?void 0:i.foreignKeyRef)==null?void 0:v.id)!==((b=this.foreignKeyRef)==null?void 0:b.id)&&(this.setForeignKeyRef((i==null?void 0:i.foreignKeyRef)||null,r),r==null||r.add(this,W.Updated),l.push(this)),i!=null&&i.entity&&(i==null?void 0:i.entity.type)===o.DefinitionEntity&&(i==null?void 0:i.entity).parent===i)if(((A=this.entity)==null?void 0:A.type)===o.DefinitionEntity&&this.entity.parent===this)f_(this.entity,i.entity)||d$e(this.entity,i.entity,r);else{const E=i.entity.clone(r,this,L.UUID.uuid(),!0);this.setEntity(E,r),c.push(E)}else i!=null&&i.entity&&(this.setEntity(i==null?void 0:i.entity,r),r==null||r.add(this,W.Updated),l.push(this));return this.inferred!==(i==null?void 0:i.inferred)&&this.metaSync({inferred:(i==null?void 0:i.inferred)??!1},r),r==null||r.attemptAutoclose(V.MergeDataTypes,this.id),{updated:O(l),added:O(c),removed:O(e),affected:O(y),self:this}}addToAndGroup(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AddToAndGroup))){return this.checkCanEdit(this,r)?(this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(i)||(this.andChildrenGroup.push(i),r==null||r.add(i,W.Affected)),r==null||r.attemptAutoclose(V.AddToAndGroup,this.id),this):(ae.warn(`[${V.AddToAndGroup}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.AddToAndGroup,this.id),this)}addToOrGroup(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AddToOrGroup))){return this.checkCanEdit(this,r)?(this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(i)||(this.orChildrenGroup.push(i),r==null||r.add(i,W.Affected)),r==null||r.attemptAutoclose(V.AddToOrGroup,this.id),this):(ae.warn(`[${V.AddToOrGroup}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.AddToOrGroup,this.id),this)}setForeignKeyRef(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetDataTypeForeignKeyRef))){if(!this.checkCanEdit(this,r))return ae.warn(`[${V.SetDataTypeForeignKeyRef}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.SetDataTypeForeignKeyRef,this.id),this;const l=this.foreignKeyRef;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.foreignKeyRef=i,r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(V.SetDataTypeForeignKeyRef,this.id),this}setEntity(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetDataTypeEntityValue))){var c;if(!this.checkCanEdit(this,r))return ae.warn(`[${V.SetDataTypeEntityValue}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.SetDataTypeEntityValue,this.id),this;const l=this.entity;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.entity=i,r==null||r.add(this,W.Affected),l&&l.type===o.DefinitionEntity&&((c=l.parent)==null?void 0:c.id)===this.id&&(l==null||l.remove({ignoreUpstream:!0},r))),r==null||r.attemptAutoclose(V.SetDataTypeEntityValue,this.id),this}isObject(){return!!this.entity&&(this.entity.type===o.DefinitionEntity||this.entity.type===o.BuiltInBaseEntity||this.entity.name===le.KeyValue)&&!this.isList}canBeObject(){var r;let i=!1;if(this.parent.type!==o.DataType&&this.parent.type!==o.ActionDescriptor&&this.parent.type!==o.BuiltInBaseEntity&&this.parent.type!==o.DefinitionEntity&&this.parent.type!==o.FunctionDeclaration){const l=(r=this.project.requestActiveDynamicValue(this.parent))==null?void 0:r.value;l?!l.valueAsType&&(l.value===""||l.value===null||o2t(l))&&(i=!0):i=!0}return(this.isObject()||!this.entity||this.entity.name===le.Untyped)&&i}hasStrictObjectStructure(){var i;return this.isObject()&&((i=this.entity)==null?void 0:i.type)===o.DefinitionEntity}isInlineDeclaredEntity(){var i,r;return((i=this.entity)==null?void 0:i.type)===o.DefinitionEntity&&((r=this.entity.parent)==null?void 0:r.id)===(this==null?void 0:this.id)}isIndependentlyUserDeclaredEntity(){var i,r;return((i=this.entity)==null?void 0:i.type)===o.DefinitionEntity&&((r=this.entity)==null?void 0:r.parent)!==this}canModifyObjectStructure(){var r;const i=this.isIndependentlyUserDeclaredEntity();return(this.isInlineDeclaredEntity()||this.canBeObject()||((r=this.entity)==null?void 0:r.name)===le.KeyValue)&&!i}inferFromInputs(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"infer-data-type-from-inputs"))){var v;const l=[],c=[],e=[],y=[];if(!this.inferred)return r==null||r.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:[],added:[],removed:[],affected:[],self:this};if(!this.entity&&i.length){const b=oe(this.parent,this.project)+" data type definition",A={id:L.UUID.uuid(),deletable:!0,editable:!0,type:o.DefinitionEntity,version:L.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||B().toISOString(),author:L.sessionAuthor,previousVersion:null,deleted:!1,name:b,description:((v=this.parent)==null?void 0:v.description)||null,codeName:null,static:!0,abstract:!1,properties:[],methods:[],extends:null,implements:[],abstractMethods:[],allPropertiesImplement:null,additionalPropertiesDataType:null,additionalProperties:!0,x:0,y:0,parent:this.toReference()},E=me(A,this.project);E.hydrateAncestors(),E.setParent(this,r),E.initChildren(r),r==null||r.add(E,W.Added),E.metaSync(A,r),this.setEntity(E,r),r==null||r.add(this,W.Updated)}if(this.entity){const{updated:b,added:A,removed:E,affected:w}=this.entity.inferFromInputs(i,r);c.push(...b),l.push(...A),e.push(...E),y.push(...w)}return this.like||this.metaSync({like:!0},r),r==null||r.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:O(c),added:O(l),removed:O(e),affected:O(y),self:this}}};R(vi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...l)=>null}),R(vi,"type",o.DataType),R(vi,"USER_MANAGED_PARENT_TYPES",[o.Property,o.ArgumentDeclaration,o.ReturnStatement,o.BreakStatement,o.ContinueStatement,o.VariableDeclaration,o.ValueDescriptor,o.InputMap,o.OutputMap,o.DataType,o.FunctionDeclaration,o.ActionDescriptor,o.Loop,o.Search,o.DefinitionEntity]),R(vi,"PARENT_TYPES",[...vi.USER_MANAGED_PARENT_TYPES,o.BuiltInBaseEntity]),R(vi,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","foreignKeyAllowed","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),R(vi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","index","author","previousVersion"]),R(vi,"BASE_PROPERTIES",[...vi.MUTABLE_BASE_PROPERTIES,...vi.INMUTABLE_BASE_PROPERTIES]),R(vi,"MUTABLE_META_PROPERTIES",[...vi.MUTABLE_BASE_PROPERTIES,"inferred"]),R(vi,"INMUTABLE_META_PROPERTIES",[...vi.INMUTABLE_BASE_PROPERTIES]),R(vi,"META_PROPERTIES",[...vi.MUTABLE_META_PROPERTIES,...vi.INMUTABLE_META_PROPERTIES]),R(vi,"MUTABLE_UPSTREAM_PROPERTIES",["entity","foreignKeyRef","parent"]),R(vi,"INMUTABLE_UPSTREAM_PROPERTIES",[]),R(vi,"UPSTREAM_PROPERTIES",[...vi.MUTABLE_UPSTREAM_PROPERTIES,...vi.INMUTABLE_UPSTREAM_PROPERTIES]),R(vi,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),R(vi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),R(vi,"DOWNSTREAM_PROPERTIES",[...vi.MUTABLE_DOWNSTREAM_PROPERTIES,...vi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(vi,"PROPERTIES",[...vi.META_PROPERTIES,...vi.UPSTREAM_PROPERTIES,...vi.DOWNSTREAM_PROPERTIES]);let dn=vi;function mxe(d){var r;const p=d.implements.flatMap(l=>Txe(d,l));return(r=d.dataType)==null||r.validate(),[...p,...xc(d),...vxe(d)]}function Txe(d,p){const i=[];if(!d.implements)return i;if(!p.abstract){const l=Ut({id:`${d.id}--${be.PropertyImplementsNonAbstact}`,message:`Property "${oe(d,d.project)}" with id "${d.id}" implements a non-abstract property "${oe(p,d.project)}" with id "${p.id}".`,severity:ce.Error,code:be.PropertyImplementsNonAbstact,entity:d});i.push(l.error)}if(d.static&&!p.static){const l=Ut({id:`${d.id}--${be.NonStaticPropertyImplementsStatic}`,message:`Static property "${oe(d,d.project)}" with id "${d.id}" implements a non-static property "${oe(p,d.project)}" with id "${p.id}".`,severity:ce.Error,code:be.NonStaticPropertyImplementsStatic,entity:d});i.push(l.error)}if(!d.static&&p.static){const l=Ut({id:`${d.id}--${be.StaticPropertyImplementsNonStatic}`,message:`Non-static property "${oe(d,d.project)}" with id "${d.id}" implements a static property "${oe(p,d.project)}" with id "${p.id}".`,severity:ce.Error,code:be.StaticPropertyImplementsNonStatic,entity:d});i.push(l.error)}if(!Rr(d.dataType,p.dataType)){const l=Ut({id:`${d.id}--${be.PropertyImplementsIncompatibleType}`,message:`Property "${oe(d,d.project)}" with id "${d.id}" implements a property "${oe(p,d.project)}" with id "${p.id}" that has an incompatible data type.`,severity:ce.Error,code:be.PropertyImplementsIncompatibleType,entity:d});i.push(l.error)}return nn(d.errors,i)}function vxe(d,p){const r=[...d.parent.allProperties].filter(l=>{var c;return l.id!==d.id&&!d.implements.find(e=>e.id===l.id)&&l.id!==((c=d.extends)==null?void 0:c.id)});return xT(d,[Ji],r,p)}const d2t=Object.freeze(Object.defineProperty({__proto__:null,validate:mxe,validateImplementation:Txe,validatePropertyEntityName:vxe},Symbol.toStringTag,{value:"Module"}));function u2t(d,p){const i=[];if(d.parent){const l=p.get(d.parent);if(!l)i.push(new Oe({id:`${d.id}--${d.parent}--${re.ReferencedEntityNotFound}`,code:re.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${d.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}));else{const c=Op(l);if(c){const e=l!==c?`The entity of type '${d.type}' with id '${d.id}' have 'parent' with id '${d.parent}' because the entity belongs to a built-in '${c.type}' entity with id '${c.id}' (${oe(c,l.project)}) higher up in the tree.`:`The entity of type '${d.type}' with id '${d.id}' have 'parent' with id '${d.parent}' because it is a built-in entity of type ${c.type}.`;i.push(new Oe({id:`${d.id}--${re.InvalidBuiltInEntityReference}`,code:re.InvalidBuiltInEntityReference,severity:ce.Error,message:e}))}else if(![o.DefinitionEntity].includes(l.type))i.push(new Oe({id:`${d.id}--${d.parent}--${re.InvalidParentReference}`,code:re.InvalidParentReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a parent reference that isn't pointing to an entity of type 'definition-entity'.`}));else{const y=Hr(l).filter(v=>!v.interactive);if(y.length){let v=y.length>1?`The entity of type '${d.type}' with id '${d.id}' can't be added to the 'parent' entity with id '${l.id}' because it extends or implements multiple '${o.BuiltInBaseEntity}' entities that are non-interactive ("${Dt(y.map(b=>oe(b,b.project)),'", "','" and "')}").`:`The entity of type '${d.type}' with id '${d.id}' can't be added to the 'parent' entity with id '${l.id}' because it extends or implements a '${o.BuiltInBaseEntity}' entity that is non-interactive ("${oe(y[0],y[0].project)}").`;v+=`
|
|
387
|
+
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`}))}A===o.DataType&&(!l.parentRelationType||!(l.parentRelationType===Fe.AndDataTypeGroup||l.parentRelationType===Fe.OrDataTypeGroup))&&c.push(new Oe({id:`${i.id}--${re.InvalidParentRelationType}`,code:re.InvalidParentRelationType,severity:ce.Error,message:`The entity with id '${i.id}' and type '${i.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`}))}return{errors:c,modifiedData:l}}get isGroup(){const i=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(i.length>1){let r=0;for(const l of i)if(l.isResolved&&(r++,r>1))return!0}return!1}get isResolved(){return[o.BuiltInBaseEntity,o.ActionDescriptor].includes(this.parent.type)||Op(this.parent)?!0:!(!this.entity&&!this.isGroup&&!this.foreignKeyRef&&!this.foreignKeyAllowed)}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],l=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);r.push(...v.updated),l.push(...v.added),c.push(...v.removed),e.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}onDetachedDependencyRemoved(i,r,l){const c=[],e=[],y=[],v=[];return r==="entity-field"&&this.setEntity(null,l),r==="foreign-key-ref-field"&&this.setForeignKeyRef(null,l),{updated:O(c),added:O(e),removed:O(y),affected:O(v),self:this}}onDetachedDependencyRestored(i,r,l){const c=[],e=[],y=[],v=[];return r==="entity-field"&&this.setEntity(i,l),r==="foreign-key-ref-field"&&this.setForeignKeyRef(i,l),{updated:O(c),added:O(e),removed:O(y),affected:O(v),self:this}}unsubscribeFromDependencies(){var i,r,l,c;return(r=(i=this.entity)==null?void 0:i.unsubscribeDependents)==null||r.call(i,[{entity:this,field:"entity-field"}]),(c=(l=this.foreignKeyRef)==null?void 0:l.unsubscribeDependents)==null||c.call(l,[{entity:this,field:"foreign-key-ref-field"}]),this}subscribeToDependencies(){var i,r,l,c;return(r=(i=this.entity)==null?void 0:i.subscribeDependents)==null||r.call(i,[{entity:this,field:"entity-field"}]),(c=(l=this.foreignKeyRef)==null?void 0:l.subscribeDependents)==null||c.call(l,[{entity:this,field:"foreign-key-ref-field"}]),this}increaseVersion(i){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=L.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this)}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new vi(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.entity=this.entity,i.foreignKeyRef=this.foreignKeyRef,i.andChildrenGroup=this.andChildrenGroup?[...this.andChildrenGroup]:this.andChildrenGroup,i.orChildrenGroup=this.orChildrenGroup?[...this.orChildrenGroup]:this.orChildrenGroup,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const r=[],l=[],c=[],e=[];if(this.parent&&this.parent.type!==o.BuiltInBaseEntity){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...y.updated),l.push(...y.added),c.push(...y.removed)}return{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}async restoreVersion(i){var v;const r=[],l=[],c=[],e=[];if(this.version===i)return{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this};if(!this.knownVersions){const b=new Map;for(const[A,E]of this.knownVersions||new Map){if(b.set(A,E),E.activeVersion=!1,E.knownVersions)for(const[w,P]of E.knownVersions)b.set(w,P);E.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const b=await this.APILoadVersion({},i);if(!b)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new vi(b,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.entity=y.entity,this.foreignKeyRef=y.foreignKeyRef,this.andChildrenGroup=y.andChildrenGroup?[...y.andChildrenGroup]:null,this.orChildrenGroup=y.orChildrenGroup?[...y.orChildrenGroup]:null,this.parent=y.parent,{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.UpdateWithShallowTransfer))){var l,c;if(!this.checkCanEdit(this,r))return ae.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const e=ye(i.parent),y=this.project.get(e),v=this.parent;if(v&&v.id!==(y==null?void 0:y.id)&&this.removeFromParent(r),y)this.setParent(y,r),this.addSelfToProject(r);else throw r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.entity){const e=ye(i.entity),y=this.project.get(e);y&&(y.type===o.DefinitionEntity&&y.parent===this||this.setEntity(y,null))}if(i.foreignKeyRef){const e=ye(i.foreignKeyRef),y=this.project.get(e);y&&this.setForeignKeyRef(y,null)}return(l=i.andChildrenGroup)==null||l.forEach(e=>{const y=ye(e),v=this.project.get(y);v&&(this.addToAndGroup(v,r),v.setParent(this,r))}),[...this.andChildrenGroup||[]].forEach(e=>{var v;((v=i.andChildrenGroup)==null?void 0:v.find(b=>ye(b)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),(c=i.orChildrenGroup)==null||c.forEach(e=>{const y=ye(e),v=this.project.get(y);v&&(this.addToOrGroup(v,r),v.setParent(this,r))}),[...this.orChildrenGroup||[]].forEach(e=>{var v;((v=i.orChildrenGroup)==null?void 0:v.find(b=>ye(b)===e.id))||(this.removeChildGroup(e,r),e.removeFromParent(r))}),this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],r=[],l=[],c=[];if(this.initialData.parent){const e=ye(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null),i.push(y);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.entity){const e=ye(this.initialData.entity),y=this.project.get(e);y&&(y.type===o.DefinitionEntity&&y.parent===this||(this.setEntity(y,null),y.type!==o.BuiltInBaseEntity&&y.type!==o.PrimitiveEntity&&i.push(y)))}if(this.initialData.foreignKeyRef){const e=ye(this.initialData.foreignKeyRef),y=this.project.get(e);y&&this.setForeignKeyRef(y,null)}return{updated:O(i),added:O(r),removed:O(l),affected:O(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AfterAllChildrenInitialized))){var y,v,b;if(!this.checkCanEdit(this,i))return ae.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(this.initialized=!0,((y=this.parent)==null?void 0:y.type)===o.DataType){let A=this.index||0;const E=(this.parentRelationType===Fe.AndDataTypeGroup?this.parent.andChildrenGroup||[]:this.parent.orChildrenGroup||[]).filter(P=>!P.deleted&&P.id!==this.id);E.length&&(A>E.length+1?A=E.length:A<0&&(A=0)),E.find(P=>(P.index||0)===A&&!P.deleted)&&E.filter(P=>(P.index||0)>=A&&!P.deleted).forEach(P=>{P.metaSync({index:(P.index||0)+1},i),i==null||i.add(P,W.Updated),r.push(P)}),this.metaSync({index:A},i)}return(v=this.andChildrenGroup)!=null&&v.length&&this.andChildrenGroup.sort((A,E)=>(A.index||0)-(E.index||0)),(b=this.orChildrenGroup)!=null&&b.length&&this.orChildrenGroup.sort((A,E)=>(A.index||0)-(E.index||0)),this.captureVersion(),i==null||i.attemptAutoclose(V.AfterAllChildrenInitialized,this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],l=[],c=[],e=[];return this.parent.type===o.DataType?(this.parentRelationType===Fe.AndDataTypeGroup?this.parent.addToAndGroup(this,i):this.parentRelationType===Fe.OrDataTypeGroup&&this.parent.addToOrGroup(this,i),e.push(this.parent)):this.parent.type===o.DefinitionEntity?(this.parent.setAdditionalPropertiesDataType(this,i),e.push(this.parent)):this.parent.type!==o.BuiltInBaseEntity&&this.parent.setDataType(this,i),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}setParent(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetParent))){var l;return this.checkCanEditWithCounterpartAndSideEffects(this,i,V.SetParent,r)?(((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(V.SetParent,this.id),this):this}removeChildGroup(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveChildGroup))){if(!this.checkCanEdit(this,r))return ae.warn(`[removeChildGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.RemoveChildGroup,this.id),this;if(this.andChildrenGroup){const l=this.andChildrenGroup.findIndex(c=>c.id===i.id);l!==-1&&(this.andChildrenGroup.splice(l,1),r==null||r.add(this,W.Updated))}if(this.orChildrenGroup){const l=this.orChildrenGroup.findIndex(c=>c.id===i.id);l!==-1&&(this.orChildrenGroup.splice(l,1),r==null||r.add(this,W.Updated))}return r==null||r.attemptAutoclose(V.RemoveChildGroup,this.id),this}initChildren(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"init-children"))){var r,l,c,e,y,v,b,A,E,w;if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.entity)if(this.initialData.entity.type===o.GenericReference){const P=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=P}else this.entity=me(this.initialData.entity,this.project),(((l=(r=this.initialData.entity)==null?void 0:r.parent)==null?void 0:l.id)===this.id||((e=(c=this.initialData.entity)==null?void 0:c.parent)==null?void 0:e.type)===o.GenericReference&&((v=(y=this.initialData.entity)==null?void 0:y.parent)==null?void 0:v.entityId)==this.id)&&this.entity.setParent(this,null),(A=(b=this.entity).initChildren)==null||A.call(b,i);if(this.initialData.foreignKeyRef)if(this.initialData.foreignKeyRef.type===o.GenericReference){const P=this.project.findSubscribedInstanceFromReference(this.initialData.foreignKeyRef);this.foreignKeyRef=P}else this.foreignKeyRef=me(this.initialData.foreignKeyRef,this.project),(w=(E=this.foreignKeyRef).initChildren)==null||w.call(E,i);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(P=>{const x=me(P,this.project);return x.setParent(this,null),x.initChildren(i),x})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(P=>{const x=me(P,this.project);return x.setParent(this,null),x.initChildren(i),x})),this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const l=$n(this,i,r),c=Nn(this,l),e=this.toMeta();return this.options=l.options||e.options,this.parentRelationType=l.parentRelationType||e.parentRelationType,this.isList=l.isList!==void 0?l.isList:e.isList,this.inferred=l.inferred!==void 0?l.inferred:e.inferred,this.like=l.like!==void 0?l.like:e.like,this.asType=l.asType!==void 0?l.asType:e.asType,this.index=l.index!==void 0?l.index:e.index,this.implementationChooseOne=l.implementationChooseOne!==void 0?l.implementationChooseOne:e.implementationChooseOne,this.staticEntities=l.staticEntities!==void 0?l.staticEntities:e.staticEntities,this.interactiveEntities=l.interactiveEntities!==void 0?l.interactiveEntities:e.interactiveEntities,this.actionEntities=l.actionEntities!==void 0?l.actionEntities:e.actionEntities,super.baseMetaSync(l,this,r),l.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):l.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Be,...r){return await vi.repository.APILoad(this.id,...r),this}async APICreate(i=Be,...r){return await vi.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Be,...r){return await vi.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Be,...r){return await vi.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Be,...r){return await vi.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Be,r,...l){return await vi.repository.APILoadVersion(this.id,r,...l)}removeFromParent(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveFromParent))){var y,v;if(!this.checkCanEdit(this,i))return ae.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(((y=this.parent)==null?void 0:y.type)===o.DataType)this.parent.removeChildGroup(this,i);else if(((v=this.parent)==null?void 0:v.type)===o.DefinitionEntity)this.parent.removeAdditionalPropertiesDataType(i);else{const b=this.parent;b==null||b.removeDataType(i)}return this.parent&&this.parent.type!==o.BuiltInBaseEntity&&r.push(this.parent),i==null||i.attemptAutoclose(V.RemoveFromParent,this.id),{added:O(c),updated:O(r),removed:O(l),affected:O(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveEntity))){const l=[],c=[],e=[],y=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(V.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(v=>{const{updated:b,removed:A,added:E}=v.entity.onDetachedDependencyRemoved(this,v.field,r);l.push(...b),c.push(...A),e.push(...E)}),this.entity&&this.entity.type===o.DefinitionEntity&&this.entity.parent===this){const{updated:v,removed:b}=this.entity.remove({ignoreUpstream:!0},r);l.push(...v),c.push(...b)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(v=>{const{removed:b,updated:A}=v.remove({ignoreUpstream:!0},r);c.push(...b),l.push(...A)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(v=>{const{removed:b,updated:A}=v.remove({ignoreUpstream:!0},r);c.push(...b),l.push(...A)}),!i){const v=this.removeFromParent(r);e.push(...v.added),l.push(...v.updated),c.push(...v.removed),y.push(...v.affected)}return r==null||r.attemptAutoclose(V.RemoveEntity,this.id),{added:O(e),updated:O(l),removed:O(c),affected:O(y),self:this}}restore({}={},i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RestoreEntity))){if(!this.checkCanEdit(this,i))return ae.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:b,added:A}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),c.push(...b),r.push(...A)}),this.entity&&this.entity.type===o.DefinitionEntity&&this.entity.parent===this){const{updated:y}=this.entity.restore({},i);l.push(...y)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(y=>{const{updated:v,added:b}=y.restore({},i);l.push(...v),r.push(...b)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(y=>{const{updated:v,added:b}=y.restore({},i);l.push(...v),r.push(...b)}),this.parent.type===o.DataType){const y=this.parent;Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this)}if(this.parent.type===o.DataType){const y=this.parent;this.parentRelationType===Fe.AndDataTypeGroup?Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this):this.parentRelationType===Fe.OrDataTypeGroup&&Array.isArray(y.orChildrenGroup)&&y.orChildrenGroup.push(this)}else if(this.parent.type===o.DefinitionEntity){const y=this.parent;y.setAdditionalPropertiesDataType(this,i),l.push(y)}else{const y=this.parent;y.setDataType(this,i),l.push(y)}return i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:O(r),updated:O(l),removed:O(c),affected:O(e),self:this}}toFlat(i=new Set){var l,c,e,y;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(v=>v.toFlat(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(v=>v.toFlat(i)))||[],...((e=this.entity)==null?void 0:e.toFlat(i))||[],...((y=this.foreignKeyRef)==null?void 0:y.toFlat(i))||[]])}toFlatIds(i=new Set){var l,c,e,y;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(v=>v.toFlatIds(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(v=>v.toFlatIds(i)))||[],...((e=this.entity)==null?void 0:e.toFlatIds(i))||[],...((y=this.foreignKeyRef)==null?void 0:y.toFlatIds(i))||[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,like:this.like,isList:this.isList,inferred:this.inferred,index:this.index,foreignKeyAllowed:this.foreignKeyAllowed,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,options:this.options,asType:this.asType,type:this.type,editable:this.editable,deletable:this.deletable}}toJSON(i=new Set){var r,l,c,e,y;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,options:this.options,isList:this.isList,asType:this.asType,index:this.index,like:this.like,foreignKeyAllowed:this.foreignKeyAllowed,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,foreignKeyRef:((r=this.foreignKeyRef)==null?void 0:r.toJSON(i))||null,andChildrenGroup:((l=this.andChildrenGroup)==null?void 0:l.map(v=>v.toJSON(i)))||null,orChildrenGroup:((c=this.orChildrenGroup)==null?void 0:c.map(v=>v.toJSON(i)))||null,entity:((e=this.entity)==null?void 0:e.parent)===this?this.entity.toJSON(i):((y=this.entity)==null?void 0:y.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=dt){var l,c,e,y,v,b,A,E,w,P;let r;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||jn(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(r),(v=i.seenEntities)==null||v.add(this.id),{id:r,version:L.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,options:this.options,isList:this.isList,asType:this.asType,like:this.like,index:this.index,inferred:this.inferred,foreignKeyAllowed:this.foreignKeyAllowed,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,foreignKeyRef:((b=this.foreignKeyRef)==null?void 0:b.toJSONClone({...i,newId:null}))||null,andChildrenGroup:((A=this.andChildrenGroup)==null?void 0:A.map(x=>x.toJSONClone({...i,newId:null})))||null,orChildrenGroup:((E=this.orChildrenGroup)==null?void 0:E.map(x=>x.toJSONClone({...i,newId:null})))||null,entity:((w=this.entity)==null?void 0:w.parent)===this?this.entity.toJSONClone({...i,newId:null}):((P=this.entity)==null?void 0:P.toReference({seenEntityMaps:i.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=dt){var l;let r=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+L.UUID.uuid()+"--ref",type:o.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=dt){var l,c,e,y,v;let r=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,isList:this.isList,options:this.options,asType:this.asType,index:this.index,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,foreignKeyAllowed:this.foreignKeyAllowed,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,foreignKeyRef:((c=this.foreignKeyRef)==null?void 0:c.toReference(i))||null,andChildrenGroup:((e=this.andChildrenGroup)==null?void 0:e.map(b=>b.toReference(i)))||null,orChildrenGroup:((y=this.orChildrenGroup)==null?void 0:y.map(b=>b.toReference(i)))||null,entity:((v=this.entity)==null?void 0:v.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var l,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatJSON(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(y=>y.toFlatJSON(i)))||[],...((e=this.entity)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(){var i,r;return{id:this.id,type:this.type,options:this.options||void 0,isList:this.isList,like:this.like,parentRelationType:this.parentRelationType||void 0,foreignKeyRef:((i=this.foreignKeyRef)==null?void 0:i.id)||null,asType:this.asType,entity:((r=this.entity)==null?void 0:r.id)||null,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var l,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...this.entity&&this.entity.type==o.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(i)||[]])}clearErrors(){var i,r,l,c;return this.errors=[],(i=this.andChildrenGroup)==null||i.forEach(e=>e.clearErrors()),(r=this.orChildrenGroup)==null||r.forEach(e=>e.clearErrors()),this.inferred&&this.entity&&this.entity.type===o.DefinitionEntity&&((l=this.entity)==null?void 0:l.parent)===this&&((c=this.entity)==null||c.clearErrors()),this}validate(){const i=hxe(this);return this.errors=i,{success:!0}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.CloneEntity)),r=null,l=null,c=!0){var x,M,k,q;const e=Vn(r,this),y=r||this.parent,v=l||L.UUID.uuid(),b=new Set([...this.project.getAllBuiltInIds(),...rn()]),A={id:v,version:L.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||"1",previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:o.DataType,isList:this.isList,asType:this.asType,options:this.options,index:this.index,parentRelationType:this.parentRelationType,staticEntities:this.staticEntities,foreignKeyAllowed:this.foreignKeyAllowed,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,foreignKeyRef:((x=this.foreignKeyRef)==null?void 0:x.toReference())||null,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:y.toReference()},E=Ui(A,e);E.hydrateAncestors(),E.setParent(y,null),c&&(E.subscribe(),E.addSelfToProject(i)),E.initChildren(i),i==null||i.add(E,W.Added);const w=(M=this.andChildrenGroup)==null?void 0:M.map(Z=>b.has(Z.id)?e.getBuiltIn(Z.id):Z.clone(i,E,L.UUID.uuid(),c)),P=(k=this.orChildrenGroup)==null?void 0:k.map(Z=>b.has(Z.id)?e.getBuiltIn(Z.id):Z.clone(i,E,L.UUID.uuid(),c));if(E.andChildrenGroup=w||null,E.orChildrenGroup=P||null,this.entity&&this.entity.type===o.DefinitionEntity&&((q=this.entity)==null?void 0:q.parent)===this)if(b.has(this.entity.id))E.setEntity(e.getBuiltIn(this.entity.id),i);else{const Z=this.entity.clone(i,E,L.UUID.uuid(),c);E.setEntity(Z,i)}else if(this.entity){const Z=e.get(this.entity.id)||e.getBuiltIn(this.entity.id);E.setEntity(Z,i)}return i==null||i.attemptAutoclose(V.CloneEntity,this.id),E}merge(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.MergeDataTypes))){var v,b,A;const l=[],c=[],e=[],y=[];if(!this.checkCanEdit(this,r))return ae.warn(`[${V.MergeDataTypes}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.MergeDataTypes,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.asType!==(i==null?void 0:i.asType)&&(this.metaSync({asType:i==null?void 0:i.asType},r),r==null||r.add(this,W.Updated),l.push(this)),this.index!==(i==null?void 0:i.index)&&(this.metaSync({index:i==null?void 0:i.index},r),r==null||r.add(this,W.Updated),l.push(this)),this.foreignKeyAllowed!==(i==null?void 0:i.foreignKeyAllowed)&&(this.metaSync({foreignKeyAllowed:i==null?void 0:i.foreignKeyAllowed},r),r==null||r.add(this,W.Updated),l.push(this)),this.isList!==(i==null?void 0:i.isList)&&(this.metaSync({isList:i==null?void 0:i.isList},r),r==null||r.add(this,W.Updated),l.push(this)),this.like!==(i==null?void 0:i.like)&&(this.metaSync({like:i==null?void 0:i.like},r),r==null||r.add(this,W.Updated),l.push(this)),((v=i==null?void 0:i.foreignKeyRef)==null?void 0:v.id)!==((b=this.foreignKeyRef)==null?void 0:b.id)&&(this.setForeignKeyRef((i==null?void 0:i.foreignKeyRef)||null,r),r==null||r.add(this,W.Updated),l.push(this)),i!=null&&i.entity&&(i==null?void 0:i.entity.type)===o.DefinitionEntity&&(i==null?void 0:i.entity).parent===i)if(((A=this.entity)==null?void 0:A.type)===o.DefinitionEntity&&this.entity.parent===this)f_(this.entity,i.entity)||d$e(this.entity,i.entity,r);else{const E=i.entity.clone(r,this,L.UUID.uuid(),!0);this.setEntity(E,r),c.push(E)}else i!=null&&i.entity&&(this.setEntity(i==null?void 0:i.entity,r),r==null||r.add(this,W.Updated),l.push(this));return this.inferred!==(i==null?void 0:i.inferred)&&this.metaSync({inferred:(i==null?void 0:i.inferred)??!1},r),r==null||r.attemptAutoclose(V.MergeDataTypes,this.id),{updated:O(l),added:O(c),removed:O(e),affected:O(y),self:this}}addToAndGroup(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AddToAndGroup))){return this.checkCanEdit(this,r)?(this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(i)||(this.andChildrenGroup.push(i),r==null||r.add(i,W.Affected)),r==null||r.attemptAutoclose(V.AddToAndGroup,this.id),this):(ae.warn(`[${V.AddToAndGroup}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.AddToAndGroup,this.id),this)}addToOrGroup(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AddToOrGroup))){return this.checkCanEdit(this,r)?(this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(i)||(this.orChildrenGroup.push(i),r==null||r.add(i,W.Affected)),r==null||r.attemptAutoclose(V.AddToOrGroup,this.id),this):(ae.warn(`[${V.AddToOrGroup}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.AddToOrGroup,this.id),this)}setForeignKeyRef(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetDataTypeForeignKeyRef))){if(!this.checkCanEdit(this,r))return ae.warn(`[${V.SetDataTypeForeignKeyRef}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.SetDataTypeForeignKeyRef,this.id),this;const l=this.foreignKeyRef;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.foreignKeyRef=i,r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(V.SetDataTypeForeignKeyRef,this.id),this}setEntity(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetDataTypeEntityValue))){var c;if(!this.checkCanEdit(this,r))return ae.warn(`[${V.SetDataTypeEntityValue}] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.SetDataTypeEntityValue,this.id),this;const l=this.entity;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.entity=i,r==null||r.add(this,W.Affected),l&&l.type===o.DefinitionEntity&&((c=l.parent)==null?void 0:c.id)===this.id&&(l==null||l.remove({ignoreUpstream:!0},r))),r==null||r.attemptAutoclose(V.SetDataTypeEntityValue,this.id),this}isObject(){return!!this.entity&&(this.entity.type===o.DefinitionEntity||this.entity.type===o.BuiltInBaseEntity||this.entity.name===le.KeyValue)&&!this.isList}canBeObject(){var r;let i=!1;if(this.parent.type!==o.DataType&&this.parent.type!==o.ActionDescriptor&&this.parent.type!==o.BuiltInBaseEntity&&this.parent.type!==o.DefinitionEntity&&this.parent.type!==o.FunctionDeclaration){const l=(r=this.project.requestActiveDynamicValue(this.parent))==null?void 0:r.value;l?!l.valueAsType&&(l.value===""||l.value===null||o2t(l))&&(i=!0):i=!0}return(this.isObject()||!this.entity||this.entity.name===le.Untyped)&&i}hasStrictObjectStructure(){var i;return this.isObject()&&((i=this.entity)==null?void 0:i.type)===o.DefinitionEntity}isInlineDeclaredEntity(){var i,r;return((i=this.entity)==null?void 0:i.type)===o.DefinitionEntity&&((r=this.entity.parent)==null?void 0:r.id)===(this==null?void 0:this.id)}isIndependentlyUserDeclaredEntity(){var i,r;return((i=this.entity)==null?void 0:i.type)===o.DefinitionEntity&&((r=this.entity)==null?void 0:r.parent)!==this}canModifyObjectStructure(){var r;const i=this.isIndependentlyUserDeclaredEntity();return(this.isInlineDeclaredEntity()||this.canBeObject()||((r=this.entity)==null?void 0:r.name)===le.KeyValue)&&!i}inferFromInputs(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"infer-data-type-from-inputs"))){var v;const l=[],c=[],e=[],y=[];if(!this.inferred)return r==null||r.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:[],added:[],removed:[],affected:[],self:this};if(!this.entity&&i.length){const b=oe(this.parent,this.project)+" data type definition",A={id:L.UUID.uuid(),deletable:!0,editable:!0,type:o.DefinitionEntity,version:L.UUID.uuid(),createdAt:(r==null?void 0:r.timestamp)||B().toISOString(),author:L.sessionAuthor,previousVersion:null,deleted:!1,name:b,description:((v=this.parent)==null?void 0:v.description)||null,codeName:null,static:!0,abstract:!1,properties:[],methods:[],extends:null,implements:[],abstractMethods:[],allPropertiesImplement:null,additionalPropertiesDataType:null,additionalProperties:!0,x:0,y:0,parent:this.toReference()},E=me(A,this.project);E.hydrateAncestors(),E.setParent(this,r),E.initChildren(r),r==null||r.add(E,W.Added),E.metaSync(A,r),this.setEntity(E,r),r==null||r.add(this,W.Updated)}if(this.entity){const{updated:b,added:A,removed:E,affected:w}=this.entity.inferFromInputs(i,r);c.push(...b),l.push(...A),e.push(...E),y.push(...w)}return this.like||this.metaSync({like:!0},r),r==null||r.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:O(c),added:O(l),removed:O(e),affected:O(y),self:this}}};R(vi,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...l)=>null}),R(vi,"type",o.DataType),R(vi,"USER_MANAGED_PARENT_TYPES",[o.Property,o.ArgumentDeclaration,o.ReturnStatement,o.BreakStatement,o.ContinueStatement,o.VariableDeclaration,o.ValueDescriptor,o.InputMap,o.OutputMap,o.DataType,o.FunctionDeclaration,o.ActionDescriptor,o.Loop,o.Search,o.DefinitionEntity]),R(vi,"PARENT_TYPES",[...vi.USER_MANAGED_PARENT_TYPES,o.BuiltInBaseEntity]),R(vi,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","foreignKeyAllowed","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),R(vi,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","index","author","previousVersion"]),R(vi,"BASE_PROPERTIES",[...vi.MUTABLE_BASE_PROPERTIES,...vi.INMUTABLE_BASE_PROPERTIES]),R(vi,"MUTABLE_META_PROPERTIES",[...vi.MUTABLE_BASE_PROPERTIES,"inferred"]),R(vi,"INMUTABLE_META_PROPERTIES",[...vi.INMUTABLE_BASE_PROPERTIES]),R(vi,"META_PROPERTIES",[...vi.MUTABLE_META_PROPERTIES,...vi.INMUTABLE_META_PROPERTIES]),R(vi,"MUTABLE_UPSTREAM_PROPERTIES",["entity","foreignKeyRef","parent"]),R(vi,"INMUTABLE_UPSTREAM_PROPERTIES",[]),R(vi,"UPSTREAM_PROPERTIES",[...vi.MUTABLE_UPSTREAM_PROPERTIES,...vi.INMUTABLE_UPSTREAM_PROPERTIES]),R(vi,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),R(vi,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),R(vi,"DOWNSTREAM_PROPERTIES",[...vi.MUTABLE_DOWNSTREAM_PROPERTIES,...vi.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(vi,"PROPERTIES",[...vi.META_PROPERTIES,...vi.UPSTREAM_PROPERTIES,...vi.DOWNSTREAM_PROPERTIES]);let dn=vi;function mxe(d){var r;const p=d.implements.flatMap(l=>Txe(d,l));return(r=d.dataType)==null||r.validate(),[...p,...xc(d),...vxe(d)]}function Txe(d,p){const i=[];if(!d.implements)return i;if(!p.abstract){const l=Ut({id:`${d.id}--${be.PropertyImplementsNonAbstact}`,message:`Property "${oe(d,d.project)}" with id "${d.id}" implements a non-abstract property "${oe(p,d.project)}" with id "${p.id}".`,severity:ce.Error,code:be.PropertyImplementsNonAbstact,entity:d});i.push(l.error)}if(d.static&&!p.static){const l=Ut({id:`${d.id}--${be.NonStaticPropertyImplementsStatic}`,message:`Static property "${oe(d,d.project)}" with id "${d.id}" implements a non-static property "${oe(p,d.project)}" with id "${p.id}".`,severity:ce.Error,code:be.NonStaticPropertyImplementsStatic,entity:d});i.push(l.error)}if(!d.static&&p.static){const l=Ut({id:`${d.id}--${be.StaticPropertyImplementsNonStatic}`,message:`Non-static property "${oe(d,d.project)}" with id "${d.id}" implements a static property "${oe(p,d.project)}" with id "${p.id}".`,severity:ce.Error,code:be.StaticPropertyImplementsNonStatic,entity:d});i.push(l.error)}if(!Rr(d.dataType,p.dataType)){const l=Ut({id:`${d.id}--${be.PropertyImplementsIncompatibleType}`,message:`Property "${oe(d,d.project)}" with id "${d.id}" implements a property "${oe(p,d.project)}" with id "${p.id}" that has an incompatible data type.`,severity:ce.Error,code:be.PropertyImplementsIncompatibleType,entity:d});i.push(l.error)}return nn(d.errors,i)}function vxe(d,p){const r=[...d.parent.allProperties].filter(l=>{var c;return l.id!==d.id&&!d.implements.find(e=>e.id===l.id)&&l.id!==((c=d.extends)==null?void 0:c.id)});return xT(d,[Ji],r,p)}const d2t=Object.freeze(Object.defineProperty({__proto__:null,validate:mxe,validateImplementation:Txe,validatePropertyEntityName:vxe},Symbol.toStringTag,{value:"Module"}));function u2t(d,p){const i=[];if(d.parent){const l=p.get(d.parent);if(!l)i.push(new Oe({id:`${d.id}--${d.parent}--${re.ReferencedEntityNotFound}`,code:re.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${d.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}));else{const c=Op(l);if(c){const e=l!==c?`The entity of type '${d.type}' with id '${d.id}' have 'parent' with id '${d.parent}' because the entity belongs to a built-in '${c.type}' entity with id '${c.id}' (${oe(c,l.project)}) higher up in the tree.`:`The entity of type '${d.type}' with id '${d.id}' have 'parent' with id '${d.parent}' because it is a built-in entity of type ${c.type}.`;i.push(new Oe({id:`${d.id}--${re.InvalidBuiltInEntityReference}`,code:re.InvalidBuiltInEntityReference,severity:ce.Error,message:e}))}else if(![o.DefinitionEntity].includes(l.type))i.push(new Oe({id:`${d.id}--${d.parent}--${re.InvalidParentReference}`,code:re.InvalidParentReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a parent reference that isn't pointing to an entity of type 'definition-entity'.`}));else{const y=Hr(l).filter(v=>!v.interactive);if(y.length){let v=y.length>1?`The entity of type '${d.type}' with id '${d.id}' can't be added to the 'parent' entity with id '${l.id}' because it extends or implements multiple '${o.BuiltInBaseEntity}' entities that are non-interactive ("${Dt(y.map(b=>oe(b,b.project)),'", "','" and "')}").`:`The entity of type '${d.type}' with id '${d.id}' can't be added to the 'parent' entity with id '${l.id}' because it extends or implements a '${o.BuiltInBaseEntity}' entity that is non-interactive ("${oe(y[0],y[0].project)}").`;v+=`
|
|
388
388
|
${Ap}`,i.push(new Oe({id:`${d.id}--${re.NonInteractiveEntityReferenced}`,code:re.NonInteractiveEntityReferenced,severity:ce.Error,message:v}))}else d.implements&&d.implements.forEach(v=>{const b=p.get(v);if(v===d.id)return i.push(new Oe({id:`${d.id}--${d.implements}--${re.SelfReference}`,code:re.SelfReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a reference to itself at 'implements'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`})),i;if(!b)i.push(new Oe({id:`${d.id}--${d.implements}--${re.ReferencedEntityNotFound}`,code:re.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${d.implements}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}));else{const A=l.properties.find(E=>E.implements.find(w=>{var P;return(P=d.implements)==null?void 0:P.includes(w.id)}));A?i.push(new Oe({id:`${d.id}--${Re.PropertyOverwritesOtherSiblingWithSameImplementation}`,code:Re.PropertyOverwritesOtherSiblingWithSameImplementation,severity:ce.Error,message:`The property with id "${d.id}" is trying to implement the property with id "${d.implements}", but the parent entity already has a property with id '${A.id}' that implements the same base property.`})):[o.Property].includes(b.type)?b.abstract||i.push(new Oe({id:`${d.id}--${d.implements}--${re.InvalidImplementsReference}`,code:re.InvalidImplementsReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an abstract entity.`})):i.push(new Oe({id:`${d.id}--${d.implements}--${re.InvalidImplementsReference}`,code:re.InvalidImplementsReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an entity of type 'property'.`}))}})}}}const r=hr(d,{},p);return i.push(...r.errors),i}function bxe(d,p){const i=[],r=[],l=[],c=[];if(d.implements.find(e=>e.id===Q["built-in-base-entity"].BUILT_IN_PERSISTED_ENTITY_ENTITY.properties.database.id)){let e=d.defaultValue;if(!d.defaultValue){const y=Xn.new(p);y.name=le.EntityTemplate,y.parent=d.toReference();const v=me(y,d.project);v.hydrateAncestors(),v.addSelfToProject(p),p==null||p.add(v,W.Added),r.push(v),v.initChildren(p),e=v}if(!e.valueAsTypeSingle){const y=axe(d.project);y&&e.setValueAsTypeSingle(y,p)}}return{updated:O(i),added:O(r),removed:O(l),affected:O(c),self:d}}var Exe=(d=>(d.PropertyImplements="property-implements-field",d.PropertyExtends="property-extends-field",d.PropertyDataTypeEntity="property-data-type-entity-field",d.PropertyDataType="property-data-type-field",d))(Exe||{});const ii=class ii extends Un{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"name");R(this,"codeName",null);R(this,"description",null);R(this,"private");R(this,"abstract");R(this,"index");R(this,"static");R(this,"unique");R(this,"required");R(this,"constant",!1);R(this,"interactive",!1);R(this,"type",o.Property);R(this,"hidden",!1);R(this,"parentRelationType",null);R(this,"defaultValue",null);R(this,"dataType",null);R(this,"implements",[]);R(this,"extends",null);R(this,"project");R(this,"errors",[]);R(this,"parent");R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"suggestion",!1);R(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=r,this.id=i.id,this.name=i.name,this.description=i.description,this.private=i.private,this.abstract=i.abstract,this.index=i.index,this.static=i.static,this.required=i.required||!1,this.unique=i.unique||!1,this.codeName=i.codeName,this.hidden=i.hidden||!1,this.constant=i.constant||!1,this.interactive=i.interactive||!1,this.onProjectInitialized=this.onProjectInitialized.bind(this)}static new(i=null){return{id:L.UUID.uuid(),version:L.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||L.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,unique:!1,type:o.Property,parentRelationType:null,name:"",codeName:null,description:"",dataType:null,implements:[],extends:null,private:!1,abstract:!1,static:!1,constant:!1,interactive:!0,hidden:!1,index:0,required:!1,defaultValue:null,parent:null}}static fromGenerationTarget(i,r){const l=ye(i.parent),c=r.get(l),e=[];i.implements&&i.implements.forEach(A=>{e.push(r.get(A)||r.getBuiltIn(A))});let y=null;if(i.extends){const A=ye(i.extends);y=r.get(A)}const v={id:i.id,version:L.UUID.uuid(),createdAt:B().toISOString(),author:L.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:o.Property,index:c.properties.length,unique:i.unique||!1,parentRelationType:i.parentRelationType||null,private:i.private||!1,abstract:i.abstract||!1,static:i.static||!1,required:i.required||!1,constant:i.constant||!1,interactive:i.interactive||!1,hidden:!1,codeName:i.codeName||null,description:i.description||null,defaultValue:null,implements:e,extends:y,dataType:null,parent:c},b=me(v,r);return b.setParent(c,null),b}static validateGenerationTarget(i,r){let l=JSON.parse(JSON.stringify(i));const c=[],e=u2t(l,r),y=uP(l,r);return c.push(...e,...y,...Pn(l)),{errors:c,modifiedData:l}}get isExtendedProperty(){const i=this.parent.allBasePropertiesFromExtendedAndImplementedEntities.find(r=>{var l;return r.id===((l=this.extends)==null?void 0:l.id)});return!!i&&i.id!==this.id&&!i.abstract}get codeNativeValueValidation(){const i=[...this.implements].filter(l=>!this.implements.filter(y=>y.id!==l.id).some(y=>!!y.implements.find(v=>v.id===l.id)));return this._codeNativeValueValidation||(i==null?void 0:i.some(l=>l.codeNativeValueValidation))?(l,c)=>{const e=[];let y=c;if(this._codeNativeValueValidation){const v=this._codeNativeValueValidation(l,c);v&&(e.push(...v.errors),y=v.override)}return i.forEach(v=>{const b=v.codeNativeValueValidation;if(b){const A=b(l,c);A&&(e.push(...A.errors),y=A.override)}}),{errors:om(e),override:y}}:null}validateGeneratedUpdate(i){const r=[];return i.parent&&r.push(new Oe({id:`${this.id}--${re.InvalidParentUpdate}`,code:re.InvalidParentUpdate,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
389
389
|
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`})),(i.readsValue||i.writesValue)&&r.push(new Oe({id:`${this.id}--${Re.InvalidObjectStructure}`,code:Re.InvalidObjectStructure,severity:ce.Error,message:`Entity of type '${this.type}' with id '${this.id}' is not a value reading or writing entity.
|
|
390
390
|
${Ag}`})),{errors:r,modifiedData:i}}onProjectInitialized(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,new Date().toISOString(),this,!0,"on-property-received-project-initialized"))){return bxe(this,r),r==null||r.attemptAutoclose("on-property-received-project-initialized",this.id),this}subscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]||(this.detachedDependents[r.entity.id]=r)}),this}unsubscribeDependents(i){return i.forEach(r=>{this.detachedDependents[r.entity.id]&&delete this.detachedDependents[r.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const r=[],l=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);r.push(...v.updated),l.push(...v.added),c.push(...v.removed),e.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}onDetachedDependencyRemoved(i,r,l){const c=[],e=[],y=[],v=[];if(r==="property-implements-field"&&(this.removeImplementation(i,l),c.push(this)),r==="property-extends-field"){const{updated:b,added:A,removed:E,affected:w}=this.remove({ignoreUpstream:!1},l);c.push(...b),e.push(...A),y.push(...E),v.push(...w)}return{updated:O(c),added:O(e),removed:O(y),affected:O(v),self:this}}onDetachedDependencyRestored(i,r,l){const c=[],e=[],y=[],v=[];if(r==="property-implements-field"&&(this.addImplementation(i,l),c.push(this)),r==="property-extends-field"){const{updated:b,added:A,removed:E,affected:w}=this.restore({},l);c.push(...b),e.push(...A),y.push(...E),v.push(...w)}return{updated:O(c),added:O(e),removed:O(y),affected:O(v),self:this}}unsubscribeFromDependencies(){var i,r,l,c,e,y,v;return this.implements.forEach(b=>{this.project.getBuiltIn(b.id)||b.unsubscribeDependents([{entity:this,field:"property-implements-field"}])}),(r=(i=this.extends)==null?void 0:i.unsubscribeDependents)==null||r.call(i,[{entity:this,field:"property-extends-field"}]),(e=(c=(l=this.dataType)==null?void 0:l.entity)==null?void 0:c.unsubscribeDependents)==null||e.call(c,[{entity:this,field:"property-data-type-entity-field"}]),(v=(y=this.dataType)==null?void 0:y.unsubscribeDependents)==null||v.call(y,[{entity:this,field:"property-data-type-field"}]),this.project.off(ti.PROJECT_INITIALIZED,this.onProjectInitialized),this}subscribeToDependencies(){var i,r,l,c,e,y,v;return this.implements.forEach(b=>{this.project.getBuiltIn(b.id)||b.subscribeDependents([{entity:this,field:"property-implements-field"}])}),(r=(i=this.extends)==null?void 0:i.subscribeDependents)==null||r.call(i,[{entity:this,field:"property-extends-field"}]),(e=(c=(l=this.dataType)==null?void 0:l.entity)==null?void 0:c.subscribeDependents)==null||e.call(c,[{entity:this,field:"property-data-type-entity-field"}]),(v=(y=this.dataType)==null?void 0:y.subscribeDependents)==null||v.call(y,[{entity:this,field:"property-data-type-field"}]),this.project.on(ti.PROJECT_INITIALIZED,this.onProjectInitialized),this}increaseVersion(i){if(i&&!B(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&B(i).isSame(B(this.createdAt))?this:(this.previousVersion=this.version,this.version=L.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this)}captureVersion(){var r;const i=((r=this.knownVersions)==null?void 0:r.get(this.version))||new ii(this,this.project);return i.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,i):new Map([[this.version,i]]),i.defaultValue=this.defaultValue,i.dataType=this.dataType,i.implements=[...this.implements],i.extends=this.extends,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const r=[],l=[],c=[],e=[];if(this.parent&&this.parent.type!==o.PrimitiveEntity&&this.parent.type!==o.BuiltInBaseEntity){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);r.push(this.parent,...y.updated),l.push(...y.added),c.push(...y.removed)}return{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}async restoreVersion(i){var v;const r=[],l=[],c=[],e=[];if(this.version===i)return{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this};if(!this.knownVersions){const b=new Map;for(const[A,E]of this.knownVersions||new Map){if(b.set(A,E),E.activeVersion=!1,E.knownVersions)for(const[w,P]of E.knownVersions)b.set(w,P);E.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const b=await this.APILoadVersion({},i);if(!b)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new ii(b,this.project)}return this.metaSync(y.toShallowJSON(),null),this.previousVersion=y.previousVersion,this.version=y.version,this.createdAt=y.createdAt,this.author=y.author,this.deleted=y.deleted,this.defaultValue=y.defaultValue,this.dataType=y.dataType,this.implements=[...y.implements],this.parent=y.parent,{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}updateWithShallowTransfer(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.UpdateWithShallowTransfer))){if(!this.checkCanEdit(this,r))return ae.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,r),this.version=i.version,this.createdAt=i.createdAt,this.author=i.author,this.deleted=i.deleted,this.previousVersion=i.previousVersion,this.unsubscribeFromDependencies(),i.parent){const l=ye(i.parent),c=this.project.get(l),e=this.parent;if(e&&e.id!==(c==null?void 0:c.id)&&this.removeFromParent(r),c)this.setParent(c,null);else throw r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${l}' that isn't found in the project`)}else throw r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.implements.forEach(l=>{const c=ye(l),e=this.project.get(c);if(e)this.addImplementation(e,r);else throw new Error(`${Sn(this.type)} with id '${this.id}' has a 'implements' reference "${c}" which is missing in the project`)}),i.extends){const l=ye(i.extends),c=this.project.get(l);if(c)this.setExtends(c,r);else if(l)throw new Error(`${Sn(this.type)} with id '${this.id}' has a 'extends' reference "${l}" which is missing in the project`)}return this.captureVersion(),this.subscribeToDependencies(),r==null||r.attemptAutoclose(V.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],r=[],l=[],c=[];if(this.initialData.parent){const e=ye(this.initialData.parent),y=this.project.get(e);if(y)this.setParent(y,null);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${e}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if((this.initialData.implements||[]).forEach(e=>{const y=ye(e),v=this.project.get(y);if(v)this.addImplementation(v,null),i.push(v);else throw new Error(`${Sn(this.type)} with id '${this.id}' has a 'implements' reference "${y}" which is missing in the project`)}),this.initialData.extends){const e=ye(this.initialData.extends),y=this.project.get(e);if(y)this.setExtends(y,null),i.push(y);else if(e)throw new Error(`${Sn(this.type)} with id '${this.id}' has a 'extends' reference "${e}" which is missing in the project`)}return{updated:O(i),added:O(r),removed:O(l),affected:O(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this,i))return ae.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(this.initialized=!0,this.parent.type===o.DefinitionEntity&&this.parentRelationType!==Sp.AllPropertiesImplementationTarget){let M=this.index||0;const k=this.parent.properties.filter(Z=>!Z.deleted&&Z.id!==this.id);k.length&&(M>k.length+1?M=k.length:M<0&&(M=0)),k.find(Z=>(Z.index||0)===M&&!Z.deleted)&&k.filter(Z=>(Z.index||0)>=M&&!Z.deleted).forEach(Z=>{Z.metaSync({index:(Z.index||0)+1},i),i==null||i.add(Z,W.Updated),r.push(Z)}),this.metaSync({index:M},i)}const{updated:y,added:v,removed:b,affected:A}=this.syncWithImplementation(i);r.push(...y),l.push(...v),c.push(...b),e.push(...A);const{updated:E,added:w,removed:P,affected:x}=bxe(this,i);return r.push(...E),l.push(...w),c.push(...P),e.push(...x),this.captureVersion(),i==null||i.attemptAutoclose(V.AfterAllChildrenInitialized,this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const r=[this],l=[],c=[],e=[];return this.parentRelationType===Sp.AllPropertiesImplementationTarget?this.parent.setAllPropertiesImplement(this,i):this.parent.addProperty(this,i),r.push(this.parent),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}setParent(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetParent))){var l;return this.checkCanEditWithCounterpartAndSideEffects(this,i,V.SetParent,r)?(((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(V.SetParent,this.id),this):this}addImplementation(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.AddImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)||(this.implements.push(i),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(V.AddImplementation,this.id),this):(ae.warn(`[addImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.AddImplementation,this.id),this)}removeImplementation(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveImplementation))){return this.checkCanEdit(this,r)?(this.implements.includes(i)&&(this.implements=this.implements.filter(l=>l.id!==i.id),r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose(V.RemoveImplementation,this.id),this):(ae.warn(`[removeImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.RemoveImplementation,this.id),this)}setExtends(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetExtends))){var l;return this.checkCanEdit(this,r)?(((l=this.extends)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.extends=i,r&&(r==null||r.add(this,W.Updated))),r==null||r.attemptAutoclose(V.SetExtends,this.id),this):(ae.warn(`[setExtends] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.SetExtends,this.id),this)}initChildren(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=me(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(i)),this.initialData.dataType){const r=me(this.initialData.dataType,this.project);r.setParent(this,null),r.initChildren(i),this.dataType=r}if(this.implements=this.initialData.implements.map(r=>me(r,this.project)),this.initialData.extends){const r=me(this.initialData.extends,this.project);this.setExtends(r,null)}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(i),i==null||i.attemptAutoclose("init-children",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const l=$n(this,i,r),c=Nn(this,l),e=this.toMeta();return this.name=l.name!==void 0?l.name:e.name,this.codeName=l.codeName!==void 0?l.codeName:e.codeName,this.description=l.description!==void 0?l.description:e.description,this.abstract=l.abstract!==void 0?l.abstract:e.abstract,this.private=l.private!==void 0?l.private:e.private,this.index=l.index||(l.index!==0?e.index:0),this.static=l.static!==void 0?l.static:e.static,this.hidden=l.hidden!==void 0?l.hidden:e.hidden,this.constant=l.constant!==void 0?l.constant:e.constant,this.interactive=l.interactive!==void 0?l.interactive:e.interactive,this.required=l.required!==void 0?l.required:e.required,this.unique=l.unique!==void 0?l.unique:e.unique,super.baseMetaSync(l,this,r),l.deleted===!0&&!e.deleted?r==null||r.add(this,W.Removed):l.deleted===!1&&e.deleted?r==null||r.add(this,W.Added):c&&(r==null||r.add(this,W.Updated)),r==null||r.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Be,...r){return await ii.repository.APILoad(this.id,...r),this}async APICreate(i=Be,...r){return await ii.repository.APICreate(this.toShallowJSON(),...r),this}async APIUpdate(i=Be,...r){return await ii.repository.APIUpdate(this.toShallowJSON(),...r),this}async APIDelete(i=Be,...r){return await ii.repository.APIDelete(this.toShallowJSON(),...r),this}async APIClone(i=Be,...r){return await ii.repository.APIClone(this.id,...r),this}async APILoadVersion(i=Be,r,...l){return await ii.repository.APILoadVersion(this.id,r,...l)}removeFromParent(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveFromParent))){if(!this.checkCanEdit(this,i))return ae.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];return this.parent.type===o.DefinitionEntity&&(this.parentRelationType===Sp.AllPropertiesImplementationTarget?this.parent.removeAllPropertiesImplement(i):this.parent.removeProperty(this,i),e.push(this.parent)),i==null||i.attemptAutoclose(V.RemoveFromParent,this.id),{added:O(c),updated:O(r),removed:O(l),affected:O(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveEntity))){var v;if(!this.checkCanDelete(this,r))return ae.warn(`[remove] User is not allowed to delete or edit this ${this.type} entity with id: ${this.id}`),r==null||r.event({id:`${V.RemoveEntity}-${this.id}`,action:V.RemoveEntity,owner:this,errorReason:tn.ActionOwnerEntityNonDeletable,rootAction:((v=r==null?void 0:r.self)==null?void 0:v.id)===this.id&&(r==null?void 0:r.autoCloseActionName)===V.RemoveEntity}),r==null||r.attemptAutoclose(V.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const l=[],c=[],e=[],y=[];if(r!=null&&r.hasRemoved(this.id))return r==null||r.attemptAutoclose(V.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(c.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},r),Object.values(this.detachedDependents).forEach(b=>{const{updated:A,removed:E,added:w}=b.entity.onDetachedDependencyRemoved(this,b.field,r);l.push(...A),c.push(...E),e.push(...w)}),this.defaultValue){const{updated:b,removed:A}=this.defaultValue.remove({ignoreUpstream:!0},r);l.push(...b),c.push(...A)}if(this.dataType){const{updated:b,removed:A}=this.dataType.remove({ignoreUpstream:!0},r);l.push(...b),c.push(...A)}if(!i){const b=this.removeFromParent(r);e.push(...b.added),l.push(...b.updated),c.push(...b.removed),y.push(...b.affected)}return r==null||r.attemptAutoclose(V.RemoveEntity,this.id),{added:O(e),updated:O(l),removed:O(c),affected:O(y),self:this}}restore({}={},i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RestoreEntity))){if(!this.checkCanEdit(this,i))return ae.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},i),Object.values(this.detachedDependents).forEach(y=>{const{updated:v,removed:b,added:A}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),c.push(...b),r.push(...A)}),this.defaultValue){const{updated:y}=this.defaultValue.restore({},i);l.push(...y)}if(this.dataType){const{updated:y}=this.dataType.restore({},i);l.push(...y)}return this.parent.type===o.DefinitionEntity&&(this.parentRelationType===Sp.AllPropertiesImplementationTarget?this.parent.removeAllPropertiesImplement(i):this.parent.addProperty(this,i),e.push(this.parent)),i==null||i.attemptAutoclose(V.RestoreEntity,this.id),{added:O(r),updated:O(l),removed:O(c),affected:O(e),self:this}}toFlat(i=new Set){var l,c;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.defaultValue)==null?void 0:l.toFlat(i))||[],...((c=this.dataType)==null?void 0:c.toFlat(i))||[],...this.parent.toFlat(i)])}toFlatIds(i=new Set){var l,c;if(i.has(this.id))return[];if(i.add(this.id),!this.parent)throw new Error(`Property with id '${this.id}' has no parent and cannot be flattened`);return[this.id,...((l=this.defaultValue)==null?void 0:l.toFlatIds(i))||[],...((c=this.dataType)==null?void 0:c.toFlatIds(i))||[],...this.parent.toFlatIds(i)]}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,codeName:this.codeName,description:this.description,index:this.index,hidden:this.hidden,private:this.private,abstract:this.abstract,required:this.required,unique:this.unique,constant:this.constant,interactive:this.interactive,static:this.static,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name}}toJSON(i=new Set){var r,l,c;return i.has(this.id)?this.toReference():(i.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,unique:this.unique,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,parentRelationType:this.parentRelationType,defaultValue:((r=this.defaultValue)==null?void 0:r.toJSON(i))||null,dataType:((l=this.dataType)==null?void 0:l.toJSON(i))||null,implements:this.implements.map(e=>e.toJSON(i)),extends:((c=this.extends)==null?void 0:c.toJSON(i))||null,parent:this.parent.toReference()})}toJSONClone(i=dt){var l,c,e,y,v,b,A;let r;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?r=i.seenEntityMaps.get(this.id):(r=i.newId||jn(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,r)),(c=i.seenEntities)!=null&&c.has(r)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(r),(v=i.seenEntities)==null||v.add(this.id),{id:r,version:L.UUID.uuid(),createdAt:i.timestamp||B().toISOString(),author:L.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,editable:this.editable,deletable:this.deletable,name:this.name,codeName:this.codeName,description:this.description,index:this.index,unique:this.unique,private:this.private,required:this.required,static:this.static,constant:this.constant,interactive:this.interactive,abstract:this.abstract,hidden:this.hidden,parentRelationType:this.parentRelationType,defaultValue:((b=this.defaultValue)==null?void 0:b.toJSONClone({...i,newId:null}))||null,dataType:((A=this.dataType)==null?void 0:A.toJSONClone({...i,newId:null}))||null,implements:this.implements.map(E=>this.project.getBuiltIn(E.id)?E.toJSON(i.seenEntities):E.toJSONClone({...i,newId:null})),extends:(()=>{var E;return this.extends&&this.project.getBuiltIn(this.extends.id)?this.extends.toJSON():((E=this.extends)==null?void 0:E.toJSONClone({...i,newId:null}))||null})(),parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=dt){var l;let r=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r+"--"+L.UUID.uuid()+"--ref",type:o.GenericReference,entityId:r,version:this.version,entityType:this.type}}toShallowJSON(i=dt){var l,c,e,y;let r=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(r=i.seenEntityMaps.get(this.id)),{id:r,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,codeName:this.codeName,description:this.description,type:this.type,editable:this.editable,deletable:this.deletable,index:this.index,private:this.private,required:this.required,unique:this.unique,abstract:this.abstract,static:this.static,constant:this.constant,interactive:this.interactive,hidden:this.hidden,parentRelationType:this.parentRelationType,defaultValue:((c=this.defaultValue)==null?void 0:c.toReference(i))||null,dataType:((e=this.dataType)==null?void 0:e.toReference(i))||null,implements:this.implements.map(v=>v.toReference(i)),extends:((y=this.extends)==null?void 0:y.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var l,c;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.defaultValue)==null?void 0:l.toFlatJSON(i))||[],...((c=this.dataType)==null?void 0:c.toFlatJSON(i))||[],...this.implements.flatMap(e=>e.toFlatJSON(i)),...this.parent.toFlatJSON(i)])}toGenerationTarget(){var i;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,parentRelationType:this.parentRelationType,implements:this.implements.map(r=>r.id),extends:(i=this.extends)==null?void 0:i.id,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var l,c;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((l=this.defaultValue)==null?void 0:l.toFlatGenerationTarget(i))||[],...((c=this.dataType)==null?void 0:c.toFlatGenerationTarget(i))||[],...this.implements.flatMap(e=>e.toFlatGenerationTarget(i))])}clearErrors(){var i,r;return this.errors=[],(i=this.defaultValue)==null||i.clearErrors(),(r=this.dataType)==null||r.clearErrors(),this}validate(){return this.errors=mxe(this),{success:!0}}getErrors(){var r,l;return[...this.errors,...((r=this.defaultValue)==null?void 0:r.getErrors())||[],...((l=this.dataType)==null?void 0:l.getErrors())||[],...this.implements.flatMap(c=>c.getErrors())]}getShallowErrors(){return this.errors}implement(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"implement-self-as-property")),l=null){var b;const c=l||L.UUID.uuid(),e=ii.new(r);e.id=c,e.name=this.name,e.description=this.description,e.index=this.index,e.private=this.private,e.required=this.required,e.static=this.static,e.constant=this.constant,e.unique=this.unique,e.hidden=this.hidden,e.interactive=this.interactive,e.parent=i.toReference(),e.implements=[this.toJSON()];const y=me(e,this.project);y.hydrateAncestors(),y.addSelfToProject(r),r==null||r.add(y,W.Added),y.initChildren(r);const v=(b=this.defaultValue)==null?void 0:b.clone(r,y,L.UUID.uuid());return v&&(v.editable=!0,v.deletable=!0),y}clone(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.CloneEntity)),r=null,l=null,c=!0){var w,P;const e=Vn(r,this),y=l||L.UUID.uuid(),v=r||this.parent,b=new Set([...this.project.getAllBuiltInIds(),...rn()]),A={hidden:!1,id:y,version:L.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||"1",previousVersion:null,deleted:!1,type:this.type,editable:!0,deletable:!0,name:this.name,codeName:this.codeName,description:this.description,index:this.index,private:this.private,constant:this.constant,unique:this.unique,interactive:this.interactive,required:this.required,abstract:this.abstract,static:this.static,parentRelationType:this.parentRelationType,defaultValue:null,dataType:null,implements:this.implements.map(x=>x.toJSON()),extends:this.extends,parent:v.toReference()},E=Ui(A,e);if(E.hydrateAncestors(),E.setParent(v,i),c&&(E.subscribe(),E.addSelfToProject(i)),E.initChildren(i),i==null||i.add(E,W.Added),this.dataType&&b.has(this.dataType.id))E.setDataType(e.getBuiltIn(this.dataType.id),i);else{const x=((w=this.dataType)==null?void 0:w.clone(i,E,L.UUID.uuid(),c))||null;x&&E.setDataType(x,i)}if(this.defaultValue){const x=(P=this.defaultValue)==null?void 0:P.clone(i,E,L.UUID.uuid(),c);E.setDefaultValue(x||null,i)}return this.implements.length&&this.implements.forEach(x=>{const M=e.get(x.id)||e.getBuiltIn(x.id);if(M){E.addImplementation(M,i);return}}),E.addSelfToProject(null),i==null||i.attemptAutoclose(V.CloneEntity,this.id),E}setDataType(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.SetDataType))){if(!this.checkCanEdit(this,r))return ae.warn(`[setDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose(V.SetDataType,this.id),this;const l=this.dataType;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},r),this.dataType=i,this.subscribeToDependencies(),r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose(V.SetDataType,this.id),this}removeDataType(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,V.RemoveDataType))){return this.checkCanEdit(this,i)?(this.dataType&&(this.dataType.remove({ignoreUpstream:!0},i),i==null||i.add(this,W.Affected),this.dataType=null),i==null||i.attemptAutoclose(V.RemoveDataType,this.id),this):(ae.warn(`[removeDataType] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(V.RemoveDataType,this.id),this)}getDataType(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"get-data-type"))){return i==null||i.attemptAutoclose("get-data-type",this.id),this.dataType}getDefaultValue(){var c;let i=null;for(const e of this.implements){const y=e.getDefaultValue();(!i||Kl(i))&&y&&(i=y)}let r=this.defaultValue;const l=(c=this.extends)==null?void 0:c.getDefaultValue();return Kl(r)&&l&&!Kl(l)&&(r=l),Kl(r)&&i&&!Kl(i)&&(r=i),r}setDefaultValue(i,r=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"set-default-value"))){if(!this.checkCanEdit(this,r))return ae.warn(`[setDefaultValue] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),r==null||r.attemptAutoclose("set-default-value",this.id),this;const l=this.defaultValue;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(l==null||l.remove({ignoreUpstream:!0},r),this.defaultValue=i,r==null||r.add(this,W.Affected)),r==null||r.attemptAutoclose("set-default-value",this.id),this}syncWithImplementation(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"sync-with-implementation"))){var x,M,k,q,Z,X,se,ee,he,de,fe;if(!this.checkCanEdit(this,i))return ae.warn(`[syncWithImplementation] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose("sync-with-implementation",this.id),{added:[],updated:[],removed:[],affected:[],self:this};const r=[],l=[],c=[],e=[];this.parent.type!==o.PrimitiveEntity&&this.interactive&&this.parent.getAllPropertiesImplements().forEach(ne=>{this.addImplementation(ne,i)});let y=null;const v=new Set([...this.project.getAllBuiltInIds(),...rn()]);for(const Te of this.implements)(x=Te.dataType)!=null&&x.isResolved&&(y?(M=Te.dataType.orChildrenGroup)!=null&&M.length&&Te.dataType.implementationChooseOne&&(y=Te.dataType):y=Te.dataType);const b=Rr(this.dataType,y);if(!this.dataType||!((k=this.dataType)!=null&&k.isResolved)||(q=this.dataType)!=null&&q.isResolved&&(y!=null&&y.isResolved)&&!b.compatible){if(y&&((Z=y.orChildrenGroup)!=null&&Z.length)&&y.implementationChooseOne){if(!this.dataType||this.dataType&&v.has(this.dataType.id)){const ne=dn.new(i);ne.parent=this.toReference();const ue=me(ne,this.project);ue.hydrateAncestors(),i==null||i.add(ue,W.Added),ue.addSelfToProject(i),ue.afterAllChildrenInitialized(i)}const Te=y.orChildrenGroup.some(ne=>ne.foreignKeyAllowed);if(((se=(X=this.dataType)==null?void 0:X.entity)==null?void 0:se.type)===o.DefinitionEntity&&qi(this.dataType.entity,De.PERSISTED_ENTITY)&&Te){const ne=nxe(this.dataType.entity);ne&&this.dataType.setForeignKeyRef(ne,i),(ee=this.dataType)==null||ee.setEntity(null,i)}else{const ne=y.orChildrenGroup.find(ue=>{var Pe;return((Pe=ue.entity)==null?void 0:Pe.id)===Q["primitive-entity"].string.id});if(ne)(he=this.dataType)==null||he.setEntity(ne.entity,i);else{const ue=y.orChildrenGroup.filter(Le=>Le.isResolved),Pe=ue.filter(Le=>{var Ue;return((Ue=Le.entity)==null?void 0:Ue.type)===o.PrimitiveEntity});Pe.length?(de=this.dataType)==null||de.setEntity(Pe[0].entity,i):ue.length&&((fe=this.dataType)==null||fe.setEntity(ue[0].entity,i))}}}else if(y&&v.has(y.id))this.setDataType(y,i);else if(y){const Te=y.clone(i,this,L.UUID.uuid(),!0);this.setDataType(Te,i),l.push(Te)}}if(!this.defaultValue){let Te=null;for(const ne of this.implements){const ue=ne.getDefaultValue();ue&&(Te=ue)}if(Te){const ne=Te.clone(i,this,L.UUID.uuid(),!0);this.setDefaultValue(ne,i),l.push(ne)}}let A=!1,E=!1,w=!1,P=!1;return this.implements.forEach(Te=>{Te.required&&(A=!0),Te.constant&&(w=!0),Te.unique&&(E=!0),Te.static&&(P=!0)}),this.metaSync({required:A||this.required,constant:w||this.constant,unique:E||this.unique,static:P||this.static},i),i==null||i.attemptAutoclose("sync-with-implementation",this.id),{updated:O(r),added:O(l),removed:O(c),affected:O(e),self:this}}implementAsInputMap(i=this.project.addChangeSet(new H(this.project,L.sessionAuthor,B().toISOString(),this,!0,"implement-as-return-declaration")),r,l){const c=hs.new(i);c.id=l||c.id,c.name=this.name,c.description=this.description,c.parent=r.toReference(),c.declaration=this.toJSON();const e=Ui(c,this.project);e.hydrateAncestors(),e.addSelfToProject(i),i==null||i.add(e,W.Added),e.initChildren(i);const y=new Set([...this.project.getAllBuiltInIds(),...rn()]);if(this.dataType)if(y.has(this.dataType.id))e.setDataType(this.dataType,i),i==null||i.add(e,W.Affected);else{const v=this.dataType.clone(i,e);e.setDataType(v,i)}if(this.defaultValue){const v=this.defaultValue.clone(i,e);e.setDefaultValue(v,i)}return i==null||i.attemptAutoclose("implement-as-return-declaration",this.id),e}};R(ii,"repository",{APICreate:async(i,...r)=>i,APIUpdate:async(i,...r)=>i,APIDelete:async(i,...r)=>i,APIClone:async(i,...r)=>{},APILoad:async(i,...r)=>null,APILoadVersion:async(i,r,...l)=>null}),R(ii,"type",o.Property),R(ii,"USER_MANAGED_PARENT_TYPES",[o.DefinitionEntity]),R(ii,"PARENT_TYPES",[...ii.USER_MANAGED_PARENT_TYPES,o.PrimitiveEntity,o.BuiltInBaseEntity]),R(ii,"MUTABLE_BASE_PROPERTIES",["name","codeName","description","private","abstract","static","required","constant","unique","interactive"]),R(ii,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),R(ii,"BASE_PROPERTIES",[...ii.MUTABLE_BASE_PROPERTIES,...ii.INMUTABLE_BASE_PROPERTIES]),R(ii,"MUTABLE_META_PROPERTIES",[...ii.MUTABLE_BASE_PROPERTIES,"index"]),R(ii,"INMUTABLE_META_PROPERTIES",[...ii.INMUTABLE_BASE_PROPERTIES]),R(ii,"META_PROPERTIES",[...ii.MUTABLE_META_PROPERTIES,...ii.INMUTABLE_META_PROPERTIES]),R(ii,"MUTABLE_UPSTREAM_PROPERTIES",[]),R(ii,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements","extends"]),R(ii,"UPSTREAM_PROPERTIES",[...ii.MUTABLE_UPSTREAM_PROPERTIES,...ii.INMUTABLE_UPSTREAM_PROPERTIES]),R(ii,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),R(ii,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),R(ii,"DOWNSTREAM_PROPERTIES",[...ii.MUTABLE_DOWNSTREAM_PROPERTIES,...ii.INMUTABLE_DOWNSTREAM_PROPERTIES]),R(ii,"PROPERTIES",[...ii.META_PROPERTIES,...ii.UPSTREAM_PROPERTIES,...ii.DOWNSTREAM_PROPERTIES]);let Ga=ii;function Axe(d){var y,v;const p=d.implements.flatMap(b=>p2t(d,b)),i=c2t(d,d.extends),r=y2t(d),l=f2t(d);d.methods.flatMap(b=>b.validate()),d.abstractMethods.flatMap(b=>b.validate()),(y=d.allPropertiesImplement)==null||y.validate(),(v=d.additionalPropertiesDataType)==null||v.validate();const c=[...p,...i,...r,...l,...Rxe(d)];return nn(d.errors,c)}function gxe(d,p){const i=p.properties.filter(c=>c.abstract),r=[];let l=[...d.properties];return i.forEach(c=>{const e=l.find(y=>!!y.implements.find(v=>v.id===c.id));e?l=l.filter(y=>y.id!==e.id):r.push(c)}),r}function Ixe(d,p){const i=p.abstractMethods,r=[];let l=[...d.methods];return i.forEach(c=>{const e=l.find(y=>{var v;return((v=y.implements)==null?void 0:v.id)===c.id});e?l=l.filter(y=>y.id!==e.id):r.push(c)}),r}function p2t(d,p){const i=[];if(!p.abstract){const A=Ut({id:d.id+"--"+be.ImplementingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is implementing a non-abstract entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.ImplementingNonAbstractEntity,entity:d});return i.push(A.error),i}const r=p.properties.filter(A=>A.abstract),l=[];let c=[...d.properties];r.forEach(A=>{const E=c.find(w=>!!w.implements.find(P=>P.id===A.id));E?c=c.filter(w=>w.id!==E.id):l.push(A)}),l.length&&l.forEach(A=>{const E=Ut({id:d.id+"--"+be.MissingPropertyImplementation+"--"+A.id,message:`Property "${A.name}" with id "${A.id}" of entity "${p.name}" with id "${p.id}" is not implemented when entity "${d.name}" with id "${d.id}" implements it`,severity:ce.Error,code:be.MissingPropertyImplementation,entity:d});i.push(E.error)});const e=[];let y=[...d.methods];p.abstractMethods.forEach(A=>{const E=y.find(w=>{var P;return((P=w.implements)==null?void 0:P.id)===A.id});E?y=y.filter(w=>w.id!==E.id):e.push(A)}),e.length&&e.forEach(A=>{const E=Ut({id:d.id+"--"+be.MissingMethodImplementation+"--"+A.id,message:`Method "${A.name}" with id "${A.id}" of entity "${p.name}" with id "${p.id}" is not implemented when entity "${d.name}" with id "${d.id}" implements it`,severity:ce.Error,code:be.MissingMethodImplementation,entity:d});i.push(E.error)});const v=[];p.properties.forEach(A=>{const E=c.find(w=>w.name===A.name);E&&v.push([E,A])}),v.length&&v.forEach(([A])=>{const E=Ut({id:d.id+"--"+Re.PropertyOverwritesOtherSiblingWithSameName+"--"+A.id,message:`Property "${A.name}" with id "${A.id}" of entity "${d.name}" with id "${d.id}" overwrites the property with the same name from the base entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:Re.PropertyOverwritesOtherSiblingWithSameName,entity:d});i.push(E.error)});const b=[];return p.methods.forEach(A=>{const E=y.find(w=>w.name===A.name);E&&b.push([E,A])}),b.length&&b.forEach(([A])=>{const E=Ut({id:d.id+"--"+Re.MethodOverwritesOtherSiblingWithSameName+"--"+A.id,message:`Method "${A.name}" with id "${A.id}" of entity "${d.name}" with id "${d.id}" overwrites the method with the same name from the base entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:Re.MethodOverwritesOtherSiblingWithSameName,entity:d});i.push(E.error)}),i}function c2t(d,p){const i=[];if(!p)return i;const r=[];if(!d.abstract&&p.abstract){const c=Ut({id:d.id+"--"+p.id+"--"+be.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not-abstract but is extending an abstract entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:p});return i.push(c.error),i}if(d.abstract&&!p.abstract){const c=Ut({id:d.id+"--"+p.id+"--"+be.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but is extending an non-abstract entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:p});return i.push(c.error),i}d.properties.forEach(c=>{const e=p.properties.find(y=>{var v;return y.name===c.name&&((v=c.extends)==null?void 0:v.id)!==y.id});c.implements.find(y=>y.id===(e==null?void 0:e.id))||e&&r.push(c)}),r.length&&r.forEach(c=>{const e=Ut({id:d.id+"--"+Re.PropertyOverwritesOtherSiblingWithSameName,message:`Property "${c.name}" with id "${c.id}" of entity "${d.name}" with id "${d.id}" overwrites the property with the same name from the extended entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:Re.PropertyOverwritesOtherSiblingWithSameName,entity:d});i.push(e.error)});const l=[];return d.methods.forEach(c=>{var y;const e=p.methods.find(v=>{var b;return v.name===c.name&&((b=c.extends)==null?void 0:b.id)!==v.id});((y=c.implements)==null?void 0:y.id)!==(e==null?void 0:e.id)&&e&&l.push(c)}),l.length&&l.forEach(c=>{const e=Ut({id:d.id+"--"+Re.MethodOverwritesOtherSiblingWithSameName,message:`Method "${c.name}" with id "${c.id}" of entity "${d.name}" with id "${d.id}" overwrites the method with the same name from the extended entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:Re.MethodOverwritesOtherSiblingWithSameName,entity:d});i.push(e.error)}),i}function f2t(d){const p=[];if(!d.properties.length){const i=Ut({id:d.id+"--"+be.NoProperties,message:"No properties implemented",severity:ce.Warning,code:be.NoProperties,entity:d});p.push(i.error)}return d.properties.forEach(i=>{i.validate()}),p}function y2t(d){const p=[];if(d.abstract){if(d.methods.length){const i=Ut({id:d.id+"--"+be.AbstractEntityWithNonAbstractMethods,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract but has non-abstract methods`,severity:ce.Error,code:be.AbstractEntityWithNonAbstractMethods,entity:d});p.push(i.error)}if(d.properties.some(i=>!i.abstract)){const i=Ut({id:d.id+"--"+be.AbstractEntityWithNonAbstractProperties,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract but has non-abstract properties`,severity:ce.Error,code:be.AbstractEntityWithNonAbstractProperties,entity:d});p.push(i.error),d.properties.forEach(r=>{if(!r.abstract){const l=Ut({id:d.id+"--"+be.StaticEntityWithNonStaticProperties+"--"+r.id,message:`Property "${r.name}" with id "${r.id}" of entity "${d.name}" with id "${d.id}" is not marked as abstract but the entity is marked as abstract`,severity:ce.Error,code:be.StaticEntityWithNonStaticProperties,entity:d});p.push(l.error)}})}}else{if(d.abstractMethods.length){const i=Ut({id:d.id+"--"+be.AbstractPropertyInNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not marked as abstract but has abstract methods`,severity:ce.Error,code:be.AbstractPropertyInNonAbstractEntity,entity:d});p.push(i.error)}d.properties.some(i=>i.abstract)&&d.properties.forEach(i=>{if(i.abstract){const r=Ut({id:d.id+"--"+be.AbstractPropertyInNonAbstractEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${d.name}" with id "${d.id}" is marked as abstract but the entity is not marked as abstract`,severity:ce.Error,code:be.AbstractPropertyInNonAbstractEntity,entity:d,firstRelationship:i});p.push(r.error)}})}return d.static&&d.properties.some(i=>!i.static)&&d.properties.forEach(i=>{if(!i.static){const r=Ut({id:d.id+"--"+be.NonStaticPropertyInStaticEntity+"--"+i.id,message:`Property "${i.name}" with id "${i.id}" of entity "${d.name}" with id "${d.id}" is not marked as static but the entity is marked as static`,severity:ce.Error,code:be.NonStaticPropertyInStaticEntity,entity:d,firstRelationship:i});p.push(r.error)}}),p}function h2t(d,p){const i=[],r=Hr(p);if(!p.abstract){const e=new $i({id:d.id+"--"+p.id+"--"+be.ImplementingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is implementing a non-abstract built-in entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.ImplementingNonAbstractEntity,entity:d,firstRelationship:p});i.push(e)}const l=d.implements.filter(e=>e.id!==p.id);if(d.abstract){const e=new $i({id:d.id+"--"+p.id+"--"+be.AbstractEntityImplements,message:`Entity "${d.name}" with id "${d.id}" is marked as abstract and cannot implement built-in entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.AbstractEntityImplements,entity:d,firstRelationship:p});i.push(e)}if(d.static&&!p.static){const e=new $i({id:d.id+"--"+p.id+"--"+be.StaticImplementingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is marked as static and cannot implement non-static built-in entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.StaticImplementingNonStaticEntity,entity:d,firstRelationship:p});i.push(e)}if(!d.static&&p.static){const e=new $i({id:d.id+"--"+p.id+"--"+be.NonStaticImplementingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is not marked as static and cannot implement static built-in entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.NonStaticImplementingStaticEntity,entity:d,firstRelationship:p});i.push(e)}return l.length&&l.forEach(e=>{if(e.type===o.BuiltInBaseEntity){const y=r.filter(v=>v.id!==e.id);y.length&&y.forEach(v=>{if(v.id!==e.id){const b=new $i({id:d.id+"--"+v.id+"--"+e.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${v.name}" with id "${v.id}" but also implements entity "${e.name}" with id "${e.id}" which is incompatible`,severity:ce.Error,code:be.ImplementsIncompatibleEntities,entity:d,firstRelationship:v,secondRelationship:e});i.push(b)}})}else{Hr(e).forEach(A=>{const E=r.filter(w=>w.id!==A.id);E.length&&E.forEach(w=>{if(w.id!==A.id){const P=new $i({id:d.id+"--"+w.id+"--"+A.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${w.name}" with id "${w.id}" but also implements entity "${A.name}" with id "${A.id}" which is incompatible`,severity:ce.Error,code:be.ImplementsIncompatibleEntities,entity:d,firstRelationship:w,secondRelationship:A});i.push(P)}})});const v=jd(p.ownDeclaredProperties,e.ownDeclaredProperties,Re.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,Re.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);i.push(...v.errors);const b=jd(p.abstractMethods,[...e.abstractMethods,...e.methods],Re.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,Re.MethodOverwritesOtherImplementedEntitysMethodWithSameName);i.push(...b.errors)}}),O(d.extends?Hr(d.extends):[]).forEach(e=>{if(!r.find(y=>y.id===e.id)){const y=new $i({id:d.id+"--"+p.id+"--"+e.id+"--"+be.ExtendsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${p.name}" with id "${p.id}" but also extends entity "${e.name}" with id "${e.id}" which is incompatible`,severity:ce.Error,code:be.ExtendsIncompatibleEntities,entity:d,firstRelationship:p,secondRelationship:e});i.push(y)}}),i}function m2t(d,p,i=!1){var b,A;const r=[],l=Hr(p);if(!d.abstract&&p.abstract){const E=Ut({id:d.id+"--"+p.id+"--"+be.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is not-abstract but is extending an abstract entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:p});r.push(E.error)}if(d.abstract&&!p.abstract){const E=Ut({id:d.id+"--"+p.id+"--"+be.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but is extending an non-abstract entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:p});r.push(E.error)}if(!d.static&&p.static){const E=Ut({id:d.id+"--"+p.id+"--"+be.NonStaticExtendingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is not static but is extending a static entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.NonStaticExtendingStaticEntity,entity:d,firstRelationship:p});r.push(E.error)}if(d.static&&!p.static){const E=Ut({id:d.id+"--"+p.id+"--"+be.StaticExtendingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but is extending an non-static entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.StaticExtendingNonStaticEntity,entity:d,firstRelationship:p});r.push(E.error)}if(!Bc(p)){const E=Ut({id:d.id+"--"+p.id+"--"+be.ExtendingNonInteractiveEntity,message:`Entity "${d.name}" with id "${d.id}" is extending an non-interactive entity "${p.name}" with id "${p.id}"`,severity:ce.Error,code:be.ExtendingNonInteractiveEntity,entity:d,firstRelationship:p});r.push(E.error)}if(d.extends&&((b=d.extends)==null?void 0:b.id)!==p.id)if(((A=d.extends)==null?void 0:A.type)===o.BuiltInBaseEntity){const E=l.filter(w=>{var P;return w.id!==((P=d.extends)==null?void 0:P.id)});E.length&&E.forEach(w=>{var P,x,M,k;if(w.id!==((P=d.extends)==null?void 0:P.id)){const q=Ut({id:d.id+"--"+w.id+"--"+((x=d.extends)==null?void 0:x.id)+"--"+be.ExtendsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${w.name}" with id "${w.id}" but also extends entity "${(M=d.extends)==null?void 0:M.name}" with id "${(k=d.extends)==null?void 0:k.id}" which is incompatible`,severity:ce.Error,code:be.ExtendsIncompatibleEntities,entity:d,firstRelationship:w,secondRelationship:d.extends});r.push(q.error)}})}else{Hr(d.extends).forEach(q=>{const Z=l.filter(X=>X.id!==q.id);Z.length&&Z.forEach(X=>{if(X.id!==q.id){const se=new $i({id:d.id+"--"+X.id+"--"+q.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${X.name}" with id "${X.id}" but also extends or implements entity "${q.name}" with id "${q.id}" which is incompatible`,severity:ce.Error,code:be.ImplementsIncompatibleEntities,entity:d,firstRelationship:X,secondRelationship:q});r.push(se)}})});const w=!!Hr(d.extends).find(q=>q.id===p.id);let P=[...d.extends.properties];w&&(P=P.filter(q=>!p.properties.find(Z=>Z.id===q.id||Z.name===q.name||!!q.implements.find(X=>X.id===Z.id))));let x=[...d.extends.methods];w&&(x=x.filter(q=>!p.methods.find(Z=>{var X;return Z.id===q.id||Z.name===q.name||Z.id===((X=q.implements)==null?void 0:X.id)})));const M=jd(p.ownDeclaredProperties,P,Re.PropertyOverwritesOtherExtendedEntitysPropertyWithSameImplementation,Re.PropertyOverwritesOtherExtendedEntitysPropertyWithSameName);r.push(...M.errors);const k=jd(p.abstractMethods,x,Re.MethodOverwritesOtherExtendedEntitysMethodWithSameImplementation,Re.MethodOverwritesOtherExtendedEntitysMethodWithSameName);r.push(...k.errors)}i&&ae.log("self.implements.length",d.implements.length),d.implements.length&&d.implements.forEach(E=>{if(E.type===o.BuiltInBaseEntity){const w=l.filter(P=>P.id!==E.id);w.length&&w.forEach(P=>{if(P.id!==E.id){const x=new $i({id:d.id+"--"+P.id+"--"+E.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${P.name}" with id "${P.id}" but also implements entity "${E.name}" with id "${E.id}" which is incompatible`,severity:ce.Error,code:be.ImplementsIncompatibleEntities,entity:d,firstRelationship:P,secondRelationship:E});r.push(x)}})}else{Hr(E).forEach(M=>{const k=l.filter(q=>q.id!==M.id);k.length&&k.forEach(q=>{if(q.id!==M.id){const Z=new $i({id:d.id+"--"+q.id+"--"+M.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is implementing built-in entity "${q.name}" with id "${q.id}" but also implements entity "${M.name}" with id "${M.id}" which is incompatible`,severity:ce.Error,code:be.ImplementsIncompatibleEntities,entity:d,firstRelationship:q,secondRelationship:M});r.push(Z)}})});const P=jd(p.ownDeclaredProperties,E.ownDeclaredProperties,Re.PropertyOverwritesOtherImplementedEntitysPropertyWithSameImplementation,Re.PropertyOverwritesOtherImplementedEntitysPropertyWithSameName);r.push(...P.errors);const x=jd(p.abstractMethods,[...E.abstractMethods,...E.methods],Re.MethodOverwritesOtherImplementedEntitysMethodWithSameImplementation,Re.MethodOverwritesOtherImplementedEntitysMethodWithSameName);r.push(...x.errors)}});const e=jd(d.ownDeclaredProperties,p.ownDeclaredProperties,Re.PropertyOverwritesOtherSiblingWithSameImplementation,Re.PropertyOverwritesOtherSiblingWithSameName);r.push(...e.errors);const y=jd(p.methods,p.abstractMethods,Re.MethodOverwritesOtherSiblingWithSameImplementation,Re.MethodOverwritesOtherSiblingWithSameName);return r.push(...y.errors),O(d.extends?Hr(d.extends):[]).forEach(E=>{if(!l.find(w=>w.id===E.id)){const w=new $i({id:d.id+"--"+p.id+"--"+E.id+"--"+be.ImplementsIncompatibleEntities,message:`Entity "${d.name}" with id "${d.id}" is extending built-in entity "${p.name}" with id "${p.id}" but also extends entity "${E.name}" with id "${E.id}" which is incompatible`,severity:ce.Error,code:be.ImplementsIncompatibleEntities,entity:d,firstRelationship:p,secondRelationship:E});r.push(w)}}),r}function T2t(d){const p=[];if(d.implements.forEach(i=>{if(!i.static){const r=new $i({id:d.id+"--"+i.id+"--"+be.StaticImplementingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but implements entity "${i.name}" with id "${i.id}" which is non-static`,severity:ce.Error,code:be.StaticImplementingNonStaticEntity,entity:d,firstRelationship:i});p.push(r)}}),d.extends&&!d.extends.static){const i=new $i({id:d.id+"--"+d.extends.id+"--"+be.StaticExtendingNonStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is static but extends entity "${d.extends.name}" with id "${d.extends.id}" which is non-static`,severity:ce.Error,code:be.StaticExtendingNonStaticEntity,entity:d,firstRelationship:d.extends});p.push(i)}return p}function v2t(d){const p=[];if(d.implements.length){const i=new $i({id:d.id+"--"+be.AbstractEntityImplements,message:`Entity "${d.name}" with id "${d.id}" cannot be marked as abstract because it implements other entities`,severity:ce.Error,code:be.AbstractEntityImplements,entity:d});p.push(i)}if(d.extends&&!d.extends.abstract){const i=new $i({id:d.id+"--"+d.extends.id+"--"+be.AbstractExtendingNonAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is abstract but extends entity "${d.extends.name}" with id "${d.extends.id}" which is non-abstract`,severity:ce.Error,code:be.AbstractExtendingNonAbstractEntity,entity:d,firstRelationship:d.extends});p.push(i)}return p}function b2t(d){const p=[];if(d.extends&&d.extends.static){const i=new $i({id:d.id+"--"+d.extends.id+"--"+be.NonStaticExtendingStaticEntity,message:`Entity "${d.name}" with id "${d.id}" is non-static but extends entity "${d.extends.name}" with id "${d.extends.id}" which is static`,severity:ce.Error,code:be.NonStaticExtendingStaticEntity,entity:d,firstRelationship:d.extends});p.push(i)}return p}function E2t(d){const p=[];if(d.extends&&d.extends.abstract){const i=new $i({id:d.id+"--"+d.extends.id+"--"+be.NonAbstractExtendingAbstractEntity,message:`Entity "${d.name}" with id "${d.id}" is non-abstract but extends entity "${d.extends.name}" with id "${d.extends.id}" which is abstract`,severity:ce.Error,code:be.NonAbstractExtendingAbstractEntity,entity:d,firstRelationship:d.extends});p.push(i)}return p}function Rxe(d,p){const r=[...d.project.entities].filter(l=>l.id!==d.id);return xT(d,[Ji,Uc],r,p)}const A2t=Object.freeze(Object.defineProperty({__proto__:null,getBaseMethodsNotImplemented:Ixe,getBasePropertiesNotImplemented:gxe,validate:Axe,validateCanBecomeAbstract:v2t,validateCanBecomeNonAbstract:E2t,validateCanBecomeNonStatic:b2t,validateCanBecomeStatic:T2t,validateCanExtendEntity:m2t,validateCanImplementEntity:h2t,validateDefinitionEntityName:Rxe},Symbol.toStringTag,{value:"Module"}));function g2t(d,p){const i=[];if(d.parent)if(d.id===d.parent)i.push(new Oe({id:`${d.id}--${d.parent}--${re.SelfReference}`,code:re.SelfReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a reference to itself at 'parent'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`}));else{const r=p.get(d.parent);r?[o.Project,o.DataType].includes(r.type)||i.push(new Oe({id:`${d.id}--${d.parent}--${re.InvalidParentReference}`,code:re.InvalidParentReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a parent reference that isn't pointing to an entity of type 'project' or 'data-type'.`})):i.push(new Oe({id:`${d.id}--${d.parent}--${re.ReferencedEntityNotFound}`,code:re.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${d.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}return d.implements&&Array.isArray(d.implements)?d.implements.forEach(r=>{if(d.id===r){i.push(new Oe({id:`${d.id}--${r}--${re.SelfReference}`,code:re.SelfReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has a reference to itself at one of the 'implements' references. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`}));return}const l=p.get(r);l?[o.DefinitionEntity,o.BuiltInBaseEntity].includes(l.type)?l.abstract||i.push(new Oe({id:`${d.id}--${r}--${re.InvalidImplementsReference}`,code:re.InvalidImplementsReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an abstract entity.`})):i.push(new Oe({id:`${d.id}--${r}--${re.InvalidImplementsReference}`,code:re.InvalidImplementsReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`})):i.push(new Oe({id:`${d.id}--${r}--${re.ReferencedEntityNotFound}`,code:re.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${r}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}):i.push(new Oe({id:`${d.id}--${Re.InvalidObjectStructure}`,code:Re.InvalidObjectStructure,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'implements' property that isn't an array.`})),d.extends&&Array.isArray(d.extends)&&d.extends.forEach(r=>{const l=p.get(r);l?[o.DefinitionEntity,o.BuiltInBaseEntity].includes(l.type)?l.abstract&&i.push(new Oe({id:`${d.id}--${r}--${re.InvalidExtendsReference}`,code:re.InvalidExtendsReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'extends' reference that isn't pointing to a non-abstract entity. Did you want to use the property 'implements', which holds a list of references to absract entities, instead?`})):i.push(new Oe({id:`${d.id}--${r}--${re.InvalidExtendsReference}`,code:re.InvalidExtendsReference,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", has an 'extends' reference that isn't pointing to an entity of type 'definition-entity' or 'built-in-base-entity'.`})):i.push(new Oe({id:`${d.id}--${r}--${re.ReferencedEntityNotFound}`,code:re.ReferencedEntityNotFound,severity:ce.Error,message:`Entity of type "${d.type}" with id "${d.id}", is referencing an entity with id "${r}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`}))}),i}var qg=(d=>(d.Extends="extends",d.Implements="implements",d))(qg||{});const bi=class bi extends Un{constructor(i,r){super(i);R(this,"initialData");R(this,"id");R(this,"name");R(this,"codeName",null);R(this,"description",null);R(this,"x");R(this,"y");R(this,"static");R(this,"abstract");R(this,"type",o.DefinitionEntity);R(this,"additionalProperties",!1);R(this,"properties",[]);R(this,"allPropertiesImplement",null);R(this,"additionalPropertiesDataType",null);R(this,"methods",[]);R(this,"abstractMethods",[]);R(this,"extends",null);R(this,"implements",[]);R(this,"project");R(this,"errors",[]);R(this,"parent");R(this,"detachedDependents",{});R(this,"knownVersions",null);R(this,"activeVersion",!1);R(this,"initialized",!1);R(this,"startedInitialization",!1);R(this,"suggestedProperties",[]);R(this,"suggestedMethods",[]);this.initialData=i,this.project=r,this.id=i.id,this.name=i.name,this.description=i.description,this.x=i.x,this.y=i.y,this.codeName=i.codeName,this.static=i.static,this.abstract=i.abstract}static new(i=null){return{id:L.UUID.uuid(),version:L.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||L.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:o.DefinitionEntity,additionalProperties:!1,additionalPropertiesDataType:null,allPropertiesImplement:null,name:"",codeName:null,description:"",static:!1,abstract:!1,properties:[],methods:[],abstractMethods:[],extends:null,implements:[],x:0,y:0,parent:null}}static fromGenerationTarget(i,r){let l=r;if(i.parent){const b=ye(i.parent);l=r.get(b)}const c=[];i.implements&&i.implements.forEach(b=>{c.push(r.get(b)||r.getBuiltIn(b))});let e=null;i.extends&&(e=r.get(i.extends)||r.getBuiltIn(i.extends));const y={id:i.id,version:L.UUID.uuid(),createdAt:B().toISOString(),author:L.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:o.DefinitionEntity,codeName:i.codeName||null,description:i.description,static:i.static,abstract:i.abstract,additionalProperties:i.additionalProperties||!1,allPropertiesImplement:null,additionalPropertiesDataType:null,properties:[],methods:[],abstractMethods:[],extends:e,implements:c,x:0,y:0,parent:l},v=me(y,r);return v.setParent(l,null),v}static validateGenerationTarget(i,r){let l=JSON.parse(JSON.stringify(i));const c=[],e=g2t(l,r),y=lP(l,r);c.push(...e,...y,...Pn(l));const v=l.parent?r.get(l.parent):null;if(v&&v.type===o.DataType){const b=v;b.entity&&c.push(new Oe({id:`${i.id}--${re.NewEntityWouldOverriteExisting}`,code:re.NewEntityWouldOverriteExisting,severity:ce.Error,message:`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${b.id}' because it already has an 'entity' child. Data type entities can only have one 'entity' as children.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyx-code/project-logic-tree",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6645",
|
|
4
4
|
"author": "Sergio Herrero",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",
|