@elyx-code/project-logic-tree 0.0.6006 → 0.0.6008

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
@@ -26901,14 +26901,17 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
26901
26901
  return this.outputs.filter((e) => !e.writesValues.length);
26902
26902
  }
26903
26903
  get usedInternalCalls() {
26904
- return this.internalCalls.filter((e) => !!e.calledBy.length);
26904
+ return this.internalCalls.filter(
26905
+ (e) => !!e.calledBy.length
26906
+ );
26905
26907
  }
26906
26908
  get unusedInternalCalls() {
26907
26909
  const e = this.usedInternalCalls;
26908
- return this.internalCalls.filter((t) => {
26909
- if (!t.calledBy.length || e.find((i) => i.id === t.id || i.declaration.id === t.declaration.id))
26910
- return !1;
26911
- });
26910
+ return this.internalCalls.filter((i) => !(e.find(
26911
+ (o) => o.id === i.id
26912
+ ) || e.find(
26913
+ (o) => o.declaration === i.declaration
26914
+ )));
26912
26915
  }
26913
26916
  removeInput(e) {
26914
26917
  const t = this.inputs.findIndex((i) => i.id === e.id);
@@ -60,7 +60,7 @@ Specifically for variables, their scope is also calculated from their value read
60
60
  You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`,issue:null})),{errors:t,modifiedData:i}}addSelfToProject(){return this.parent===this.project&&this.project.addVariableDeclaration(this),this.readsValue&&this.readsValue.addValueReader(this),this.writesValues.forEach(e=>{e.setValueWriter(this)}),this.successCalls.forEach(e=>{e.addSuccessCaller(this)}),this.errorCalls.forEach(e=>{e.addErrorCaller(this)}),this.calledBySuccess.forEach(e=>{e.addSuccessCall(this)}),this.calledByError.forEach(e=>{e.addErrorCall(this)}),this.calledByEntry.forEach(e=>{e.addCall(this)}),this}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(e=>e.readsValue||e.dynamicArguments.length||e.defaultValue)}get unusedInputs(){return this.inputs.filter(e=>!e.readsValue&&!e.dynamicArguments.length&&!e.defaultValue)}get usedOutputs(){return this.outputs.filter(e=>e.writesValues.length)}get unusedOutputs(){return this.outputs.filter(e=>!e.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(e=>!!e.calledBy.length)}get unusedInternalCalls(){return this.internalCalls.filter(e=>!e.calledBy.length)}removeInput(e){const t=this.inputs.findIndex(i=>i.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(i=>i.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const i=this.errorCalls.findIndex(a=>a.id===e.id);return i>-1&&this.errorCalls.splice(i,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}addValueReader(e){return this.writesValues.includes(e)?this:(this.writesValues.push(e),this)}removeValueReader(e){return this.writesValues=this.writesValues.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.initialData.dataType&&(this.dataType=R(this.initialData.dataType,this.project),this.dataType.setParent(this),this.dataType.initChildren()),ca.initWritesValues(this,this.parent),la.initReadsValue(this),this.successCalls=this.initialData.successCalls.map(e=>{const t=R(e,this.project);return t.addSuccessCaller(this),[r.BreakStatement,r.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==r.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=R(e,this.project);return t.addErrorCaller(this),[r.BreakStatement,r.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==r.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.internalCalls=this.initialData.internalCalls.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.inputs.push(...this.generateUnusedInputs()),this.outputs.push(...this.generateUnusedOutputs()),this)}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,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.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),ha(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const i=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.readsValue&&(i.push(this.readsValue),this.readsValue.removeValueReader(this)),this.writesValues.forEach(s=>{i.push(s),s.readsValue=null}),this.inputs.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),this.outputs.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),this.successCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),this.internalCalls.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),this.dataType){const{affected:s,removed:o}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});i.push(...s),a.push(...o)}return e||this.calledBy.forEach(s=>{i.push(s),s.removeCall(this)}),{affected:S(i),removed:S(a)}}restore({seenEntities:e}={seenEntities:new Set}){this.subscribe();const t=[];if(this.readsValue&&(t.push(this.readsValue),this.readsValue.addValueReader(this)),this.writesValues.forEach(i=>{t.push(i),i.setValueWriter(this)}),this.inputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(i=>{t.push(i),i.addSuccessCaller(this)}),this.errorCalls.forEach(i=>{t.push(i),i.addErrorCaller(this)}),this.internalCalls.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.dataType){const{affected:i}=this.dataType.restore({seenEntities:e});t.push(...i)}return this.calledBySuccess.forEach(i=>{t.push(i),i.addSuccessCall(this)}),this.calledByError.forEach(i=>{t.push(i),i.addErrorCall(this)}),this.calledByEntry.forEach(i=>{t.push(i),i.addCall(this)}),{affected:S(t),self:this}}toFlat(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this,...((i=this.dataType)==null?void 0:i.toFlat(e))||[],...this.writesValues.flatMap(a=>a.toFlat(e)),...this.successCalls.flatMap(a=>a.toFlat(e)),...this.errorCalls.flatMap(a=>a.toFlat(e)),...this.inputs.flatMap(a=>a.toFlat(e)),...this.outputs.flatMap(a=>a.toFlat(e)),...this.internalCalls.flatMap(a=>a.toFlat(e))])}toFlatIds(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((i=this.dataType)==null?void 0:i.toFlatIds(e))||[],...this.writesValues.flatMap(a=>a.toFlatIds(e)),...this.successCalls.flatMap(a=>a.toFlatIds(e)),...this.errorCalls.flatMap(a=>a.toFlatIds(e)),...this.inputs.flatMap(a=>a.toFlatIds(e)),...this.outputs.flatMap(a=>a.toFlatIds(e)),...this.internalCalls.flatMap(a=>a.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,dataType:((e=this.dataType)==null?void 0:e.toJSON())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(i=>i.toJSON()),inputs:this.inputs.map(i=>i.toJSON()),outputs:this.outputs.map(i=>i.toJSON()),successCalls:this.successCalls.map(i=>i.toJSON()),errorCalls:this.errorCalls.map(i=>i.toJSON()),internalCalls:this.internalCalls.map(i=>i.toJSON()),calledBySuccess:this.calledBySuccess.map(i=>i.toReference()),calledByError:this.calledByError.map(i=>i.toReference()),calledByEntry:this.calledByEntry.map(i=>i.toReference()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+$.UUID.uuid()+"--ref",type:r.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,x:this.x,y:this.y,dataType:((e=this.dataType)==null?void 0:e.toReference())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(i=>i.toReference()),inputs:this.inputs.map(i=>i.toReference()),outputs:this.outputs.map(i=>i.toReference()),successCalls:this.successCalls.map(i=>i.toReference()),errorCalls:this.errorCalls.map(i=>i.toReference()),calledBySuccess:this.calledBySuccess.map(i=>i.toReference()),calledByError:this.calledByError.map(i=>i.toReference()),calledByEntry:this.calledByEntry.map(i=>i.toReference()),internalCalls:this.internalCalls.map(i=>i.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.dataType)==null?void 0:i.toFlatJSON(e))||[],...this.writesValues.flatMap(a=>a.toFlatJSON(e)),...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.internalCalls.flatMap(a=>a.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===r.Project?void 0:this.parent.id;return{id:this.id,type:this.type,name:this.name,description:this.description,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.dataType)==null?void 0:i.toFlatGenerationTarget(e))||[],...this.writesValues.flatMap(a=>a.toFlatGenerationTarget(e)),...this.successCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(a=>a.toFlatGenerationTarget(e)),...this.inputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.outputs.flatMap(a=>a.toFlatGenerationTarget(e)),...this.internalCalls.flatMap(a=>a.toFlatGenerationTarget(e))])}clearErrors(){var e;return this.errors=[],this.inputs.forEach(t=>t.clearErrors()),this.outputs.forEach(t=>t.clearErrors()),this.successCalls.forEach(t=>t.clearErrors()),this.errorCalls.forEach(t=>t.clearErrors()),this.internalCalls.forEach(t=>t.clearErrors()),(e=this.dataType)==null||e.clearErrors(),this}validate(){const e=I9(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t,i;return[...this.errors,...((t=this.dataType)==null?void 0:t.getErrors())||[],...this.inputs.flatMap(a=>a.getErrors()),...this.internalCalls.flatMap(a=>a.getErrors()),...this.outputs.flatMap(a=>a.getErrors()),...((i=this.readsValue)==null?void 0:i.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return((e=this.dataType)==null?void 0:e.defaultValue)||null}clone(e){return new re(this.toJSON(),this.project)}addInternalCall(e){return this.internalCalls.find(t=>t===e)||this.internalCalls.push(e),this}createInstance(e=this.project,t={}){const i={id:t.id||$.UUID.uuid(),version:t.version||1,type:r.VariableInstance,parent:e.toReference(),successCalls:t.successCalls||[],errorCalls:t.errorCalls||[],inputs:t.inputs||[],outputs:t.outputs||[],writesValues:t.writesValues||[],internalCalls:t.internalCalls||[],readsValue:t.readsValue||null,calledByEntry:t.calledByEntry||[],calledBySuccess:t.calledBySuccess||[],calledByError:t.calledByError||[],declaration:this.toJSON(),x:0,y:0},a=R(i,this.project);return a.setParent(e),a.initChildren(),e===this.project&&this.project.addVariableInstance(a),a}generateUnusedInputs(){if(this.dataType)if(this.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.dataType.entity.type))return[...this.dataType.entity.properties,...this.dataType.entity.extendedProperties].filter(i=>!this.inputs.find(a=>a.declaration===i)).map(i=>{const a={id:$.UUID.uuid(),version:1,type:r.InputMap,parent:this.toReference(),name:null,description:null,dynamicArguments:[],declaration:i,defaultValue:null,index:i.index,readsValue:null},s=R(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,s})}else return[];else return[];return[]}generateUnusedOutputs(){if(this.dataType)if(this.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.dataType.entity.type))return[...this.dataType.entity.properties,...this.dataType.entity.extendedProperties].filter(i=>!this.outputs.find(a=>a.declaration===i)).map(i=>{const a={id:$.UUID.uuid(),version:1,type:r.OutputMap,parent:this.toReference(),declaration:i,index:i.index,writesValues:[]},s=R(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,s})}else return[];else return[];return[]}generateUnusedInternalCalls(){if(this.dataType)if(this.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.dataType.entity.type))return[...this.dataType.entity.getAllInteractiveMethods()].filter(i=>!this.internalCalls.find(s=>{var d,p,h,T,f;return(((d=s.declaration)==null?void 0:d.id)||((h=(p=s.initialData)==null?void 0:p.declaration)==null?void 0:h.entityId)||((f=(T=s.initialData)==null?void 0:T.declaration)==null?void 0:f.id))===i.id})).map(i=>{const a=i.createInternalCall(this);return a.suggestion=!0,a})}else return[];else return[];return[]}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(){return this.dataType||null}getUnusedInputs(){return this.inputs.filter(e=>e.suggestion||!e.readsValue&&!e.defaultValue)}getUnusedOutputs(){return this.outputs.filter(e=>e.suggestion||!e.writesValues.length)}getUsedInputs(){return this.inputs.filter(e=>!e.suggestion&&(e.readsValue||e.defaultValue))}getUsedOutputs(){return this.outputs.filter(e=>!e.suggestion&&e.writesValues.length)}};l(re,"MUTABLE_BASE_PROPERTIES",["name","description"]),l(re,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),l(re,"BASE_PROPERTIES",[...re.MUTABLE_BASE_PROPERTIES,...re.INMUTABLE_BASE_PROPERTIES]),l(re,"MUTABLE_META_PROPERTIES",[...re.MUTABLE_BASE_PROPERTIES,"x","y"]),l(re,"INMUTABLE_META_PROPERTIES",[...re.INMUTABLE_BASE_PROPERTIES]),l(re,"META_PROPERTIES",[...re.MUTABLE_META_PROPERTIES,...re.INMUTABLE_META_PROPERTIES]),l(re,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),l(re,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","dataType"]),l(re,"UPSTREAM_PROPERTIES",[...re.MUTABLE_UPSTREAM_PROPERTIES,...re.INMUTABLE_UPSTREAM_PROPERTIES]),l(re,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),l(re,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),l(re,"DOWNSTREAM_PROPERTIES",[...re.MUTABLE_DOWNSTREAM_PROPERTIES,...re.INMUTABLE_DOWNSTREAM_PROPERTIES]),l(re,"PROPERTIES",[...re.META_PROPERTIES,...re.UPSTREAM_PROPERTIES,...re.DOWNSTREAM_PROPERTIES]);let hr=re;function P9(n){const e=ax(),t=n.toJSON();e.safeParse(t).success,n.inputs.forEach(d=>d.validate()),n.outputs.forEach(d=>d.validate()),n.internalCalls.forEach(d=>d.validate());const s=[...En(n)];if(n.id==="exec-sequentially-result-variable-id"){const d=j({id:`${n.id}--${O.PropertyImplementsNonAbstact}`,message:`Property "${A(n,n.project)}" with id "${n.id}" implements a non-abstract property "${A(n,n.project)}" with id "${n.id}".`,issue:null,severity:m.Error,code:O.PropertyImplementsNonAbstact,entity:n});s.push(d.error)}const o=Id(n);return s.push(...o),X(n.errors,s)}const ie=class ie{constructor(e,t){l(this,"initialData");l(this,"id");l(this,"version");l(this,"x");l(this,"y");l(this,"type",r.VariableInstance);l(this,"writesValues",[]);l(this,"readsValue",null);l(this,"declaration");l(this,"inputs",[]);l(this,"outputs",[]);l(this,"calledBySuccess",[]);l(this,"calledByError",[]);l(this,"calledByEntry",[]);l(this,"successCalls",[]);l(this,"errorCalls",[]);l(this,"internalCalls",[]);l(this,"project");l(this,"errors",[]);l(this,"parent");l(this,"initialized",!1);l(this,"suggestion",!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 i=t;if(e.parent){const b=D(e.parent);i=t.get(b)}const a=D(e.declaration),s=t.get(a),o=e.calledByEntry.map(b=>{const I=D(b);return t.get(I)}),d=e.calledBySuccess.map(b=>{const I=D(b);return t.get(I)}),p=e.calledByError.map(b=>{const I=D(b);return t.get(I)});let h=null;if(e.readsValue){const b=D(e.readsValue);h=t.get(b)}const T={id:e.id,version:1,type:r.VariableInstance,declaration:s.toReference(),calledByEntry:o,calledBySuccess:d,calledByError:p,errorCalls:[],successCalls:[],internalCalls:[],readsValue:h,inputs:[],outputs:[],writesValues:[],x:0,y:0,parent:i},f=R(T,t);return f.setParent(i),f.initChildren(),f}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=Ge(i,{parent:{list:!1,types:[...st,r.Project],optional:!0},declaration:{list:!1,types:[r.VariableDeclaration]}},t);return i=s.modifiedData,a.push(...s.errors,...Ae(i)),{errors:a,modifiedData:i}}validateGeneratedUpdate(e){const t=[];let i=JSON.parse(JSON.stringify(e));const a=ua(i,this);return i=a.modifiedData,t.push(...a.errors),e.parent&&t.push(new E({id:`${this.id}--${y.InvalidParentUpdate}`,code:y.InvalidParentUpdate,severity:m.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
61
61
  If an entity is called by another, they must be in the same scope, which means they have the same parent.
62
62
  Specifically for variables, their scope is also calculated from their value readers and value writters.
63
- You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`,issue:null})),{errors:t,modifiedData:i}}addSelfToProject(){return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&this.readsValue.addValueReader(this),this.writesValues.forEach(e=>{e.setValueWriter(this)}),this.successCalls.forEach(e=>{e.addSuccessCaller(this)}),this.errorCalls.forEach(e=>{e.addErrorCaller(this)}),this.calledBySuccess.forEach(e=>{e.addSuccessCall(this)}),this.calledByError.forEach(e=>{e.addErrorCall(this)}),this.calledByEntry.forEach(e=>{e.addCall(this)}),this}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(e=>e.readsValue||e.dynamicArguments.length||e.defaultValue)}get unusedInputs(){return this.inputs.filter(e=>!e.readsValue&&!e.dynamicArguments.length&&!e.defaultValue)}get usedOutputs(){return this.outputs.filter(e=>e.writesValues.length)}get unusedOutputs(){return this.outputs.filter(e=>!e.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(e=>!!e.calledBy.length)}get unusedInternalCalls(){const e=this.usedInternalCalls;return this.internalCalls.filter(t=>{if(!t.calledBy.length||e.find(i=>i.id===t.id||i.declaration.id===t.declaration.id))return!1})}removeInput(e){const t=this.inputs.findIndex(i=>i.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(i=>i.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const i=this.errorCalls.findIndex(a=>a.id===e.id);return i>-1&&this.errorCalls.splice(i,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}addValueReader(e){return this.writesValues.includes(e)?this:(this.writesValues.push(e),this)}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===r.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!e)return this;this.declaration=e}else this.declaration=R(this.initialData.declaration,this.project),this.declaration.setParent(this.parent),this.declaration.initChildren();return ca.initWritesValues(this,this.parent),la.initReadsValue(this),this.inputs=this.initialData.inputs.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.successCalls=this.initialData.successCalls.map(e=>{const t=R(e,this.project);return t.addSuccessCaller(this),[r.BreakStatement,r.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==r.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=R(e,this.project);return t.addErrorCaller(this),[r.BreakStatement,r.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==r.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.internalCalls=this.initialData.internalCalls.reduce((e,t)=>{if(t.type===r.GenericReference){const i=this.project.findSubscribedInstanceFromReference(t);if(!i)return e;const a=i;return a.setParent(this),[...e,a]}else{const i=R(t,this.project);return i.setParent(this),i.initChildren(),[...e,i]}},[]),this.inputs.push(...this.generateUnusedInputs()),this.outputs.push(...this.generateUnusedOutputs()),this.internalCalls.push(...this.generateUnusedInternalCalls()),this}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,this}removeValueReader(e){return this.writesValues=this.writesValues.filter(t=>t.id!==e.id),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.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),ha(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const i=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.readsValue&&(i.push(this.readsValue),this.readsValue.removeValueReader(this)),this.writesValues.forEach(s=>{i.push(s),s.readsValue=null}),this.inputs.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),this.outputs.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),this.successCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),this.internalCalls.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),e||this.calledBy.forEach(s=>{i.push(s),s.removeCall(this)}),{affected:S(i),removed:S(a)})}restore({seenEntities:e}={seenEntities:new Set}){this.subscribe();const t=[];return this.readsValue&&(t.push(this.readsValue),this.readsValue.addValueReader(this)),this.writesValues.forEach(i=>{t.push(i),i.setValueWriter(this)}),this.inputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(i=>{t.push(i),i.addSuccessCaller(this)}),this.errorCalls.forEach(i=>{t.push(i),i.addErrorCaller(this)}),this.internalCalls.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.calledBySuccess.forEach(i=>{t.push(i),i.addSuccessCall(this)}),this.calledByError.forEach(i=>{t.push(i),i.addErrorCall(this)}),this.calledByEntry.forEach(i=>{t.push(i),i.addCall(this)}),{affected:S(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.writesValues.flatMap(i=>i.toFlat(e)),...this.successCalls.flatMap(i=>i.toFlat(e)),...this.errorCalls.flatMap(i=>i.toFlat(e)),...this.inputs.flatMap(i=>i.toFlat(e)),...this.outputs.flatMap(i=>i.toFlat(e)),...this.internalCalls.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.writesValues.flatMap(i=>i.toFlatIds(e)),...this.successCalls.flatMap(i=>i.toFlatIds(e)),...this.errorCalls.flatMap(i=>i.toFlatIds(e)),...this.inputs.flatMap(i=>i.toFlatIds(e)),...this.outputs.flatMap(i=>i.toFlatIds(e)),...this.internalCalls.flatMap(i=>i.toFlatIds(e))])}toJSON(){var e;return{id:this.id,version:this.version,type:this.type,declaration:this.declaration.toReference(),readsValue:((e=this.readsValue)==null?void 0:e.toReference())||null,writesValues:this.writesValues.map(t=>t.toJSON()),inputs:this.inputs.map(t=>t.toJSON()),outputs:this.outputs.map(t=>t.toJSON()),successCalls:this.successCalls.map(t=>t.toJSON()),errorCalls:this.errorCalls.map(t=>t.toJSON()),internalCalls:this.internalCalls.map(t=>t.toJSON()),calledBySuccess:this.calledBySuccess.map(t=>t.toReference()),calledByError:this.calledByError.map(t=>t.toReference()),calledByEntry:this.calledByEntry.map(t=>t.toReference()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+$.UUID.uuid()+"--ref",type:r.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:((e=this.declaration)==null?void 0:e.toReference())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(i=>i.toReference()),inputs:this.inputs.map(i=>i.toReference()),outputs:this.outputs.map(i=>i.toReference()),successCalls:this.successCalls.map(i=>i.toReference()),errorCalls:this.errorCalls.map(i=>i.toReference()),calledBySuccess:this.calledBySuccess.map(i=>i.toReference()),calledByError:this.calledByError.map(i=>i.toReference()),calledByEntry:this.calledByEntry.map(i=>i.toReference()),internalCalls:this.internalCalls.map(i=>i.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.declaration)==null?void 0:i.toFlatJSON(e))||[],...this.writesValues.flatMap(a=>a.toFlatJSON(e)),...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.internalCalls.flatMap(a=>a.toFlatJSON(e)),...this.calledBy.flatMap(a=>a.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===r.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){var i,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.declaration)==null?void 0:i.toFlatGenerationTarget(e))||[],...((a=this.readsValue)==null?void 0:a.toFlatGenerationTarget(e))||[],...this.writesValues.flatMap(s=>s.toFlatGenerationTarget(e)),...this.successCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.inputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.outputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.internalCalls.flatMap(s=>s.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.inputs.forEach(e=>e.clearErrors()),this.outputs.forEach(e=>e.clearErrors()),this.successCalls.forEach(e=>e.clearErrors()),this.errorCalls.forEach(e=>e.clearErrors()),this.internalCalls.forEach(e=>e.clearErrors()),this}validate(){const e=P9(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t;return[...this.errors,...this.inputs.flatMap(i=>i.getErrors()),...this.internalCalls.flatMap(i=>i.getErrors()),...this.outputs.flatMap(i=>i.getErrors()),...((t=this.readsValue)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e,t;return((t=(e=this.declaration)==null?void 0:e.dataType)==null?void 0:t.defaultValue)||null}clone(e){return new ie(this.toJSON(),this.project)}addInternalCall(e){return this.internalCalls.find(t=>t===e)||this.internalCalls.push(e),this}setDeclaration(e){return this.declaration!==e&&(this.declaration=e),this}generateUnusedInputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.properties,...this.declaration.dataType.entity.extendedProperties].filter(i=>!this.inputs.find(a=>a.declaration===i)).map(i=>{const a={id:$.UUID.uuid(),version:1,type:r.InputMap,parent:this.toReference(),name:null,description:null,dynamicArguments:[],declaration:i,defaultValue:null,index:i.index,readsValue:null},s=R(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,s})}else return[];else return[];return[]}generateUnusedOutputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.properties,...this.declaration.dataType.entity.extendedProperties].filter(i=>!this.outputs.find(a=>a.declaration===i)).map(i=>{const a={id:$.UUID.uuid(),version:1,type:r.OutputMap,parent:this.toReference(),declaration:i,index:i.index,writesValues:[]},s=R(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,s})}else return[];else return[];return[]}generateUnusedInternalCalls(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.getAllInteractiveMethods()].filter(i=>!this.internalCalls.find(s=>{var d,p,h,T,f;return(((d=s.declaration)==null?void 0:d.id)||((h=(p=s.initialData)==null?void 0:p.declaration)==null?void 0:h.entityId)||((f=(T=s.initialData)==null?void 0:T.declaration)==null?void 0:f.id))===i.id})).map(i=>{const a=i.createInternalCall(this);return a.suggestion=!0,a})}else return[];else return[];return[]}getDataType(){var e;return((e=this.declaration)==null?void 0:e.getDataType())||null}getUnusedInputs(){return this.inputs.filter(e=>e.suggestion||!e.readsValue&&!e.defaultValue)}getUnusedOutputs(){return this.outputs.filter(e=>e.suggestion||!e.writesValues.length)}getUsedInputs(){return this.inputs.filter(e=>!e.suggestion&&(e.readsValue||e.defaultValue))}getUsedOutputs(){return this.outputs.filter(e=>!e.suggestion&&e.writesValues.length)}};l(ie,"MUTABLE_BASE_PROPERTIES",[]),l(ie,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),l(ie,"BASE_PROPERTIES",[...ie.MUTABLE_BASE_PROPERTIES,...ie.INMUTABLE_BASE_PROPERTIES]),l(ie,"MUTABLE_META_PROPERTIES",[...ie.MUTABLE_BASE_PROPERTIES,"x","y"]),l(ie,"INMUTABLE_META_PROPERTIES",[...ie.INMUTABLE_BASE_PROPERTIES]),l(ie,"META_PROPERTIES",[...ie.MUTABLE_META_PROPERTIES,...ie.INMUTABLE_META_PROPERTIES]),l(ie,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),l(ie,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),l(ie,"UPSTREAM_PROPERTIES",[...ie.MUTABLE_UPSTREAM_PROPERTIES,...ie.INMUTABLE_UPSTREAM_PROPERTIES]),l(ie,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),l(ie,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),l(ie,"DOWNSTREAM_PROPERTIES",[...ie.MUTABLE_DOWNSTREAM_PROPERTIES,...ie.INMUTABLE_DOWNSTREAM_PROPERTIES]),l(ie,"PROPERTIES",[...ie.META_PROPERTIES,...ie.UPSTREAM_PROPERTIES,...ie.DOWNSTREAM_PROPERTIES]);let fr=ie;function D9(n){var s;const e=tU(),t=n.toJSON();e.safeParse(t).success,(s=n.dataType)==null||s.validate();const a=[];if(n.id==="iterate-over-employee-list-continue-statement-employee-dto-output-decl-id"){const o=j({id:`${n.id}--${O.PropertyImplementsNonAbstact}`,message:`Property "${A(n,n.project)}" with id "${n.id}" implements a non-abstract property "${A(n,n.project)}" with id "${n.id}".`,issue:null,severity:m.Error,code:O.PropertyImplementsNonAbstact,entity:n});a.push(o.error)}return X(n.errors,a)}const ae=class ae{constructor(e,t){l(this,"initialData");l(this,"id");l(this,"version");l(this,"name");l(this,"description",null);l(this,"index");l(this,"required");l(this,"isError");l(this,"type",r.ReturnDeclaration);l(this,"dataType",null);l(this,"readsValue",null);l(this,"project");l(this,"errors",[]);l(this,"parent");l(this,"initialized",!1);l(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.index=e.index,this.name=e.name,this.description=e.description,this.required=e.required,this.isError=e.isError}static fromGenerationTarget(e,t){const i=D(e.parent),a=t.get(i);let s=null;if(e.readsValue){const p=D(e.readsValue);s=t.get(p)}const o={id:e.id,version:1,name:e.name,type:r.ReturnDeclaration,index:a.outputs.length,isError:!1,description:e.description,required:e.required,readsValue:s,dataType:null,parent:a},d=R(o,t);return d.setParent(a),d.initChildren(),d}static validateGenerationTarget(e,t){var d,p;let i=JSON.parse(JSON.stringify(e));const a=[],s=Ge(i,{parent:{list:!1,types:[r.ReturnStatement,r.Search,r.BreakStatement,r.ContinueStatement]}},t),o=ud(i,t);if(i=s.modifiedData,i.parent){const h=t.get(D(i.parent));if(h&&[r.BreakStatement,r.ContinueStatement].includes(h.type)){const T=h,f=T.parent,b=[...f.breakStatements.filter(B=>B.id!==h.id),...f.continueStatements.filter(B=>B.id!==h.id)];if(T.outputs.length)a.push(new E({id:`${i.id}--${g.NoOverlapWithImplementedSignature}`,code:g.NoOverlapWithImplementedSignature,severity:m.Error,message:`Entity of type '${r.ReturnDeclaration}' with id '${i.id}' cannot be added to the parent entity of type '${T.type}' with id '${T.id}'. This '${T.type}' already has return declarations.
63
+ You shouldn't have to manually update a 'parent' property. The equivalent result is to change its value readers, value writters, or callers.`,issue:null})),{errors:t,modifiedData:i}}addSelfToProject(){return this.parent===this.project&&this.project.addVariableInstance(this),this.readsValue&&this.readsValue.addValueReader(this),this.writesValues.forEach(e=>{e.setValueWriter(this)}),this.successCalls.forEach(e=>{e.addSuccessCaller(this)}),this.errorCalls.forEach(e=>{e.addErrorCaller(this)}),this.calledBySuccess.forEach(e=>{e.addSuccessCall(this)}),this.calledByError.forEach(e=>{e.addErrorCall(this)}),this.calledByEntry.forEach(e=>{e.addCall(this)}),this}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}get usedInputs(){return this.inputs.filter(e=>e.readsValue||e.dynamicArguments.length||e.defaultValue)}get unusedInputs(){return this.inputs.filter(e=>!e.readsValue&&!e.dynamicArguments.length&&!e.defaultValue)}get usedOutputs(){return this.outputs.filter(e=>e.writesValues.length)}get unusedOutputs(){return this.outputs.filter(e=>!e.writesValues.length)}get usedInternalCalls(){return this.internalCalls.filter(e=>!!e.calledBy.length)}get unusedInternalCalls(){const e=this.usedInternalCalls;return this.internalCalls.filter(i=>!(e.find(o=>o.id===i.id)||e.find(o=>o.declaration===i.declaration)))}removeInput(e){const t=this.inputs.findIndex(i=>i.id===e.id);return t>-1&&this.inputs.splice(t,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(i=>i.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const i=this.errorCalls.findIndex(a=>a.id===e.id);return i>-1&&this.errorCalls.splice(i,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}addValueReader(e){return this.writesValues.includes(e)?this:(this.writesValues.push(e),this)}setParent(e){return this.parent=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.declaration.type===r.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.declaration);if(!e)return this;this.declaration=e}else this.declaration=R(this.initialData.declaration,this.project),this.declaration.setParent(this.parent),this.declaration.initChildren();return ca.initWritesValues(this,this.parent),la.initReadsValue(this),this.inputs=this.initialData.inputs.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.successCalls=this.initialData.successCalls.map(e=>{const t=R(e,this.project);return t.addSuccessCaller(this),[r.BreakStatement,r.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==r.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=R(e,this.project);return t.addErrorCaller(this),[r.BreakStatement,r.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==r.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.internalCalls=this.initialData.internalCalls.reduce((e,t)=>{if(t.type===r.GenericReference){const i=this.project.findSubscribedInstanceFromReference(t);if(!i)return e;const a=i;return a.setParent(this),[...e,a]}else{const i=R(t,this.project);return i.setParent(this),i.initChildren(),[...e,i]}},[]),this.inputs.push(...this.generateUnusedInputs()),this.outputs.push(...this.generateUnusedOutputs()),this.internalCalls.push(...this.generateUnusedInternalCalls()),this}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,this}removeValueReader(e){return this.writesValues=this.writesValues.filter(t=>t.id!==e.id),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.x=e.x||this.x,this.y=e.y||this.y,this}async load(){return this}async create(){return this}async update(e){return this.sync(e),ha(e,this),this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const i=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.readsValue&&(i.push(this.readsValue),this.readsValue.removeValueReader(this)),this.writesValues.forEach(s=>{i.push(s),s.readsValue=null}),this.inputs.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),this.outputs.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),this.successCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),this.internalCalls.forEach(s=>{const{affected:o,removed:d}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...d)}),e||this.calledBy.forEach(s=>{i.push(s),s.removeCall(this)}),{affected:S(i),removed:S(a)})}restore({seenEntities:e}={seenEntities:new Set}){this.subscribe();const t=[];return this.readsValue&&(t.push(this.readsValue),this.readsValue.addValueReader(this)),this.writesValues.forEach(i=>{t.push(i),i.setValueWriter(this)}),this.inputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(i=>{t.push(i),i.addSuccessCaller(this)}),this.errorCalls.forEach(i=>{t.push(i),i.addErrorCaller(this)}),this.internalCalls.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.calledBySuccess.forEach(i=>{t.push(i),i.addSuccessCall(this)}),this.calledByError.forEach(i=>{t.push(i),i.addErrorCall(this)}),this.calledByEntry.forEach(i=>{t.push(i),i.addCall(this)}),{affected:S(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.writesValues.flatMap(i=>i.toFlat(e)),...this.successCalls.flatMap(i=>i.toFlat(e)),...this.errorCalls.flatMap(i=>i.toFlat(e)),...this.inputs.flatMap(i=>i.toFlat(e)),...this.outputs.flatMap(i=>i.toFlat(e)),...this.internalCalls.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.writesValues.flatMap(i=>i.toFlatIds(e)),...this.successCalls.flatMap(i=>i.toFlatIds(e)),...this.errorCalls.flatMap(i=>i.toFlatIds(e)),...this.inputs.flatMap(i=>i.toFlatIds(e)),...this.outputs.flatMap(i=>i.toFlatIds(e)),...this.internalCalls.flatMap(i=>i.toFlatIds(e))])}toJSON(){var e;return{id:this.id,version:this.version,type:this.type,declaration:this.declaration.toReference(),readsValue:((e=this.readsValue)==null?void 0:e.toReference())||null,writesValues:this.writesValues.map(t=>t.toJSON()),inputs:this.inputs.map(t=>t.toJSON()),outputs:this.outputs.map(t=>t.toJSON()),successCalls:this.successCalls.map(t=>t.toJSON()),errorCalls:this.errorCalls.map(t=>t.toJSON()),internalCalls:this.internalCalls.map(t=>t.toJSON()),calledBySuccess:this.calledBySuccess.map(t=>t.toReference()),calledByError:this.calledByError.map(t=>t.toReference()),calledByEntry:this.calledByEntry.map(t=>t.toReference()),parent:this.parent.toReference(),x:this.x,y:this.y}}toReference(){return{id:this.id+"--"+$.UUID.uuid()+"--ref",type:r.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,declaration:((e=this.declaration)==null?void 0:e.toReference())||null,readsValue:((t=this.readsValue)==null?void 0:t.toReference())||null,writesValues:this.writesValues.map(i=>i.toReference()),inputs:this.inputs.map(i=>i.toReference()),outputs:this.outputs.map(i=>i.toReference()),successCalls:this.successCalls.map(i=>i.toReference()),errorCalls:this.errorCalls.map(i=>i.toReference()),calledBySuccess:this.calledBySuccess.map(i=>i.toReference()),calledByError:this.calledByError.map(i=>i.toReference()),calledByEntry:this.calledByEntry.map(i=>i.toReference()),internalCalls:this.internalCalls.map(i=>i.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.declaration)==null?void 0:i.toFlatJSON(e))||[],...this.writesValues.flatMap(a=>a.toFlatJSON(e)),...this.successCalls.flatMap(a=>a.toFlatJSON(e)),...this.errorCalls.flatMap(a=>a.toFlatJSON(e)),...this.inputs.flatMap(a=>a.toFlatJSON(e)),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.internalCalls.flatMap(a=>a.toFlatJSON(e)),...this.calledBy.flatMap(a=>a.toFlatJSON(e))])}toGenerationTarget(){const e=this.parent.type===r.Project?void 0:this.parent.id;return{id:this.id,type:this.type,declaration:this.declaration.id,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){var i,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.declaration)==null?void 0:i.toFlatGenerationTarget(e))||[],...((a=this.readsValue)==null?void 0:a.toFlatGenerationTarget(e))||[],...this.writesValues.flatMap(s=>s.toFlatGenerationTarget(e)),...this.successCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(s=>s.toFlatGenerationTarget(e)),...this.inputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.outputs.flatMap(s=>s.toFlatGenerationTarget(e)),...this.internalCalls.flatMap(s=>s.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.inputs.forEach(e=>e.clearErrors()),this.outputs.forEach(e=>e.clearErrors()),this.successCalls.forEach(e=>e.clearErrors()),this.errorCalls.forEach(e=>e.clearErrors()),this.internalCalls.forEach(e=>e.clearErrors()),this}validate(){const e=P9(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t;return[...this.errors,...this.inputs.flatMap(i=>i.getErrors()),...this.internalCalls.flatMap(i=>i.getErrors()),...this.outputs.flatMap(i=>i.getErrors()),...((t=this.readsValue)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e,t;return((t=(e=this.declaration)==null?void 0:e.dataType)==null?void 0:t.defaultValue)||null}clone(e){return new ie(this.toJSON(),this.project)}addInternalCall(e){return this.internalCalls.find(t=>t===e)||this.internalCalls.push(e),this}setDeclaration(e){return this.declaration!==e&&(this.declaration=e),this}generateUnusedInputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.properties,...this.declaration.dataType.entity.extendedProperties].filter(i=>!this.inputs.find(a=>a.declaration===i)).map(i=>{const a={id:$.UUID.uuid(),version:1,type:r.InputMap,parent:this.toReference(),name:null,description:null,dynamicArguments:[],declaration:i,defaultValue:null,index:i.index,readsValue:null},s=R(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,s})}else return[];else return[];return[]}generateUnusedOutputs(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.properties,...this.declaration.dataType.entity.extendedProperties].filter(i=>!this.outputs.find(a=>a.declaration===i)).map(i=>{const a={id:$.UUID.uuid(),version:1,type:r.OutputMap,parent:this.toReference(),declaration:i,index:i.index,writesValues:[]},s=R(a,this.project);return s.setParent(this),s.initChildren(),s.suggestion=!0,s})}else return[];else return[];return[]}generateUnusedInternalCalls(){if(this.declaration.dataType)if(this.declaration.dataType.entity){if([r.CustomEntity,r.PrimitiveEntity,r.BuiltInBaseEntity].includes(this.declaration.dataType.entity.type))return[...this.declaration.dataType.entity.getAllInteractiveMethods()].filter(i=>!this.internalCalls.find(s=>{var d,p,h,T,f;return(((d=s.declaration)==null?void 0:d.id)||((h=(p=s.initialData)==null?void 0:p.declaration)==null?void 0:h.entityId)||((f=(T=s.initialData)==null?void 0:T.declaration)==null?void 0:f.id))===i.id})).map(i=>{const a=i.createInternalCall(this);return a.suggestion=!0,a})}else return[];else return[];return[]}getDataType(){var e;return((e=this.declaration)==null?void 0:e.getDataType())||null}getUnusedInputs(){return this.inputs.filter(e=>e.suggestion||!e.readsValue&&!e.defaultValue)}getUnusedOutputs(){return this.outputs.filter(e=>e.suggestion||!e.writesValues.length)}getUsedInputs(){return this.inputs.filter(e=>!e.suggestion&&(e.readsValue||e.defaultValue))}getUsedOutputs(){return this.outputs.filter(e=>!e.suggestion&&e.writesValues.length)}};l(ie,"MUTABLE_BASE_PROPERTIES",[]),l(ie,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),l(ie,"BASE_PROPERTIES",[...ie.MUTABLE_BASE_PROPERTIES,...ie.INMUTABLE_BASE_PROPERTIES]),l(ie,"MUTABLE_META_PROPERTIES",[...ie.MUTABLE_BASE_PROPERTIES,"x","y"]),l(ie,"INMUTABLE_META_PROPERTIES",[...ie.INMUTABLE_BASE_PROPERTIES]),l(ie,"META_PROPERTIES",[...ie.MUTABLE_META_PROPERTIES,...ie.INMUTABLE_META_PROPERTIES]),l(ie,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry","readsValue"]),l(ie,"INMUTABLE_UPSTREAM_PROPERTIES",["declaration","parent"]),l(ie,"UPSTREAM_PROPERTIES",[...ie.MUTABLE_UPSTREAM_PROPERTIES,...ie.INMUTABLE_UPSTREAM_PROPERTIES]),l(ie,"MUTABLE_DOWNSTREAM_PROPERTIES",["writesValues","inputs","outputs","successCalls","errorCalls","internalCalls"]),l(ie,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),l(ie,"DOWNSTREAM_PROPERTIES",[...ie.MUTABLE_DOWNSTREAM_PROPERTIES,...ie.INMUTABLE_DOWNSTREAM_PROPERTIES]),l(ie,"PROPERTIES",[...ie.META_PROPERTIES,...ie.UPSTREAM_PROPERTIES,...ie.DOWNSTREAM_PROPERTIES]);let fr=ie;function D9(n){var s;const e=tU(),t=n.toJSON();e.safeParse(t).success,(s=n.dataType)==null||s.validate();const a=[];if(n.id==="iterate-over-employee-list-continue-statement-employee-dto-output-decl-id"){const o=j({id:`${n.id}--${O.PropertyImplementsNonAbstact}`,message:`Property "${A(n,n.project)}" with id "${n.id}" implements a non-abstract property "${A(n,n.project)}" with id "${n.id}".`,issue:null,severity:m.Error,code:O.PropertyImplementsNonAbstact,entity:n});a.push(o.error)}return X(n.errors,a)}const ae=class ae{constructor(e,t){l(this,"initialData");l(this,"id");l(this,"version");l(this,"name");l(this,"description",null);l(this,"index");l(this,"required");l(this,"isError");l(this,"type",r.ReturnDeclaration);l(this,"dataType",null);l(this,"readsValue",null);l(this,"project");l(this,"errors",[]);l(this,"parent");l(this,"initialized",!1);l(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.index=e.index,this.name=e.name,this.description=e.description,this.required=e.required,this.isError=e.isError}static fromGenerationTarget(e,t){const i=D(e.parent),a=t.get(i);let s=null;if(e.readsValue){const p=D(e.readsValue);s=t.get(p)}const o={id:e.id,version:1,name:e.name,type:r.ReturnDeclaration,index:a.outputs.length,isError:!1,description:e.description,required:e.required,readsValue:s,dataType:null,parent:a},d=R(o,t);return d.setParent(a),d.initChildren(),d}static validateGenerationTarget(e,t){var d,p;let i=JSON.parse(JSON.stringify(e));const a=[],s=Ge(i,{parent:{list:!1,types:[r.ReturnStatement,r.Search,r.BreakStatement,r.ContinueStatement]}},t),o=ud(i,t);if(i=s.modifiedData,i.parent){const h=t.get(D(i.parent));if(h&&[r.BreakStatement,r.ContinueStatement].includes(h.type)){const T=h,f=T.parent,b=[...f.breakStatements.filter(B=>B.id!==h.id),...f.continueStatements.filter(B=>B.id!==h.id)];if(T.outputs.length)a.push(new E({id:`${i.id}--${g.NoOverlapWithImplementedSignature}`,code:g.NoOverlapWithImplementedSignature,severity:m.Error,message:`Entity of type '${r.ReturnDeclaration}' with id '${i.id}' cannot be added to the parent entity of type '${T.type}' with id '${T.id}'. This '${T.type}' already has return declarations.
64
64
  ${Td}`,issue:null}));else{const B=(p=(d=b[0])==null?void 0:d.outputs[0])==null?void 0:p.name;B!==i.name&&a.push(new E({id:`${i.id}--${g.NoOverlapWithImplementedSignature}`,code:g.NoOverlapWithImplementedSignature,severity:m.Error,message:`Entity of type '${r.ReturnDeclaration}' with id '${i.id}' cannot be added to the parent entity of type '${T.type}' with id '${T.id}'. This new 'return-declaration' doesn't have the same name "${B}" as the return declarations on the other statements in the same scope.
65
65
  ${Td}`,issue:null}))}}else if(h&&h.type===r.ReturnStatement){const T=h.parent;if(T&&Me.includes(T.type)){const f=T.implements;if(f)if(f.returnsType===L.Fixed){const b=f.fixedReturns.find(Le=>Le.name===i.name),I=f.fixedReturns.filter(Le=>!h.outputs.find(Qv=>Qv.type===r.ReturnDeclaration&&Qv.name===Le.name)),B=h.outputs.filter(Le=>Le.type===r.ReturnDeclaration),G=B.find(Le=>Le.name===i.name),q=B.length?`The parent entity already implements the following return declarations: ${N(B.map(Le=>`'${Le.id}' (${Le.name})`),", "," and ")}.`:"The parent entity does not yet have any implemented return declarations.",jt=I.length?`The parent entity is still missing the following returns in the implementation: ${N(I.map(Le=>`'${Le.id}' (${Le.name})`),", "," and ")}.`:"The parent entity has all the returns it needs implemented.";b?G&&a.push(new E({id:`${i.id}--${g.NoOverlapWithImplementedSignature}`,code:g.NoOverlapWithImplementedSignature,severity:m.Error,message:`Entity of type '${r.ReturnDeclaration}' with id '${i.id}' should not exist in a parent entity of type '${h.type}' with id '${h.id}' that implements a ${r.ActionDescriptor} with fixed outputs.
66
66
  Adding a new return would make the implementation invalid. An return with the same name already exists in the parent entity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6006",
3
+ "version": "0.0.6008",
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",