@elyx-code/project-logic-tree 0.0.6101 → 0.0.6103

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 CHANGED
@@ -25078,13 +25078,13 @@ ${xo}`,
25078
25078
  u,
25079
25079
  this.project
25080
25080
  );
25081
- i && p.subscribe(), p.setParent(l);
25081
+ i && p.subscribe(), p.setParent(l), p.initChildren();
25082
25082
  const y = ((f = this.dataType) == null ? void 0 : f.clone(
25083
25083
  p,
25084
25084
  o + "-data-type-id",
25085
25085
  i
25086
25086
  )) || null;
25087
- return y && p.setDataType(y), this.implements && (p.implements = this.implements), p;
25087
+ return y && p.setDataType(y), this.implements && (p.implements = this.implements), p.addSelfToProject(), p;
25088
25088
  }
25089
25089
  setDataType(e) {
25090
25090
  return this.dataType = e, this;
@@ -26193,7 +26193,7 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
26193
26193
  return this.project.unsubscribeInstance(this), this;
26194
26194
  }
26195
26195
  sync(e) {
26196
- return this.version = e.version || this.version, this.isNullable = e.isNullable || this.isNullable, this.isList = e.isList || this.isList, this.constant = e.constant || this.constant, this.asType = e.asType || this.asType, this.options = e.options || this.options, this.parentRelationType = e.parentRelationType || this.parentRelationType, this.like = e.like || this.like, this.inferred = e.inferred || this.inferred, this;
26196
+ return this.version = e.version || this.version, this.options = e.options || this.options, this.parentRelationType = e.parentRelationType || this.parentRelationType, this.isList = e.isList !== void 0 ? e.isList : this.isList, this.inferred = e.inferred !== void 0 ? e.inferred : this.inferred, this.like = e.like !== void 0 ? e.like : this.like, this.asType = e.asType !== void 0 ? e.asType : this.asType, this.implementationChooseOne = e.implementationChooseOne !== void 0 ? e.implementationChooseOne : this.implementationChooseOne, this.constant = e.constant !== void 0 ? e.constant : this.constant, this.isNullable = e.isNullable !== void 0 ? e.isNullable : this.isNullable, this;
26197
26197
  }
26198
26198
  async load() {
26199
26199
  return this;
@@ -19,7 +19,7 @@ Please provide a unique 'name' string.`,severity:T.Error,code:S.NameNotUniqueInS
19
19
  Please provide a unique 'name' string.`,severity:T.Error,code:S.NameNotUniqueInScope,issue:null}))}}return t}function I2(i,e){switch(i.type){case n.CustomEntity:return Lo(i,e);case n.FunctionDeclaration:return Tu(i,e);case n.VariableDeclaration:return Eu(i,e);case n.Property:return bu(i,e);case n.ArgumentDeclaration:return Ru(i,e);case n.ReturnDeclaration:return gu(i,e);default:return[]}}function Ze(i,e,t){const a=`${Mo(i)}-${e}-id`;return t.instances[a]?_.UUID.uuid():a}function vu(i,e){let t="",r=null;if(i.parent){const s=e.get(i.parent);s&&(r=s)}let a="";return r&&(a=`${Mo(C(r,e))}-`),t=`${a}${Mo(C(i,e))}-id`,e.instances[t]?_.UUID.uuid():t}function D2(i){var o;const e=J9(),t=i.toJSON();e.safeParse(t).success;const a=P2(i);(o=i.dataType)==null||o.validate();const s=[...a];if(i.id==="80c86e1b-caca-4ba5-9b1f-38f72d10e4a3"){const l=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});s.push(l.error)}return s}function P2(i){const e=[];if(!i.implements)return e;const t=i.implements;if(!t.abstract){const a=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(t,i.project)}" with id "${t.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});e.push(a.error)}if(i.static&&!t.static){const a=H({id:`${i.id}--${M.NonStaticPropertyImplementsStatic}`,message:`Static property "${C(i,i.project)}" with id "${i.id}" implements a non-static property "${C(t,i.project)}" with id "${t.id}".`,issue:null,severity:T.Error,code:M.NonStaticPropertyImplementsStatic,entity:i});e.push(a.error)}if(!i.static&&t.static){const a=H({id:`${i.id}--${M.StaticPropertyImplementsNonStatic}`,message:`Non-static property "${C(i,i.project)}" with id "${i.id}" implements a static property "${C(t,i.project)}" with id "${t.id}".`,issue:null,severity:T.Error,code:M.StaticPropertyImplementsNonStatic,entity:i});e.push(a.error)}if(!jt(i.dataType,t.dataType)){const a=H({id:`${i.id}--${M.PropertyImplementsIncompatibleType}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a property "${C(t,i.project)}" with id "${t.id}" that has an incompatible data type.`,issue:null,severity:T.Error,code:M.PropertyImplementsIncompatibleType,entity:i});e.push(a.error)}return ie(i.errors,e)}function A2(i,e){const t=[];if(i.parent){const a=e.get(i.parent);if(!a)t.push(new b({id:`${i.id}--${i.parent}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${i.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const s=nr(a);if(s){const o=a!==s?`The entity of type '${i.type}' with id '${i.id}' have 'parent' with id '${i.parent}' because the entity belongs to a built-in '${s.type}' entity with id '${s.id}' (${C(s,a.project)}) higher up in the tree.`:`The entity of type '${i.type}' with id '${i.id}' have 'parent' with id '${i.parent}' because it is a built-in entity of type ${s.type}.`;t.push(new b({id:`${i.id}--${h.InvalidBuiltInEntityReference}`,code:h.InvalidBuiltInEntityReference,severity:T.Error,message:o,issue:null}))}else if(![n.CustomEntity].includes(a.type))t.push(new b({id:`${i.id}--${i.parent}--${h.InvalidParentReference}`,code:h.InvalidParentReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a parent reference that isn't pointing to an entity of type 'custom-entity'.`,issue:null}));else{const l=tr(a).filter(p=>!p.interactive);if(l.length){let p=l.length>1?`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${a.id}' because it extends or implements multiple '${n.BuiltInBaseEntity}' entities that are non-interactive ("${U(l.map(y=>C(y,y.project)),'", "','" and "')}").`:`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${a.id}' because it extends or implements a '${n.BuiltInBaseEntity}' entity that is non-interactive ("${C(l[0],l[0].project)}").`;p+=`
20
20
  ${Qn}`,t.push(new b({id:`${i.id}--${h.NonInteractiveEntityReferenced}`,code:h.NonInteractiveEntityReferenced,severity:T.Error,message:p,issue:null}))}else if(i.implements){const p=e.get(i.implements);if(i.id===i.implements)return t.push(new b({id:`${i.id}--${i.implements}--${h.SelfReference}`,code:h.SelfReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a reference to itself at 'implements'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null})),t;if(!p)t.push(new b({id:`${i.id}--${i.implements}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${i.implements}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const y=a.properties.find(f=>{var m;return((m=f.implements)==null?void 0:m.id)===i.implements});y?t.push(new b({id:`${i.id}--${S.PropertyOverwrite}`,code:S.PropertyOverwrite,severity:T.Error,message:`The property with id "${i.id}" is trying to implement the property with id "${i.implements}", but the parent entity already has a property with id '${y.id}' that implements the same base property.`,issue:null})):[n.Property].includes(p.type)?p.abstract||t.push(new b({id:`${i.id}--${i.implements}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):t.push(new b({id:`${i.id}--${i.implements}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an entity of type 'property'.`,issue:null}))}}}}}const r=Ye(i,{},e);return t.push(...r.errors),t}const be=class be{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"private");c(this,"abstract");c(this,"index");c(this,"static");c(this,"required");c(this,"type",n.Property);c(this,"hidden",!1);c(this,"dataType",null);c(this,"implements",null);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.private=e.private,this.abstract=e.abstract,this.index=e.index,this.static=e.static,this.required=e.required||!1,this.hidden=e.hidden||!1}static fromGenerationTarget(e,t){const r=N(e.parent),a=t.get(r);let s=null;if(e.implements){const p=N(e.implements);s=t.get(p)}const o={id:e.id,version:1,name:e.name,type:n.Property,index:a.properties.length,private:e.private||!1,abstract:e.abstract||!1,static:e.static||!1,required:e.required||!1,hidden:!1,description:e.description,implements:s,dataType:null,parent:a},l=g(o,t);return l.setParent(a),l.initChildren(),l}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=A2(r,t),o=bu(r,t);return a.push(...s,...o,...Le(r)),{errors:a,modifiedData:r}}get isExtendedProperty(){const e=this.parent.allBasePropertiesFromExtendedAndImplementedEntities.find(t=>t.name===this.name);return!!e&&e.id!==this.id&&!e.abstract}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new b({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
21
21
  This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),(e.readsValue||e.writesValue)&&t.push(new b({id:`${this.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' is not a value reading or writing entity.
22
- ${Uo}`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent.addProperty(this),e.push(this.parent),{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.dataType){const e=g(this.initialData.dataType,this.project);e.setParent(this),e.initChildren(),this.dataType=e}if(this.initialData.implements){const e=g(this.initialData.implements,this.project);this.implements=e}return this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.name=e.name||this.name,this.description=e.description||this.description,this.abstract=e.abstract||this.abstract,this.private=e.private||this.private,this.index=e.index||(e.index!==0?this.index:0),this.static=e.static||this.static,this.required=e.required||this.required,this.hidden=e.hidden||this.hidden,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.dataType){const{affected:s,removed:o}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return e||this.parent.type===n.CustomEntity&&(this.parent.removeProperty(this),r.push(this.parent)),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.dataType){const{affected:r}=this.dataType.restore({seenEntities:e});t.push(...r)}return this.parent.type===n.CustomEntity&&(this.parent.addProperty(this),t.push(this.parent)),{affected:t,self:this}}toFlat(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.dataType)==null?void 0:r.toFlat(e))||[]])}toFlatIds(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.dataType)==null?void 0:r.toFlatIds(e))||[]])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,abstract:this.abstract,hidden:this.hidden,dataType:((e=this.dataType)==null?void 0:e.toJSON())||null,implements:((t=this.implements)==null?void 0:t.toJSON())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,name:this.name,description:this.description,type:this.type,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,hidden:this.hidden,dataType:((e=this.dataType)==null?void 0:e.toReference())||null,implements:((t=this.implements)==null?void 0:t.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.dataType)==null?void 0:r.toFlatJSON(e))||[],...((a=this.implements)==null?void 0:a.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,implements:((e=this.implements)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.dataType)==null?void 0:r.toFlatGenerationTarget(e))||[]])}clearErrors(){var e;return this.errors=[],(e=this.dataType)==null||e.clearErrors(),this}validate(){return this.errors=D2(this),this.errors.length,{success:!0,error:null,data:null}}getErrors(){var t;return[...this.errors,...((t=this.dataType)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return((e=this.dataType)==null?void 0:e.defaultValue)||null}clone(e=null,t=null,r=!0){var m;const a=t||Ze(C(this,this.project),n.Property,this.project),s=a.split("-id"),o=s[s.length-1||0]||a;let l=e||this.parent;const p={hidden:!1,id:a,version:this.version,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,dataType:null,implements:this.implements,parent:l},y=qt(p,this.project);r&&y.subscribe(),y.setParent(l);const f=((m=this.dataType)==null?void 0:m.clone(y,o+"-data-type-id",r))||null;return f&&y.setDataType(f),this.implements&&(y.implements=this.implements),y}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(){return this.dataType}};c(be,"MUTABLE_BASE_PROPERTIES",["name","description","private","abstract","static","required"]),c(be,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(be,"BASE_PROPERTIES",[...be.MUTABLE_BASE_PROPERTIES,...be.INMUTABLE_BASE_PROPERTIES]),c(be,"MUTABLE_META_PROPERTIES",[...be.MUTABLE_BASE_PROPERTIES,"index"]),c(be,"INMUTABLE_META_PROPERTIES",[...be.INMUTABLE_BASE_PROPERTIES]),c(be,"META_PROPERTIES",[...be.MUTABLE_META_PROPERTIES,...be.INMUTABLE_META_PROPERTIES]),c(be,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(be,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements"]),c(be,"UPSTREAM_PROPERTIES",[...be.MUTABLE_UPSTREAM_PROPERTIES,...be.INMUTABLE_UPSTREAM_PROPERTIES]),c(be,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),c(be,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(be,"DOWNSTREAM_PROPERTIES",[...be.MUTABLE_DOWNSTREAM_PROPERTIES,...be.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(be,"PROPERTIES",[...be.META_PROPERTIES,...be.UPSTREAM_PROPERTIES,...be.DOWNSTREAM_PROPERTIES]);let wr=be;function O2(i){const e=lk(),t=i.toJSON();e.safeParse(t).success;const a=S2(i),s=C2(i),o=St(i);i.inputs.forEach(p=>p.validate()),o.forEach(p=>p.validate());const l=[...a,...s];if(i.id==="getCompanyByIdEndpointReachedEntityEvent"){const p=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});l.push(p.error)}return ie(i.errors,l)}function S2(i){const e=[];if(!i.calls.length){const t=H({id:`${i.id}--${M.ScopeWithoutLogic}`,message:`Action "${C(i,i.project)}" with id "${i.id}" does not have any logic defined. So it doesn't do anything.`,issue:null,severity:T.Warning,code:M.ScopeWithoutLogic,entity:i});e.push(t.error)}return ie(i.errors,e)}function C2(i){const e=[];return i.implements,ie(i.errors,e)}const Re=class Re{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"collapsed");c(this,"private");c(this,"index",null);c(this,"type",n.FunctionDeclaration);c(this,"implements",null);c(this,"inputs",[]);c(this,"returnStatements",[]);c(this,"calls",[]);c(this,"parent");c(this,"detachedChildren",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.private=e.private,this.collapsed=e.collapsed,this.x=e.x,this.y=e.y,this.index=e.index}static fromGenerationTarget(e,t){let r=t;if(e.parent){const l=N(e.parent);r=t.get(l)}let a=null;if(e.implements){const l=N(e.implements);a=t.get(l)}const s={id:e.id,version:1,name:e.name,type:n.FunctionDeclaration,index:r.type===n.CustomEntity?r.methods.length:null,description:e.description,collapsed:!1,private:!1,returnStatements:[],calls:[],inputs:[],implements:a,x:0,y:0,parent:r},o=g(s,t);return o.setParent(r),o.initChildren(),o}static validateGenerationTarget(e,t){var f;let r=JSON.parse(JSON.stringify(e));const a=[],s=Ye(r,{parent:{list:!1,types:[n.Project,n.InstalledProject,n.CustomEntity,n.Loop],optional:!0},implements:{list:!1,types:[n.ActionDescriptor],optional:!0}},t);r=s.modifiedData;const o=Tu(r,t),l=r.parent?t.get(r.parent):null;if(l&&l.type===n.CustomEntity){const m=l,v=tr(m).filter(P=>!P.interactive);if(v.length){let P=v.length>1?`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${m.id}' because it extends or implements multiple '${n.BuiltInBaseEntity}' entities that are non-interactive ("${U(v.map(A=>C(A,A.project)),'", "','" and "')}").`:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${m.id}' because it extends or implements a '${n.BuiltInBaseEntity}' entity that is non-interactive ("${C(v[0],v[0].project)}").`;P+=`
22
+ ${Uo}`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent.addProperty(this),e.push(this.parent),{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.dataType){const e=g(this.initialData.dataType,this.project);e.setParent(this),e.initChildren(),this.dataType=e}if(this.initialData.implements){const e=g(this.initialData.implements,this.project);this.implements=e}return this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.name=e.name||this.name,this.description=e.description||this.description,this.abstract=e.abstract||this.abstract,this.private=e.private||this.private,this.index=e.index||(e.index!==0?this.index:0),this.static=e.static||this.static,this.required=e.required||this.required,this.hidden=e.hidden||this.hidden,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.dataType){const{affected:s,removed:o}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}return e||this.parent.type===n.CustomEntity&&(this.parent.removeProperty(this),r.push(this.parent)),{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.dataType){const{affected:r}=this.dataType.restore({seenEntities:e});t.push(...r)}return this.parent.type===n.CustomEntity&&(this.parent.addProperty(this),t.push(this.parent)),{affected:t,self:this}}toFlat(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.dataType)==null?void 0:r.toFlat(e))||[]])}toFlatIds(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.dataType)==null?void 0:r.toFlatIds(e))||[]])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,abstract:this.abstract,hidden:this.hidden,dataType:((e=this.dataType)==null?void 0:e.toJSON())||null,implements:((t=this.implements)==null?void 0:t.toJSON())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,name:this.name,description:this.description,type:this.type,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,hidden:this.hidden,dataType:((e=this.dataType)==null?void 0:e.toReference())||null,implements:((t=this.implements)==null?void 0:t.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.dataType)==null?void 0:r.toFlatJSON(e))||[],...((a=this.implements)==null?void 0:a.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,implements:((e=this.implements)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.dataType)==null?void 0:r.toFlatGenerationTarget(e))||[]])}clearErrors(){var e;return this.errors=[],(e=this.dataType)==null||e.clearErrors(),this}validate(){return this.errors=D2(this),this.errors.length,{success:!0,error:null,data:null}}getErrors(){var t;return[...this.errors,...((t=this.dataType)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return((e=this.dataType)==null?void 0:e.defaultValue)||null}clone(e=null,t=null,r=!0){var m;const a=t||Ze(C(this,this.project),n.Property,this.project),s=a.split("-id"),o=s[s.length-1||0]||a;let l=e||this.parent;const p={hidden:!1,id:a,version:this.version,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,dataType:null,implements:this.implements,parent:l},y=qt(p,this.project);r&&y.subscribe(),y.setParent(l),y.initChildren();const f=((m=this.dataType)==null?void 0:m.clone(y,o+"-data-type-id",r))||null;return f&&y.setDataType(f),this.implements&&(y.implements=this.implements),y.addSelfToProject(),y}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(){return this.dataType}};c(be,"MUTABLE_BASE_PROPERTIES",["name","description","private","abstract","static","required"]),c(be,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(be,"BASE_PROPERTIES",[...be.MUTABLE_BASE_PROPERTIES,...be.INMUTABLE_BASE_PROPERTIES]),c(be,"MUTABLE_META_PROPERTIES",[...be.MUTABLE_BASE_PROPERTIES,"index"]),c(be,"INMUTABLE_META_PROPERTIES",[...be.INMUTABLE_BASE_PROPERTIES]),c(be,"META_PROPERTIES",[...be.MUTABLE_META_PROPERTIES,...be.INMUTABLE_META_PROPERTIES]),c(be,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(be,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements"]),c(be,"UPSTREAM_PROPERTIES",[...be.MUTABLE_UPSTREAM_PROPERTIES,...be.INMUTABLE_UPSTREAM_PROPERTIES]),c(be,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),c(be,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(be,"DOWNSTREAM_PROPERTIES",[...be.MUTABLE_DOWNSTREAM_PROPERTIES,...be.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(be,"PROPERTIES",[...be.META_PROPERTIES,...be.UPSTREAM_PROPERTIES,...be.DOWNSTREAM_PROPERTIES]);let wr=be;function O2(i){const e=lk(),t=i.toJSON();e.safeParse(t).success;const a=S2(i),s=C2(i),o=St(i);i.inputs.forEach(p=>p.validate()),o.forEach(p=>p.validate());const l=[...a,...s];if(i.id==="getCompanyByIdEndpointReachedEntityEvent"){const p=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});l.push(p.error)}return ie(i.errors,l)}function S2(i){const e=[];if(!i.calls.length){const t=H({id:`${i.id}--${M.ScopeWithoutLogic}`,message:`Action "${C(i,i.project)}" with id "${i.id}" does not have any logic defined. So it doesn't do anything.`,issue:null,severity:T.Warning,code:M.ScopeWithoutLogic,entity:i});e.push(t.error)}return ie(i.errors,e)}function C2(i){const e=[];return i.implements,ie(i.errors,e)}const Re=class Re{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"collapsed");c(this,"private");c(this,"index",null);c(this,"type",n.FunctionDeclaration);c(this,"implements",null);c(this,"inputs",[]);c(this,"returnStatements",[]);c(this,"calls",[]);c(this,"parent");c(this,"detachedChildren",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.private=e.private,this.collapsed=e.collapsed,this.x=e.x,this.y=e.y,this.index=e.index}static fromGenerationTarget(e,t){let r=t;if(e.parent){const l=N(e.parent);r=t.get(l)}let a=null;if(e.implements){const l=N(e.implements);a=t.get(l)}const s={id:e.id,version:1,name:e.name,type:n.FunctionDeclaration,index:r.type===n.CustomEntity?r.methods.length:null,description:e.description,collapsed:!1,private:!1,returnStatements:[],calls:[],inputs:[],implements:a,x:0,y:0,parent:r},o=g(s,t);return o.setParent(r),o.initChildren(),o}static validateGenerationTarget(e,t){var f;let r=JSON.parse(JSON.stringify(e));const a=[],s=Ye(r,{parent:{list:!1,types:[n.Project,n.InstalledProject,n.CustomEntity,n.Loop],optional:!0},implements:{list:!1,types:[n.ActionDescriptor],optional:!0}},t);r=s.modifiedData;const o=Tu(r,t),l=r.parent?t.get(r.parent):null;if(l&&l.type===n.CustomEntity){const m=l,v=tr(m).filter(P=>!P.interactive);if(v.length){let P=v.length>1?`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${m.id}' because it extends or implements multiple '${n.BuiltInBaseEntity}' entities that are non-interactive ("${U(v.map(A=>C(A,A.project)),'", "','" and "')}").`:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${m.id}' because it extends or implements a '${n.BuiltInBaseEntity}' entity that is non-interactive ("${C(v[0],v[0].project)}").`;P+=`
23
23
  ${Qn}`,a.push(new b({id:`${e.id}--${h.NonInteractiveEntityReferenced}`,code:h.NonInteractiveEntityReferenced,severity:T.Error,message:P,issue:null}))}else{const P=m.methods.find(F=>{var k;return((k=F.implements)==null?void 0:k.id)===r.implements});P&&a.push(new b({id:`${r.id}--${S.MethodOverwrite}`,code:S.MethodOverwrite,severity:T.Error,message:`The '${n.FunctionDeclaration}' with id "${r.id}" is trying to implement the '${n.ActionDescriptor}' with id "${r.implements}", but the parent custom-entity already has a ${n.FunctionDeclaration} with id '${P.id}' that implements the same base method.
24
24
  A ${n.FunctionDeclaration} that has a parent of type '${n.CustomEntity}' is considered a method of that entity, and cannot implement the same '${n.ActionDescriptor}' more than once.
25
25
  ${n.ActionDescriptor} entities inside a ${n.CustomEntity} are considered abstract methods that can be implemented by ${n.FunctionDeclaration} entities inside the same parent.
@@ -34,7 +34,7 @@ ${Qn}`,issue:null}))}}}const o=r.parent&&t.get(r.parent)||t.getBuiltIn(r.parent)
34
34
  The entitities of type '${U(f,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property so no 'parentRelationType' is needed.`,issue:null})),o.dataType)){const m=(p=o.dataType)==null?void 0:p.id;a.push(new b({id:`${e.id}--${h.NewEntityWouldOverriteExisting}`,code:h.NewEntityWouldOverriteExisting,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.type}', cannot be added as a child to the entity with id '${r.parent}' and type '${y}', because it already has a 'data-type' child with id '${m}'.
35
35
  The entitities of type '${U(f,"', '","' 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:
36
36
  ${un({describe_entity:m})}
37
- Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}y===n.DataType&&(!r.parentRelationType||!(r.parentRelationType===We.AndDataTypeGroup||r.parentRelationType===We.OrDataTypeGroup))&&a.push(new b({id:`${e.id}--${h.InvalidParentRelationType}`,code:h.InvalidParentRelationType,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.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'.`,issue:null}))}return{errors:a,modifiedData:r}}get isGroup(){const e=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(e.length>1){let t=0;for(const r of e)if(r.isResolved&&(t++,t>1))return!0}return!1}get isResolved(){return[n.BuiltInBaseEntity,n.ActionDescriptor].includes(this.parent.type)||nr(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent.type===n.DataType?this.parentRelationType===We.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===We.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.defaultValue&&(this.defaultValue=g(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this),this.defaultValue.initChildren()),this.initialData.entity)if(this.initialData.entity.type===n.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=e}else this.entity=g(this.initialData.entity,this.project);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.isNullable=e.isNullable||this.isNullable,this.isList=e.isList||this.isList,this.constant=e.constant||this.constant,this.asType=e.asType||this.asType,this.options=e.options||this.options,this.parentRelationType=e.parentRelationType||this.parentRelationType,this.like=e.like||this.like,this.inferred=e.inferred||this.inferred,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(!e){this.parent.type===n.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===n.DataType){if(this.parentRelationType===We.AndDataTypeGroup){if(Array.isArray(s.andChildrenGroup)){const o=s.andChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.andChildrenGroup.splice(o,1)}}else if(this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(s.orChildrenGroup)){const o=s.orChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.orChildrenGroup.splice(o,1)}}else this.parent.removeDataType();r.push(s)}return{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.defaultValue){const{affected:r}=this.defaultValue.restore({seenEntities:e});t.push(...r)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:r}=this.entity.restore({seenEntities:e});t.push(...r)}if(this.parent.type===n.DataType){const r=this.parent;Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this)}if(this.parent.type===n.DataType){const r=this.parent;this.parentRelationType===We.AndDataTypeGroup?Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this):this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(r.orChildrenGroup)&&r.orChildrenGroup.push(this)}else{const r=this.parent;r.setDataType(this),t.push(r)}return{affected:t,self:this}}toFlat(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlat(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlat(e)))||[],...((s=this.entity)==null?void 0:s.toFlat(e))||[]])}toFlatIds(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlatIds(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatIds(e)))||[],...((s=this.entity)==null?void 0:s.toFlatIds(e))||[]])}toJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,asType:this.asType,defaultValue:((e=this.defaultValue)==null?void 0:e.toJSON())||null,like:this.like,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toJSON()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toJSON()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isList:this.isList,isNullable:this.isNullable,options:this.options,constant:this.constant,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference())||null,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toReference()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toReference()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r,a,s,o;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.defaultValue)==null?void 0:r.toFlatJSON(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(l=>l.toFlatJSON(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(l=>l.toFlatJSON(e)))||[],...((o=this.entity)==null?void 0:o.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,like:this.like,parentRelationType:this.parentRelationType,asType:this.asType,entity:((e=this.entity)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.defaultValue)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==n.CustomEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,r,a;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.andChildrenGroup)==null||t.forEach(s=>s.clearErrors()),(r=this.orChildrenGroup)==null||r.forEach(s=>s.clearErrors()),this.inferred&&((a=this.entity)==null||a.clearErrors()),this}validate(){const e=B2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(e=null,t=null,r=!0){var v,P,A,D;let a=e||this.parent;const s=t||Ze(ka(this),n.DataType,this.project),o=s.split("-id"),l=o[o.length-1||0]||s,p={id:s,version:1,type:n.DataType,isNullable:this.isNullable,isList:this.isList,constant:this.constant,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,defaultValue:null,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:a.toReference()},y=qt(p,this.project);e&&y.setParent(e),r&&y.subscribe(),y.initChildren();const f=(v=this.defaultValue)==null?void 0:v.clone(y,l+"-default-value-id",r);y.defaultValue=f||null;const m=(P=this.andChildrenGroup)==null?void 0:P.map((F,k)=>F.clone(this,l+"-and-group-data-type-"+k+"-id",r)),R=(A=this.orChildrenGroup)==null?void 0:A.map((F,k)=>F.clone(this,l+"-or-group-data-type-"+k+"-id",r));if(y.andChildrenGroup=m||null,y.orChildrenGroup=R||null,this.entity&&this.entity.type===n.CustomEntity&&((D=this.entity)==null?void 0:D.parent)===this){const F=this.entity.clone(y,l+"-inferred-entity-id",r);y.setEntity(F)}else this.entity&&y.setEntity(this.entity);return y}merge(e){const t=[],r=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isNullable!==(e==null?void 0:e.isNullable)&&(this.sync({isNullable:e==null?void 0:e.isNullable}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),t.push(this)),this.constant!==(e==null?void 0:e.constant)&&(this.sync({constant:e==null?void 0:e.constant}),t.push(this)),this.like!==(e==null?void 0:e.like)&&(this.sync({like:e==null?void 0:e.like}),t.push(this)),e!=null&&e.inferred){if(e.entity&&e.entity.type===n.CustomEntity&&e.entity.parent===e){const s=e.entity.clone(this,this.id+"--inferred-entity-id",!0);this.setEntity(s),r.push(s)}else e.entity&&(this.setEntity(e.entity),t.push(this));this.inferred||(this.sync({inferred:!0}),t.push(this))}else if(this.inferred){if(this.sync({inferred:!1}),t.push(this),this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this))}else e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this));if(e.defaultValue)if(this.defaultValue){const{updated:s,added:o,removed:l}=this.defaultValue.merge(e.defaultValue);t.push(...s),r.push(...o),a.push(...l)}else{const s=e.defaultValue.clone(this,this.id+"--default-value-id",!0);this.setDefaultValue(s),r.push(s)}else if(this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}return{updated:E(t),added:E(r),removed:E(a),self:this}}addToAndGroup(e){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(e)||this.andChildrenGroup.push(e),this}addToOrGroup(e){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(e)||this.orChildrenGroup.push(e),this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}setEntity(e){return this.entity=e,this}isObject(){return!!this.entity&&(this.entity.type===n.CustomEntity||this.entity.name===I.KeyValue)}hasStrictObjectStructure(){var e;return this.isObject()&&((e=this.entity)==null?void 0:e.type)===n.CustomEntity}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const r={id:this.id+"--infered-entity",type:n.CustomEntity,version:1,name:C(this,this.project),description:((t=this.parent)==null?void 0:t.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},a=g(r,this.project);a.sync(r),a.setParent(this),a.initChildren(),this.setEntity(a)}return this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(ge,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(ge,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(ge,"BASE_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"MUTABLE_META_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,"inferred"]),c(ge,"INMUTABLE_META_PROPERTIES",[...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"META_PROPERTIES",[...ge.MUTABLE_META_PROPERTIES,...ge.INMUTABLE_META_PROPERTIES]),c(ge,"MUTABLE_UPSTREAM_PROPERTIES",["entity","andChildrenGroup","orChildrenGroup","parent"]),c(ge,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(ge,"UPSTREAM_PROPERTIES",[...ge.MUTABLE_UPSTREAM_PROPERTIES,...ge.INMUTABLE_UPSTREAM_PROPERTIES]),c(ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),c(ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ge,"DOWNSTREAM_PROPERTIES",[...ge.MUTABLE_DOWNSTREAM_PROPERTIES,...ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ge,"PROPERTIES",[...ge.META_PROPERTIES,...ge.UPSTREAM_PROPERTIES,...ge.DOWNSTREAM_PROPERTIES]);let wi=ge;function _2(i){var l;const e=H6(),t=i.toJSON();e.safeParse(t).success;const a=N2(i),s=wn(i),o=[...a,...s];if(i.id==="exec-sequentially-operation-call-id"){const p=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});o.push(p.error)}return i.outputs.forEach(p=>p.validate()),(l=i.error)==null||l.validate(),ie(i.errors,o)}function N2(i){const e=[];return i.inputs.forEach(t=>{t.validate()}),ie(i.errors,e)}const de=class de{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Operation);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"process",null);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"error",null);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const m=N(e.parent);r=t.get(m)}const a=N(e.declaration),s=t.get(a),o=e.calledByEntry.map(m=>{const R=N(m);return t.get(R)}),l=e.calledBySuccess.map(m=>{const R=N(m);return t.get(R)}),p=e.calledByError.map(m=>{const R=N(m);return t.get(R)}),y={id:e.id,version:1,type:n.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:r},f=g(y,t);return f.setParent(r),f.initChildren(),f}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=Ye(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);r=s.modifiedData,a.push(...s.errors,...Le(r));const o=N(r.declaration);if(o){const l=kP(o,t);a.push(...l)}else{const l=`
37
+ Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}y===n.DataType&&(!r.parentRelationType||!(r.parentRelationType===We.AndDataTypeGroup||r.parentRelationType===We.OrDataTypeGroup))&&a.push(new b({id:`${e.id}--${h.InvalidParentRelationType}`,code:h.InvalidParentRelationType,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.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'.`,issue:null}))}return{errors:a,modifiedData:r}}get isGroup(){const e=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(e.length>1){let t=0;for(const r of e)if(r.isResolved&&(t++,t>1))return!0}return!1}get isResolved(){return[n.BuiltInBaseEntity,n.ActionDescriptor].includes(this.parent.type)||nr(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent.type===n.DataType?this.parentRelationType===We.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===We.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.defaultValue&&(this.defaultValue=g(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this),this.defaultValue.initChildren()),this.initialData.entity)if(this.initialData.entity.type===n.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=e}else this.entity=g(this.initialData.entity,this.project);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.options=e.options||this.options,this.parentRelationType=e.parentRelationType||this.parentRelationType,this.isList=e.isList!==void 0?e.isList:this.isList,this.inferred=e.inferred!==void 0?e.inferred:this.inferred,this.like=e.like!==void 0?e.like:this.like,this.asType=e.asType!==void 0?e.asType:this.asType,this.implementationChooseOne=e.implementationChooseOne!==void 0?e.implementationChooseOne:this.implementationChooseOne,this.constant=e.constant!==void 0?e.constant:this.constant,this.isNullable=e.isNullable!==void 0?e.isNullable:this.isNullable,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(!e){this.parent.type===n.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===n.DataType){if(this.parentRelationType===We.AndDataTypeGroup){if(Array.isArray(s.andChildrenGroup)){const o=s.andChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.andChildrenGroup.splice(o,1)}}else if(this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(s.orChildrenGroup)){const o=s.orChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.orChildrenGroup.splice(o,1)}}else this.parent.removeDataType();r.push(s)}return{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.defaultValue){const{affected:r}=this.defaultValue.restore({seenEntities:e});t.push(...r)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:r}=this.entity.restore({seenEntities:e});t.push(...r)}if(this.parent.type===n.DataType){const r=this.parent;Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this)}if(this.parent.type===n.DataType){const r=this.parent;this.parentRelationType===We.AndDataTypeGroup?Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this):this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(r.orChildrenGroup)&&r.orChildrenGroup.push(this)}else{const r=this.parent;r.setDataType(this),t.push(r)}return{affected:t,self:this}}toFlat(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlat(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlat(e)))||[],...((s=this.entity)==null?void 0:s.toFlat(e))||[]])}toFlatIds(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlatIds(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatIds(e)))||[],...((s=this.entity)==null?void 0:s.toFlatIds(e))||[]])}toJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,asType:this.asType,defaultValue:((e=this.defaultValue)==null?void 0:e.toJSON())||null,like:this.like,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toJSON()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toJSON()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isList:this.isList,isNullable:this.isNullable,options:this.options,constant:this.constant,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference())||null,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toReference()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toReference()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r,a,s,o;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.defaultValue)==null?void 0:r.toFlatJSON(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(l=>l.toFlatJSON(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(l=>l.toFlatJSON(e)))||[],...((o=this.entity)==null?void 0:o.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,like:this.like,parentRelationType:this.parentRelationType,asType:this.asType,entity:((e=this.entity)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.defaultValue)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==n.CustomEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,r,a;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.andChildrenGroup)==null||t.forEach(s=>s.clearErrors()),(r=this.orChildrenGroup)==null||r.forEach(s=>s.clearErrors()),this.inferred&&((a=this.entity)==null||a.clearErrors()),this}validate(){const e=B2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(e=null,t=null,r=!0){var v,P,A,D;let a=e||this.parent;const s=t||Ze(ka(this),n.DataType,this.project),o=s.split("-id"),l=o[o.length-1||0]||s,p={id:s,version:1,type:n.DataType,isNullable:this.isNullable,isList:this.isList,constant:this.constant,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,defaultValue:null,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:a.toReference()},y=qt(p,this.project);e&&y.setParent(e),r&&y.subscribe(),y.initChildren();const f=(v=this.defaultValue)==null?void 0:v.clone(y,l+"-default-value-id",r);y.defaultValue=f||null;const m=(P=this.andChildrenGroup)==null?void 0:P.map((F,k)=>F.clone(this,l+"-and-group-data-type-"+k+"-id",r)),R=(A=this.orChildrenGroup)==null?void 0:A.map((F,k)=>F.clone(this,l+"-or-group-data-type-"+k+"-id",r));if(y.andChildrenGroup=m||null,y.orChildrenGroup=R||null,this.entity&&this.entity.type===n.CustomEntity&&((D=this.entity)==null?void 0:D.parent)===this){const F=this.entity.clone(y,l+"-inferred-entity-id",r);y.setEntity(F)}else this.entity&&y.setEntity(this.entity);return y}merge(e){const t=[],r=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isNullable!==(e==null?void 0:e.isNullable)&&(this.sync({isNullable:e==null?void 0:e.isNullable}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),t.push(this)),this.constant!==(e==null?void 0:e.constant)&&(this.sync({constant:e==null?void 0:e.constant}),t.push(this)),this.like!==(e==null?void 0:e.like)&&(this.sync({like:e==null?void 0:e.like}),t.push(this)),e!=null&&e.inferred){if(e.entity&&e.entity.type===n.CustomEntity&&e.entity.parent===e){const s=e.entity.clone(this,this.id+"--inferred-entity-id",!0);this.setEntity(s),r.push(s)}else e.entity&&(this.setEntity(e.entity),t.push(this));this.inferred||(this.sync({inferred:!0}),t.push(this))}else if(this.inferred){if(this.sync({inferred:!1}),t.push(this),this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this))}else e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this));if(e.defaultValue)if(this.defaultValue){const{updated:s,added:o,removed:l}=this.defaultValue.merge(e.defaultValue);t.push(...s),r.push(...o),a.push(...l)}else{const s=e.defaultValue.clone(this,this.id+"--default-value-id",!0);this.setDefaultValue(s),r.push(s)}else if(this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}return{updated:E(t),added:E(r),removed:E(a),self:this}}addToAndGroup(e){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(e)||this.andChildrenGroup.push(e),this}addToOrGroup(e){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(e)||this.orChildrenGroup.push(e),this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}setEntity(e){return this.entity=e,this}isObject(){return!!this.entity&&(this.entity.type===n.CustomEntity||this.entity.name===I.KeyValue)}hasStrictObjectStructure(){var e;return this.isObject()&&((e=this.entity)==null?void 0:e.type)===n.CustomEntity}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const r={id:this.id+"--infered-entity",type:n.CustomEntity,version:1,name:C(this,this.project),description:((t=this.parent)==null?void 0:t.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},a=g(r,this.project);a.sync(r),a.setParent(this),a.initChildren(),this.setEntity(a)}return this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(ge,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(ge,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(ge,"BASE_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"MUTABLE_META_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,"inferred"]),c(ge,"INMUTABLE_META_PROPERTIES",[...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"META_PROPERTIES",[...ge.MUTABLE_META_PROPERTIES,...ge.INMUTABLE_META_PROPERTIES]),c(ge,"MUTABLE_UPSTREAM_PROPERTIES",["entity","andChildrenGroup","orChildrenGroup","parent"]),c(ge,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(ge,"UPSTREAM_PROPERTIES",[...ge.MUTABLE_UPSTREAM_PROPERTIES,...ge.INMUTABLE_UPSTREAM_PROPERTIES]),c(ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),c(ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ge,"DOWNSTREAM_PROPERTIES",[...ge.MUTABLE_DOWNSTREAM_PROPERTIES,...ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ge,"PROPERTIES",[...ge.META_PROPERTIES,...ge.UPSTREAM_PROPERTIES,...ge.DOWNSTREAM_PROPERTIES]);let wi=ge;function _2(i){var l;const e=H6(),t=i.toJSON();e.safeParse(t).success;const a=N2(i),s=wn(i),o=[...a,...s];if(i.id==="exec-sequentially-operation-call-id"){const p=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});o.push(p.error)}return i.outputs.forEach(p=>p.validate()),(l=i.error)==null||l.validate(),ie(i.errors,o)}function N2(i){const e=[];return i.inputs.forEach(t=>{t.validate()}),ie(i.errors,e)}const de=class de{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Operation);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"process",null);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"error",null);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const m=N(e.parent);r=t.get(m)}const a=N(e.declaration),s=t.get(a),o=e.calledByEntry.map(m=>{const R=N(m);return t.get(R)}),l=e.calledBySuccess.map(m=>{const R=N(m);return t.get(R)}),p=e.calledByError.map(m=>{const R=N(m);return t.get(R)}),y={id:e.id,version:1,type:n.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:r},f=g(y,t);return f.setParent(r),f.initChildren(),f}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=Ye(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);r=s.modifiedData,a.push(...s.errors,...Le(r));const o=N(r.declaration);if(o){const l=kP(o,t);a.push(...l)}else{const l=`
38
38
  All built-in 'action-descriptor' entity ids are:
39
39
  - ${t.operationDeclarations.map(p=>`${p.id} (${C(p,t)})`).join(`
40
40
  - `)}.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6101",
3
+ "version": "0.0.6103",
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",