@elyx-code/project-logic-tree 0.0.6044 → 0.0.6045
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 +11 -8
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34571,8 +34571,9 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
34571
34571
|
}
|
|
34572
34572
|
// Add the current entity to the project state in all the right places including other instances it is related to
|
|
34573
34573
|
addSelfToProject() {
|
|
34574
|
+
var a;
|
|
34574
34575
|
const e = [this], t = [], i = [];
|
|
34575
|
-
return this.parent.setDefaultValue(this), e.push(this.parent), {
|
|
34576
|
+
return (a = this.parent) == null || a.setDefaultValue(this), e.push(this.parent), {
|
|
34576
34577
|
updated: R(e),
|
|
34577
34578
|
added: R(t),
|
|
34578
34579
|
removed: R(i),
|
|
@@ -34684,6 +34685,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
34684
34685
|
]);
|
|
34685
34686
|
}
|
|
34686
34687
|
toJSON() {
|
|
34688
|
+
var e;
|
|
34687
34689
|
return {
|
|
34688
34690
|
id: this.id,
|
|
34689
34691
|
version: this.version,
|
|
@@ -34692,9 +34694,8 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
34692
34694
|
autogeneration: this.autogeneration,
|
|
34693
34695
|
value: this.value,
|
|
34694
34696
|
// @ts-ignore
|
|
34695
|
-
valueAsType: this.valueAsType ? Array.isArray(this.valueAsType) ? this.valueAsType.map((
|
|
34696
|
-
parent: this.parent.toReference()
|
|
34697
|
-
// parent: null,
|
|
34697
|
+
valueAsType: this.valueAsType ? Array.isArray(this.valueAsType) ? this.valueAsType.map((t) => t.toReference()) : this.valueAsType.toReference() : null,
|
|
34698
|
+
parent: (e = this.parent) == null ? void 0 : e.toReference()
|
|
34698
34699
|
};
|
|
34699
34700
|
}
|
|
34700
34701
|
toReference() {
|
|
@@ -34706,15 +34707,16 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
34706
34707
|
};
|
|
34707
34708
|
}
|
|
34708
34709
|
toShallowJSON() {
|
|
34710
|
+
var e;
|
|
34709
34711
|
return {
|
|
34710
34712
|
id: this.id,
|
|
34711
34713
|
version: this.version,
|
|
34712
34714
|
type: this.type,
|
|
34713
34715
|
name: this.name,
|
|
34714
|
-
valueAsType: this.valueAsType ? Array.isArray(this.valueAsType) ? this.valueAsType.map((
|
|
34716
|
+
valueAsType: this.valueAsType ? Array.isArray(this.valueAsType) ? this.valueAsType.map((t) => t.toReference()) : this.valueAsType.toReference() : null,
|
|
34715
34717
|
value: this.value,
|
|
34716
34718
|
autogeneration: this.autogeneration,
|
|
34717
|
-
parent: this.parent.toReference()
|
|
34719
|
+
parent: (e = this.parent) == null ? void 0 : e.toReference()
|
|
34718
34720
|
};
|
|
34719
34721
|
}
|
|
34720
34722
|
toFlatJSON(e = /* @__PURE__ */ new Set()) {
|
|
@@ -34726,14 +34728,15 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
|
|
|
34726
34728
|
]);
|
|
34727
34729
|
}
|
|
34728
34730
|
toGenerationTarget() {
|
|
34731
|
+
var e;
|
|
34729
34732
|
return {
|
|
34730
34733
|
id: this.id,
|
|
34731
34734
|
type: this.type,
|
|
34732
34735
|
name: this.name,
|
|
34733
|
-
valueAsType: this.valueAsType ? Array.isArray(this.valueAsType) ? this.valueAsType.map((
|
|
34736
|
+
valueAsType: this.valueAsType ? Array.isArray(this.valueAsType) ? this.valueAsType.map((t) => t.id) : this.valueAsType.id : null,
|
|
34734
34737
|
value: this.value,
|
|
34735
34738
|
autogeneration: this.autogeneration,
|
|
34736
|
-
parent: this.parent.id
|
|
34739
|
+
parent: (e = this.parent) == null ? void 0 : e.id
|
|
34737
34740
|
};
|
|
34738
34741
|
}
|
|
34739
34742
|
toFlatGenerationTarget(e = /* @__PURE__ */ new Set()) {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -150,7 +150,7 @@ You can update the existing 'primitive-value' with the 'update' action, for exam
|
|
|
150
150
|
}
|
|
151
151
|
}\`\`\`
|
|
152
152
|
Or 'delete' and then 'post' actions to replace it.`,issue:null})):t.push(new E({id:`${r.id}--${r.parent}--${h.InvalidParentReference}`,code:h.InvalidParentReference,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}", has a parent reference that isn't pointing to an entity of type 'input-map' or 'data-type'.`,issue:null})):t.push(new E({id:`${r.id}--${r.parent}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${r.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))}else t.push(new E({id:`${r.id}--${D.InvalidObjectStructure}`,code:D.InvalidObjectStructure,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}" is missing a 'parent' reference. The 'parent' of a primitive value entity must be a reference to an entity of type 'input-map' or 'data-type'.`,issue:null}));else return t.push(new E({id:`${r.id}--${D.InvalidObjectStructure}`,code:D.InvalidObjectStructure,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}" is missing a 'parent' reference. The 'parent' of a primitive value entity must be a reference to an entity of type 'input-map' or 'data-type'.`,issue:null})),t;if(r.valueAsType){const i=[],a=[],s=r.valueAsType;Array.isArray(s)?s.forEach(o=>{typeof o=="string"?a.push(o):i.push(o)}):typeof s=="string"?a.push(s):i.push(s),i.forEach(o=>{const c=Do(o);t.push(...c),c.length===0&&a.push(o.entityId)}),a.forEach(o=>{const c=e.get(o);c?[n.CustomEntity,n.BuiltInBaseEntity].includes(c.type)||t.push(new E({id:`${r.id}--${o}--${h.InvalidImplementsReference}`,code:h.InvalidImplementsReference,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'valueAsType' reference that isn't pointing to an entity of type 'custom-entity', 'function-declaration' or 'operation'.`,issue:null})):t.push(new E({id:`${r.id}--${o}--${h.ReferencedEntityNotFound}`,code:h.ReferencedEntityNotFound,severity:T.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${o}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}))})}return t}const ve=class ve{constructor(e,t){l(this,"initialData");l(this,"type",n.PrimitiveValue);l(this,"id");l(this,"version");l(this,"name");l(this,"autogeneration",null);l(this,"value",null);l(this,"valueAsType",null);l(this,"errors",[]);l(this,"parent");l(this,"standaloneParent");l(this,"project");l(this,"initialized",!1);l(this,"standalone",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.autogeneration=e.autogeneration,this.value=e.value}static fromGenerationTarget(e,t){const i=w(e.parent),a=t.get(i);let s=null;e.valueAsType&&(Array.isArray(e.valueAsType)?s=e.valueAsType.map(p=>t.get(p)||t.getBuiltIn(p)):s=t.get(e.valueAsType)||t.getBuiltIn(e.valueAsType));const o={id:e.id,version:1,type:n.PrimitiveValue,name:e.name,autogeneration:e.autogeneration,valueAsType:s,value:e.value||null,parent:a},c=R(o,t);return c.setParent(a),c.initChildren(),c}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=x5(i,t);return a.push(...s,..._e(i)),{errors:a,modifiedData:i}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new E({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
153
|
-
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],i=[];return
|
|
153
|
+
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){var a;const e=[this],t=[],i=[];return(a=this.parent)==null||a.setDefaultValue(this),e.push(this.parent),{updated:g(e),added:g(t),removed:g(i),self:this}}setParent(e){return this.parent=e,this}setStandaloneParent(e){return this.standaloneParent=e,this}setValueAsType(e){return this.valueAsType=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.standalone){if(this.initialData.valueAsType)if(Array.isArray(this.initialData.valueAsType))this.valueAsType=this.initialData.valueAsType.map(e=>{const t=this.project.get(e.id);if(!t)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${e.type}' with id '${e.id}' that is not part of the project state.`);return t});else{const e=this.project.get(this.initialData.valueAsType.id);if(!e)throw new Error(`Standalone entity of type '${this.type}' with id '${this.id}' has a reference to an entity of type '${this.initialData.valueAsType.type}' with id '${this.initialData.valueAsType.id}' that is not part of the project state.`);this.valueAsType=e}return this}return this.initialData.valueAsType&&(Array.isArray(this.initialData.valueAsType)?this.valueAsType=this.initialData.valueAsType.map(e=>R(e,this.project)):this.valueAsType=R(this.initialData.valueAsType,this.project)),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.subscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.name=e.name||this.name,this.autogeneration=e.autogeneration||this.autogeneration,e.value!==void 0&&(this.value=e.value),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(),{affected:g(i),removed:g(a)})}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),{affected:t,self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.valueAsType?Array.isArray(this.valueAsType)?this.valueAsType.flatMap(i=>i.toFlat(e)):this.valueAsType.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.valueAsType?Array.isArray(this.valueAsType)?this.valueAsType.flatMap(i=>i.toFlatIds(e)):this.valueAsType.toFlatIds(e):[]])}toJSON(){var e;return{id:this.id,version:this.version,type:this.type,name:this.name,autogeneration:this.autogeneration,value:this.value,valueAsType:this.valueAsType?Array.isArray(this.valueAsType)?this.valueAsType.map(t=>t.toReference()):this.valueAsType.toReference():null,parent:(e=this.parent)==null?void 0:e.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e;return{id:this.id,version:this.version,type:this.type,name:this.name,valueAsType:this.valueAsType?Array.isArray(this.valueAsType)?this.valueAsType.map(t=>t.toReference()):this.valueAsType.toReference():null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.toReference()}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.valueAsType?Array.isArray(this.valueAsType)?this.valueAsType.flatMap(i=>i.toFlatJSON(e)):this.valueAsType.toFlatJSON(e):[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,name:this.name,valueAsType:this.valueAsType?Array.isArray(this.valueAsType)?this.valueAsType.map(t=>t.id):this.valueAsType.id:null,value:this.value,autogeneration:this.autogeneration,parent:(e=this.parent)==null?void 0:e.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.valueAsType?Array.isArray(this.valueAsType)?this.valueAsType.flatMap(i=>i.toFlatGenerationTarget(e)):this.valueAsType.toFlatGenerationTarget(e):[]])}clearErrors(){return this.errors=[],this}validate(){const e=U5(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(e=null,t=null,i=!0){const a=this.toJSON(),s=t||tt(this.name,n.PrimitiveValue,this.project);a.id=s;const o=Ut(a,this.project);return e&&o.setParent(e),i&&o.subscribe(),o}merge(e){const t=[],i=[],a=[];return this.valueAsType!==(e==null?void 0:e.valueAsType)&&(this.setValueAsType(e.valueAsType),t.push(this)),this.value!==e.value&&(this.value=e.value,t.push(this)),this.autogeneration!==e.autogeneration&&(this.autogeneration=e.autogeneration,t.push(this)),this.name!==e.name&&(this.name=e.name,t.push(this)),{updated:g(t),added:g(i),removed:g(a),self:this}}};l(ve,"MUTABLE_BASE_PROPERTIES",["name","autogeneration","value"]),l(ve,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),l(ve,"BASE_PROPERTIES",[...ve.MUTABLE_BASE_PROPERTIES,...ve.INMUTABLE_BASE_PROPERTIES]),l(ve,"MUTABLE_META_PROPERTIES",[...ve.MUTABLE_BASE_PROPERTIES]),l(ve,"INMUTABLE_META_PROPERTIES",[...ve.INMUTABLE_BASE_PROPERTIES]),l(ve,"META_PROPERTIES",[...ve.MUTABLE_META_PROPERTIES,...ve.INMUTABLE_META_PROPERTIES]),l(ve,"MUTABLE_UPSTREAM_PROPERTIES",[]),l(ve,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),l(ve,"UPSTREAM_PROPERTIES",[...ve.MUTABLE_UPSTREAM_PROPERTIES,...ve.INMUTABLE_UPSTREAM_PROPERTIES]),l(ve,"MUTABLE_DOWNSTREAM_PROPERTIES",["valueAsType"]),l(ve,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),l(ve,"DOWNSTREAM_PROPERTIES",[...ve.MUTABLE_DOWNSTREAM_PROPERTIES,...ve.INMUTABLE_DOWNSTREAM_PROPERTIES]),l(ve,"PROPERTIES",[...ve.META_PROPERTIES,...ve.UPSTREAM_PROPERTIES,...ve.DOWNSTREAM_PROPERTIES]);let bi=ve;function j5(r){var s;const e=z8(),t=r.toJSON();e.safeParse(t).success,r.outputs.forEach(o=>o.validate()),(s=r.throws)==null||s.validate();const a=[];return ae(r.errors,a)}function k5(r){var s;const e=J8(),t=r.toJSON();e.safeParse(t).success,r.outputs.forEach(o=>o.validate()),(s=r.throws)==null||s.validate();const a=[];return ae(r.errors,a)}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",n.ContinueStatement);l(this,"outputs",[]);l(this,"calledBySuccess",[]);l(this,"calledByError",[]);l(this,"calledByEntry",[]);l(this,"throws",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.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){const i=w(e.parent),a=t.get(i),s=e.calledByEntry.map(f=>{const m=w(f);return t.get(m)}),o=e.calledBySuccess.map(f=>{const m=w(f);return t.get(m)}),c=e.calledByError.map(f=>{const m=w(f);return t.get(m)}),p={id:e.id,version:1,type:n.ContinueStatement,x:0,y:0,outputs:[],calledBySuccess:o,calledByError:c,calledByEntry:s,throws:null,parent:a},y=R(p,t);return y.setParent(a),y.initChildren(),y}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=Je(i,{parent:{list:!1,types:[n.Loop]}},t);return i=s.modifiedData,a.push(...s.errors,..._e(i)),{errors:a,modifiedData:i}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new E({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
154
154
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
155
155
|
You shouldn't have to manually update a 'parent' property.
|
|
156
156
|
Specifically for continue statements the parent needs to always be the 'loop' entity that contains it.`,issue:null})),{errors:t,modifiedData:e}}addSelfToProject(){const e=[this],t=[],i=[];return 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)}),this.parent.addContinueStatement(this),e.push(this),{updated:g(e),added:g(t),removed:g(i),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}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}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}addOutputDeclaration(e){return this.outputs.find(t=>t.id===e.id)||this.outputs.push(e),this}removeOutputDeclaration(e){return this.outputs=this.outputs.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.outputs=this.initialData.outputs.map(e=>{const t=R(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.throws&&(this.throws=R(this.initialData.throws,this.project),this.throws.setParent(this),this.throws.initChildren()),this.parent.addContinueStatement(this),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.outputs.forEach(s=>{const{affected:o,removed:c}=s.remove({ignoreUpstream:!0,seenEntities:t});i.push(...o),a.push(...c)}),this.throws){const{affected:s,removed:o}=this.throws.remove({ignoreUpstream:!0,seenEntities:t});i.push(...s),a.push(...o)}return this.parent.removeContinueStatement(this),e||this.calledBy.forEach(s=>{i.push(s),s.removeCall(this)}),{affected:g(i),removed:g(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.outputs.forEach(i=>{const{affected:a}=i.restore({seenEntities:e});t.push(...a)}),this.throws){const{affected:i}=this.throws.restore({seenEntities:e});t.push(...i)}return this.parent.addContinueStatement(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:g(t),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.outputs.flatMap(i=>i.toFlat(e)),...this.calledBy.flatMap(i=>i.toFlat(e)),...this.throws?this.throws.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.outputs.flatMap(i=>i.toFlatIds(e)),...this.calledBy.flatMap(i=>i.toFlatIds(e)),...this.throws?this.throws.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()),outputs:this.outputs.map(i=>i.toJSON()),throws:((e=this.throws)==null?void 0:e.toJSON())||null,parent:((t=this.parent)==null?void 0:t.toReference())||null}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e;return{id:this.id,version:this.version,type:this.type,x:this.x,y:this.y,outputs:this.outputs.map(t=>t.toReference()),calledBySuccess:this.calledBySuccess.map(t=>t.toReference()),calledByError:this.calledByError.map(t=>t.toReference()),calledByEntry:this.calledByEntry.map(t=>t.toReference()),throws:((e=this.throws)==null?void 0:e.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var i;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.outputs.flatMap(a=>a.toFlatJSON(e)),...this.calledBy.flatMap(a=>a.toFlatJSON(e)),...((i=this.throws)==null?void 0:i.toFlatJSON(e))||[]])}toGenerationTarget(){return{id:this.id,type:this.type,calledByEntry:this.calledByEntry.map(e=>e.id),calledByError:this.calledByError.map(e=>e.id),calledBySuccess:this.calledBySuccess.map(e=>e.id),parent:this.parent.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.outputs.flatMap(i=>i.toFlatGenerationTarget(e)),...this.throws?this.throws.toFlatGenerationTarget(e):[]])}clearErrors(){var e;return this.errors=[],this.outputs.forEach(t=>t.clearErrors()),(e=this.throws)==null||e.clearErrors(),this}validate(){const e=k5(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.outputs.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(e){return new Ie(this.toJSON(),this.project)}};l(Ie,"MUTABLE_BASE_PROPERTIES",[]),l(Ie,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),l(Ie,"BASE_PROPERTIES",[...Ie.MUTABLE_BASE_PROPERTIES,...Ie.INMUTABLE_BASE_PROPERTIES]),l(Ie,"MUTABLE_META_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","parent"]),l(Ie,"INMUTABLE_UPSTREAM_PROPERTIES",[]),l(Ie,"UPSTREAM_PROPERTIES",[...Ie.MUTABLE_UPSTREAM_PROPERTIES,...Ie.INMUTABLE_UPSTREAM_PROPERTIES]),l(Ie,"MUTABLE_DOWNSTREAM_PROPERTIES",["outputs","throws"]),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 Et=Ie;const lt=class lt{constructor(e,t){l(this,"initialData");l(this,"id");l(this,"version");l(this,"x");l(this,"y");l(this,"type",n.ReturnStatement);l(this,"outputs",[]);l(this,"calledBySuccess",[]);l(this,"calledByError",[]);l(this,"calledByEntry",[]);l(this,"throws",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.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){const i=w(e.parent),a=t.get(i),s=e.calledByEntry.map(f=>{const m=w(f);return t.get(m)}),o=e.calledBySuccess.map(f=>{const m=w(f);return t.get(m)}),c=e.calledByError.map(f=>{const m=w(f);return t.get(m)}),p={id:e.id,version:1,type:n.ReturnStatement,x:0,y:0,outputs:[],calledBySuccess:o,calledByError:c,calledByEntry:s,throws:null,parent:a},y=R(p,t);return y.setParent(a),y.initChildren(),y}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=Je(i,{parent:{list:!1,types:dt}},t);return i=s.modifiedData,a.push(...s.errors,..._e(i)),{errors:a,modifiedData:i}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new E({id:`${this.id}--${h.InvalidParentUpdate}`,code:h.InvalidParentUpdate,severity:T.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
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.6045",
|
|
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",
|