@elyx-code/project-logic-tree 0.0.6574 → 0.0.6575
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 +9 -18
- package/dist/index.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -50468,7 +50468,7 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
50468
50468
|
)) {
|
|
50469
50469
|
var v;
|
|
50470
50470
|
const l = [], c = [], e = [], y = [];
|
|
50471
|
-
if (
|
|
50471
|
+
if (this.asType !== (i == null ? void 0 : i.asType) && (this.metaSync(
|
|
50472
50472
|
{
|
|
50473
50473
|
asType: i == null ? void 0 : i.asType
|
|
50474
50474
|
},
|
|
@@ -50489,25 +50489,16 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
50489
50489
|
},
|
|
50490
50490
|
a
|
|
50491
50491
|
), a == null || a.add(this, G.Updated), l.push(this)), i.entity && i.entity.type === p.DefinitionEntity && i.entity.parent === i)
|
|
50492
|
-
if (
|
|
50492
|
+
if (((v = this.entity) == null ? void 0 : v.type) === p.DefinitionEntity && this.entity.parent === this)
|
|
50493
50493
|
YU(
|
|
50494
50494
|
this.entity,
|
|
50495
50495
|
i.entity
|
|
50496
|
-
)
|
|
50497
|
-
|
|
50498
|
-
|
|
50499
|
-
|
|
50500
|
-
), console.log("[DataTypeState.merge] Source entity properties:", i.entity.properties.map((T) => T.name)), console.log(
|
|
50501
|
-
"[DataTypeState.merge] Before - Current entity properties:",
|
|
50502
|
-
this.entity.properties.map((T) => T.name)
|
|
50503
|
-
)), xVt(this.entity, i.entity, a), i.parent.id === "6ce33f1f-81fa-469e-8454-87f6c5ac0532" && console.log(
|
|
50504
|
-
"[DataTypeState.merge] After - Current entity properties:",
|
|
50505
|
-
this.entity.properties.map((T) => T.name)
|
|
50506
|
-
));
|
|
50507
|
-
else {
|
|
50508
|
-
i.parent.id === "6ce33f1f-81fa-469e-8454-87f6c5ac0532" && console.log(
|
|
50509
|
-
"[DataTypeState.merge] Current entity does not belong to data type. Cloning new entity."
|
|
50496
|
+
) || xVt(
|
|
50497
|
+
this.entity,
|
|
50498
|
+
i.entity,
|
|
50499
|
+
a
|
|
50510
50500
|
);
|
|
50501
|
+
else {
|
|
50511
50502
|
const T = i.entity.clone(
|
|
50512
50503
|
a,
|
|
50513
50504
|
this,
|
|
@@ -107109,13 +107100,13 @@ function xVt(d, u, i = null) {
|
|
|
107109
107100
|
);
|
|
107110
107101
|
}
|
|
107111
107102
|
), a.length > 0)
|
|
107112
|
-
throw
|
|
107103
|
+
throw new Error(
|
|
107113
107104
|
`Unprocessed target entity properties remain after merging: ${a.map(
|
|
107114
107105
|
(y) => y.id
|
|
107115
107106
|
)}`
|
|
107116
107107
|
);
|
|
107117
107108
|
if (l.length > 0)
|
|
107118
|
-
throw
|
|
107109
|
+
throw new Error(
|
|
107119
107110
|
`Unprocessed source entity properties remain after merging: ${l.map(
|
|
107120
107111
|
(y) => y.id
|
|
107121
107112
|
)}`
|
package/dist/index.umd.cjs
CHANGED
|
@@ -23,7 +23,7 @@ ${To}`}))}}}const y=l.parent&&a.get(l.parent)||a.getBuiltIn(l.parent),v=y?wo(y):
|
|
|
23
23
|
The entitities of type '${yt(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;c.push(new de({id:`${i.id}--${H.NewEntityWouldOverriteExisting}`,code:H.NewEntityWouldOverriteExisting,severity:ee.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}'.
|
|
24
24
|
The entitities of type '${yt(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:
|
|
25
25
|
${_a({describe_entity:O})}
|
|
26
|
-
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===Tr.AndDataTypeGroup||l.parentRelationType===Tr.OrDataTypeGroup))&&c.push(new de({id:`${i.id}--${H.InvalidParentRelationType}`,code:H.InvalidParentRelationType,severity:ee.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 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)||wo(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,M().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),c.push(...v.removed),e.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,a,l){const c=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(i,l),{updated:C(c),added:C(e),removed:C(y),affected:C(v),self:this}}onDetachedDependencyRestored(i,a,l){const c=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(null,l),{updated:C(c),added:C(e),removed:C(y),affected:C(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&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=V.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ht(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=[],c=[],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),c.push(...y.removed)}return{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}async restoreVersion(i){var v;const a=[],l=[],c=[],e=[];if(this.version===i)return{updated:C(a),added:C(l),removed:C(c),affected:C(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 Ht(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:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.UpdateWithShallowTransfer))){var l,c;if(!this.checkCanEdit(this,a))return Y.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=te(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=te(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=te(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=>te(T)===e.id))||(this.removeChildGroup(e,a),e.removeFromParent(a))}),(c=i.orChildrenGroup)==null||c.forEach(e=>{const y=te(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=>te(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=[],c=[];if(this.initialData.parent){const e=te(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=te(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:C(i),added:C(a),removed:C(l),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.AfterAllChildrenInitialized))){var y,v,T;if(!this.checkCanEdit(this,i))return Y.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=[],c=[],e=[];if(this.initialized=!0,((y=this.parent)==null?void 0:y.type)===p.DataType){let A=this.index||0;const b=(this.parentRelationType===Tr.AndDataTypeGroup?this.parent.andChildrenGroup||[]:this.parent.orChildrenGroup||[]).filter(L=>!L.deleted&&L.id!==this.id);b.length&&(A>b.length+1?A=b.length:A<0&&(A=0)),b.find(L=>(L.index||0)===A&&!L.deleted)&&b.filter(L=>(L.index||0)>=A&&!L.deleted).forEach(L=>{L.metaSync({index:(L.index||0)+1},i),i==null||i.add(L,k.Updated),a.push(L)}),this.metaSync({index:A},i)}return(v=this.andChildrenGroup)!=null&&v.length&&this.andChildrenGroup.sort((A,b)=>(A.index||0)-(b.index||0)),(T=this.orChildrenGroup)!=null&&T.length&&this.orChildrenGroup.sort((A,b)=>(A.index||0)-(b.index||0)),this.captureVersion(),i==null||i.attemptAutoclose(P.AfterAllChildrenInitialized,this.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],c=[],e=[];return this.parent.type===p.DataType?(this.parentRelationType===Tr.AndDataTypeGroup?this.parent.addToAndGroup(this,i):this.parentRelationType===Tr.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:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().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,M().toISOString(),this,!0,P.RemoveChildGroup))){if(!this.checkCanEdit(this,a))return Y.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(c=>c.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(c=>c.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,M().toISOString(),this,!0,"init-children"))){var a,l,c,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=re(this.initialData.entity,this.project),(((l=(a=this.initialData.entity)==null?void 0:a.parent)==null?void 0:l.id)===this.id||((e=(c=this.initialData.entity)==null?void 0:c.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=re(b,this.project);return O.setParent(this,null),O.initChildren(i),O})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(b=>{const O=re(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,M().toISOString(),this,!0,"meta-sync"))){const l=sr(this,i,a),c=nr(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,a),l.deleted===!0&&!e.deleted?a==null||a.add(this,k.Removed):l.deleted===!1&&e.deleted?a==null||a.add(this,k.Added):c&&(a==null||a.add(this,k.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=we,...a){return await Ht.repository.APILoad(this.id,...a),this}async APICreate(i=we,...a){return await Ht.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=we,...a){return await Ht.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=we,...a){return await Ht.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=we,...a){return await Ht.repository.APIClone(this.id,...a),this}async APILoadVersion(i=we,a,...l){return await Ht.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.RemoveFromParent))){var y,v;if(!this.checkCanEdit(this,i))return Y.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=[],c=[],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:C(c),updated:C(a),removed:C(l),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.RemoveEntity))){const l=[],c=[],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(c.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),c.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),c.push(...T)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);c.push(...T),l.push(...A)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);c.push(...T),l.push(...A)}),!i){const v=this.removeFromParent(a);e.push(...v.added),l.push(...v.updated),c.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose(P.RemoveEntity,this.id),{added:C(e),updated:C(l),removed:C(c),affected:C(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.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=[],c=[],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),c.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===Tr.AndDataTypeGroup?Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this):this.parentRelationType===Tr.OrDataTypeGroup&&Array.isArray(y.orChildrenGroup)&&y.orChildrenGroup.push(this)}else if(this.parent.type===p.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(P.RestoreEntity,this.id),{added:C(a),updated:C(l),removed:C(c),affected:C(e),self:this}}toFlat(i=new Set){var l,c,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlat(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(y=>y.toFlat(i)))||[],...((e=this.entity)==null?void 0:e.toFlat(i))||[]])}toFlatIds(i=new Set){var l,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatIds(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.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,c,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:((c=this.entity)==null?void 0:c.parent)===this?this.entity.toJSON(i):((e=this.entity)==null?void 0:e.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=He){var l,c,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||hr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(c=i.seenEntities)!=null&&c.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||M().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=He){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=He){var l,c,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:((c=this.andChildrenGroup)==null?void 0:c.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,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;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,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==p.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(i)||[]])}clearErrors(){var i,a,l,c;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&&((c=this.entity)==null||c.clearErrors()),this}validate(){const i=AK(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,M().toISOString(),this,!0,P.CloneEntity)),a=null,l=null,c=!0){var L,B,x;let e=yr(a,this),y=a||this.parent;const T={id:l||V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().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=Ci(T,e);A.hydrateAncestors(),a&&A.setParent(a,null),c&&(A.addSelfToProject(i),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(),c)),O=(B=this.orChildrenGroup)==null?void 0:B.map(q=>q.clone(i,A,V.UUID.uuid(),c));if(A.andChildrenGroup=b||null,A.orChildrenGroup=O||null,this.entity&&this.entity.type===p.DefinitionEntity&&((x=this.entity)==null?void 0:x.parent)===this){const q=this.entity.clone(i,A,V.UUID.uuid(),c);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,M().toISOString(),this,!0,"merge-entity"))){var v;const l=[],c=[],e=[],y=[];if(i.parent.id==="6ce33f1f-81fa-469e-8454-87f6c5ac0532"&&console.log("[DataTypeState.merge] Merging entity"),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.entity&&i.entity.type===p.DefinitionEntity&&i.entity.parent===i)if(i.parent.id==="6ce33f1f-81fa-469e-8454-87f6c5ac0532"&&console.log("[DataTypeState.merge] New source entity belongs to data type."),((v=this.entity)==null?void 0:v.type)===p.DefinitionEntity&&this.entity.parent===this)fw(this.entity,i.entity)?i.parent.id==="6ce33f1f-81fa-469e-8454-87f6c5ac0532"&&console.log("[DataTypeState.merge] Entities are compatible. Doing nothing"):(i.parent.id==="6ce33f1f-81fa-469e-8454-87f6c5ac0532"&&(console.log("[DataTypeState.merge] Entities are not compatible. Merging them granularly."),console.log("[DataTypeState.merge] Source entity properties:",i.entity.properties.map(T=>T.name)),console.log("[DataTypeState.merge] Before - Current entity properties:",this.entity.properties.map(T=>T.name))),OZ(this.entity,i.entity,a),i.parent.id==="6ce33f1f-81fa-469e-8454-87f6c5ac0532"&&console.log("[DataTypeState.merge] After - Current entity properties:",this.entity.properties.map(T=>T.name)));else{i.parent.id==="6ce33f1f-81fa-469e-8454-87f6c5ac0532"&&console.log("[DataTypeState.merge] Current entity does not belong to data type. Cloning new entity.");const T=i.entity.clone(a,this,V.UUID.uuid(),!0);this.setEntity(T,a),c.push(T)}else i.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,k.Updated),l.push(this));return this.inferred!==(i==null?void 0:i.inferred)&&this.metaSync({inferred:i.inferred},a),a==null||a.attemptAutoclose("merge-entity",this.id),{updated:C(l),added:C(c),removed:C(e),affected:C(y),self:this}}addToAndGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.AddToAndGroup))){return this.checkCanEdit(this,a)?(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):(Y.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,M().toISOString(),this,!0,P.AddToOrGroup))){return this.checkCanEdit(this,a)?(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):(Y.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,M().toISOString(),this,!0,"set-data-type-entity-value"))){var c;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&&((c=l.parent)==null?void 0:c.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&&this.parent.type!==p.FunctionDeclaration){const l=(a=this.project.requestActiveDynamicValue(this.parent))==null?void 0:a.value;l?!l.valueAsType&&(l.value===""||l.value===null||bi(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,M().toISOString(),this,!0,"infer-data-type-from-inputs"))){var v;const l=[],c=[],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=S(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)||M().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=re(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);c.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:C(c),added:C(l),removed:C(e),affected:C(y),self:this}}};_(Ht,"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}),_(Ht,"type",p.DataType),_(Ht,"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.FunctionDeclaration,p.ActionDescriptor,p.Loop,p.Search,p.DefinitionEntity]),_(Ht,"PARENT_TYPES",[...Ht.USER_MANAGED_PARENT_TYPES,p.BuiltInBaseEntity]),_(Ht,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),_(Ht,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","index","author","previousVersion"]),_(Ht,"BASE_PROPERTIES",[...Ht.MUTABLE_BASE_PROPERTIES,...Ht.INMUTABLE_BASE_PROPERTIES]),_(Ht,"MUTABLE_META_PROPERTIES",[...Ht.MUTABLE_BASE_PROPERTIES,"inferred"]),_(Ht,"INMUTABLE_META_PROPERTIES",[...Ht.INMUTABLE_BASE_PROPERTIES]),_(Ht,"META_PROPERTIES",[...Ht.MUTABLE_META_PROPERTIES,...Ht.INMUTABLE_META_PROPERTIES]),_(Ht,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),_(Ht,"INMUTABLE_UPSTREAM_PROPERTIES",[]),_(Ht,"UPSTREAM_PROPERTIES",[...Ht.MUTABLE_UPSTREAM_PROPERTIES,...Ht.INMUTABLE_UPSTREAM_PROPERTIES]),_(Ht,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),_(Ht,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),_(Ht,"DOWNSTREAM_PROPERTIES",[...Ht.MUTABLE_DOWNSTREAM_PROPERTIES,...Ht.INMUTABLE_DOWNSTREAM_PROPERTIES]),_(Ht,"PROPERTIES",[...Ht.META_PROPERTIES,...Ht.UPSTREAM_PROPERTIES,...Ht.DOWNSTREAM_PROPERTIES]);let Zr=Ht;function ZCe(d,u){var L,B,x;const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.SyncInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.SyncInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[],y=(((L=d.implements)==null?void 0:L.inputs)||[]).filter(q=>q.parentRelationType===he.FixedArguments&&!d.inputs.find(Z=>Z.implements.find(W=>W.id===q.id)));d.inputs.sort((q,Z)=>q.index-Z.index);const v=((B=d.implements)==null?void 0:B.id)===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id;let T=!0;if(v){const q=d.parent.properties.find(W=>W.implements.find(J=>J.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id)),Z=(((x=q==null?void 0:q.defaultValue)==null?void 0:x.value)||"").toString().toLowerCase();T=!(Z==="get"||Z==="head"||Z==="options")}y.forEach(q=>{if(q.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.inputs.body.id&&!T)return;d.inputs.forEach(ae=>{ae.index>=q.index&&ae.metaSync({index:ae.index+1},i)});const W=ns.new(i);W.implements=[q.toJSON()],W.index=q.index,W.parent=d.toReference(),W.name=q.name;const J=re(W,d.project);J.hydrateAncestors(),i==null||i.add(J,k.Added),J.setParent(d,i),J.initChildren(i),J.addSelfToProject(i)}),d.inputs.forEach(q=>{const{updated:Z,added:W,removed:J,affected:ae}=q.afterAllChildrenInitialized(i);a.push(...Z),l.push(...W),c.push(...J),e.push(...ae)}),d.inputs.sort((q,Z)=>q.index-Z.index);const{updated:A,added:b,removed:O}=d.removeUnrecognizedInputs(i);return a.push(...A),l.push(...b),c.push(...O),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function WCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.SyncInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.SyncInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];d.inputs.sort((A,b)=>A.index-b.index);const{updated:y,added:v,removed:T}=d.removeUnrecognizedInputs(i);return a.push(...y),l.push(...v),c.push(...T),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function HCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.SyncInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.SyncInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];d.inputs.sort((A,b)=>A.index-b.index);const{updated:y,added:v,removed:T}=d.removeUnrecognizedInputs(i);return a.push(...y),l.push(...v),c.push(...T),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function JCe(d,u){var b;const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];d.inputs.forEach(O=>{var B;if(!(((B=d.implements)==null?void 0:B.inputs)||[]).find(x=>O.implements.find(q=>q.id===x.id))){const x=O.remove({ignoreUpstream:!1},i);c.push(...x.removed),a.push(...x.updated)}}),d.inputs.filter((O,L)=>{const B=d.inputs.findIndex(q=>q.implements.every(Z=>O.implements.includes(Z))&&q.name===O.name&&q!==O);if(B===-1)return!1;const x=d.inputs[B];return M(x==null?void 0:x.createdAt).isSame(M(O.createdAt))?L>B:!!M(x==null?void 0:x.createdAt).isAfter(O.createdAt)}).forEach(O=>{const L=O.remove({ignoreUpstream:!1},i);c.push(...L.removed),a.push(...L.updated)});let v=!0;const T=d.parent.properties.find(O=>O.implements.find(L=>L.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id)),A=(((b=T==null?void 0:T.defaultValue)==null?void 0:b.value)||"").toString().toLowerCase();if(v=!(A==="get"||A==="head"||A==="options"),!v){const O=d.inputs.find(L=>L.implements.find(B=>B.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.inputs.body.id));if(O){const L=O.remove({ignoreUpstream:!1},i);c.push(...L.removed),a.push(...L.updated)}}return i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function zCe(d,u){var i,a,l,c;return d.parent.type!==p.Loop?!1:((a=(i=d.dataType)==null?void 0:i.entity)==null?void 0:a.id)===((c=(l=u==null?void 0:u.dataType)==null?void 0:l.entity)==null?void 0:c.id)}function YCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];return d.inputs.forEach(v=>{var A;if(zCe(d,v))return;if(!(((A=d.implements)==null?void 0:A.inputs)||[]).find(b=>v.implements.find(O=>O.id===b.id))){const b=v.remove({ignoreUpstream:!1},i);c.push(...b.removed),a.push(...b.updated)}}),d.inputs.filter((v,T)=>{const A=d.inputs.findIndex(O=>O.implements.every(L=>v.implements.includes(L))&&O.name===v.name&&O!==v);if(A===-1)return!1;const b=d.inputs[A];return M(b==null?void 0:b.createdAt).isSame(M(v.createdAt))?T>A:!!M(b==null?void 0:b.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);c.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function SCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];return d.inputs.filter((v,T)=>{const A=d.inputs.findIndex(O=>O.implements.every(L=>v.implements.includes(L))&&O.name===v.name&&O!==v);if(A===-1)return!1;const b=d.inputs[A];return M(b==null?void 0:b.createdAt).isSame(M(v.createdAt))?T>A:!!M(b==null?void 0:b.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);c.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function XCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];return d.inputs.filter((v,T)=>{const A=d.inputs.findIndex(O=>O.implements.every(L=>v.implements.includes(L))&&O.name===v.name&&O!==v);if(A===-1)return!1;const b=d.inputs[A];return M(b==null?void 0:b.createdAt).isSame(M(v.createdAt))?T>A:!!M(b==null?void 0:b.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);c.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}var wK=(d=>(d.FunctionDeclarationImplements="function-declaration-implements",d.FunctionDeclarationExtends="function-declaration-extends",d.FunctionDeclarationDataType="function-declaration-data-type",d.FunctionDeclarationDataTypeEntity="function-declaration-data-type-entity",d))(wK||{});const Jt=class Jt extends pr{constructor(i,a){super(i);_(this,"initialData");_(this,"id");_(this,"name");_(this,"codeName",null);_(this,"description",null);_(this,"x");_(this,"y");_(this,"collapsed");_(this,"private");_(this,"index",null);_(this,"type",p.FunctionDeclaration);_(this,"implements",null);_(this,"extends",null);_(this,"dataType",null);_(this,"inputs",[]);_(this,"calls",[]);_(this,"parent");_(this,"detachedChildren",[]);_(this,"errors",[]);_(this,"project");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.description=i.description,this.private=i.private,this.collapsed=i.collapsed,this.x=i.x,this.y=i.y,this.codeName=i.codeName,this.index=i.index}static new(i=null){return{id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.FunctionDeclaration,name:"",dataType:null,codeName:null,description:"",collapsed:!1,private:!1,index:null,implements:null,extends:null,inputs:[],parent:null,calls:[],x:0,y:0}}static fromGenerationTarget(i,a){let l=a;if(i.parent){const T=te(i.parent);l=a.get(T)}let c=null;if(i.implements){const T=te(i.implements);c=a.get(T)}let e=null;if(i.extends){const T=te(i.extends);e=a.get(T)}const y={id:i.id,version:V.UUID.uuid(),createdAt:M().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:p.FunctionDeclaration,dataType:null,index:l.type===p.DefinitionEntity?l.methods.length:null,codeName:i.codeName||null,description:i.description||null,collapsed:!1,private:!1,calls:[],inputs:[],implements:c,extends:e,x:0,y:0,parent:l},v=re(y,a);return v.setParent(l,null),v}static validateGenerationTarget(i,a){var b;let l=JSON.parse(JSON.stringify(i));const c=[],e=xr(l,{parent:{list:!1,types:[p.Project,p.InstalledProject,p.DefinitionEntity,p.Loop],optional:!0},implements:{list:!1,types:[p.ActionDescriptor],optional:!0}},a);l=e.modifiedData;const y=oR(l,a),v=l.parent?a.get(l.parent):null;if(v&&v.type===p.DefinitionEntity){const O=v,B=sn(O).filter(q=>!q.interactive),x=O.methods.find(q=>{var Z;return((Z=q.implements)==null?void 0:Z.id)===l.implements});if(x&&c.push(new de({id:`${l.id}--${oe.MethodOverwritesOtherSiblingWithSameImplementation}`,code:oe.MethodOverwritesOtherSiblingWithSameImplementation,severity:ee.Error,message:`The '${p.FunctionDeclaration}' with id "${l.id}" is trying to implement the '${p.ActionDescriptor}' with id "${l.implements}", but the parent definition-entity already has a ${p.FunctionDeclaration} with id '${x.id}' that implements the same base method.
|
|
26
|
+
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===Tr.AndDataTypeGroup||l.parentRelationType===Tr.OrDataTypeGroup))&&c.push(new de({id:`${i.id}--${H.InvalidParentRelationType}`,code:H.InvalidParentRelationType,severity:ee.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 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)||wo(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,M().toISOString(),this,!0,"sync-dependents"))){const a=[],l=[],c=[],e=[];return Object.values(this.detachedDependents).forEach(y=>{const v=y.entity.afterAllChildrenInitialized(i);a.push(...v.updated),l.push(...v.added),c.push(...v.removed),e.push(...v.affected)}),i==null||i.attemptAutoclose("sync-dependents",this.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}onDetachedDependencyRemoved(i,a,l){const c=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(i,l),{updated:C(c),added:C(e),removed:C(y),affected:C(v),self:this}}onDetachedDependencyRestored(i,a,l){const c=[],e=[],y=[],v=[];return a==="entity"&&this.setEntity(null,l),{updated:C(c),added:C(e),removed:C(y),affected:C(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&&!M(i).isValid())throw new Error(`The shared timestamp '${i}' is not a valid ISO 8601 date string.`);return i&&M(i).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=V.UUID.uuid(),this.createdAt=M(i).toISOString()||M().toISOString(),this)}captureVersion(){var a;const i=((a=this.knownVersions)==null?void 0:a.get(this.version))||new Ht(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=[],c=[],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),c.push(...y.removed)}return{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}async restoreVersion(i){var v;const a=[],l=[],c=[],e=[];if(this.version===i)return{updated:C(a),added:C(l),removed:C(c),affected:C(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 Ht(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:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}updateWithShallowTransfer(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.UpdateWithShallowTransfer))){var l,c;if(!this.checkCanEdit(this,a))return Y.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=te(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=te(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=te(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=>te(T)===e.id))||(this.removeChildGroup(e,a),e.removeFromParent(a))}),(c=i.orChildrenGroup)==null||c.forEach(e=>{const y=te(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=>te(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=[],c=[];if(this.initialData.parent){const e=te(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=te(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:C(i),added:C(a),removed:C(l),affected:C(c),self:this}}afterAllChildrenInitialized(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.AfterAllChildrenInitialized))){var y,v,T;if(!this.checkCanEdit(this,i))return Y.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=[],c=[],e=[];if(this.initialized=!0,((y=this.parent)==null?void 0:y.type)===p.DataType){let A=this.index||0;const b=(this.parentRelationType===Tr.AndDataTypeGroup?this.parent.andChildrenGroup||[]:this.parent.orChildrenGroup||[]).filter(L=>!L.deleted&&L.id!==this.id);b.length&&(A>b.length+1?A=b.length:A<0&&(A=0)),b.find(L=>(L.index||0)===A&&!L.deleted)&&b.filter(L=>(L.index||0)>=A&&!L.deleted).forEach(L=>{L.metaSync({index:(L.index||0)+1},i),i==null||i.add(L,k.Updated),a.push(L)}),this.metaSync({index:A},i)}return(v=this.andChildrenGroup)!=null&&v.length&&this.andChildrenGroup.sort((A,b)=>(A.index||0)-(b.index||0)),(T=this.orChildrenGroup)!=null&&T.length&&this.orChildrenGroup.sort((A,b)=>(A.index||0)-(b.index||0)),this.captureVersion(),i==null||i.attemptAutoclose(P.AfterAllChildrenInitialized,this.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}addSelfToProject(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){const a=[this],l=[],c=[],e=[];return this.parent.type===p.DataType?(this.parentRelationType===Tr.AndDataTypeGroup?this.parent.addToAndGroup(this,i):this.parentRelationType===Tr.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:C(a),added:C(l),removed:C(c),affected:C(e),self:this}}setParent(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().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,M().toISOString(),this,!0,P.RemoveChildGroup))){if(!this.checkCanEdit(this,a))return Y.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(c=>c.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(c=>c.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,M().toISOString(),this,!0,"init-children"))){var a,l,c,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=re(this.initialData.entity,this.project),(((l=(a=this.initialData.entity)==null?void 0:a.parent)==null?void 0:l.id)===this.id||((e=(c=this.initialData.entity)==null?void 0:c.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=re(b,this.project);return O.setParent(this,null),O.initChildren(i),O})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(b=>{const O=re(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,M().toISOString(),this,!0,"meta-sync"))){const l=sr(this,i,a),c=nr(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,a),l.deleted===!0&&!e.deleted?a==null||a.add(this,k.Removed):l.deleted===!1&&e.deleted?a==null||a.add(this,k.Added):c&&(a==null||a.add(this,k.Updated)),a==null||a.attemptAutoclose("meta-sync",this.id),this}async APILoad(i=we,...a){return await Ht.repository.APILoad(this.id,...a),this}async APICreate(i=we,...a){return await Ht.repository.APICreate(this.toShallowJSON(),...a),this}async APIUpdate(i=we,...a){return await Ht.repository.APIUpdate(this.toShallowJSON(),...a),this}async APIDelete(i=we,...a){return await Ht.repository.APIDelete(this.toShallowJSON(),...a),this}async APIClone(i=we,...a){return await Ht.repository.APIClone(this.id,...a),this}async APILoadVersion(i=we,a,...l){return await Ht.repository.APILoadVersion(this.id,a,...l)}removeFromParent(i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.RemoveFromParent))){var y,v;if(!this.checkCanEdit(this,i))return Y.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=[],c=[],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:C(c),updated:C(a),removed:C(l),affected:C(e),self:this}}remove({ignoreUpstream:i}={ignoreUpstream:!1},a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.RemoveEntity))){const l=[],c=[],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(c.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),c.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),c.push(...T)}if(this.andChildrenGroup&&this.andChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);c.push(...T),l.push(...A)}),this.orChildrenGroup&&this.orChildrenGroup.forEach(v=>{const{removed:T,updated:A}=v.remove({ignoreUpstream:!0},a);c.push(...T),l.push(...A)}),!i){const v=this.removeFromParent(a);e.push(...v.added),l.push(...v.updated),c.push(...v.removed),y.push(...v.affected)}return a==null||a.attemptAutoclose(P.RemoveEntity,this.id),{added:C(e),updated:C(l),removed:C(c),affected:C(y),self:this}}restore({}={},i=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.RestoreEntity))){if(!this.checkCanEdit(this,i))return Y.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=[],c=[],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),c.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===Tr.AndDataTypeGroup?Array.isArray(y.andChildrenGroup)&&y.andChildrenGroup.push(this):this.parentRelationType===Tr.OrDataTypeGroup&&Array.isArray(y.orChildrenGroup)&&y.orChildrenGroup.push(this)}else if(this.parent.type===p.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(P.RestoreEntity,this.id),{added:C(a),updated:C(l),removed:C(c),affected:C(e),self:this}}toFlat(i=new Set){var l,c,e;return i.has(this.id)?[]:(i.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlat(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.flatMap(y=>y.toFlat(i)))||[],...((e=this.entity)==null?void 0:e.toFlat(i))||[]])}toFlatIds(i=new Set){var l,c,e;return i.has(this.id)?[]:(i.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(y=>y.toFlatIds(i)))||[],...((c=this.orChildrenGroup)==null?void 0:c.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,c,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:((c=this.entity)==null?void 0:c.parent)===this?this.entity.toJSON(i):((e=this.entity)==null?void 0:e.toReference())||null,parent:this.parent.toReference()})}toJSONClone(i=He){var l,c,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||hr(this,this.project,i.uuidStrategy),i.seenEntityMaps&&i.seenEntityMaps.set(this.id,a)),(c=i.seenEntities)!=null&&c.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||M().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=He){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=He){var l,c,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:((c=this.andChildrenGroup)==null?void 0:c.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,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;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,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==p.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(i)||[]])}clearErrors(){var i,a,l,c;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&&((c=this.entity)==null||c.clearErrors()),this}validate(){const i=AK(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,M().toISOString(),this,!0,P.CloneEntity)),a=null,l=null,c=!0){var L,B,x;let e=yr(a,this),y=a||this.parent;const T={id:l||V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().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=Ci(T,e);A.hydrateAncestors(),a&&A.setParent(a,null),c&&(A.addSelfToProject(i),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(),c)),O=(B=this.orChildrenGroup)==null?void 0:B.map(q=>q.clone(i,A,V.UUID.uuid(),c));if(A.andChildrenGroup=b||null,A.orChildrenGroup=O||null,this.entity&&this.entity.type===p.DefinitionEntity&&((x=this.entity)==null?void 0:x.parent)===this){const q=this.entity.clone(i,A,V.UUID.uuid(),c);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,M().toISOString(),this,!0,"merge-entity"))){var v;const l=[],c=[],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.entity&&i.entity.type===p.DefinitionEntity&&i.entity.parent===i)if(((v=this.entity)==null?void 0:v.type)===p.DefinitionEntity&&this.entity.parent===this)fw(this.entity,i.entity)||OZ(this.entity,i.entity,a);else{const T=i.entity.clone(a,this,V.UUID.uuid(),!0);this.setEntity(T,a),c.push(T)}else i.entity&&(this.setEntity(i.entity,a),a==null||a.add(this,k.Updated),l.push(this));return this.inferred!==(i==null?void 0:i.inferred)&&this.metaSync({inferred:i.inferred},a),a==null||a.attemptAutoclose("merge-entity",this.id),{updated:C(l),added:C(c),removed:C(e),affected:C(y),self:this}}addToAndGroup(i,a=this.project.addChangeSet(new G(this.project,V.sessionAuthor,M().toISOString(),this,!0,P.AddToAndGroup))){return this.checkCanEdit(this,a)?(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):(Y.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,M().toISOString(),this,!0,P.AddToOrGroup))){return this.checkCanEdit(this,a)?(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):(Y.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,M().toISOString(),this,!0,"set-data-type-entity-value"))){var c;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&&((c=l.parent)==null?void 0:c.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&&this.parent.type!==p.FunctionDeclaration){const l=(a=this.project.requestActiveDynamicValue(this.parent))==null?void 0:a.value;l?!l.valueAsType&&(l.value===""||l.value===null||bi(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,M().toISOString(),this,!0,"infer-data-type-from-inputs"))){var v;const l=[],c=[],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=S(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)||M().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=re(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);c.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:C(c),added:C(l),removed:C(e),affected:C(y),self:this}}};_(Ht,"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}),_(Ht,"type",p.DataType),_(Ht,"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.FunctionDeclaration,p.ActionDescriptor,p.Loop,p.Search,p.DefinitionEntity]),_(Ht,"PARENT_TYPES",[...Ht.USER_MANAGED_PARENT_TYPES,p.BuiltInBaseEntity]),_(Ht,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),_(Ht,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","index","author","previousVersion"]),_(Ht,"BASE_PROPERTIES",[...Ht.MUTABLE_BASE_PROPERTIES,...Ht.INMUTABLE_BASE_PROPERTIES]),_(Ht,"MUTABLE_META_PROPERTIES",[...Ht.MUTABLE_BASE_PROPERTIES,"inferred"]),_(Ht,"INMUTABLE_META_PROPERTIES",[...Ht.INMUTABLE_BASE_PROPERTIES]),_(Ht,"META_PROPERTIES",[...Ht.MUTABLE_META_PROPERTIES,...Ht.INMUTABLE_META_PROPERTIES]),_(Ht,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),_(Ht,"INMUTABLE_UPSTREAM_PROPERTIES",[]),_(Ht,"UPSTREAM_PROPERTIES",[...Ht.MUTABLE_UPSTREAM_PROPERTIES,...Ht.INMUTABLE_UPSTREAM_PROPERTIES]),_(Ht,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),_(Ht,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),_(Ht,"DOWNSTREAM_PROPERTIES",[...Ht.MUTABLE_DOWNSTREAM_PROPERTIES,...Ht.INMUTABLE_DOWNSTREAM_PROPERTIES]),_(Ht,"PROPERTIES",[...Ht.META_PROPERTIES,...Ht.UPSTREAM_PROPERTIES,...Ht.DOWNSTREAM_PROPERTIES]);let Zr=Ht;function ZCe(d,u){var L,B,x;const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.SyncInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.SyncInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[],y=(((L=d.implements)==null?void 0:L.inputs)||[]).filter(q=>q.parentRelationType===he.FixedArguments&&!d.inputs.find(Z=>Z.implements.find(W=>W.id===q.id)));d.inputs.sort((q,Z)=>q.index-Z.index);const v=((B=d.implements)==null?void 0:B.id)===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.id;let T=!0;if(v){const q=d.parent.properties.find(W=>W.implements.find(J=>J.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id)),Z=(((x=q==null?void 0:q.defaultValue)==null?void 0:x.value)||"").toString().toLowerCase();T=!(Z==="get"||Z==="head"||Z==="options")}y.forEach(q=>{if(q.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.inputs.body.id&&!T)return;d.inputs.forEach(ae=>{ae.index>=q.index&&ae.metaSync({index:ae.index+1},i)});const W=ns.new(i);W.implements=[q.toJSON()],W.index=q.index,W.parent=d.toReference(),W.name=q.name;const J=re(W,d.project);J.hydrateAncestors(),i==null||i.add(J,k.Added),J.setParent(d,i),J.initChildren(i),J.addSelfToProject(i)}),d.inputs.forEach(q=>{const{updated:Z,added:W,removed:J,affected:ae}=q.afterAllChildrenInitialized(i);a.push(...Z),l.push(...W),c.push(...J),e.push(...ae)}),d.inputs.sort((q,Z)=>q.index-Z.index);const{updated:A,added:b,removed:O}=d.removeUnrecognizedInputs(i);return a.push(...A),l.push(...b),c.push(...O),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function WCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.SyncInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.SyncInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];d.inputs.sort((A,b)=>A.index-b.index);const{updated:y,added:v,removed:T}=d.removeUnrecognizedInputs(i);return a.push(...y),l.push(...v),c.push(...T),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function HCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.SyncInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.SyncInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];d.inputs.sort((A,b)=>A.index-b.index);const{updated:y,added:v,removed:T}=d.removeUnrecognizedInputs(i);return a.push(...y),l.push(...v),c.push(...T),i==null||i.attemptAutoclose(P.SyncInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function JCe(d,u){var b;const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];d.inputs.forEach(O=>{var B;if(!(((B=d.implements)==null?void 0:B.inputs)||[]).find(x=>O.implements.find(q=>q.id===x.id))){const x=O.remove({ignoreUpstream:!1},i);c.push(...x.removed),a.push(...x.updated)}}),d.inputs.filter((O,L)=>{const B=d.inputs.findIndex(q=>q.implements.every(Z=>O.implements.includes(Z))&&q.name===O.name&&q!==O);if(B===-1)return!1;const x=d.inputs[B];return M(x==null?void 0:x.createdAt).isSame(M(O.createdAt))?L>B:!!M(x==null?void 0:x.createdAt).isAfter(O.createdAt)}).forEach(O=>{const L=O.remove({ignoreUpstream:!1},i);c.push(...L.removed),a.push(...L.updated)});let v=!0;const T=d.parent.properties.find(O=>O.implements.find(L=>L.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.properties.method.id)),A=(((b=T==null?void 0:T.defaultValue)==null?void 0:b.value)||"").toString().toLowerCase();if(v=!(A==="get"||A==="head"||A==="options"),!v){const O=d.inputs.find(L=>L.implements.find(B=>B.id===pe["built-in-base-entity"].BUILT_IN_HTTP_ENDPOINT_ENTITY.methods.handler.inputs.body.id));if(O){const L=O.remove({ignoreUpstream:!1},i);c.push(...L.removed),a.push(...L.updated)}}return i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function zCe(d,u){var i,a,l,c;return d.parent.type!==p.Loop?!1:((a=(i=d.dataType)==null?void 0:i.entity)==null?void 0:a.id)===((c=(l=u==null?void 0:u.dataType)==null?void 0:l.entity)==null?void 0:c.id)}function YCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];return d.inputs.forEach(v=>{var A;if(zCe(d,v))return;if(!(((A=d.implements)==null?void 0:A.inputs)||[]).find(b=>v.implements.find(O=>O.id===b.id))){const b=v.remove({ignoreUpstream:!1},i);c.push(...b.removed),a.push(...b.updated)}}),d.inputs.filter((v,T)=>{const A=d.inputs.findIndex(O=>O.implements.every(L=>v.implements.includes(L))&&O.name===v.name&&O!==v);if(A===-1)return!1;const b=d.inputs[A];return M(b==null?void 0:b.createdAt).isSame(M(v.createdAt))?T>A:!!M(b==null?void 0:b.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);c.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function SCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];return d.inputs.filter((v,T)=>{const A=d.inputs.findIndex(O=>O.implements.every(L=>v.implements.includes(L))&&O.name===v.name&&O!==v);if(A===-1)return!1;const b=d.inputs[A];return M(b==null?void 0:b.createdAt).isSame(M(v.createdAt))?T>A:!!M(b==null?void 0:b.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);c.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}function XCe(d,u){const i=u===void 0?d.project.addChangeSet(new G(d.project,V.sessionAuthor,M().toISOString(),d,!0,P.RemoveUnrecognizedInputs)):u;if(!d.checkCanEdit(d,i))return Y.warn(`[${P.RemoveUnrecognizedInputs}] User is not allowed to edit this ${d.type} entity with id: ${d.id}`),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:[],added:[],removed:[],affected:[],self:d};const a=[],l=[],c=[],e=[];return d.inputs.filter((v,T)=>{const A=d.inputs.findIndex(O=>O.implements.every(L=>v.implements.includes(L))&&O.name===v.name&&O!==v);if(A===-1)return!1;const b=d.inputs[A];return M(b==null?void 0:b.createdAt).isSame(M(v.createdAt))?T>A:!!M(b==null?void 0:b.createdAt).isAfter(v.createdAt)}).forEach(v=>{const T=v.remove({ignoreUpstream:!1},i);c.push(...T.removed),a.push(...T.updated)}),i==null||i.attemptAutoclose(P.RemoveUnrecognizedInputs,d.id),{updated:C(a),added:C(l),removed:C(c),affected:C(e),self:d}}var wK=(d=>(d.FunctionDeclarationImplements="function-declaration-implements",d.FunctionDeclarationExtends="function-declaration-extends",d.FunctionDeclarationDataType="function-declaration-data-type",d.FunctionDeclarationDataTypeEntity="function-declaration-data-type-entity",d))(wK||{});const Jt=class Jt extends pr{constructor(i,a){super(i);_(this,"initialData");_(this,"id");_(this,"name");_(this,"codeName",null);_(this,"description",null);_(this,"x");_(this,"y");_(this,"collapsed");_(this,"private");_(this,"index",null);_(this,"type",p.FunctionDeclaration);_(this,"implements",null);_(this,"extends",null);_(this,"dataType",null);_(this,"inputs",[]);_(this,"calls",[]);_(this,"parent");_(this,"detachedChildren",[]);_(this,"errors",[]);_(this,"project");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);this.initialData=i,this.project=a,this.id=i.id,this.name=i.name,this.description=i.description,this.private=i.private,this.collapsed=i.collapsed,this.x=i.x,this.y=i.y,this.codeName=i.codeName,this.index=i.index}static new(i=null){return{id:V.UUID.uuid(),version:V.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||M().toISOString(),author:(i==null?void 0:i.author)||V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.FunctionDeclaration,name:"",dataType:null,codeName:null,description:"",collapsed:!1,private:!1,index:null,implements:null,extends:null,inputs:[],parent:null,calls:[],x:0,y:0}}static fromGenerationTarget(i,a){let l=a;if(i.parent){const T=te(i.parent);l=a.get(T)}let c=null;if(i.implements){const T=te(i.implements);c=a.get(T)}let e=null;if(i.extends){const T=te(i.extends);e=a.get(T)}const y={id:i.id,version:V.UUID.uuid(),createdAt:M().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:p.FunctionDeclaration,dataType:null,index:l.type===p.DefinitionEntity?l.methods.length:null,codeName:i.codeName||null,description:i.description||null,collapsed:!1,private:!1,calls:[],inputs:[],implements:c,extends:e,x:0,y:0,parent:l},v=re(y,a);return v.setParent(l,null),v}static validateGenerationTarget(i,a){var b;let l=JSON.parse(JSON.stringify(i));const c=[],e=xr(l,{parent:{list:!1,types:[p.Project,p.InstalledProject,p.DefinitionEntity,p.Loop],optional:!0},implements:{list:!1,types:[p.ActionDescriptor],optional:!0}},a);l=e.modifiedData;const y=oR(l,a),v=l.parent?a.get(l.parent):null;if(v&&v.type===p.DefinitionEntity){const O=v,B=sn(O).filter(q=>!q.interactive),x=O.methods.find(q=>{var Z;return((Z=q.implements)==null?void 0:Z.id)===l.implements});if(x&&c.push(new de({id:`${l.id}--${oe.MethodOverwritesOtherSiblingWithSameImplementation}`,code:oe.MethodOverwritesOtherSiblingWithSameImplementation,severity:ee.Error,message:`The '${p.FunctionDeclaration}' with id "${l.id}" is trying to implement the '${p.ActionDescriptor}' with id "${l.implements}", but the parent definition-entity already has a ${p.FunctionDeclaration} with id '${x.id}' that implements the same base method.
|
|
27
27
|
A ${p.FunctionDeclaration} that has a parent of type '${p.DefinitionEntity}' is considered a method of that entity, and cannot implement the same '${p.ActionDescriptor}' more than once.
|
|
28
28
|
${p.ActionDescriptor} entities inside a ${p.DefinitionEntity} are considered abstract methods that can be implemented by ${p.FunctionDeclaration} entities inside the same parent.
|
|
29
29
|
If you want to modify the existing implementation, you can update the existing method instead, but it will have to match the same base ${p.ActionDescriptor} signature, otherwise the implementation will have a validation error.`})),!l.implements&&B.length){let q=B.length>1?`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${O.id}' because it extends or implements multiple '${p.BuiltInBaseEntity}' entities that are non-interactive ("${yt(B.map(Z=>S(Z,Z.project)),'", "','" and "')}").`:`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${O.id}' because it extends or implements a '${p.BuiltInBaseEntity}' entity that is non-interactive ("${S(B[0],B[0].project)}").`;q+=`
|
|
@@ -105,7 +105,7 @@ This variable's data-type 'entity' is a ${a.type} which doesn't have any methods
|
|
|
105
105
|
Built-in entity types can't have methods attached to them by the user. They are predefined entities that can't be modified. You can reference them as the 'declaration' property on a new 'internal-call' entity in a variable`):a.type===p.DefinitionEntity?e=`
|
|
106
106
|
This variable's data-type 'entity' is a definition entity which extends or implements a non-interactive 'built-in-base-entity'.s`:a.type===p.BuiltInBaseEntity&&(e=`
|
|
107
107
|
This variable's data-type 'entity' is a non-interactive 'built-in-base-entity'.s`),!d.declaration)u.push(_t({id:`${d.id}--${oe.InternalCallDeclarationNotFound}`,code:oe.InternalCallDeclarationNotFound,severity:ee.Error,message:`Entity of type "${d.type}" with id "${d.id}" doesn't have a declaration method ('${p.FunctionDeclaration}' or '${p.ActionDescriptor}') attached to it.${e}`,entity:d}).error);else{const y=c.find(v=>v.id===d.declaration.id);y?y.type!==p.FunctionDeclaration&&y.type!==p.ActionDescriptor&&u.push(_t({id:`${d.id}--${oe.InternalCallDeclarationIsInvalidType}`,code:oe.InternalCallDeclarationIsInvalidType,severity:ee.Error,message:`Entity of type "${d.type}" with id "${d.id}", points to a 'declaration' that isn't a '${p.FunctionDeclaration}' or '${p.ActionDescriptor}' entity.
|
|
108
|
-
The declaration of the internal-call must be a '${p.FunctionDeclaration}' entity which exists as a method in the entity of the data-type of the parent variable.${e}`,entity:d}).error):u.push(_t({id:`${d.id}--${oe.InternalCallDeclarationNotFoundInParentDatatypeEntity}`,code:oe.InternalCallDeclarationNotFoundInParentDatatypeEntity,severity:ee.Error,message:`Entity of type "${d.type}" with id "${d.id}", belongs to a variable whose data type entity doesn't contain its declaration method ('${p.FunctionDeclaration}' or '${p.ActionDescriptor}') with id "${d.declaration}".${e}`,entity:d}).error)}}return u}const uPe=Object.freeze(Object.defineProperty({__proto__:null,validate:_Z,validateParentRelation:DZ},Symbol.toStringTag,{value:"Module"}));function Qf(d,u){if(d.type!==p.Property||u.type!==p.Property)throw new Error(`Expected property entities for comparison. But got ${d.type} and ${u.type}.`);return d===u||d.id===u.id?!0:d.name!==u.name||d.static!==u.static||d.abstract!==u.abstract?!1:Xr(d.dataType,u.dataType).compatible}function h0(d,u,i=null){var l,c;if(u.type!==p.Property||d.type!==p.Property)throw new Error(`Expected property entities for merging. But got ${u.type} and ${d.type}.`);return u===d||u.id===d.id||(u.name!==d.name&&d.metaSync({name:u.name},i),u.static!==d.static&&d.metaSync({static:u.static},i),u.abstract!==d.abstract&&d.metaSync({abstract:u.abstract},i),Xr(u.dataType,d.dataType).compatible||(d.dataType&&u.dataType?d.dataType.merge(u.dataType,i):!d.dataType&&u.dataType?u.dataType.clone(i,d):d.dataType&&!u.dataType&&d.setDataType(null,i)),((l=d.extends)==null?void 0:l.id)!==((c=u.extends)==null?void 0:c.id)&&d.setExtends(u.extends,i),[...d.implements].forEach(e=>{u.implements.find(v=>e.id===v.id)||d.removeImplementation(e,i)}),u.implements.forEach(e=>{d.implements.find(v=>v.id===e.id)||d.addImplementation(e,i)})),d}function OZ(d,u,i=null){var c,e;if(u.type!==p.DefinitionEntity||d.type!==p.DefinitionEntity)throw new Error(`Expected definition entities for merging. But got ${u.type} and ${d.type}.`);if(u===d||u.id===d.id)return d;u.name!==d.name&&d.metaSync({name:u.name},i),u.abstract!==d.abstract&&d.metaSync({abstract:u.abstract},i),u.static!==d.static&&d.metaSync({static:u.static},i),u.additionalProperties!==d.additionalProperties&&d.metaSync({additionalProperties:u.additionalProperties},i),u.description!==d.description&&d.metaSync({description:u.description},i),u.codeName!==d.codeName&&d.metaSync({codeName:u.codeName},i),((c=u.extends)==null?void 0:c.id)!==((e=d.extends)==null?void 0:e.id)&&d.setExtension(u.extends,i),[...d.implements].forEach(y=>{u.implements.find(T=>y.id===T.id)||d.removeImplementation(y,i)}),u.implements.forEach(y=>{d.implements.find(T=>T.id===y.id)||d.addImplementation(y,i)}),u.additionalPropertiesDataType&&!d.additionalPropertiesDataType?u.additionalPropertiesDataType.clone(i,d):!u.additionalPropertiesDataType&&d.additionalPropertiesDataType?d.removeAdditionalPropertiesDataType(i):u.additionalPropertiesDataType&&d.additionalPropertiesDataType&&d.additionalPropertiesDataType.merge(u.additionalPropertiesDataType,i),u.allPropertiesImplement&&!d.allPropertiesImplement?u.allPropertiesImplement.clone(i,d):!u.allPropertiesImplement&&d.allPropertiesImplement?d.removeAllPropertiesImplement(i):u.allPropertiesImplement&&d.allPropertiesImplement&&h0(d.allPropertiesImplement,u.allPropertiesImplement,i),u.properties.length<d.properties.length&&d.properties.forEach(y=>{u.properties.find(T=>Qf(T,y))||y.remove({ignoreUpstream:!1},i)});let a=[...d.properties],l=[...u.properties];for(let y=0;y<u.properties.length;y++){const v=u.properties[y],T=a.find(A=>Qf(v,A));T&&(a=a.filter(A=>A.id!==T.id),l=l.filter(A=>A.id!==v.id))}if([...l].forEach(y=>{const v=a.find(T=>T.name===y.name);v&&(h0(v,y,i),a=a.filter(T=>T.id!==v.id),l=l.filter(T=>T.id!==y.id))}),[...l].forEach(y=>{const v=a.find(T=>Qf(y,T));v&&(h0(v,y,i),a=a.filter(T=>T.id!==v.id),l=l.filter(T=>T.id!==y.id))}),[...l].forEach(y=>{y.clone(i,d),l=l.filter(v=>v.id!==y.id)}),[...a].forEach(y=>{y.remove({ignoreUpstream:!1},i),a=a.filter(v=>v.id!==y.id)}),a.length>0)throw console.warn("stillUnprocessedOriginalTargetEntityProperties: ",a.map(y=>y.name)),new Error(`Unprocessed target entity properties remain after merging: ${a.map(y=>y.id)}`);if(l.length>0)throw console.warn("stillUnprocessedSourceEntityProperties: ",l.map(y=>y.name)),new Error(`Unprocessed source entity properties remain after merging: ${l.map(y=>y.id)}`);return d}function fw(d,u){if(d.type!==p.DefinitionEntity||u.type!==p.DefinitionEntity)throw new Error(`Expected definition entities for comparison. But got ${d.type} and ${u.type}.`);if(d===u||d.id===u.id)return!0;if(d.properties.length!==u.properties.length)return!1;let i=[...u.properties];const a=[];for(let l=0;l<d.properties.length;l++){const c=d.properties[l];i.find(y=>{const v=Qf(c,y);return v&&(i=i.filter(T=>T.id!==y.id)),v})||a.push(c)}return!(a.length>0)}var Ds=(d=>(d.BothUnconstrained="both-unconstrained",d.AConstraintBUnconstrained="a-constraint-b-unconstrained",d.BConstraintAUnconstrained="b-constraint-a-unconstrained",d.Same="same",d.AIsListBIsNot="a-is-list-b-is-not",d.BIsListAIsNot="b-is-list-a-is-not",d.AIsNullableBIsNot="a-is-nullable-b-is-not",d.BIsNullableAIsNot="b-is-nullable-a-is-not",d.AIsTemplateBIsNot="a-is-template-b-is-not",d.BIsTemplateAIsNot="b-is-template-a-is-not",d.BothUntyped="both-untyped",d.AIsUntypedBIsNot="a-is-untyped-b-is-not",d.BIsUntypedAIsNot="b-is-untyped-a-is-not",d.TypeEntityMismatch="type-entity-mismatch",d.SameDefinitionEntities="same-definition-entities",d.CompatibleDefinitionEntities="compatible-definition-entities",d.IncompatibleDefinitionEntities="incompatible-definition-entities",d.SamePrimitiveEntities="same-primitive-entities",d.IncompatiblePrimitiveEntities="incompatible-primitive-entities",d.SameBuiltInBaseEntities="same-built-in-base-entities",d.IncompatibleBuiltInBaseEntities="incompatible-built-in-base-entities",d.CheckUnknown="check-unknown",d))(Ds||{});function Xr(d,u){var l,c,e,y,v,T,A,b,O,L,B;if(d&&d.type!==p.DataType||u&&u.type!==p.DataType)throw new Error(`Expected data-type entities for comparison. But got ${d==null?void 0:d.type} and ${u==null?void 0:u.type}.`);if(d===null&&u===null)return{compatible:!0,type:"both-unconstrained"};if(d===null)return{compatible:!0,type:"a-constraint-b-unconstrained"};if(u===null)return{compatible:!0,type:"b-constraint-a-unconstrained"};if(d===u)return{compatible:!0,type:"same"};if(d.id===u.id)return{compatible:!0,type:"same"};if(d.isList===!1&&u.isList===!0||d.isList===!0&&u.isList===!1)return{compatible:!1,type:d.isList?"a-is-list-b-is-not":"b-is-list-a-is-not"};if(d.asType===!1&&u.asType===!0||d.asType===!0&&u.asType===!1)return{compatible:!1,type:d.asType?"a-is-template-b-is-not":"b-is-template-a-is-not"};let i=!d.entity||d.entity.type===p.PrimitiveEntity&&d.entity.name===ie.Untyped,a=!u.entity||u.entity.type===p.PrimitiveEntity&&u.entity.name===ie.Untyped;if(i&&!a)return{compatible:!0,type:"a-is-untyped-b-is-not"};if(!i&&a)return{compatible:!0,type:"b-is-untyped-a-is-not"};if(i&&a)return{compatible:!0,type:"both-untyped"};if(((l=d.entity)==null?void 0:l.type)!==((c=u.entity)==null?void 0:c.type))return{compatible:!1,type:"type-entity-mismatch"};if(((e=d.entity)==null?void 0:e.type)===p.DefinitionEntity){if(((y=d.entity)==null?void 0:y.id)===((v=u.entity)==null?void 0:v.id))return{compatible:!0,type:"same-definition-entities"};const x=fw(d.entity,u.entity);return{compatible:x,type:x?"compatible-definition-entities":"incompatible-definition-entities"}}return((T=d.entity)==null?void 0:T.type)===p.PrimitiveEntity?((A=d.entity)==null?void 0:A.id)===((b=u.entity)==null?void 0:b.id)?{compatible:!0,type:"same-primitive-entities"}:{compatible:!1,type:"incompatible-primitive-entities"}:((O=d.entity)==null?void 0:O.type)===p.BuiltInBaseEntity?((L=d.entity)==null?void 0:L.id)===((B=u.entity)==null?void 0:B.id)?{compatible:!0,type:"same-built-in-base-entities"}:{compatible:!1,type:"incompatible-built-in-base-entities"}:{compatible:!1,type:"check-unknown"}}function PZ(d,u=null){return d.dataType?d.dataType:null}function yw(d,u=null){var a;const i=(a=d.declaration)==null?void 0:a.getDataType(u);return i&&i.isResolved?i:d.readsValue?ga(d.readsValue,u):null}function $Z(d,u=null){return ga(d.declaration,u)}function NZ(d,u=null){return d.dataType&&!d.dataType.inferred?d.dataType:(d.dataType&&d.dataType.inferred||!d.dataType)&&d.project.initialized?(d.inferDataTypeAndSyncInstancesInputsAndOutputs(u),d.dataType):null}function hw(d,u=null){var i;return((i=d.declaration)==null?void 0:i.dataType)||null}function VZ(d,u=null){return(d==null?void 0:d.dataType)||null}function LZ(d,u=null){return(d==null?void 0:d.dataType)||null}function BZ(d,u=null){var a;if((!d.dataType||d.dataType.inferred)&&d.project.initialized,d.dataType)return u==null||u.attemptAutoclose("get-data-type",d.id),d.dataType;const i=(a=d.implements)==null?void 0:a.getDataType(u);return u==null||u.attemptAutoclose("get-data-type",d.id),i||null}function MZ(d,u=null){var a;if((!d.dataType||d.dataType.inferred)&&d.project.initialized,d.dataType)return u==null||u.attemptAutoclose("infer-break-statement-data-type",d.id),d.dataType;if(d.parent.dataType)return u==null||u.attemptAutoclose("infer-break-statement-data-type",d.id),d.parent.dataType;const i=(a=d.implements)==null?void 0:a.getDataType(u);return u==null||u.attemptAutoclose("infer-break-statement-data-type",d.id),i||null}function xZ(d,u=null){var a;if((!d.dataType||d.dataType.inferred)&&d.project.initialized,d.dataType)return u==null||u.attemptAutoclose("infer-continue-statement-data-type",d.id),d.dataType;if(d.parent.dataType)return u==null||u.attemptAutoclose("infer-continue-statement-data-type",d.id),d.parent.dataType;const i=(a=d.implements)==null?void 0:a.getDataType(u);return u==null||u.attemptAutoclose("infer-continue-statement-data-type",d.id),i||null}function UZ(d,u=null){return(d==null?void 0:d.dataType)||null}function jZ(d,u=null){var i;return((i=d==null?void 0:d.declaration)==null?void 0:i.getDataType(u))||null}function GZ(d,u=null){var i;return((i=d==null?void 0:d.declaration)==null?void 0:i.getDataType(u))||null}function kZ(d,u=null){return d.getDataType(u)||null}function ga(d,u=null){switch(d.type){case p.VariableDeclaration:return NZ(d,u);case p.ArgumentDeclaration:return PZ(d,u);case p.VariableInstance:return $Z(d,u);case p.InputMap:return yw(d,u);case p.OutputMap:return hw(d,u);case p.Property:return VZ(d,u);case p.ValueDescriptor:return LZ(d,u);case p.ReturnStatement:return BZ(d,u);case p.BreakStatement:return MZ(d,u);case p.ContinueStatement:return xZ(d,u);case p.Search:return UZ(d,u);case p.FunctionCall:return jZ(d,u);case p.InternalCall:return GZ(d,u);case p.Loop:return kZ(d,u);default:throw new Error(`Cannot infer data type from entity of type ${d.type}.`)}}function m0(d,u=null){switch(d.type){case p.ArgumentDeclaration:return d.getDataType(u);case p.InputMap:return d.getDataType(u);case p.VariableDeclaration:return d.getDataType(u);case p.VariableInstance:return d.getDataType(u);case p.OutputMap:return d.getDataType(u);case p.Property:return d.getDataType(u);case p.ValueDescriptor:return d.getDataType(u);case p.ReturnStatement:return d.getDataType(u);case p.BreakStatement:return d.getDataType(u);case p.ContinueStatement:return d.getDataType(u);case p.Search:return d.getDataType(u);case p.FunctionCall:return d.getDataType(u);case p.InternalCall:return d.getDataType(u);case p.Loop:return d.getDataType(u);default:return null}}function Id(d){if(!d)return ie.Untyped;if(d.entity){if(d.entity.type===p.DefinitionEntity)return d.asType?ie.EntityTemplate:ie.Untyped;if(d.entity.type===p.PrimitiveEntity)return d.asType?ie.EntityTemplate:d.entity.name;if(d.entity.type===p.ActionDescriptor)return ie.ActionDescriptor;if(d.entity.type===p.BuiltInBaseEntity)return d.asType?ie.EntityTemplate:ie.Untyped}return ie.Untyped}var FZ=(d=>(d.Declaration="declaration",d))(FZ||{});const ti=class ti extends pr{constructor(i,a){super(i);_(this,"initialData");_(this,"id");_(this,"index");_(this,"type",p.InternalCall);_(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,"project");_(this,"errors",[]);_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);this.initialData=i,this.project=a,this.id=i.id,this.index=i.index,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)||M().toISOString(),author:(i==null?void 0:i.author)||V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.InternalCall,writesValues:[],catchesError:!0,declaration:null,inputs:[],outputs:[],error:null,index:0,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[]}}static fromGenerationTarget(i,a){const l=te(i.parent),c=a.get(l),e=te(i.declaration),y=a.get(e),v=i.calledByEntry.map(L=>{const B=te(L);return a.get(B)}),T=i.calledBySuccess.map(L=>{const B=te(L);return a.get(B)}),A=i.calledByError.map(L=>{const B=te(L);return a.get(B)}),b={id:i.id,version:V.UUID.uuid(),createdAt:M().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.InternalCall,writesValues:[],catchesError:i.catchesError||!1,index:c.internalCalls.length,declaration:y.toReference(),calledByEntry:v,calledBySuccess:T,calledByError:A,errorCalls:[],successCalls:[],inputs:[],outputs:[],error:null,parent:c},O=re(b,a);return O.setParent(c,null),O}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const c=[],e=xr(l,{parent:{list:!1,types:$t}},a);l=e.modifiedData;const y=te(l.parent),v=a.get(y);if(v){const T=m0(v,null),A=T==null?void 0:T.entity;if(!A)c.push(new de({id:`${l.id}--${oe.InternalCallParentMissingDataType}`,code:oe.InternalCallParentMissingDataType,severity:ee.Error,message:`Entity of type "${l.type}" with id "${l.id}", belongs to a variable whose data type entity doesn't contain its declaration method (function-declaration) its id "${l.declaration}".`}));else if(![p.DefinitionEntity,p.BuiltInBaseEntity,p.PrimitiveEntity].includes(A.type))c.push(new de({id:`${l.id}--${oe.InternalCallParentDeclarationEntityInvalidType}`,code:oe.InternalCallParentDeclarationEntityInvalidType,severity:ee.Error,message:`Entity of type "${l.type}" with id "${l.id}", belongs to a variable whose data type 'entity' is not a definition entity, built-in base entity or primitive entity.
|
|
108
|
+
The declaration of the internal-call must be a '${p.FunctionDeclaration}' entity which exists as a method in the entity of the data-type of the parent variable.${e}`,entity:d}).error):u.push(_t({id:`${d.id}--${oe.InternalCallDeclarationNotFoundInParentDatatypeEntity}`,code:oe.InternalCallDeclarationNotFoundInParentDatatypeEntity,severity:ee.Error,message:`Entity of type "${d.type}" with id "${d.id}", belongs to a variable whose data type entity doesn't contain its declaration method ('${p.FunctionDeclaration}' or '${p.ActionDescriptor}') with id "${d.declaration}".${e}`,entity:d}).error)}}return u}const uPe=Object.freeze(Object.defineProperty({__proto__:null,validate:_Z,validateParentRelation:DZ},Symbol.toStringTag,{value:"Module"}));function Qf(d,u){if(d.type!==p.Property||u.type!==p.Property)throw new Error(`Expected property entities for comparison. But got ${d.type} and ${u.type}.`);return d===u||d.id===u.id?!0:d.name!==u.name||d.static!==u.static||d.abstract!==u.abstract?!1:Xr(d.dataType,u.dataType).compatible}function h0(d,u,i=null){var l,c;if(u.type!==p.Property||d.type!==p.Property)throw new Error(`Expected property entities for merging. But got ${u.type} and ${d.type}.`);return u===d||u.id===d.id||(u.name!==d.name&&d.metaSync({name:u.name},i),u.static!==d.static&&d.metaSync({static:u.static},i),u.abstract!==d.abstract&&d.metaSync({abstract:u.abstract},i),Xr(u.dataType,d.dataType).compatible||(d.dataType&&u.dataType?d.dataType.merge(u.dataType,i):!d.dataType&&u.dataType?u.dataType.clone(i,d):d.dataType&&!u.dataType&&d.setDataType(null,i)),((l=d.extends)==null?void 0:l.id)!==((c=u.extends)==null?void 0:c.id)&&d.setExtends(u.extends,i),[...d.implements].forEach(e=>{u.implements.find(v=>e.id===v.id)||d.removeImplementation(e,i)}),u.implements.forEach(e=>{d.implements.find(v=>v.id===e.id)||d.addImplementation(e,i)})),d}function OZ(d,u,i=null){var c,e;if(u.type!==p.DefinitionEntity||d.type!==p.DefinitionEntity)throw new Error(`Expected definition entities for merging. But got ${u.type} and ${d.type}.`);if(u===d||u.id===d.id)return d;u.name!==d.name&&d.metaSync({name:u.name},i),u.abstract!==d.abstract&&d.metaSync({abstract:u.abstract},i),u.static!==d.static&&d.metaSync({static:u.static},i),u.additionalProperties!==d.additionalProperties&&d.metaSync({additionalProperties:u.additionalProperties},i),u.description!==d.description&&d.metaSync({description:u.description},i),u.codeName!==d.codeName&&d.metaSync({codeName:u.codeName},i),((c=u.extends)==null?void 0:c.id)!==((e=d.extends)==null?void 0:e.id)&&d.setExtension(u.extends,i),[...d.implements].forEach(y=>{u.implements.find(T=>y.id===T.id)||d.removeImplementation(y,i)}),u.implements.forEach(y=>{d.implements.find(T=>T.id===y.id)||d.addImplementation(y,i)}),u.additionalPropertiesDataType&&!d.additionalPropertiesDataType?u.additionalPropertiesDataType.clone(i,d):!u.additionalPropertiesDataType&&d.additionalPropertiesDataType?d.removeAdditionalPropertiesDataType(i):u.additionalPropertiesDataType&&d.additionalPropertiesDataType&&d.additionalPropertiesDataType.merge(u.additionalPropertiesDataType,i),u.allPropertiesImplement&&!d.allPropertiesImplement?u.allPropertiesImplement.clone(i,d):!u.allPropertiesImplement&&d.allPropertiesImplement?d.removeAllPropertiesImplement(i):u.allPropertiesImplement&&d.allPropertiesImplement&&h0(d.allPropertiesImplement,u.allPropertiesImplement,i),u.properties.length<d.properties.length&&d.properties.forEach(y=>{u.properties.find(T=>Qf(T,y))||y.remove({ignoreUpstream:!1},i)});let a=[...d.properties],l=[...u.properties];for(let y=0;y<u.properties.length;y++){const v=u.properties[y],T=a.find(A=>Qf(v,A));T&&(a=a.filter(A=>A.id!==T.id),l=l.filter(A=>A.id!==v.id))}if([...l].forEach(y=>{const v=a.find(T=>T.name===y.name);v&&(h0(v,y,i),a=a.filter(T=>T.id!==v.id),l=l.filter(T=>T.id!==y.id))}),[...l].forEach(y=>{const v=a.find(T=>Qf(y,T));v&&(h0(v,y,i),a=a.filter(T=>T.id!==v.id),l=l.filter(T=>T.id!==y.id))}),[...l].forEach(y=>{y.clone(i,d),l=l.filter(v=>v.id!==y.id)}),[...a].forEach(y=>{y.remove({ignoreUpstream:!1},i),a=a.filter(v=>v.id!==y.id)}),a.length>0)throw new Error(`Unprocessed target entity properties remain after merging: ${a.map(y=>y.id)}`);if(l.length>0)throw new Error(`Unprocessed source entity properties remain after merging: ${l.map(y=>y.id)}`);return d}function fw(d,u){if(d.type!==p.DefinitionEntity||u.type!==p.DefinitionEntity)throw new Error(`Expected definition entities for comparison. But got ${d.type} and ${u.type}.`);if(d===u||d.id===u.id)return!0;if(d.properties.length!==u.properties.length)return!1;let i=[...u.properties];const a=[];for(let l=0;l<d.properties.length;l++){const c=d.properties[l];i.find(y=>{const v=Qf(c,y);return v&&(i=i.filter(T=>T.id!==y.id)),v})||a.push(c)}return!(a.length>0)}var Ds=(d=>(d.BothUnconstrained="both-unconstrained",d.AConstraintBUnconstrained="a-constraint-b-unconstrained",d.BConstraintAUnconstrained="b-constraint-a-unconstrained",d.Same="same",d.AIsListBIsNot="a-is-list-b-is-not",d.BIsListAIsNot="b-is-list-a-is-not",d.AIsNullableBIsNot="a-is-nullable-b-is-not",d.BIsNullableAIsNot="b-is-nullable-a-is-not",d.AIsTemplateBIsNot="a-is-template-b-is-not",d.BIsTemplateAIsNot="b-is-template-a-is-not",d.BothUntyped="both-untyped",d.AIsUntypedBIsNot="a-is-untyped-b-is-not",d.BIsUntypedAIsNot="b-is-untyped-a-is-not",d.TypeEntityMismatch="type-entity-mismatch",d.SameDefinitionEntities="same-definition-entities",d.CompatibleDefinitionEntities="compatible-definition-entities",d.IncompatibleDefinitionEntities="incompatible-definition-entities",d.SamePrimitiveEntities="same-primitive-entities",d.IncompatiblePrimitiveEntities="incompatible-primitive-entities",d.SameBuiltInBaseEntities="same-built-in-base-entities",d.IncompatibleBuiltInBaseEntities="incompatible-built-in-base-entities",d.CheckUnknown="check-unknown",d))(Ds||{});function Xr(d,u){var l,c,e,y,v,T,A,b,O,L,B;if(d&&d.type!==p.DataType||u&&u.type!==p.DataType)throw new Error(`Expected data-type entities for comparison. But got ${d==null?void 0:d.type} and ${u==null?void 0:u.type}.`);if(d===null&&u===null)return{compatible:!0,type:"both-unconstrained"};if(d===null)return{compatible:!0,type:"a-constraint-b-unconstrained"};if(u===null)return{compatible:!0,type:"b-constraint-a-unconstrained"};if(d===u)return{compatible:!0,type:"same"};if(d.id===u.id)return{compatible:!0,type:"same"};if(d.isList===!1&&u.isList===!0||d.isList===!0&&u.isList===!1)return{compatible:!1,type:d.isList?"a-is-list-b-is-not":"b-is-list-a-is-not"};if(d.asType===!1&&u.asType===!0||d.asType===!0&&u.asType===!1)return{compatible:!1,type:d.asType?"a-is-template-b-is-not":"b-is-template-a-is-not"};let i=!d.entity||d.entity.type===p.PrimitiveEntity&&d.entity.name===ie.Untyped,a=!u.entity||u.entity.type===p.PrimitiveEntity&&u.entity.name===ie.Untyped;if(i&&!a)return{compatible:!0,type:"a-is-untyped-b-is-not"};if(!i&&a)return{compatible:!0,type:"b-is-untyped-a-is-not"};if(i&&a)return{compatible:!0,type:"both-untyped"};if(((l=d.entity)==null?void 0:l.type)!==((c=u.entity)==null?void 0:c.type))return{compatible:!1,type:"type-entity-mismatch"};if(((e=d.entity)==null?void 0:e.type)===p.DefinitionEntity){if(((y=d.entity)==null?void 0:y.id)===((v=u.entity)==null?void 0:v.id))return{compatible:!0,type:"same-definition-entities"};const x=fw(d.entity,u.entity);return{compatible:x,type:x?"compatible-definition-entities":"incompatible-definition-entities"}}return((T=d.entity)==null?void 0:T.type)===p.PrimitiveEntity?((A=d.entity)==null?void 0:A.id)===((b=u.entity)==null?void 0:b.id)?{compatible:!0,type:"same-primitive-entities"}:{compatible:!1,type:"incompatible-primitive-entities"}:((O=d.entity)==null?void 0:O.type)===p.BuiltInBaseEntity?((L=d.entity)==null?void 0:L.id)===((B=u.entity)==null?void 0:B.id)?{compatible:!0,type:"same-built-in-base-entities"}:{compatible:!1,type:"incompatible-built-in-base-entities"}:{compatible:!1,type:"check-unknown"}}function PZ(d,u=null){return d.dataType?d.dataType:null}function yw(d,u=null){var a;const i=(a=d.declaration)==null?void 0:a.getDataType(u);return i&&i.isResolved?i:d.readsValue?ga(d.readsValue,u):null}function $Z(d,u=null){return ga(d.declaration,u)}function NZ(d,u=null){return d.dataType&&!d.dataType.inferred?d.dataType:(d.dataType&&d.dataType.inferred||!d.dataType)&&d.project.initialized?(d.inferDataTypeAndSyncInstancesInputsAndOutputs(u),d.dataType):null}function hw(d,u=null){var i;return((i=d.declaration)==null?void 0:i.dataType)||null}function VZ(d,u=null){return(d==null?void 0:d.dataType)||null}function LZ(d,u=null){return(d==null?void 0:d.dataType)||null}function BZ(d,u=null){var a;if((!d.dataType||d.dataType.inferred)&&d.project.initialized,d.dataType)return u==null||u.attemptAutoclose("get-data-type",d.id),d.dataType;const i=(a=d.implements)==null?void 0:a.getDataType(u);return u==null||u.attemptAutoclose("get-data-type",d.id),i||null}function MZ(d,u=null){var a;if((!d.dataType||d.dataType.inferred)&&d.project.initialized,d.dataType)return u==null||u.attemptAutoclose("infer-break-statement-data-type",d.id),d.dataType;if(d.parent.dataType)return u==null||u.attemptAutoclose("infer-break-statement-data-type",d.id),d.parent.dataType;const i=(a=d.implements)==null?void 0:a.getDataType(u);return u==null||u.attemptAutoclose("infer-break-statement-data-type",d.id),i||null}function xZ(d,u=null){var a;if((!d.dataType||d.dataType.inferred)&&d.project.initialized,d.dataType)return u==null||u.attemptAutoclose("infer-continue-statement-data-type",d.id),d.dataType;if(d.parent.dataType)return u==null||u.attemptAutoclose("infer-continue-statement-data-type",d.id),d.parent.dataType;const i=(a=d.implements)==null?void 0:a.getDataType(u);return u==null||u.attemptAutoclose("infer-continue-statement-data-type",d.id),i||null}function UZ(d,u=null){return(d==null?void 0:d.dataType)||null}function jZ(d,u=null){var i;return((i=d==null?void 0:d.declaration)==null?void 0:i.getDataType(u))||null}function GZ(d,u=null){var i;return((i=d==null?void 0:d.declaration)==null?void 0:i.getDataType(u))||null}function kZ(d,u=null){return d.getDataType(u)||null}function ga(d,u=null){switch(d.type){case p.VariableDeclaration:return NZ(d,u);case p.ArgumentDeclaration:return PZ(d,u);case p.VariableInstance:return $Z(d,u);case p.InputMap:return yw(d,u);case p.OutputMap:return hw(d,u);case p.Property:return VZ(d,u);case p.ValueDescriptor:return LZ(d,u);case p.ReturnStatement:return BZ(d,u);case p.BreakStatement:return MZ(d,u);case p.ContinueStatement:return xZ(d,u);case p.Search:return UZ(d,u);case p.FunctionCall:return jZ(d,u);case p.InternalCall:return GZ(d,u);case p.Loop:return kZ(d,u);default:throw new Error(`Cannot infer data type from entity of type ${d.type}.`)}}function m0(d,u=null){switch(d.type){case p.ArgumentDeclaration:return d.getDataType(u);case p.InputMap:return d.getDataType(u);case p.VariableDeclaration:return d.getDataType(u);case p.VariableInstance:return d.getDataType(u);case p.OutputMap:return d.getDataType(u);case p.Property:return d.getDataType(u);case p.ValueDescriptor:return d.getDataType(u);case p.ReturnStatement:return d.getDataType(u);case p.BreakStatement:return d.getDataType(u);case p.ContinueStatement:return d.getDataType(u);case p.Search:return d.getDataType(u);case p.FunctionCall:return d.getDataType(u);case p.InternalCall:return d.getDataType(u);case p.Loop:return d.getDataType(u);default:return null}}function Id(d){if(!d)return ie.Untyped;if(d.entity){if(d.entity.type===p.DefinitionEntity)return d.asType?ie.EntityTemplate:ie.Untyped;if(d.entity.type===p.PrimitiveEntity)return d.asType?ie.EntityTemplate:d.entity.name;if(d.entity.type===p.ActionDescriptor)return ie.ActionDescriptor;if(d.entity.type===p.BuiltInBaseEntity)return d.asType?ie.EntityTemplate:ie.Untyped}return ie.Untyped}var FZ=(d=>(d.Declaration="declaration",d))(FZ||{});const ti=class ti extends pr{constructor(i,a){super(i);_(this,"initialData");_(this,"id");_(this,"index");_(this,"type",p.InternalCall);_(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,"project");_(this,"errors",[]);_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);this.initialData=i,this.project=a,this.id=i.id,this.index=i.index,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)||M().toISOString(),author:(i==null?void 0:i.author)||V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.InternalCall,writesValues:[],catchesError:!0,declaration:null,inputs:[],outputs:[],error:null,index:0,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[]}}static fromGenerationTarget(i,a){const l=te(i.parent),c=a.get(l),e=te(i.declaration),y=a.get(e),v=i.calledByEntry.map(L=>{const B=te(L);return a.get(B)}),T=i.calledBySuccess.map(L=>{const B=te(L);return a.get(B)}),A=i.calledByError.map(L=>{const B=te(L);return a.get(B)}),b={id:i.id,version:V.UUID.uuid(),createdAt:M().toISOString(),author:V.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.InternalCall,writesValues:[],catchesError:i.catchesError||!1,index:c.internalCalls.length,declaration:y.toReference(),calledByEntry:v,calledBySuccess:T,calledByError:A,errorCalls:[],successCalls:[],inputs:[],outputs:[],error:null,parent:c},O=re(b,a);return O.setParent(c,null),O}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const c=[],e=xr(l,{parent:{list:!1,types:$t}},a);l=e.modifiedData;const y=te(l.parent),v=a.get(y);if(v){const T=m0(v,null),A=T==null?void 0:T.entity;if(!A)c.push(new de({id:`${l.id}--${oe.InternalCallParentMissingDataType}`,code:oe.InternalCallParentMissingDataType,severity:ee.Error,message:`Entity of type "${l.type}" with id "${l.id}", belongs to a variable whose data type entity doesn't contain its declaration method (function-declaration) its id "${l.declaration}".`}));else if(![p.DefinitionEntity,p.BuiltInBaseEntity,p.PrimitiveEntity].includes(A.type))c.push(new de({id:`${l.id}--${oe.InternalCallParentDeclarationEntityInvalidType}`,code:oe.InternalCallParentDeclarationEntityInvalidType,severity:ee.Error,message:`Entity of type "${l.type}" with id "${l.id}", belongs to a variable whose data type 'entity' is not a definition entity, built-in base entity or primitive entity.
|
|
109
109
|
This variable's data-type has an 'entity' field that references an entity with id '${A.id}' and of type '${A.type}'.`}));else{const b=my(A);let O="";b?A.methods.length?O=`
|
|
110
110
|
All 'function-declaration' entities attached as methods to the parent data-type 'entity' field, available to be called as 'internal-calls' in this variable are:
|
|
111
111
|
- ${A.methods.map(q=>q.id).join(`
|
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.6575",
|
|
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",
|