@elyx-code/project-logic-tree 0.0.6077 → 0.0.6078
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 +12 -0
- package/dist/index.umd.cjs +1 -1
- package/dist/tree/state/loop/loop.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27616,6 +27616,18 @@ ${uo(t)}`,
|
|
|
27616
27616
|
);
|
|
27617
27617
|
return t.slice(0, t.length - 1);
|
|
27618
27618
|
}
|
|
27619
|
+
static fromLoopOutputDeclarationToBodyArgumentDeclarationName(e) {
|
|
27620
|
+
return e.name.replace(
|
|
27621
|
+
"Result list of '",
|
|
27622
|
+
"Previous iteration results of '"
|
|
27623
|
+
);
|
|
27624
|
+
}
|
|
27625
|
+
static fromBodyArgumentDeclarationToLoopOutputDeclarationName(e) {
|
|
27626
|
+
return e.name.replace(
|
|
27627
|
+
"Previous iteration results of '",
|
|
27628
|
+
"Result list of '"
|
|
27629
|
+
);
|
|
27630
|
+
}
|
|
27619
27631
|
validateGeneratedUpdate(e) {
|
|
27620
27632
|
const t = [];
|
|
27621
27633
|
return e.parent && t.push(
|
package/dist/index.umd.cjs
CHANGED
|
@@ -48,7 +48,7 @@ ${Lo(t)}`,issue:null}));else{const p=t.events.find(y=>y.implements.id===e.implem
|
|
|
48
48
|
You can attach new logic to the existing 'global-event' but creating a new callable entity that gets called by it.`,issue:null}))}return{errors:a,modifiedData:i}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new E({id:`${this.id}--${f.InvalidParentUpdate}`,code:f.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an '${this.type}', must be the root project as it is a globally declared entity.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],i=[];return this.project.addGlobalEvent(this),{updated:b(e),added:b(t),removed:b(i),self:this}}replaceDetachedChild(e,t){const i=this.detachedChildren.indexOf(e);return i!==-1&&(this.detachedChildren[i]=t),this}subscribeDetachedChild(e){return this.detachedChildren.includes(e)||this.detachedChildren.push(e),this}setParent(e){return this.parent=e,this}addCall(e){return this.calls.includes(e)||this.calls.push(e),this}removeCall(e){const t=this.calls.indexOf(e);return t!==-1&&this.calls.splice(t,1),this}addInputDeclaration(e){return this.inputs.includes(e)||this.inputs.push(e),this}removeInputDeclaration(e){const t=this.inputs.findIndex(i=>i.id===e.id);return t>-1&&this.inputs.splice(t,1),this}initChildren(){return this.initialized?this:(this.initialized=!0,this.inputs=this.initialData.inputs.map(e=>{const t=v(e,this.project);return t.setParent(this),t.initChildren(),t}),this.calls=this.initialData.calls.map(e=>{const t=v(e,this.project);return t.addEntryCaller(this),t.type!==n.InternalCall&&(t.setParent(this),t.initChildren()),t}),this.returnStatements=this.initialData.returnStatements.map(e=>{const t=v(e,this.project);return t.setParent(this),t.initChildren(),t}),this.implements=v(this.initialData.implements,this.project),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.x=e.x||this.x,this.y=e.y||this.y,this.collapsed=e.collapsed!==void 0?e.collapsed:this.collapsed,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 i=[],a=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.inputs.forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...p)}),St(this).forEach(o=>{const{affected:l,removed:p}=o.remove({ignoreUpstream:!0,seenEntities:t});i.push(...l),a.push(...p)}),{affected:b(i),removed:b(a)})}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputs.forEach(a=>{const{affected:s}=a.restore({seenEntities:e});t.push(...s)}),St(this).forEach(a=>{const{affected:s}=a.restore({seenEntities:e});t.push(...s)}),{affected:b(t),self:this})}toFlat(e=new Set){if(e.has(this.id))return[];e.add(this.id);const t=St(this);return[this,...this.inputs.flatMap(a=>a.toFlat(e)),...this.calls.flatMap(a=>a.toFlat(e)),...this.returnStatements.flatMap(a=>a.toFlat(e)),...this.implements?this.implements.toFlat(e):[],...t.flatMap(a=>a.toFlat(e))]}toFlatIds(e=new Set){if(e.has(this.id))return[];e.add(this.id);const t=St(this);return[this.id,...this.inputs.flatMap(a=>a.toFlatIds(e)),...this.calls.flatMap(a=>a.toFlatIds(e)),...this.returnStatements.flatMap(a=>a.toFlatIds(e)),...this.implements?this.implements.toFlatIds(e):[],...t.flatMap(a=>a.toFlatIds(e))]}toJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,x:this.x,y:this.y,collapsed:this.collapsed,implements:this.implements.toJSON(),returnStatements:this.returnStatements.map(e=>e.toJSON()),inputs:this.inputs.map(e=>e.toJSON()),calls:this.calls.map(e=>e.toJSON()),parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){return{id:this.id,version:this.version,type:this.type,name:this.name,collapsed:this.collapsed,x:this.x,y:this.y,implements:this.implements.toReference(),inputs:this.inputs.map(e=>e.toReference()),calls:this.calls.map(e=>e.toReference()),returnStatements:this.returnStatements.map(e=>e.toReference()),parent:this.parent.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.inputs.flatMap(i=>i.toFlatJSON(e)),...this.calls.flatMap(i=>i.toFlatJSON(e)),...this.returnStatements.flatMap(i=>i.toFlatJSON(e))])}toGenerationTarget(){return{id:this.id,name:this.name,type:this.type,implements:this.implements.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.inputs.flatMap(i=>i.toFlatGenerationTarget(e)),...this.calls.flatMap(i=>i.toFlatGenerationTarget(e)),...this.returnStatements.flatMap(i=>i.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.inputs.forEach(e=>e.clearErrors()),this.calls.forEach(e=>e.clearErrors()),this.returnStatements.forEach(e=>e.clearErrors()),this}validate(){const e=c2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){const e=St(this);return[...this.errors,...this.inputs.flatMap(i=>i.getErrors()),...e.flatMap(i=>i.getErrors())]}getShallowErrors(){return this.errors}clone(){return new de(this.toJSON(),this.project)}getVariableInstances(){return re(this).filter(i=>i.type===n.VariableInstance)}addReturnStatement(e){return this.returnStatements.includes(e)||this.returnStatements.push(e),this}removeReturnStatement(e){const t=this.returnStatements.indexOf(e);return t!==-1&&this.returnStatements.splice(t,1),this}};d(de,"MUTABLE_BASE_PROPERTIES",["description"]),d(de,"INMUTABLE_BASE_PROPERTIES",["id","version","name","type"]),d(de,"BASE_PROPERTIES",[...de.MUTABLE_BASE_PROPERTIES,...de.INMUTABLE_BASE_PROPERTIES]),d(de,"MUTABLE_META_PROPERTIES",[...de.MUTABLE_BASE_PROPERTIES,"x","y","collapsed"]),d(de,"INMUTABLE_META_PROPERTIES",[...de.INMUTABLE_BASE_PROPERTIES]),d(de,"META_PROPERTIES",[...de.MUTABLE_META_PROPERTIES,...de.INMUTABLE_META_PROPERTIES]),d(de,"MUTABLE_UPSTREAM_PROPERTIES",[]),d(de,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements"]),d(de,"UPSTREAM_PROPERTIES",[...de.MUTABLE_UPSTREAM_PROPERTIES,...de.INMUTABLE_UPSTREAM_PROPERTIES]),d(de,"MUTABLE_DOWNSTREAM_PROPERTIES",["inputs","calls","returnStatements"]),d(de,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),d(de,"DOWNSTREAM_PROPERTIES",[...de.MUTABLE_DOWNSTREAM_PROPERTIES,...de.INMUTABLE_DOWNSTREAM_PROPERTIES]),d(de,"PROPERTIES",[...de.META_PROPERTIES,...de.UPSTREAM_PROPERTIES,...de.DOWNSTREAM_PROPERTIES]);let Oi=de;function d2(r){var o,l;const e=N9(),t=r.toJSON();e.safeParse(t).success,r.inputs.forEach(p=>p.validate()),r.outputs.forEach(p=>p.validate()),(o=r.error)==null||o.validate(),(l=r.body)==null||l.validate();const s=[...Cn(r)];return ie(r.errors,s)}const z=class z{constructor(e,t){d(this,"initialData");d(this,"id");d(this,"version");d(this,"x");d(this,"y");d(this,"type",n.Loop);d(this,"declaration");d(this,"inputs",[]);d(this,"outputs",[]);d(this,"process",null);d(this,"successCalls",[]);d(this,"errorCalls",[]);d(this,"error",null);d(this,"breakStatements",[]);d(this,"continueStatements",[]);d(this,"outputsDeclarations",[]);d(this,"body");d(this,"calledBySuccess",[]);d(this,"calledByError",[]);d(this,"calledByEntry",[]);d(this,"parent");d(this,"detachedChildren",[]);d(this,"currentIterationNumberArgumentDeclaration");d(this,"currentValueArgumentDeclaration",null);d(this,"errors",[]);d(this,"project");d(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 i=t;if(e.parent){const m=N(e.parent);i=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.Loop,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,process:null,errorCalls:[],successCalls:[],inputs:[],outputs:[],body:null,breakStatements:[],continueStatements:[],outputsDeclarations:[],error:null,x:0,y:0,parent:i},h=v(y,t);return h.setParent(i),h.initChildren(),h}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=He(i,{parent:{list:!1,types:[...ut,n.Project],optional:!0},declaration:{list:!1,types:[n.ActionDescriptor]}},t);return i=s.modifiedData,a.push(...s.errors,...Le(i)),e.declaration?t.get(e.declaration)?t.conditionDeclarations.find(p=>p.id===e.declaration)||a.push(new E({id:`${e.id}--${f.InvalidImplementsReference}`,code:f.InvalidImplementsReference,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't pointing to an action descriptor reserved for '${n.Condition}' entities.
|
|
49
49
|
${Go(t)}`,issue:null})):a.push(new E({id:`${e.id}--${f.ReferencedEntityNotFound}`,code:f.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't found in the project. The 'declaration' property must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
|
|
50
50
|
${Go(t)}`,issue:null})):a.push(new E({id:`${e.id}--${S.InvalidObjectStructure}`,code:S.InvalidObjectStructure,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' is missing the 'declaration' property. This property is required for a '${e.type}' entity and must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
|
|
51
|
-
${Go(t)}`,issue:null})),{errors:a,modifiedData:i}}static fromReturnDeclarationToBodyArgumentDeclarationName(e){return`Previous iteration results of '${C(e,e.project)}'`}static fromBodyArgumentDeclarationToReturnDeclarationName(e){const t=e.name.replace("Previous iteration results of '","");return t.slice(0,t.length-1)}static fromReturnDeclarationToLoopOutputDeclarationName(e){return`Result list of '${C(e,e.project)}'`}static fromLoopOutputDeclarationToReturnDeclarationName(e){const t=e.name.replace("Result list of '","");return t.slice(0,t.length-1)}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new E({id:`${this.id}--${f.InvalidParentUpdate}`,code:f.InvalidParentUpdate,severity:T.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.
|
|
51
|
+
${Go(t)}`,issue:null})),{errors:a,modifiedData:i}}static fromReturnDeclarationToBodyArgumentDeclarationName(e){return`Previous iteration results of '${C(e,e.project)}'`}static fromBodyArgumentDeclarationToReturnDeclarationName(e){const t=e.name.replace("Previous iteration results of '","");return t.slice(0,t.length-1)}static fromReturnDeclarationToLoopOutputDeclarationName(e){return`Result list of '${C(e,e.project)}'`}static fromLoopOutputDeclarationToReturnDeclarationName(e){const t=e.name.replace("Result list of '","");return t.slice(0,t.length-1)}static fromLoopOutputDeclarationToBodyArgumentDeclarationName(e){return e.name.replace("Result list of '","Previous iteration results of '")}static fromBodyArgumentDeclarationToLoopOutputDeclarationName(e){return e.name.replace("Previous iteration results of '","Result list of '")}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new E({id:`${this.id}--${f.InvalidParentUpdate}`,code:f.InvalidParentUpdate,severity:T.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.
|
|
52
52
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
53
53
|
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],i=[];return this.parent===this.project&&this.project.addLoop(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:b(e),added:b(t),removed:b(i),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}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)}addOutputDeclaration(e){return this.outputsDeclarations.includes(e)?this:(this.outputsDeclarations.push(e),this)}removeOutputDeclaration(e){const t=this.outputsDeclarations.findIndex(i=>i.id===e.id);return t>-1&&this.outputsDeclarations.splice(t,1),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}setBody(e){return this.body=e,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}replaceDetachedChild(e,t){const i=this.detachedChildren.indexOf(e);return i!==-1&&(this.detachedChildren[i]=t),this}subscribeDetachedChild(e){return this.detachedChildren.includes(e)||this.detachedChildren.push(e),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.declaration=v(this.initialData.declaration,this.project),this.successCalls=this.initialData.successCalls.map(e=>{const t=v(e,this.project);return t.addSuccessCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=v(e,this.project);return t.addErrorCaller(this),[n.BreakStatement,n.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==n.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputs=this.initialData.inputs.map(e=>{const t=v(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=v(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.process&&(this.process=v(this.initialData.process,this.project),this.process.setParent(this),this.process.initChildren()),this.initialData.body&&(this.body=v(this.initialData.body,this.project),this.body.setParent(this),this.body.initChildren()),this.initialData.error&&(this.error=v(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),this.syncChildren(),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}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.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...l)}),this.body.remove({ignoreUpstream:!0,seenEntities:t}),this.error){const{affected:s,removed:o}=this.error.remove({ignoreUpstream:!0,seenEntities:t});i.push(...s),a.push(...o)}return this.successCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{i.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{i.push(s),s.removeCall(this)}),{affected:b(i),removed:b(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),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.body.restore({seenEntities:e}),this.successCalls.forEach(i=>{t.push(i),i.addSuccessCaller(this)}),this.errorCalls.forEach(i=>{t.push(i),i.addErrorCaller(this)}),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:b(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.inputs.flatMap(i=>i.toFlat(e)),...this.outputs.flatMap(i=>i.toFlat(e)),...this.process?this.process.toFlat(e):[],...this.successCalls.flatMap(i=>i.toFlat(e)),...this.errorCalls.flatMap(i=>i.toFlat(e)),...this.error?this.error.toFlat(e):[],...this.body?this.body.toFlat(e):[],...this.continueStatements.flatMap(i=>i.toFlat(e)),...this.breakStatements.flatMap(i=>i.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.inputs.flatMap(i=>i.toFlatIds(e)),...this.outputs.flatMap(i=>i.toFlatIds(e)),...this.process?this.process.toFlatIds(e):[],...this.successCalls.flatMap(i=>i.toFlatIds(e)),...this.errorCalls.flatMap(i=>i.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[],...this.body?this.body.toFlatIds(e):[],...this.continueStatements.flatMap(i=>i.toFlatIds(e)),...this.breakStatements.flatMap(i=>i.toFlatIds(e))])}toJSON(){var e,t;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,calledBySuccess:this.calledBySuccess.map(i=>i.toReference()),calledByError:this.calledByError.map(i=>i.toReference()),calledByEntry:this.calledByEntry.map(i=>i.toReference()),process:((e=this.process)==null?void 0:e.toJSON())||null,declaration:this.declaration.toJSON(),inputs:this.inputs.map(i=>i.toJSON()),outputs:this.outputs.map(i=>i.toJSON()),outputsDeclarations:this.outputsDeclarations.map(i=>i.toJSON()),successCalls:this.successCalls.map(i=>i.toJSON()),errorCalls:this.errorCalls.map(i=>i.toJSON()),error:((t=this.error)==null?void 0:t.toJSON())||null,body:this.body.toJSON(),parent:this.parent.toReference(),breakStatements:this.breakStatements.map(i=>i.toJSON()),continueStatements:this.continueStatements.map(i=>i.toJSON())}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,i,a;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,body:((t=this.body)==null?void 0:t.toReference())||null,inputs:this.inputs.map(s=>s.toReference()),outputs:this.outputs.map(s=>s.toReference()),outputsDeclarations:this.outputsDeclarations.map(s=>s.toReference()),successCalls:this.successCalls.map(s=>s.toReference()),errorCalls:this.errorCalls.map(s=>s.toReference()),process:((i=this.process)==null?void 0:i.toReference())||null,calledBySuccess:this.calledBySuccess.map(s=>s.toReference()),calledByError:this.calledByError.map(s=>s.toReference()),calledByEntry:this.calledByEntry.map(s=>s.toReference()),continueStatements:this.continueStatements.map(s=>s.toReference()),breakStatements:this.breakStatements.map(s=>s.toReference()),error:((a=this.error)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.body)==null?void 0:i.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.continueStatements.flatMap(a=>a.toFlatJSON(e)),...this.breakStatements.flatMap(a=>a.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[],...this.process?this.process.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===n.Project?void 0:this.parent.id;return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),declaration:this.declaration.id,parent:e}}toFlatGenerationTarget(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.body)==null?void 0:i.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.continueStatements.flatMap(a=>a.toFlatGenerationTarget(e)),...this.breakStatements.flatMap(a=>a.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[],...this.process?this.process.toFlatGenerationTarget(e):[]])}clearErrors(){var e,t;return this.errors=[],this.inputs.forEach(i=>i.clearErrors()),this.outputs.forEach(i=>i.clearErrors()),this.successCalls.forEach(i=>i.clearErrors()),this.errorCalls.forEach(i=>i.clearErrors()),this.continueStatements.forEach(i=>i.clearErrors()),this.breakStatements.forEach(i=>i.clearErrors()),(e=this.process)==null||e.clearErrors(),(t=this.error)==null||t.clearErrors(),this}validate(){const e=d2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputs.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.body?this.body.getErrors():[],...this.error?this.error.getErrors():[],...this.process?this.process.getErrors():[]]}getShallowErrors(){return this.errors}clone(e){return new z(this.toJSON(),this.project)}getVariableInstances(){return this.body?re(this.body).filter(i=>i.type===n.VariableInstance):[]}addReturnStatement(e){return Ue.includes(this.parent.type)&&this.parent.addReturnStatement(e),this}removeReturnStatement(e){return Ue.includes(this.parent.type)&&this.parent.removeReturnStatement(e),this}addBreakStatement(e){return this.breakStatements.includes(e)||this.breakStatements.push(e),this}removeBreakStatement(e){const t=this.breakStatements.indexOf(e);return t!==-1&&this.breakStatements.splice(t,1),this}addContinueStatement(e){return this.continueStatements.includes(e)||this.continueStatements.push(e),this}removeContinueStatement(e){const t=this.continueStatements.indexOf(e);return t!==-1&&this.continueStatements.splice(t,1),this}getUniqueReturnDeclarations(){const e=[];return[...this.breakStatements,...this.continueStatements].forEach(i=>{i.outputs.forEach(s=>{e.find(l=>l===s||C(l,this.project)===C(s,this.project)&&Ut(l.dataType,s.dataType))||e.push(s)})}),b(e)}syncTerminationStatements(){const e=[],t=[],i=[],a=this.getUniqueReturnDeclarations();return[...this.breakStatements,...this.continueStatements].forEach(o=>{const l=o.outputs,p=a.filter(y=>!l.find(h=>C(y,this.project)===C(h,this.project)&&Ut(y.dataType,h.dataType)));p.length&&e.push(o),p.forEach(y=>{const h=y.clone(o);h.addSelfToProject(),t.push(h)})}),{updated:b(e),added:b(t),removed:b(i),self:this}}syncBodyInputIndexes(){const e=[],t=[],i=[];return this.body.inputs.sort((s,o)=>s.index-o.index),this.body.inputs.forEach((s,o)=>{s.index!==o&&(s.sync({index:o}),e.push(s))}),{updated:b(e),added:b(t),removed:b(i),self:this}}syncBodyArgumentsDeclarations(){const e=[],t=[],i=[],{updated:a,added:s,removed:o}=this.syncFixedBodyArgumentDeclarations();e.push(...a),t.push(...s),i.push(...o);const l=this.getUniqueReturnDeclarations(),p=this.body.inputs;l.sort((R,g)=>R.index-g.index),l.forEach(R=>{const g=R.getDataType();let A=p.find(ae=>C(ae,this.project)===z.fromReturnDeclarationToBodyArgumentDeclarationName(R)&&Ut(ae.dataType,R.dataType));if(!A){const ae=z.fromReturnDeclarationToBodyArgumentDeclarationName(R),Je={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:ae,description:`Aggretated list of all previously outputted values from each iteration by the output '${C(R,this.project)}'`,dataType:null,implements:null,index:R.index,required:R.required,parent:this.body.toReference(),writesValues:[]},gt=v(Je,this.project);gt.setParent(this.body),gt.initChildren(),gt.addSelfToProject(),t.push(gt),A=gt}const I=this.body.inputs.find(ae=>ae.index===A.index&&ae!==A),F=this.body.inputs.filter(ae=>ae!==A);let k=A.index;I&&(k=Math.max(...F.map(ae=>ae.index))+1),A.index!==k&&(A.sync({index:k}),e.push(A));const oe=A.getDataType();let fe=oe;if(g)if(!oe||!Ut(oe,g)){if(!fe){const ae=g.clone(A);ae.addSelfToProject(),fe=ae,t.push(ae),e.push(A)}fe.merge(g),fe.sync({isList:!0})}else fe.isList||(fe.sync({isList:!0}),e.push(fe));if(!g&&!fe){const ae={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!0,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},Je=v(ae,this.project);Je.sync({isList:!0}),Je.setParent(A),Je.initChildren(),Je.addSelfToProject(),t.push(Je)}});const{updated:y,added:h,removed:m}=this.removeExtraBodyArgumentDeclarations();return e.push(...y),t.push(...h),i.push(...m),{updated:b(e),added:b(t),removed:b(i),self:this}}syncOutputsDeclarations(){const e=[],t=[],i=[],a=this.getUniqueReturnDeclarations(),s=this.outputsDeclarations;return a.forEach((l,p)=>{l.index!==p&&(l.sync({index:p}),e.push(l))}),a.forEach(l=>{const p=l.getDataType();let h=s.find(g=>C(g,this.project)===z.fromReturnDeclarationToLoopOutputDeclarationName(l)&&Ut(g.dataType,l.dataType));if(!h){const g=z.fromReturnDeclarationToLoopOutputDeclarationName(l),D={id:_.UUID.uuid(),version:1,type:n.ValueDescriptor,name:g,description:`Aggretated list of all previously outputted values from each iteration by the output '${C(l,this.project)}'`,dataType:null,index:l.index,required:l.required,parent:this.toReference()},A=v(D,this.project);A.setParent(this),A.initChildren(),A.addSelfToProject(),t.push(A),h=A}h.index!==l.index&&(h.sync({index:l.index}),e.push(h));let R=h.getDataType();if(p)if(!R||!Ut(R,p)){if(!R){const g=p.clone(h);g.addSelfToProject(),R=g,t.push(g),e.push(h)}R.merge(p),R.sync({isList:!0})}else R.isList||(R.sync({isList:!0}),e.push(R));if(!p&&!R){const g={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!0,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:h.toReference()},D=v(g,this.project);D.sync({isList:!0}),D.setParent(h),D.initChildren(),D.addSelfToProject(),t.push(D)}}),s.filter(l=>!a.find(y=>C(l,this.project)===z.fromReturnDeclarationToLoopOutputDeclarationName(y))).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),i.push(...y)}),{updated:b(e),added:b(t),removed:b(i),self:this}}syncOutputMaps(){const e=[],t=[],i=[],a=this.outputsDeclarations,s=this.outputs;return a.forEach(l=>{var h;let y=s.find(m=>{var R,g;return((R=m.declaration)==null?void 0:R.id)===l.id&&Ut((g=m.declaration)==null?void 0:g.dataType,l.dataType)});if(y)((h=y.declaration)==null?void 0:h.id)!==l.id&&(y.setDeclaration(l),e.push(y));else{const m={id:_.UUID.uuid(),version:1,type:n.OutputMap,index:l.index,declaration:l.toJSON(),writesValues:[],parent:this.toReference()},R=v(m,this.project);R.setParent(this),R.initChildren(),R.addSelfToProject(),t.push(R),y=R}y.index!==l.index&&(y.sync({index:l.index}),e.push(y))}),s.filter(l=>!a.find(y=>{var h;return((h=l.declaration)==null?void 0:h.id)===y.id})).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),i.push(...y)}),{updated:b(e),added:b(t),removed:b(i),self:this}}createCurrentIterationNumberArgumentDeclaration(){const e=[],t=[],i=[];let s=this.body.inputs.find(y=>{var h;return y.name===z.CURRENT_ITERATION_NUMBER_ARG_NAME||y.id===((h=this.currentIterationNumberArgumentDeclaration)==null?void 0:h.id)});const o=this.getCurrentIterationNumberBuiltInValueDescriptor();if(!s){const y={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_ITERATION_NUMBER_ARG_NAME,description:"The number of the current iteration",dataType:null,implements:o==null?void 0:o.toJSON(),index:this.body.inputs.length,required:!0,parent:this.body.toReference(),writesValues:[]},h=v(y,this.project);h.setParent(this.body),h.initChildren(),h.addSelfToProject(),t.push(h),s=h}!s.index&&s.index!==0&&(s.sync({index:0}),e.push(s)),(!s.implements||s.implements.id!==o.id)&&(s.setImplements(o),e.push(s));let p=s.getDataType();if(!p){const y={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:s.toReference()},h=v(y,this.project);h.setParent(s),h.initChildren(),h.addSelfToProject(),t.push(h),p=h}if(!p.entity||p.entity.type!==n.PrimitiveEntity||p.entity.name!==P.Number||p.entity.id!==B["primitive-entity"].number.id){const y=this.project.getBuiltIn(B["primitive-entity"].number.id);p.setEntity(y),e.push(p)}return this.currentIterationNumberArgumentDeclaration=s,{updated:b(e),added:b(t),removed:b(i),self:this}}removeExtraBodyArgumentDeclarations(){const e=[],t=[],i=[],a=this.body.inputs,s=this.getUniqueReturnDeclarations();return a.filter(l=>l===this.currentIterationNumberArgumentDeclaration||l===this.currentValueArgumentDeclaration?!1:!s.find(y=>C(l,this.project)===z.fromReturnDeclarationToBodyArgumentDeclarationName(y))).forEach(l=>{const{affected:p,removed:y}=l.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...p),i.push(...y)}),{updated:b(e),added:b(t),removed:b(i),self:this}}createCurrentValueInputBasedOnInputMap(){var l,p,y,h,m;const e=[],t=[],i=[];switch(this.declaration.id){case $.List:{const R=this.body.inputs.find(A=>{var I;return((I=A.implements)==null?void 0:I.id)===B[n.Loop][$.List].body.inputs.currentValue.id}),g=this.inputs.find(A=>{var I;return((I=A.declaration)==null?void 0:I.id)===B[n.Loop][$.List].inputs.list.id});if(!g)break;const D=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.List].inputs.list.id);D&&(!R.implements||R.implements.id!==D.id)&&(R.setImplements(D),e.push(R));let F=R.getDataType();if(!F){const oe={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},fe=v(oe,this.project);fe.setParent(A),fe.initChildren(),fe.addSelfToProject(),t.push(fe),F=fe}const k=g.getDataType();F.merge(k),F.sync({isList:!1})}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:D,writesValues:[],dataType:null,parent:this.body.toReference()},I=v(A,this.project);I.initChildren(),I.setParent(this.body),I.addSelfToProject(),D&&(!I.implements||I.implements.id!==D.id)&&(I.setImplements(D),e.push(I)),t.push(I),this.currentValueArgumentDeclaration=I}break}case $.ManualFlow:{this.currentValueArgumentDeclaration=null;break}case $.Counted:{this.currentValueArgumentDeclaration=null;break}case $.ObjectKeys:{const R=this.body.inputs.find(A=>{var I;return((I=A.implements)==null?void 0:I.id)===B[n.Loop][$.ObjectKeys].body.inputs.currentValue.id});if(!this.inputs.find(A=>{var I;return((I=A.declaration)==null?void 0:I.id)===B[n.Loop][$.ObjectKeys].inputs.object.id}))break;const D=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.ObjectKeys].inputs.object.id);D&&(!R.implements||R.implements.id!==D.id)&&(R.setImplements(D),e.push(R));let F=R.getDataType();if(F){const k=this.project.getBuiltIn(B["primitive-entity"].string.id);((l=F.entity)==null?void 0:l.id)!==k.id&&(F.setEntity(k),e.push(F))}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=v(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),F=oe}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:D,writesValues:[],dataType:null,parent:this.body.toReference()},I=v(A,this.project);I.initChildren(),I.setParent(this.body),I.addSelfToProject(),D&&(!I.implements||I.implements.id!==D.id)&&(I.setImplements(D),e.push(I)),t.push(I),this.currentValueArgumentDeclaration=I}break}case $.ObjectValues:{const R=this.body.inputs.find(A=>{var I;return((I=A.implements)==null?void 0:I.id)===B[n.Loop][$.ObjectValues].body.inputs.currentValue.id}),g=this.inputs.find(A=>{var I;return((I=A.declaration)==null?void 0:I.id)===B[n.Loop][$.ObjectValues].inputs.object.id});if(!g)break;const D=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop][$.ObjectValues].inputs.object.id);D&&(!R.implements||R.implements.id!==D.id)&&(R.setImplements(D),e.push(R));let F=R.getDataType();if(F){const k=g.getDataType(),oe=((y=k==null?void 0:k.entity)==null?void 0:y.properties)||[];(h=F.orChildrenGroup)==null||h.forEach(fe=>{const{affected:ae,removed:Je}=fe.remove({ignoreUpstream:!1,seenEntities:new Set});e.push(...ae),i.push(...Je)}),oe.forEach(fe=>{const ae=fe.getDataType();if(ae){const Je=ae.clone(F);Je.sync({parentRelationType:Ke.OrDataTypeGroup}),Je.addSelfToProject(),t.push(Je)}else{const Je={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:Ke.OrDataTypeGroup,parent:F.toReference()},gt=v(Je,this.project);gt.setParent(F),gt.initChildren(),gt.addSelfToProject(),t.push(gt)}})}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=v(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),F=oe;const fe=g.getDataType();(((p=fe==null?void 0:fe.entity)==null?void 0:p.properties)||[]).forEach(Je=>{const gt=Je.getDataType();if(gt){const Jr=gt.clone(oe);Jr.sync({parentRelationType:Ke.OrDataTypeGroup}),Jr.addSelfToProject(),t.push(Jr)}else{const Jr={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parentRelationType:Ke.OrDataTypeGroup,parent:oe.toReference()},zo=v(Jr,this.project);zo.setParent(oe),zo.initChildren(),zo.addSelfToProject(),t.push(zo)}})}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:D,writesValues:[],dataType:null,parent:this.body.toReference()},I=v(A,this.project);I.initChildren(),I.setParent(this.body),I.addSelfToProject(),D&&(!I.implements||I.implements.id!==D.id)&&(I.setImplements(D),e.push(I)),t.push(I),this.currentValueArgumentDeclaration=I}break}case $.String:{const R=this.body.inputs.find(A=>{var I;return((I=A.implements)==null?void 0:I.id)===B[n.Loop][$.String].body.inputs.currentValue.id});if(!this.inputs.find(A=>{var I;return((I=A.declaration)==null?void 0:I.id)===B[n.Loop][$.String].inputs.string.id}))break;const D=this.getCurrentValueBuiltInValueDescriptor();if(R){this.currentValueArgumentDeclaration=R;const A=this.project.get(B[n.Loop]["string-loop"].inputs.string.id);D&&(!R.implements||R.implements.id!==D.id)&&(R.setImplements(D),e.push(R));let F=R.getDataType();if(F){const k=this.project.getBuiltIn(B["primitive-entity"].string.id);((m=F.entity)==null?void 0:m.id)!==k.id&&(F.setEntity(k),e.push(F))}else{const k={id:_.UUID.uuid(),version:1,type:n.DataType,isList:!1,entity:null,isNullable:!1,constant:!1,defaultValue:null,asType:!1,like:!1,inferred:!1,andChildrenGroup:[],orChildrenGroup:[],parent:A.toReference()},oe=v(k,this.project);oe.setParent(A),oe.initChildren(),oe.addSelfToProject(),t.push(oe),F=oe}}else{const A={id:_.UUID.uuid(),version:1,type:n.ArgumentDeclaration,name:z.CURRENT_VALUE_ARG_NAME,description:null,index:this.body.inputs.length,required:!0,implements:D,writesValues:[],dataType:null,parent:this.body.toReference()},I=v(A,this.project);I.initChildren(),I.setParent(this.body),I.addSelfToProject(),D&&(!I.implements||I.implements.id!==D.id)&&(I.setImplements(D),e.push(I)),t.push(I),this.currentValueArgumentDeclaration=I}break}}const{updated:a,added:s,removed:o}=this.removeExtraBodyArgumentDeclarations();return e.push(...a),t.push(...s),i.push(...o),{updated:b(e),added:b(t),removed:b(i),self:this}}syncFixedBodyArgumentDeclarations(){const e=[],t=[],i=[],{updated:a,added:s,removed:o}=this.createCurrentIterationNumberArgumentDeclaration();e.push(...a),t.push(...s),i.push(...o);const{updated:l,added:p,removed:y}=this.createCurrentValueInputBasedOnInputMap();return e.push(...l),t.push(...p),i.push(...y),{updated:b(e),added:b(t),removed:b(i),self:this}}syncInputMaps(){const e=[],t=[],i=[];switch(this.declaration.id){case $.List:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["list-loop"].inputs.list.id?a=s:(s.remove(),i.push(s))}),a){if(a.declaration.id!==B[n.Loop]["list-loop"].inputs.list.id){const s=this.project.get(B[n.Loop]["list-loop"].inputs.list.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["list-loop"].inputs.list.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=v(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ManualFlow:{this.inputs.forEach(a=>{a.remove(),i.push(a)});break}case $.Counted:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["counted-loop"].inputs.number.id?a=s:(s.remove(),i.push(s))}),a){if(a.declaration.id!==B[n.Loop]["counted-loop"].inputs.number.id){const s=this.project.get(B[n.Loop]["counted-loop"].inputs.number.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["counted-loop"].inputs.number.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=v(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ObjectKeys:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["object-keys-loop"].inputs.object.id?a=s:(s.remove(),i.push(s))}),a){if(a.declaration.id!==B[n.Loop]["object-keys-loop"].inputs.object.id){const s=this.project.get(B[n.Loop]["object-keys-loop"].inputs.object.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["object-keys-loop"].inputs.object.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=v(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.ObjectValues:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["object-values-loop"].inputs.object.id?a=s:(s.remove(),i.push(s))}),a){if(a.declaration.id!==B[n.Loop]["object-values-loop"].inputs.object.id){const s=this.project.get(B[n.Loop]["object-values-loop"].inputs.object.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["object-values-loop"].inputs.object.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=v(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}case $.String:{let a=null;if(this.inputs.forEach(s=>{var o;((o=s.declaration)==null?void 0:o.id)===B[n.Loop]["string-loop"].inputs.string.id?a=s:(s.remove(),i.push(s))}),a){if(a.declaration.id!==B[n.Loop]["string-loop"].inputs.string.id){const s=this.project.get(B[n.Loop]["string-loop"].inputs.string.id);a.setDeclaration(s),e.push(a)}}else{const s=this.project.get(B[n.Loop]["string-loop"].inputs.string.id),o={id:_.UUID.uuid(),version:1,type:n.InputMap,name:null,description:null,index:0,declaration:s.toJSON(),readsValue:null,defaultValue:null,parent:this.toReference()},l=v(o,this.project);l.initChildren(),l.setParent(this),l.addSelfToProject(),t.push(l)}break}}return{updated:b(e),added:b(t),removed:b(i),self:this}}getCurrentValueBuiltInValueDescriptor(){var t;const e=(t=B[n.Loop][this.declaration.id].body.inputs.currentValue)==null?void 0:t.id;return e?this.project.get(e):null}getCurrentIterationNumberBuiltInValueDescriptor(){const e=B[n.Loop][this.declaration.id].body.inputs.iterationNumber.id;return this.project.get(e)}syncBody(){var o;const e=[],t=[],i=[],a=B[n.Loop][this.declaration.id].body.id,s=this.project.getBuiltIn(a);if(this.body)((o=this.body.implements)==null?void 0:o.id)!==s.id&&(this.body.setImplements(s),this.body.setParent(this),e.push(this.body));else{const l={id:_.UUID.uuid(),version:1,type:n.FunctionDeclaration,name:s.name,description:null,inputs:[],index:null,returnStatements:[],calls:[],collapsed:!1,private:!1,implements:s.toJSON(),x:0,y:0,parent:this.toReference()},p=v(l,this.project);p.initChildren(),p.setParent(this),p.addSelfToProject(),t.push(p)}return{self:this,updated:b(e),added:b(t),removed:b(i)}}syncChildren(){const e=[],t=[],i=[],{updated:a,added:s,removed:o}=this.syncBody();e.push(...a),t.push(...s),i.push(...o);const{updated:l,added:p,removed:y}=this.syncInputMaps();e.push(...l),t.push(...p),i.push(...y);const{updated:h,added:m,removed:R}=this.syncTerminationStatements();e.push(...h),t.push(...m),i.push(...R);const{updated:g,added:D,removed:A}=this.syncBodyArgumentsDeclarations();e.push(...g),t.push(...D),i.push(...A);const{updated:I,added:F,removed:k}=this.syncBodyInputIndexes();e.push(...I),t.push(...F),i.push(...k);const{updated:oe,added:fe,removed:ae}=this.syncOutputsDeclarations();e.push(...oe),t.push(...fe),i.push(...ae);const{updated:Je,added:gt,removed:Jr}=this.syncOutputMaps();return e.push(...Je),t.push(...gt),i.push(...Jr),{self:this,updated:b(e),added:b(t),removed:b(i)}}};d(z,"CURRENT_ITERATION_NUMBER_ARG_NAME","Current iteration number"),d(z,"CURRENT_VALUE_ARG_NAME","Current value"),d(z,"MUTABLE_BASE_PROPERTIES",[]),d(z,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),d(z,"BASE_PROPERTIES",[...z.MUTABLE_BASE_PROPERTIES,...z.INMUTABLE_BASE_PROPERTIES]),d(z,"MUTABLE_META_PROPERTIES",[...z.MUTABLE_BASE_PROPERTIES,"x","y"]),d(z,"INMUTABLE_META_PROPERTIES",[...z.INMUTABLE_BASE_PROPERTIES]),d(z,"META_PROPERTIES",[...z.MUTABLE_META_PROPERTIES,...z.INMUTABLE_META_PROPERTIES]),d(z,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),d(z,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),d(z,"UPSTREAM_PROPERTIES",[...z.MUTABLE_UPSTREAM_PROPERTIES,...z.INMUTABLE_UPSTREAM_PROPERTIES]),d(z,"MUTABLE_DOWNSTREAM_PROPERTIES",["body","inputs","outputs","outputsDeclarations","successCalls","errorCalls","error","breakStatements","continueStatements"]),d(z,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),d(z,"DOWNSTREAM_PROPERTIES",[...z.MUTABLE_DOWNSTREAM_PROPERTIES,...z.INMUTABLE_DOWNSTREAM_PROPERTIES]),d(z,"PROPERTIES",[...z.META_PROPERTIES,...z.UPSTREAM_PROPERTIES,...z.DOWNSTREAM_PROPERTIES]);let _r=z;function u2(r){const e=l6(),t=r.toJSON();e.safeParse(t).success,r.inputs.forEach(o=>o.validate());const s=[...Cn(r)];return ie(r.errors,s)}const ve=class ve{constructor(e,t){d(this,"initialData");d(this,"id");d(this,"version");d(this,"x");d(this,"y");d(this,"type",n.Condition);d(this,"successCalls",[]);d(this,"errorCalls",[]);d(this,"declaration");d(this,"inputs",[]);d(this,"calledBySuccess",[]);d(this,"calledByError",[]);d(this,"calledByEntry",[]);d(this,"project");d(this,"errors",[]);d(this,"parent");d(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 i=t;if(e.parent){const h=N(e.parent);i=t.get(h)}const a=e.calledByEntry.map(h=>{const m=N(h);return t.get(m)}),s=e.calledBySuccess.map(h=>{const m=N(h);return t.get(m)}),o=e.calledByError.map(h=>{const m=N(h);return t.get(m)});let l;if(e.declaration){const h=N(e.declaration);l=t.get(h)}const p={id:e.id,version:1,type:n.Condition,declaration:l,calledByEntry:a,calledBySuccess:s,calledByError:o,errorCalls:[],successCalls:[],inputs:[],x:0,y:0,parent:i},y=v(p,t);return y.setParent(i),y.initChildren(),y}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=He(i,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);return i=s.modifiedData,a.push(...s.errors,...Le(i)),e.declaration?t.get(e.declaration)?t.conditionDeclarations.find(p=>p.id===e.declaration)||a.push(new E({id:`${e.id}--${f.InvalidImplementsReference}`,code:f.InvalidImplementsReference,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't pointing to an action descriptor reserved for '${n.Condition}' entities.
|
|
54
54
|
${$o(t)}`,issue:null})):a.push(new E({id:`${e.id}--${f.ReferencedEntityNotFound}`,code:f.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type '${e.type}' with id '${e.id}' has an 'declaration' property that isn't found in the project. The 'declaration' property must point to one of the built-in action descriptors reserved for '${n.Condition}' entities.
|
|
@@ -69,6 +69,8 @@ export declare class LoopState implements ILoop, BaseState, UserManagedEntitySta
|
|
|
69
69
|
static fromBodyArgumentDeclarationToReturnDeclarationName(argumentDeclaration: ArgumentDeclarationState): string;
|
|
70
70
|
static fromReturnDeclarationToLoopOutputDeclarationName(returnDeclaration: ReturnDeclarationState): string;
|
|
71
71
|
static fromLoopOutputDeclarationToReturnDeclarationName(outputDeclaration: ValueDescriptorState): string;
|
|
72
|
+
static fromLoopOutputDeclarationToBodyArgumentDeclarationName(outputDeclaration: ValueDescriptorState): string;
|
|
73
|
+
static fromBodyArgumentDeclarationToLoopOutputDeclarationName(argumentDeclaration: ArgumentDeclarationState): string;
|
|
72
74
|
validateGeneratedUpdate(data: Partial<ILoopGenerationTarget>): {
|
|
73
75
|
errors: EntityGenerationError[];
|
|
74
76
|
modifiedData: Partial<ILoopGenerationTarget>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyx-code/project-logic-tree",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6078",
|
|
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",
|