@elyx-code/project-logic-tree 0.0.6538 → 0.0.6539
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 +6 -2
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -51959,9 +51959,13 @@ g(kt, "repository", {
|
|
|
51959
51959
|
p.InputMap,
|
|
51960
51960
|
p.OutputMap,
|
|
51961
51961
|
p.DataType,
|
|
51962
|
-
p.ActionDescriptor
|
|
51962
|
+
p.ActionDescriptor,
|
|
51963
|
+
p.Loop,
|
|
51964
|
+
p.Search,
|
|
51965
|
+
p.DefinitionEntity
|
|
51963
51966
|
]), g(kt, "PARENT_TYPES", [
|
|
51964
|
-
...kt.USER_MANAGED_PARENT_TYPES
|
|
51967
|
+
...kt.USER_MANAGED_PARENT_TYPES,
|
|
51968
|
+
p.BuiltInBaseEntity
|
|
51965
51969
|
]), g(kt, "MUTABLE_BASE_PROPERTIES", [
|
|
51966
51970
|
"isList",
|
|
51967
51971
|
"asType",
|
package/dist/index.umd.cjs
CHANGED
|
@@ -36,7 +36,7 @@ ${mo}`}))}}}const y=l.parent&&a.get(l.parent)||a.getBuiltIn(l.parent),v=y?Io(y):
|
|
|
36
36
|
The entitities of type '${dt(b,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property so no 'parentRelationType' is needed.`})),y.dataType)){const O=(T=y.dataType)==null?void 0:T.id;f.push(new oe({id:`${i.id}--${W.NewEntityWouldOverriteExisting}`,code:W.NewEntityWouldOverriteExisting,severity:J.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 '${O}'.
|
|
37
37
|
The entitities of type '${dt(b,"', '","' 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:
|
|
38
38
|
${ga({describe_entity:O})}
|
|
39
|
-
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`}))}A===p.DataType&&(!l.parentRelationType||!(l.parentRelationType===mr.AndDataTypeGroup||l.parentRelationType===mr.OrDataTypeGroup))&&f.push(new oe({id:`${i.id}--${W.InvalidParentRelationType}`,code:W.InvalidParentRelationType,severity:J.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:f,modifiedData:l}}get isGroup(){const i=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(i.length>1){let a=0;for(const l of i)if(l.isResolved&&(a++,a>1))return!0}return!1}get isResolved(){return[p.BuiltInBaseEntity,p.ActionDescriptor].includes(this.parent.type)||Io(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],f=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),f.push(...v.removed),e.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}onDetachedDependencyRemoved(i,a,l){const f=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(i,l),{updated:g(f),added:g(e),removed:g(y),affected:g(v),self:this}}onDetachedDependencyRestored(i,a,l){const f=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(null,l),{updated:g(f),added:g(e),removed:g(y),affected:g(v),self:this}}unsubscribeFromDependencies(){var i,a;return(a=(i=this.entity)==null?void 0:i.unsubscribeDependents)==null||a.call(i,[{entity:this,field:"entity"}]),this}subscribeToDependencies(){var i,a;return(a=(i=this.entity)==null?void 0:i.subscribeDependents)==null||a.call(i,[{entity:this,field:"entity"}]),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=V.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ft(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.andChildrenGroup=this.andChildrenGroup?[...this.andChildrenGroup]:this.andChildrenGroup,i.orChildrenGroup=this.orChildrenGroup?[...this.orChildrenGroup]:this.orChildrenGroup,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],f=[],e=[];if(this.parent&&this.parent.type!==p.BuiltInBaseEntity){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),f.push(...y.removed)}return{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}async restoreVersion(i){var v;const a=[],l=[],f=[],e=[];if(this.version===i)return{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this};if(!this.knownVersions){const T=new Map;for(const[A,b]of this.knownVersions||new Map){if(T.set(A,b),b.activeVersion=!1,b.knownVersions)for(const[O,L]of b.knownVersions)T.set(O,L);b.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ft(T,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.andChildrenGroup=y.andChildrenGroup,this.orChildrenGroup=y.orChildrenGroup,this.parent=y.parent,{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.UpdateWithShallowTransfer))){var l,f;if(!this.checkCanEdit(this))return H.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,a),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=Y(i.parent),y=this.project.get(e),v=this.parent;if(v&&v.id!==(y==null?void 0:y.id)&&this.removeFromParent(a),y)this.setParent(y,a),this.addSelfToProject(a);else throw a==null||a.attemptAutoclose(P.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 a==null||a.attemptAutoclose(P.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.entity){const e=Y(i.entity),y=this.project.get(e);y&&(y.type===p.DefinitionEntity&&y.parent===this||this.setEntity(y,null))}return(l=i.andChildrenGroup)==null||l.forEach(e=>{const y=Y(e),v=this.project.get(y);v&&(this.addToAndGroup(v,a),v.setParent(this,a))}),[...this.andChildrenGroup||[]].forEach(e=>{var v;((v=i.andChildrenGroup)==null?void 0:v.find(T=>Y(T)===e.id))||(this.removeChildGroup(e,a),e.removeFromParent(a))}),(f=i.orChildrenGroup)==null||f.forEach(e=>{const y=Y(e),v=this.project.get(y);v&&(this.addToOrGroup(v,a),v.setParent(this,a))}),[...this.orChildrenGroup||[]].forEach(e=>{var v;((v=i.orChildrenGroup)==null?void 0:v.find(T=>Y(T)===e.id))||(this.removeChildGroup(e,a),e.removeFromParent(a))}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose(P.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],a=[],l=[],f=[];if(this.initialData.parent){const e=Y(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=Y(this.initialData.entity),y=this.project.get(e);y&&(y.type===p.DefinitionEntity&&y.parent===this||(this.setEntity(y,null),y.type!==p.BuiltInBaseEntity&&y.type!==p.PrimitiveEntity&&i.push(y)))}return{updated:g(i),added:g(a),removed:g(l),affected:g(f),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this))return H.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(P.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const a=[],l=[],f=[],e=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose(P.AfterAllChildrenInitialized,this.id),{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],f=[],e=[];return this.parent.type===p.DataType?(this.parentRelationType===mr.AndDataTypeGroup?this.parent.addToAndGroup(this,i):this.parentRelationType===mr.OrDataTypeGroup&&this.parent.addToOrGroup(this,i),e.push(this.parent)):this.parent.type===p.DefinitionEntity?(this.parent.setAdditionalPropertiesDataType(this,i),e.push(this.parent)):this.parent.type!==p.BuiltInBaseEntity&&this.parent.setDataType(this,i),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.SetParent))){var l;return this.checkCanEditWithCounterpartAndSideEffects(this,i,P.SetParent,a)?(((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose(P.SetParent,this.id),this):this}removeChildGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RemoveChildGroup))){if(!this.checkCanEdit(this))return H.warn(`[removeChildGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.RemoveChildGroup,this.id),this;if(this.andChildrenGroup){const l=this.andChildrenGroup.findIndex(f=>f.id===i.id);l!==-1&&(this.andChildrenGroup.splice(l,1),a==null||a.add(this,K.Updated))}if(this.orChildrenGroup){const l=this.orChildrenGroup.findIndex(f=>f.id===i.id);l!==-1&&(this.orChildrenGroup.splice(l,1),a==null||a.add(this,K.Updated))}return a==null||a.attemptAutoclose(P.RemoveChildGroup,this.id),this}initChildren(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"init-children"))){var a,l,f,e,y,v,T,A;if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.entity)if(this.initialData.entity.type===p.GenericReference){const b=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=b}else this.entity=ae(this.initialData.entity,this.project),(((l=(a=this.initialData.entity)==null?void 0:a.parent)==null?void 0:l.id)===this.id||((e=(f=this.initialData.entity)==null?void 0:f.parent)==null?void 0:e.type)===p.GenericReference&&((v=(y=this.initialData.entity)==null?void 0:y.parent)==null?void 0:v.entityId)==this.id)&&this.entity.setParent(this,null),(A=(T=this.entity).initChildren)==null||A.call(T,i);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(b=>{const O=ae(b,this.project);return O.setParent(this,null),O.initChildren(i),O})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(b=>{const O=ae(b,this.project);return O.setParent(this,null),O.initChildren(i),O})),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,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const l=Yi(this,i),f=zi(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),l.deleted===!0&&!e.deleted?a==null||a.add(this,K.Removed):l.deleted===!1&&e.deleted?a==null||a.add(this,K.Added):f&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ie,...a){return await Ft.repository.APILoad(this.id,...a),this}async APICreate(i=Ie,...a){return await Ft.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=Ie,...a){return await Ft.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=Ie,...a){return await Ft.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=Ie,...a){return await Ft.repository.APIClone(this.id,...a),this}async APILoadVersion(i=Ie,a,...l){return await Ft.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RemoveFromParent))){var y,v;if(!this.checkCanEdit(this))return H.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(P.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],l=[],f=[],e=[];if(((y=this.parent)==null?void 0:y.type)===p.DataType)this.parent.removeChildGroup(this,i);else if(((v=this.parent)==null?void 0:v.type)===p.DefinitionEntity)this.parent.removeAdditionalPropertiesDataType(i);else{const T=this.parent;T==null||T.removeDataType(i)}return this.parent&&this.parent.type!==p.BuiltInBaseEntity&&a.push(this.parent),i==null||i.attemptAutoclose(P.RemoveFromParent,this.id),{added:g(f),updated:g(a),removed:g(l),affected:g(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RemoveEntity))){const l=[],f=[],e=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose(P.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(f.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:T,removed:A,added:b}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...T),f.push(...A),e.push(...b)}),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:v,removed:T}=this.entity.remove({ignoreUpstream:!0},a);l.push(...v),f.push(...T)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);f.push(...T),l.push(...A)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);f.push(...T),l.push(...A)}),!i){const v=this.removeFromParent(a);e.push(...v.added),l.push(...v.updated),f.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose(P.RemoveEntity,this.id),{added:g(e),updated:g(l),removed:g(f),affected:g(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RestoreEntity))){if(!this.checkCanEdit(this))return H.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(P.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],l=[],f=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(P.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:T,added:A}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),f.push(...T),a.push(...A)}),this.entity&&this.entity.type===p.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:T}=y.restore({},i);l.push(...v),a.push(...T)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(y=>{const{updated:v,added:T}=y.restore({},i);l.push(...v),a.push(...T)}),this.parent.type===p.DataType){const y=this.parent;Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this)}if(this.parent.type===p.DataType){const y=this.parent;this.parentRelationType===mr.AndDataTypeGroup?Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this):this.parentRelationType===mr.OrDataTypeGroup&&Array.isArray(y.orChildrenGroup)&&y.orChildrenGroup.push(this)}else{const y=this.parent;y.setDataType(this,i),l.push(y)}return i==null||i.attemptAutoclose(P.RestoreEntity,this.id),{added:g(a),updated:g(l),removed:g(f),affected:g(e),self:this}}toFlat(i=new Set){var l,f,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlat(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(y=>y.toFlat(i)))||[],...((e=this.entity)==null?void 0:e.toFlat(i))||[]])}toFlatIds(i=new Set){var l,f,e;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatIds(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(y=>y.toFlatIds(i)))||[],...((e=this.entity)==null?void 0:e.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,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 a,l,f,e;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,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((a=this.andChildrenGroup)==null?void 0:a.map(y=>y.toJSON(i)))||null,orChildrenGroup:((l=this.orChildrenGroup)==null?void 0:l.map(y=>y.toJSON(i)))||null,entity:((f=this.entity)==null?void 0:f.parent)===this?this.entity.toJSON(i):((e=this.entity)==null?void 0:e.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=Ke){var l,f,e,y,v,T,A,b,O;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||or(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(f=i.seenEntities)!=null&&f.has(a)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:V.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,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((T=this.andChildrenGroup)==null?void 0:T.map(L=>L.toJSONClone({...i,newId:null})))||null,orChildrenGroup:((A=this.orChildrenGroup)==null?void 0:A.map(L=>L.toJSONClone({...i,newId:null})))||null,entity:((b=this.entity)==null?void 0:b.parent)===this?this.entity.toJSONClone({...i,newId:null}):((O=this.entity)==null?void 0:O.toReference({seenEntityMaps:i.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Ke){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+V.UUID.uuid()+"--ref",type:p.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Ke){var l,f,e,y;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,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,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((f=this.andChildrenGroup)==null?void 0:f.map(v=>v.toReference(i)))||null,orChildrenGroup:((e=this.orChildrenGroup)==null?void 0:e.map(v=>v.toReference(i)))||null,entity:((y=this.entity)==null?void 0:y.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var l,f,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatJSON(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(y=>y.toFlatJSON(i)))||[],...((e=this.entity)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(){var i;return{id:this.id,type:this.type,options:this.options||void 0,isList:this.isList,like:this.like,parentRelationType:this.parentRelationType||void 0,asType:this.asType,entity:((i=this.entity)==null?void 0:i.id)||null,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var l,f;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...this.entity&&this.entity.type==p.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(i)||[]])}clearErrors(){var i,a,l,f;return this.errors=[],(i=this.andChildrenGroup)==null||i.forEach(e=>e.clearErrors()),(a=this.orChildrenGroup)==null||a.forEach(e=>e.clearErrors()),this.inferred&&this.entity&&this.entity.type===p.DefinitionEntity&&((l=this.entity)==null?void 0:l.parent)===this&&((f=this.entity)==null||f.clearErrors()),this}validate(){const i=uK(this);return this.errors=i,{success:!0}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.CloneEntity)),a=null,l=null,f=!0){var L,M,k;let e=lr(a,this),y=a||this.parent;const T={id:l||V.UUID.uuid(),version:V.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:p.DataType,isList:this.isList,asType:this.asType,options:this.options,index:this.index,parentRelationType:this.parentRelationType,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:y.toReference()},A=Ti(T,e);a&&A.setParent(a,null),f&&A.subscribe(),A.initChildren(i),i==null||i.add(A,K.Added);const b=(L=this.andChildrenGroup)==null?void 0:L.map(q=>q.clone(i,A,V.UUID.uuid(),f)),O=(M=this.orChildrenGroup)==null?void 0:M.map(q=>q.clone(i,A,V.UUID.uuid(),f));if(A.andChildrenGroup=b||null,A.orChildrenGroup=O||null,this.entity&&this.entity.type===p.DefinitionEntity&&((k=this.entity)==null?void 0:k.parent)===this){const q=this.entity.clone(i,A,V.UUID.uuid(),f);A.setEntity(q,i)}else this.entity&&A.setEntity(this.entity,i);return i==null||i.attemptAutoclose(P.CloneEntity,this.id),A}merge(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"merge-entity"))){const l=[],f=[],e=[],y=[];if(this.asType!==(i==null?void 0:i.asType)&&(this.metaSync({asType:i==null?void 0:i.asType},a),a==null||a.add(this,K.Updated),l.push(this)),this.index!==(i==null?void 0:i.index)&&(this.metaSync({index:i==null?void 0:i.index},a),a==null||a.add(this,K.Updated),l.push(this)),this.isList!==(i==null?void 0:i.isList)&&(this.metaSync({isList:i==null?void 0:i.isList},a),a==null||a.add(this,K.Updated),l.push(this)),this.like!==(i==null?void 0:i.like)&&(this.metaSync({like:i==null?void 0:i.like},a),a==null||a.add(this,K.Updated),l.push(this)),i!=null&&i.inferred){if(i.entity&&i.entity.type===p.DefinitionEntity&&i.entity.parent===i){const v=i.entity.clone(a,this,V.UUID.uuid(),!0);this.setEntity(v,a),f.push(v)}else i.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,K.Updated),l.push(this));this.inferred||(this.metaSync({inferred:!0},a),a==null||a.add(this,K.Updated),l.push(this))}else if(this.inferred){if(this.metaSync({inferred:!1},a),a==null||a.add(this,K.Updated),l.push(this),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:v,removed:T}=this.entity.remove({ignoreUpstream:!0},a);e.push(...T),v.push(...v)}i.entity!==this.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,K.Updated),l.push(this))}else i.entity!==this.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,K.Updated),l.push(this));return a==null||a.attemptAutoclose("merge-entity",this.id),{updated:g(l),added:g(f),removed:g(e),affected:g(y),self:this}}addToAndGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.AddToAndGroup))){return this.checkCanEdit(this)?(this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(i)||(this.andChildrenGroup.push(i),a==null||a.add(i,K.Affected)),a==null||a.attemptAutoclose(P.AddToAndGroup,this.id),this):(H.warn(`[addToAndGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.AddToAndGroup,this.id),this)}addToOrGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.AddToOrGroup))){return this.checkCanEdit(this)?(this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(i)||(this.orChildrenGroup.push(i),a==null||a.add(i,K.Affected)),a==null||a.attemptAutoclose(P.AddToOrGroup,this.id),this):(H.warn(`[addToOrGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.AddToOrGroup,this.id),this)}setEntity(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"set-data-type-entity-value"))){var f;const l=this.entity;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.entity=i,a==null||a.add(this,K.Affected),l&&l.type===p.DefinitionEntity&&((f=l.parent)==null?void 0:f.id)===this.id&&(l==null||l.remove({ignoreUpstream:!0},a))),a==null||a.attemptAutoclose("set-data-type-entity-value",this.id),this}isObject(){return!!this.entity&&(this.entity.type===p.DefinitionEntity||this.entity.type===p.BuiltInBaseEntity||this.entity.name===ie.KeyValue)&&!this.isList}canBeObject(){var a;let i=!1;if(this.parent.type!==p.DataType&&this.parent.type!==p.ActionDescriptor&&this.parent.type!==p.BuiltInBaseEntity&&this.parent.type!==p.DefinitionEntity){const l=(a=this.project.requestActiveDynamicValue(this.parent))==null?void 0:a.value;l?!l.valueAsType&&(l.value===""||l.value===null||Pi(l))&&(i=!0):i=!0}return(this.isObject()||!this.entity||this.entity.name===ie.Untyped)&&i}hasStrictObjectStructure(){var i;return this.isObject()&&((i=this.entity)==null?void 0:i.type)===p.DefinitionEntity}isInlineDeclaredEntity(){var i,a;return((i=this.entity)==null?void 0:i.type)===p.DefinitionEntity&&((a=this.entity.parent)==null?void 0:a.id)===(this==null?void 0:this.id)}isIndependentlyUserDeclaredEntity(){var i,a;return((i=this.entity)==null?void 0:i.type)===p.DefinitionEntity&&((a=this.entity)==null?void 0:a.parent)!==this}canModifyObjectStructure(){var a;const i=this.isIndependentlyUserDeclaredEntity();return(this.isInlineDeclaredEntity()||this.canBeObject()||((a=this.entity)==null?void 0:a.name)===ie.KeyValue)&&!i}inferFromInputs(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"infer-data-type-from-inputs"))){var v;const l=[],f=[],e=[],y=[];if(!this.inferred)return a==null||a.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:[],added:[],removed:[],affected:[],self:this};if(!this.entity&&i.length){const T=ee(this.parent,this.project)+" data type definition",A={id:V.UUID.uuid(),deletable:!0,editable:!0,type:p.DefinitionEntity,version:V.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||B().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,name:T,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()},b=ae(A,this.project);b.hydrateAncestors(),b.setParent(this,a),b.initChildren(a),a==null||a.add(b,K.Added),b.metaSync(A,a),this.setEntity(b,a),a==null||a.add(this,K.Updated)}if(this.entity){const{updated:T,added:A,removed:b,affected:O}=this.entity.inferFromInputs(i,a);f.push(...T),l.push(...A),e.push(...b),y.push(...O)}return this.like||this.metaSync({like:!0},a),a==null||a.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:g(f),added:g(l),removed:g(e),affected:g(y),self:this}}};_(Ft,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),_(Ft,"type",p.DataType),_(Ft,"USER_MANAGED_PARENT_TYPES",[p.Property,p.ArgumentDeclaration,p.ReturnStatement,p.BreakStatement,p.ContinueStatement,p.VariableDeclaration,p.ValueDescriptor,p.InputMap,p.OutputMap,p.DataType,p.ActionDescriptor]),_(Ft,"PARENT_TYPES",[...Ft.USER_MANAGED_PARENT_TYPES]),_(Ft,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),_(Ft,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","index","author","previousVersion"]),_(Ft,"BASE_PROPERTIES",[...Ft.MUTABLE_BASE_PROPERTIES,...Ft.INMUTABLE_BASE_PROPERTIES]),_(Ft,"MUTABLE_META_PROPERTIES",[...Ft.MUTABLE_BASE_PROPERTIES,"inferred"]),_(Ft,"INMUTABLE_META_PROPERTIES",[...Ft.INMUTABLE_BASE_PROPERTIES]),_(Ft,"META_PROPERTIES",[...Ft.MUTABLE_META_PROPERTIES,...Ft.INMUTABLE_META_PROPERTIES]),_(Ft,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),_(Ft,"INMUTABLE_UPSTREAM_PROPERTIES",[]),_(Ft,"UPSTREAM_PROPERTIES",[...Ft.MUTABLE_UPSTREAM_PROPERTIES,...Ft.INMUTABLE_UPSTREAM_PROPERTIES]),_(Ft,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),_(Ft,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),_(Ft,"DOWNSTREAM_PROPERTIES",[...Ft.MUTABLE_DOWNSTREAM_PROPERTIES,...Ft.INMUTABLE_DOWNSTREAM_PROPERTIES]),_(Ft,"PROPERTIES",[...Ft.META_PROPERTIES,...Ft.UPSTREAM_PROPERTIES,...Ft.DOWNSTREAM_PROPERTIES]);let ln=Ft;function pK(d){var l;const u=vge(d),i=hl(d),a=[...u,...i,...ml(d)];return d.outputs.forEach(f=>f.validate()),(l=d.error)==null||l.validate(),Oi(d.errors,a)}function vge(d){const u=[];return d.inputs.forEach(i=>{i.validate()}),Oi(d.errors,u)}const Tge=Object.freeze(Object.defineProperty({__proto__:null,validate:pK},Symbol.toStringTag,{value:"Module"}));var cK=(d=>(d.Parent="parent",d))(cK||{});const Kt=class Kt extends nr{constructor(i,a){super(i);_(this,"initialData");_(this,"id");_(this,"x");_(this,"y");_(this,"type",p.Operation);_(this,"catchesError",!1);_(this,"declaration");_(this,"writesValues",[]);_(this,"inputs",[]);_(this,"outputs",[]);_(this,"successCalls",[]);_(this,"errorCalls",[]);_(this,"error",null);_(this,"calledBySuccess",[]);_(this,"calledByError",[]);_(this,"calledByEntry",[]);_(this,"parent");_(this,"errors",[]);_(this,"project");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);this.initialData=i,this.project=a,this.id=i.id,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.Operation,writesValues:[],catchesError:!0,declaration:null,inputs:[],outputs:[],error:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(i,a){let l=a;if(i.parent){const O=Y(i.parent);l=a.get(O)}const f=Y(i.declaration),e=a.get(f),y=i.calledByEntry.map(O=>{const L=Y(O);return a.get(L)}),v=i.calledBySuccess.map(O=>{const L=Y(O);return a.get(L)}),T=i.calledByError.map(O=>{const L=Y(O);return a.get(L)}),A={id:i.id,version:V.UUID.uuid(),createdAt:B().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.Operation,writesValues:[],catchesError:i.catchesError||!1,declaration:e,calledByEntry:y,calledBySuccess:v,calledByError:T,errorCalls:[],successCalls:[],inputs:[],outputs:[],error:null,x:0,y:0,parent:l},b=ae(A,a);return b.setParent(l,null),b}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const f=[],e=Or(l,{parent:{list:!1,types:[...Ki,p.Project],optional:!0}},a);l=e.modifiedData,f.push(...e.errors,...Ji(l));const y=Y(l.declaration);if(y){const v=KW(y,a);f.push(...v)}else{const v=`
|
|
39
|
+
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`}))}A===p.DataType&&(!l.parentRelationType||!(l.parentRelationType===mr.AndDataTypeGroup||l.parentRelationType===mr.OrDataTypeGroup))&&f.push(new oe({id:`${i.id}--${W.InvalidParentRelationType}`,code:W.InvalidParentRelationType,severity:J.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:f,modifiedData:l}}get isGroup(){const i=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(i.length>1){let a=0;for(const l of i)if(l.isResolved&&(a++,a>1))return!0}return!1}get isResolved(){return[p.BuiltInBaseEntity,p.ActionDescriptor].includes(this.parent.type)||Io(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(i){return{errors:[],modifiedData:i}}subscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]||(this.detachedDependents[a.entity.id]=a)}),this}unsubscribeDependents(i){return i.forEach(a=>{this.detachedDependents[a.entity.id]&&delete this.detachedDependents[a.entity.id]}),this}syncDependents(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],f=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),f.push(...v.removed),e.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}onDetachedDependencyRemoved(i,a,l){const f=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(i,l),{updated:g(f),added:g(e),removed:g(y),affected:g(v),self:this}}onDetachedDependencyRestored(i,a,l){const f=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(null,l),{updated:g(f),added:g(e),removed:g(y),affected:g(v),self:this}}unsubscribeFromDependencies(){var i,a;return(a=(i=this.entity)==null?void 0:i.unsubscribeDependents)==null||a.call(i,[{entity:this,field:"entity"}]),this}subscribeToDependencies(){var i,a;return(a=(i=this.entity)==null?void 0:i.subscribeDependents)==null||a.call(i,[{entity:this,field:"entity"}]),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=V.UUID.uuid(),this.createdAt=B(i).toISOString()||B().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ft(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.andChildrenGroup=this.andChildrenGroup?[...this.andChildrenGroup]:this.andChildrenGroup,i.orChildrenGroup=this.orChildrenGroup?[...this.orChildrenGroup]:this.orChildrenGroup,i.parent=this.parent,this}recursiveCaptureUpstreamVersions(i){const a=[],l=[],f=[],e=[];if(this.parent&&this.parent.type!==p.BuiltInBaseEntity){this.parent.increaseVersion(i);const y=this.parent.recursiveCaptureUpstreamVersions(i);a.push(this.parent,...y.updated),l.push(...y.added),f.push(...y.removed)}return{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}async restoreVersion(i){var v;const a=[],l=[],f=[],e=[];if(this.version===i)return{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this};if(!this.knownVersions){const T=new Map;for(const[A,b]of this.knownVersions||new Map){if(T.set(A,b),b.activeVersion=!1,b.knownVersions)for(const[O,L]of b.knownVersions)T.set(O,L);b.knownVersions=null}}let y=(v=this.knownVersions)==null?void 0:v.get(i);if(!y){const T=await this.APILoadVersion({},i);if(!T)throw new Error(`Version with id '${i}' for entity with id '${this.id}' not found.`);y=new Ft(T,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.andChildrenGroup=y.andChildrenGroup,this.orChildrenGroup=y.orChildrenGroup,this.parent=y.parent,{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.UpdateWithShallowTransfer))){var l,f;if(!this.checkCanEdit(this))return H.warn(`[updateWithShallowTransfer] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.UpdateWithShallowTransfer,this.id),this;if(this.metaSync(i,a),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=Y(i.parent),y=this.project.get(e),v=this.parent;if(v&&v.id!==(y==null?void 0:y.id)&&this.removeFromParent(a),y)this.setParent(y,a),this.addSelfToProject(a);else throw a==null||a.attemptAutoclose(P.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 a==null||a.attemptAutoclose(P.UpdateWithShallowTransfer,this.id),new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(i.entity){const e=Y(i.entity),y=this.project.get(e);y&&(y.type===p.DefinitionEntity&&y.parent===this||this.setEntity(y,null))}return(l=i.andChildrenGroup)==null||l.forEach(e=>{const y=Y(e),v=this.project.get(y);v&&(this.addToAndGroup(v,a),v.setParent(this,a))}),[...this.andChildrenGroup||[]].forEach(e=>{var v;((v=i.andChildrenGroup)==null?void 0:v.find(T=>Y(T)===e.id))||(this.removeChildGroup(e,a),e.removeFromParent(a))}),(f=i.orChildrenGroup)==null||f.forEach(e=>{const y=Y(e),v=this.project.get(y);v&&(this.addToOrGroup(v,a),v.setParent(this,a))}),[...this.orChildrenGroup||[]].forEach(e=>{var v;((v=i.orChildrenGroup)==null?void 0:v.find(T=>Y(T)===e.id))||(this.removeChildGroup(e,a),e.removeFromParent(a))}),this.captureVersion(),this.subscribeToDependencies(),a==null||a.attemptAutoclose(P.UpdateWithShallowTransfer,this.id),this}hydrateAncestors(){const i=[],a=[],l=[],f=[];if(this.initialData.parent){const e=Y(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=Y(this.initialData.entity),y=this.project.get(e);y&&(y.type===p.DefinitionEntity&&y.parent===this||(this.setEntity(y,null),y.type!==p.BuiltInBaseEntity&&y.type!==p.PrimitiveEntity&&i.push(y)))}return{updated:g(i),added:g(a),removed:g(l),affected:g(f),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.AfterAllChildrenInitialized))){if(!this.checkCanEdit(this))return H.warn(`[afterAllChildrenInitialized] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(P.AfterAllChildrenInitialized,this.id),{updated:[],added:[],removed:[],affected:[],self:this};const a=[],l=[],f=[],e=[];return this.initialized=!0,this.captureVersion(),i==null||i.attemptAutoclose(P.AfterAllChildrenInitialized,this.id),{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],f=[],e=[];return this.parent.type===p.DataType?(this.parentRelationType===mr.AndDataTypeGroup?this.parent.addToAndGroup(this,i):this.parentRelationType===mr.OrDataTypeGroup&&this.parent.addToOrGroup(this,i),e.push(this.parent)):this.parent.type===p.DefinitionEntity?(this.parent.setAdditionalPropertiesDataType(this,i),e.push(this.parent)):this.parent.type!==p.BuiltInBaseEntity&&this.parent.setDataType(this,i),this.subscribe(),this.subscribeToDependencies(),i==null||i.attemptAutoclose("add-self-to-project",this.id),{updated:g(a),added:g(l),removed:g(f),affected:g(e),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.SetParent))){var l;return this.checkCanEditWithCounterpartAndSideEffects(this,i,P.SetParent,a)?(((l=this.parent)==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.parent=i,a&&(a==null||a.add(this,K.Updated))),a==null||a.attemptAutoclose(P.SetParent,this.id),this):this}removeChildGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RemoveChildGroup))){if(!this.checkCanEdit(this))return H.warn(`[removeChildGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.RemoveChildGroup,this.id),this;if(this.andChildrenGroup){const l=this.andChildrenGroup.findIndex(f=>f.id===i.id);l!==-1&&(this.andChildrenGroup.splice(l,1),a==null||a.add(this,K.Updated))}if(this.orChildrenGroup){const l=this.orChildrenGroup.findIndex(f=>f.id===i.id);l!==-1&&(this.orChildrenGroup.splice(l,1),a==null||a.add(this,K.Updated))}return a==null||a.attemptAutoclose(P.RemoveChildGroup,this.id),this}initChildren(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"init-children"))){var a,l,f,e,y,v,T,A;if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.entity)if(this.initialData.entity.type===p.GenericReference){const b=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=b}else this.entity=ae(this.initialData.entity,this.project),(((l=(a=this.initialData.entity)==null?void 0:a.parent)==null?void 0:l.id)===this.id||((e=(f=this.initialData.entity)==null?void 0:f.parent)==null?void 0:e.type)===p.GenericReference&&((v=(y=this.initialData.entity)==null?void 0:y.parent)==null?void 0:v.entityId)==this.id)&&this.entity.setParent(this,null),(A=(T=this.entity).initChildren)==null||A.call(T,i);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(b=>{const O=ae(b,this.project);return O.setParent(this,null),O.initChildren(i),O})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(b=>{const O=ae(b,this.project);return O.setParent(this,null),O.initChildren(i),O})),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,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"meta-sync"))){const l=Yi(this,i),f=zi(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),l.deleted===!0&&!e.deleted?a==null||a.add(this,K.Removed):l.deleted===!1&&e.deleted?a==null||a.add(this,K.Added):f&&(a==null||a.add(this,K.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=Ie,...a){return await Ft.repository.APILoad(this.id,...a),this}async APICreate(i=Ie,...a){return await Ft.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=Ie,...a){return await Ft.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=Ie,...a){return await Ft.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=Ie,...a){return await Ft.repository.APIClone(this.id,...a),this}async APILoadVersion(i=Ie,a,...l){return await Ft.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RemoveFromParent))){var y,v;if(!this.checkCanEdit(this))return H.warn(`[removeFromParent] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(P.RemoveFromParent,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],l=[],f=[],e=[];if(((y=this.parent)==null?void 0:y.type)===p.DataType)this.parent.removeChildGroup(this,i);else if(((v=this.parent)==null?void 0:v.type)===p.DefinitionEntity)this.parent.removeAdditionalPropertiesDataType(i);else{const T=this.parent;T==null||T.removeDataType(i)}return this.parent&&this.parent.type!==p.BuiltInBaseEntity&&a.push(this.parent),i==null||i.attemptAutoclose(P.RemoveFromParent,this.id),{added:g(f),updated:g(a),removed:g(l),affected:g(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RemoveEntity))){const l=[],f=[],e=[],y=[];if(a!=null&&a.hasRemoved(this.id))return a==null||a.attemptAutoclose(P.RemoveEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(f.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},a),Object.values(this.detachedDependents).forEach(v=>{const{updated:T,removed:A,added:b}=v.entity.onDetachedDependencyRemoved(this,v.field,a);l.push(...T),f.push(...A),e.push(...b)}),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:v,removed:T}=this.entity.remove({ignoreUpstream:!0},a);l.push(...v),f.push(...T)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);f.push(...T),l.push(...A)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);f.push(...T),l.push(...A)}),!i){const v=this.removeFromParent(a);e.push(...v.added),l.push(...v.updated),f.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose(P.RemoveEntity,this.id),{added:g(e),updated:g(l),removed:g(f),affected:g(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.RestoreEntity))){if(!this.checkCanEdit(this))return H.warn(`[restore] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),i==null||i.attemptAutoclose(P.RestoreEntity,this.id),{added:[],updated:[],removed:[],affected:[],self:this};const a=[],l=[],f=[],e=[];if(i!=null&&i.hasAdded(this.id))return i==null||i.attemptAutoclose(P.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:T,added:A}=y.entity.onDetachedDependencyRestored(this,y.field,i);l.push(...v),f.push(...T),a.push(...A)}),this.entity&&this.entity.type===p.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:T}=y.restore({},i);l.push(...v),a.push(...T)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(y=>{const{updated:v,added:T}=y.restore({},i);l.push(...v),a.push(...T)}),this.parent.type===p.DataType){const y=this.parent;Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this)}if(this.parent.type===p.DataType){const y=this.parent;this.parentRelationType===mr.AndDataTypeGroup?Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this):this.parentRelationType===mr.OrDataTypeGroup&&Array.isArray(y.orChildrenGroup)&&y.orChildrenGroup.push(this)}else{const y=this.parent;y.setDataType(this,i),l.push(y)}return i==null||i.attemptAutoclose(P.RestoreEntity,this.id),{added:g(a),updated:g(l),removed:g(f),affected:g(e),self:this}}toFlat(i=new Set){var l,f,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlat(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(y=>y.toFlat(i)))||[],...((e=this.entity)==null?void 0:e.toFlat(i))||[]])}toFlatIds(i=new Set){var l,f,e;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatIds(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(y=>y.toFlatIds(i)))||[],...((e=this.entity)==null?void 0:e.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,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 a,l,f,e;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,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((a=this.andChildrenGroup)==null?void 0:a.map(y=>y.toJSON(i)))||null,orChildrenGroup:((l=this.orChildrenGroup)==null?void 0:l.map(y=>y.toJSON(i)))||null,entity:((f=this.entity)==null?void 0:f.parent)===this?this.entity.toJSON(i):((e=this.entity)==null?void 0:e.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=Ke){var l,f,e,y,v,T,A,b,O;let a;return(l=i.seenEntityMaps)!=null&&l.has(this.id)?a=i.seenEntityMaps.get(this.id):(a=i.newId||or(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(f=i.seenEntities)!=null&&f.has(a)||(e=i.seenEntities)!=null&&e.has(this.id)?this.toReference({seenEntityMaps:i.seenEntityMaps}):((y=i.seenEntities)==null||y.add(a),(v=i.seenEntities)==null||v.add(this.id),{id:a,version:V.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,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((T=this.andChildrenGroup)==null?void 0:T.map(L=>L.toJSONClone({...i,newId:null})))||null,orChildrenGroup:((A=this.orChildrenGroup)==null?void 0:A.map(L=>L.toJSONClone({...i,newId:null})))||null,entity:((b=this.entity)==null?void 0:b.parent)===this?this.entity.toJSONClone({...i,newId:null}):((O=this.entity)==null?void 0:O.toReference({seenEntityMaps:i.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:i.seenEntityMaps})})}toReference(i=Ke){var l;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a+"--"+V.UUID.uuid()+"--ref",type:p.GenericReference,entityId:a,version:this.version,entityType:this.type}}toShallowJSON(i=Ke){var l,f,e,y;let a=this.id;return(l=i.seenEntityMaps)!=null&&l.has(this.id)&&(a=i.seenEntityMaps.get(this.id)),{id:a,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,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((f=this.andChildrenGroup)==null?void 0:f.map(v=>v.toReference(i)))||null,orChildrenGroup:((e=this.orChildrenGroup)==null?void 0:e.map(v=>v.toReference(i)))||null,entity:((y=this.entity)==null?void 0:y.toReference(i))||null,parent:this.parent.toReference(i)}}toFlatJSON(i=new Set){var l,f,e;return i.has(this.id)?[]:(i.add(this.id),[this.toShallowJSON(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatJSON(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(y=>y.toFlatJSON(i)))||[],...((e=this.entity)==null?void 0:e.toFlatJSON(i))||[]])}toGenerationTarget(){var i;return{id:this.id,type:this.type,options:this.options||void 0,isList:this.isList,like:this.like,parentRelationType:this.parentRelationType||void 0,asType:this.asType,entity:((i=this.entity)==null?void 0:i.id)||null,parent:this.parent.id}}toFlatGenerationTarget(i=new Set){var l,f;return i.has(this.id)?[]:(i.add(this.id),[this.toGenerationTarget(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(e=>e.toFlatGenerationTarget(i)))||[],...this.entity&&this.entity.type==p.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(i)||[]])}clearErrors(){var i,a,l,f;return this.errors=[],(i=this.andChildrenGroup)==null||i.forEach(e=>e.clearErrors()),(a=this.orChildrenGroup)==null||a.forEach(e=>e.clearErrors()),this.inferred&&this.entity&&this.entity.type===p.DefinitionEntity&&((l=this.entity)==null?void 0:l.parent)===this&&((f=this.entity)==null||f.clearErrors()),this}validate(){const i=uK(this);return this.errors=i,{success:!0}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.CloneEntity)),a=null,l=null,f=!0){var L,M,k;let e=lr(a,this),y=a||this.parent;const T={id:l||V.UUID.uuid(),version:V.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:p.DataType,isList:this.isList,asType:this.asType,options:this.options,index:this.index,parentRelationType:this.parentRelationType,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:y.toReference()},A=Ti(T,e);a&&A.setParent(a,null),f&&A.subscribe(),A.initChildren(i),i==null||i.add(A,K.Added);const b=(L=this.andChildrenGroup)==null?void 0:L.map(q=>q.clone(i,A,V.UUID.uuid(),f)),O=(M=this.orChildrenGroup)==null?void 0:M.map(q=>q.clone(i,A,V.UUID.uuid(),f));if(A.andChildrenGroup=b||null,A.orChildrenGroup=O||null,this.entity&&this.entity.type===p.DefinitionEntity&&((k=this.entity)==null?void 0:k.parent)===this){const q=this.entity.clone(i,A,V.UUID.uuid(),f);A.setEntity(q,i)}else this.entity&&A.setEntity(this.entity,i);return i==null||i.attemptAutoclose(P.CloneEntity,this.id),A}merge(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"merge-entity"))){const l=[],f=[],e=[],y=[];if(this.asType!==(i==null?void 0:i.asType)&&(this.metaSync({asType:i==null?void 0:i.asType},a),a==null||a.add(this,K.Updated),l.push(this)),this.index!==(i==null?void 0:i.index)&&(this.metaSync({index:i==null?void 0:i.index},a),a==null||a.add(this,K.Updated),l.push(this)),this.isList!==(i==null?void 0:i.isList)&&(this.metaSync({isList:i==null?void 0:i.isList},a),a==null||a.add(this,K.Updated),l.push(this)),this.like!==(i==null?void 0:i.like)&&(this.metaSync({like:i==null?void 0:i.like},a),a==null||a.add(this,K.Updated),l.push(this)),i!=null&&i.inferred){if(i.entity&&i.entity.type===p.DefinitionEntity&&i.entity.parent===i){const v=i.entity.clone(a,this,V.UUID.uuid(),!0);this.setEntity(v,a),f.push(v)}else i.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,K.Updated),l.push(this));this.inferred||(this.metaSync({inferred:!0},a),a==null||a.add(this,K.Updated),l.push(this))}else if(this.inferred){if(this.metaSync({inferred:!1},a),a==null||a.add(this,K.Updated),l.push(this),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:v,removed:T}=this.entity.remove({ignoreUpstream:!0},a);e.push(...T),v.push(...v)}i.entity!==this.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,K.Updated),l.push(this))}else i.entity!==this.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,K.Updated),l.push(this));return a==null||a.attemptAutoclose("merge-entity",this.id),{updated:g(l),added:g(f),removed:g(e),affected:g(y),self:this}}addToAndGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.AddToAndGroup))){return this.checkCanEdit(this)?(this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(i)||(this.andChildrenGroup.push(i),a==null||a.add(i,K.Affected)),a==null||a.attemptAutoclose(P.AddToAndGroup,this.id),this):(H.warn(`[addToAndGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.AddToAndGroup,this.id),this)}addToOrGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,P.AddToOrGroup))){return this.checkCanEdit(this)?(this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(i)||(this.orChildrenGroup.push(i),a==null||a.add(i,K.Affected)),a==null||a.attemptAutoclose(P.AddToOrGroup,this.id),this):(H.warn(`[addToOrGroup] User is not allowed to edit this ${this.type} entity with id: ${this.id}`),a==null||a.attemptAutoclose(P.AddToOrGroup,this.id),this)}setEntity(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"set-data-type-entity-value"))){var f;const l=this.entity;return(l==null?void 0:l.id)!==(i==null?void 0:i.id)&&(this.entity=i,a==null||a.add(this,K.Affected),l&&l.type===p.DefinitionEntity&&((f=l.parent)==null?void 0:f.id)===this.id&&(l==null||l.remove({ignoreUpstream:!0},a))),a==null||a.attemptAutoclose("set-data-type-entity-value",this.id),this}isObject(){return!!this.entity&&(this.entity.type===p.DefinitionEntity||this.entity.type===p.BuiltInBaseEntity||this.entity.name===ie.KeyValue)&&!this.isList}canBeObject(){var a;let i=!1;if(this.parent.type!==p.DataType&&this.parent.type!==p.ActionDescriptor&&this.parent.type!==p.BuiltInBaseEntity&&this.parent.type!==p.DefinitionEntity){const l=(a=this.project.requestActiveDynamicValue(this.parent))==null?void 0:a.value;l?!l.valueAsType&&(l.value===""||l.value===null||Pi(l))&&(i=!0):i=!0}return(this.isObject()||!this.entity||this.entity.name===ie.Untyped)&&i}hasStrictObjectStructure(){var i;return this.isObject()&&((i=this.entity)==null?void 0:i.type)===p.DefinitionEntity}isInlineDeclaredEntity(){var i,a;return((i=this.entity)==null?void 0:i.type)===p.DefinitionEntity&&((a=this.entity.parent)==null?void 0:a.id)===(this==null?void 0:this.id)}isIndependentlyUserDeclaredEntity(){var i,a;return((i=this.entity)==null?void 0:i.type)===p.DefinitionEntity&&((a=this.entity)==null?void 0:a.parent)!==this}canModifyObjectStructure(){var a;const i=this.isIndependentlyUserDeclaredEntity();return(this.isInlineDeclaredEntity()||this.canBeObject()||((a=this.entity)==null?void 0:a.name)===ie.KeyValue)&&!i}inferFromInputs(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,B().toISOString(),this,!0,"infer-data-type-from-inputs"))){var v;const l=[],f=[],e=[],y=[];if(!this.inferred)return a==null||a.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:[],added:[],removed:[],affected:[],self:this};if(!this.entity&&i.length){const T=ee(this.parent,this.project)+" data type definition",A={id:V.UUID.uuid(),deletable:!0,editable:!0,type:p.DefinitionEntity,version:V.UUID.uuid(),createdAt:(a==null?void 0:a.timestamp)||B().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,name:T,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()},b=ae(A,this.project);b.hydrateAncestors(),b.setParent(this,a),b.initChildren(a),a==null||a.add(b,K.Added),b.metaSync(A,a),this.setEntity(b,a),a==null||a.add(this,K.Updated)}if(this.entity){const{updated:T,added:A,removed:b,affected:O}=this.entity.inferFromInputs(i,a);f.push(...T),l.push(...A),e.push(...b),y.push(...O)}return this.like||this.metaSync({like:!0},a),a==null||a.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:g(f),added:g(l),removed:g(e),affected:g(y),self:this}}};_(Ft,"repository",{APICreate:async(i,...a)=>i,APIUpdate:async(i,...a)=>i,APIDelete:async(i,...a)=>i,APIClone:async(i,...a)=>{},APILoad:async(i,...a)=>null,APILoadVersion:async(i,a,...l)=>null}),_(Ft,"type",p.DataType),_(Ft,"USER_MANAGED_PARENT_TYPES",[p.Property,p.ArgumentDeclaration,p.ReturnStatement,p.BreakStatement,p.ContinueStatement,p.VariableDeclaration,p.ValueDescriptor,p.InputMap,p.OutputMap,p.DataType,p.ActionDescriptor,p.Loop,p.Search,p.DefinitionEntity]),_(Ft,"PARENT_TYPES",[...Ft.USER_MANAGED_PARENT_TYPES,p.BuiltInBaseEntity]),_(Ft,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),_(Ft,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","index","author","previousVersion"]),_(Ft,"BASE_PROPERTIES",[...Ft.MUTABLE_BASE_PROPERTIES,...Ft.INMUTABLE_BASE_PROPERTIES]),_(Ft,"MUTABLE_META_PROPERTIES",[...Ft.MUTABLE_BASE_PROPERTIES,"inferred"]),_(Ft,"INMUTABLE_META_PROPERTIES",[...Ft.INMUTABLE_BASE_PROPERTIES]),_(Ft,"META_PROPERTIES",[...Ft.MUTABLE_META_PROPERTIES,...Ft.INMUTABLE_META_PROPERTIES]),_(Ft,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),_(Ft,"INMUTABLE_UPSTREAM_PROPERTIES",[]),_(Ft,"UPSTREAM_PROPERTIES",[...Ft.MUTABLE_UPSTREAM_PROPERTIES,...Ft.INMUTABLE_UPSTREAM_PROPERTIES]),_(Ft,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),_(Ft,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),_(Ft,"DOWNSTREAM_PROPERTIES",[...Ft.MUTABLE_DOWNSTREAM_PROPERTIES,...Ft.INMUTABLE_DOWNSTREAM_PROPERTIES]),_(Ft,"PROPERTIES",[...Ft.META_PROPERTIES,...Ft.UPSTREAM_PROPERTIES,...Ft.DOWNSTREAM_PROPERTIES]);let ln=Ft;function pK(d){var l;const u=vge(d),i=hl(d),a=[...u,...i,...ml(d)];return d.outputs.forEach(f=>f.validate()),(l=d.error)==null||l.validate(),Oi(d.errors,a)}function vge(d){const u=[];return d.inputs.forEach(i=>{i.validate()}),Oi(d.errors,u)}const Tge=Object.freeze(Object.defineProperty({__proto__:null,validate:pK},Symbol.toStringTag,{value:"Module"}));var cK=(d=>(d.Parent="parent",d))(cK||{});const Kt=class Kt extends nr{constructor(i,a){super(i);_(this,"initialData");_(this,"id");_(this,"x");_(this,"y");_(this,"type",p.Operation);_(this,"catchesError",!1);_(this,"declaration");_(this,"writesValues",[]);_(this,"inputs",[]);_(this,"outputs",[]);_(this,"successCalls",[]);_(this,"errorCalls",[]);_(this,"error",null);_(this,"calledBySuccess",[]);_(this,"calledByError",[]);_(this,"calledByEntry",[]);_(this,"parent");_(this,"errors",[]);_(this,"project");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);this.initialData=i,this.project=a,this.id=i.id,this.x=i.x,this.y=i.y,this.catchesError=i.catchesError||!1}static new(i=null){return{id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.Operation,writesValues:[],catchesError:!0,declaration:null,inputs:[],outputs:[],error:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(i,a){let l=a;if(i.parent){const O=Y(i.parent);l=a.get(O)}const f=Y(i.declaration),e=a.get(f),y=i.calledByEntry.map(O=>{const L=Y(O);return a.get(L)}),v=i.calledBySuccess.map(O=>{const L=Y(O);return a.get(L)}),T=i.calledByError.map(O=>{const L=Y(O);return a.get(L)}),A={id:i.id,version:V.UUID.uuid(),createdAt:B().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.Operation,writesValues:[],catchesError:i.catchesError||!1,declaration:e,calledByEntry:y,calledBySuccess:v,calledByError:T,errorCalls:[],successCalls:[],inputs:[],outputs:[],error:null,x:0,y:0,parent:l},b=ae(A,a);return b.setParent(l,null),b}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const f=[],e=Or(l,{parent:{list:!1,types:[...Ki,p.Project],optional:!0}},a);l=e.modifiedData,f.push(...e.errors,...Ji(l));const y=Y(l.declaration);if(y){const v=KW(y,a);f.push(...v)}else{const v=`
|
|
40
40
|
All built-in 'action-descriptor' entity ids are:
|
|
41
41
|
- ${a.operationDeclarations.map(T=>`${T.id} (${ee(T,a)})`).join(`
|
|
42
42
|
- `)}.
|
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.6539",
|
|
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",
|