@elyx-code/project-logic-tree 0.0.6053 → 0.0.6055

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
@@ -26036,6 +26036,13 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
26036
26036
  this.parent.type
26037
26037
  ) || Xn(this.parent) ? !0 : !(!this.entity && (!this.andChildrenGroup || !this.andChildrenGroup.length) && (!this.orChildrenGroup || !this.orChildrenGroup.length));
26038
26038
  }
26039
+ isObject() {
26040
+ return !!this.entity && (this.entity.type === n.CustomEntity || this.entity.name === g.JSON);
26041
+ }
26042
+ hasStrictObjectStructure() {
26043
+ var e;
26044
+ return this.isObject() && ((e = this.entity) == null ? void 0 : e.type) === n.CustomEntity;
26045
+ }
26039
26046
  // Only for inferred data types,
26040
26047
  // attempt to update the entity based on the inputs,
26041
26048
  // Each input is a property
@@ -34,7 +34,7 @@ ${Kn}`,issue:null}))}}}const o=i.parent&&t.get(i.parent)||t.getBuiltIn(i.parent)
34
34
  The entitities of type '${$(h,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property so no 'parentRelationType' is needed.`,issue:null})),o.dataType)){const m=(p=o.dataType)==null?void 0:p.id;a.push(new E({id:`${e.id}--${f.NewEntityWouldOverriteExisting}`,code:f.NewEntityWouldOverriteExisting,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.type}', cannot be added as a child to the entity with id '${i.parent}' and type '${y}', because it already has a 'data-type' child with id '${m}'.
35
35
  The entitities of type '${$(h,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property. You can inspect the existing data-type entity with the 'describe_entity' action. Like so:
36
36
  ${ln({describe_entity:m})}
37
- Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}y===n.DataType&&(!i.parentRelationType||!(i.parentRelationType===lt.AndDataTypeGroup||i.parentRelationType===lt.OrDataTypeGroup))&&a.push(new E({id:`${e.id}--${f.InvalidParentRelationType}`,code:f.InvalidParentRelationType,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`,issue:null}))}return{errors:a,modifiedData:i}}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}addSelfToProject(){const e=[this],t=[],i=[];return this.parent.type===n.DataType?this.parentRelationType===lt.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===lt.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:g(e),added:g(t),removed:g(i),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(i=>i.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(i=>i.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.defaultValue&&(this.defaultValue=R(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this),this.defaultValue.initChildren()),this.initialData.entity)if(this.initialData.entity.type===n.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=e}else this.entity=R(this.initialData.entity,this.project);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(e=>R(e,this.project))),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(e=>R(e,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.isNullable=e.isNullable||this.isNullable,this.isList=e.isList||this.isList,this.constant=e.constant||this.constant,this.asType=e.asType||this.asType,this.options=e.options||this.options,this.parentRelationType=e.parentRelationType||this.parentRelationType,this.like=e.like||this.like,this.inferred=e.inferred||this.inferred,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const i=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});i.push(...s),a.push(...o)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});i.push(...s),a.push(...o)}if(!e){this.parent.type===n.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===n.DataType){if(this.parentRelationType===lt.AndDataTypeGroup){if(Array.isArray(s.andChildrenGroup)){const o=s.andChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.andChildrenGroup.splice(o,1)}}else if(this.parentRelationType===lt.OrDataTypeGroup&&Array.isArray(s.orChildrenGroup)){const o=s.orChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.orChildrenGroup.splice(o,1)}}else this.parent.removeDataType();i.push(s)}return{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.defaultValue){const{affected:i}=this.defaultValue.restore({seenEntities:e});t.push(...i)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:i}=this.entity.restore({seenEntities:e});t.push(...i)}if(this.parent.type===n.DataType){const i=this.parent;Array.isArray(i.andChildrenGroup)&&i.andChildrenGroup.push(this)}if(this.parent.type===n.DataType){const i=this.parent;this.parentRelationType===lt.AndDataTypeGroup?Array.isArray(i.andChildrenGroup)&&i.andChildrenGroup.push(this):this.parentRelationType===lt.OrDataTypeGroup&&Array.isArray(i.orChildrenGroup)&&i.orChildrenGroup.push(this)}else{const i=this.parent;i.setDataType(this),t.push(i)}return{affected:t,self:this}}toFlat(e=new Set){var i,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((i=this.andChildrenGroup)==null?void 0:i.flatMap(o=>o.toFlat(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlat(e)))||[],...((s=this.entity)==null?void 0:s.toFlat(e))||[]])}toFlatIds(e=new Set){var i,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((i=this.andChildrenGroup)==null?void 0:i.flatMap(o=>o.toFlatIds(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatIds(e)))||[],...((s=this.entity)==null?void 0:s.toFlatIds(e))||[]])}toJSON(){var e,t,i,a;return{id:this.id,version:this.version,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,asType:this.asType,defaultValue:((e=this.defaultValue)==null?void 0:e.toJSON())||null,like:this.like,parentRelationType:this.parentRelationType,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toJSON()))||null,orChildrenGroup:((i=this.orChildrenGroup)==null?void 0:i.map(s=>s.toJSON()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+N.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,isList:this.isList,isNullable:this.isNullable,options:this.options,constant:this.constant,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference())||null,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toReference()))||null,orChildrenGroup:((i=this.orChildrenGroup)==null?void 0:i.map(s=>s.toReference()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var i,a,s,o;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.defaultValue)==null?void 0:i.toFlatJSON(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(l=>l.toFlatJSON(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(l=>l.toFlatJSON(e)))||[],...((o=this.entity)==null?void 0:o.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,like:this.like,parentRelationType:this.parentRelationType,asType:this.asType,entity:((e=this.entity)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var i,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.defaultValue)==null?void 0:i.toFlatGenerationTarget(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==n.CustomEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,i,a;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.andChildrenGroup)==null||t.forEach(s=>s.clearErrors()),(i=this.orChildrenGroup)==null||i.forEach(s=>s.clearErrors()),this.inferred&&((a=this.entity)==null||a.clearErrors()),this}validate(){const e=Qk(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){var b,v,D,O;const a=this.toJSON(),s=t||He(lu(this),n.DataType,this.project),o=s.split("-id"),l=o[o.length-1||0]||s;a.id=s;const p=xt(a,this.project);e&&p.setParent(e),i&&p.subscribe(),p.initChildren();const y=(b=this.defaultValue)==null?void 0:b.clone(p,l+"-default-value-id",i);p.defaultValue=y||null;const h=(v=this.andChildrenGroup)==null?void 0:v.map((S,x)=>S.clone(this,l+"-and-group-data-type-"+x+"-id",i)),m=(D=this.orChildrenGroup)==null?void 0:D.map((S,x)=>S.clone(this,l+"-or-group-data-type-"+x+"-id",i));if(p.andChildrenGroup=h||null,p.orChildrenGroup=m||null,this.entity&&this.entity.type===n.CustomEntity&&((O=this.entity)==null?void 0:O.parent)===this){const S=this.entity.clone(p,l+"-inferred-entity-id",i);p.setEntity(S)}else this.entity&&p.setEntity(this.entity);return p}merge(e){const t=[],i=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isNullable!==(e==null?void 0:e.isNullable)&&(this.sync({isNullable:e==null?void 0:e.isNullable}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),t.push(this)),this.constant!==(e==null?void 0:e.constant)&&(this.sync({constant:e==null?void 0:e.constant}),t.push(this)),this.like!==(e==null?void 0:e.like)&&(this.sync({like:e==null?void 0:e.like}),t.push(this)),e!=null&&e.inferred){if(e.entity&&e.entity.type===n.CustomEntity&&e.entity.parent===e){const s=e.entity.clone(this,this.id+"--inferred-entity-id",!0);this.setEntity(s),i.push(s)}else e.entity&&(this.setEntity(e.entity),t.push(this));this.inferred||(this.sync({inferred:!0}),t.push(this))}else if(this.inferred){if(this.sync({inferred:!1}),t.push(this),this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this))}else e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this));if(e.defaultValue)if(this.defaultValue){const{updated:s,added:o,removed:l}=this.defaultValue.merge(e.defaultValue);t.push(...s),i.push(...o),a.push(...l)}else{const s=e.defaultValue.clone(this,this.id+"--default-value-id",!0);this.setDefaultValue(s),i.push(s)}else if(this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}return{updated:g(t),added:g(i),removed:g(a),self:this}}addToAndGroup(e){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(e)||this.andChildrenGroup.push(e),this}addToOrGroup(e){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(e)||this.orChildrenGroup.push(e),this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}setEntity(e){return this.entity=e,this}isResolved(){return[n.BuiltInBaseEntity,n.ActionDescriptor].includes(this.parent.type)||er(this.parent)?!0:!(!this.entity&&(!this.andChildrenGroup||!this.andChildrenGroup.length)&&(!this.orChildrenGroup||!this.orChildrenGroup.length))}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const i={id:this.id+"--infered-entity",type:n.CustomEntity,version:1,name:C(this,this.project),description:((t=this.parent)==null?void 0:t.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},a=R(i,this.project);a.sync(i),a.setParent(this),a.initChildren(),this.setEntity(a)}return this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(Ee,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(Ee,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(Ee,"BASE_PROPERTIES",[...Ee.MUTABLE_BASE_PROPERTIES,...Ee.INMUTABLE_BASE_PROPERTIES]),c(Ee,"MUTABLE_META_PROPERTIES",[...Ee.MUTABLE_BASE_PROPERTIES,"inferred"]),c(Ee,"INMUTABLE_META_PROPERTIES",[...Ee.INMUTABLE_BASE_PROPERTIES]),c(Ee,"META_PROPERTIES",[...Ee.MUTABLE_META_PROPERTIES,...Ee.INMUTABLE_META_PROPERTIES]),c(Ee,"MUTABLE_UPSTREAM_PROPERTIES",["entity","andChildrenGroup","orChildrenGroup","parent"]),c(Ee,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(Ee,"UPSTREAM_PROPERTIES",[...Ee.MUTABLE_UPSTREAM_PROPERTIES,...Ee.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ee,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),c(Ee,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ee,"DOWNSTREAM_PROPERTIES",[...Ee.MUTABLE_DOWNSTREAM_PROPERTIES,...Ee.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ee,"PROPERTIES",[...Ee.META_PROPERTIES,...Ee.UPSTREAM_PROPERTIES,...Ee.DOWNSTREAM_PROPERTIES]);let Di=Ee;function t2(r){var l;const e=E6(),t=r.toJSON();e.safeParse(t).success;const a=n2(r),s=Cn(r),o=[...a,...s];if(r.id==="exec-sequentially-operation-call-id"){const p=z({id:`${r.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(r,r.project)}" with id "${r.id}" implements a non-abstract property "${C(r,r.project)}" with id "${r.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:r});o.push(p.error)}return r.outputs.forEach(p=>p.validate()),(l=r.error)==null||l.validate(),ae(r.errors,o)}function n2(r){const e=[];return r.inputs.forEach(t=>{t.validate()}),ae(r.errors,e)}const le=class le{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Operation);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"process",null);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"error",null);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let i=t;if(e.parent){const m=w(e.parent);i=t.get(m)}const a=w(e.declaration),s=t.get(a),o=e.calledByEntry.map(m=>{const b=w(m);return t.get(b)}),l=e.calledBySuccess.map(m=>{const b=w(m);return t.get(b)}),p=e.calledByError.map(m=>{const b=w(m);return t.get(b)}),y={id:e.id,version:1,type:n.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:i},h=R(y,t);return h.setParent(i),h.initChildren(),h}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=Je(i,{parent:{list:!1,types:[...ct,n.Project],optional:!0}},t);i=s.modifiedData,a.push(...s.errors,...Ne(i));const o=w(i.declaration);if(o){const l=zA(o,t);a.push(...l)}else{const l=`
37
+ Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}y===n.DataType&&(!i.parentRelationType||!(i.parentRelationType===lt.AndDataTypeGroup||i.parentRelationType===lt.OrDataTypeGroup))&&a.push(new E({id:`${e.id}--${f.InvalidParentRelationType}`,code:f.InvalidParentRelationType,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`,issue:null}))}return{errors:a,modifiedData:i}}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}addSelfToProject(){const e=[this],t=[],i=[];return this.parent.type===n.DataType?this.parentRelationType===lt.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===lt.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:g(e),added:g(t),removed:g(i),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(i=>i.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(i=>i.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.defaultValue&&(this.defaultValue=R(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this),this.defaultValue.initChildren()),this.initialData.entity)if(this.initialData.entity.type===n.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=e}else this.entity=R(this.initialData.entity,this.project);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(e=>R(e,this.project))),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(e=>R(e,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.isNullable=e.isNullable||this.isNullable,this.isList=e.isList||this.isList,this.constant=e.constant||this.constant,this.asType=e.asType||this.asType,this.options=e.options||this.options,this.parentRelationType=e.parentRelationType||this.parentRelationType,this.like=e.like||this.like,this.inferred=e.inferred||this.inferred,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const i=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});i.push(...s),a.push(...o)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});i.push(...s),a.push(...o)}if(!e){this.parent.type===n.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===n.DataType){if(this.parentRelationType===lt.AndDataTypeGroup){if(Array.isArray(s.andChildrenGroup)){const o=s.andChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.andChildrenGroup.splice(o,1)}}else if(this.parentRelationType===lt.OrDataTypeGroup&&Array.isArray(s.orChildrenGroup)){const o=s.orChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.orChildrenGroup.splice(o,1)}}else this.parent.removeDataType();i.push(s)}return{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.defaultValue){const{affected:i}=this.defaultValue.restore({seenEntities:e});t.push(...i)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:i}=this.entity.restore({seenEntities:e});t.push(...i)}if(this.parent.type===n.DataType){const i=this.parent;Array.isArray(i.andChildrenGroup)&&i.andChildrenGroup.push(this)}if(this.parent.type===n.DataType){const i=this.parent;this.parentRelationType===lt.AndDataTypeGroup?Array.isArray(i.andChildrenGroup)&&i.andChildrenGroup.push(this):this.parentRelationType===lt.OrDataTypeGroup&&Array.isArray(i.orChildrenGroup)&&i.orChildrenGroup.push(this)}else{const i=this.parent;i.setDataType(this),t.push(i)}return{affected:t,self:this}}toFlat(e=new Set){var i,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((i=this.andChildrenGroup)==null?void 0:i.flatMap(o=>o.toFlat(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlat(e)))||[],...((s=this.entity)==null?void 0:s.toFlat(e))||[]])}toFlatIds(e=new Set){var i,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((i=this.andChildrenGroup)==null?void 0:i.flatMap(o=>o.toFlatIds(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatIds(e)))||[],...((s=this.entity)==null?void 0:s.toFlatIds(e))||[]])}toJSON(){var e,t,i,a;return{id:this.id,version:this.version,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,asType:this.asType,defaultValue:((e=this.defaultValue)==null?void 0:e.toJSON())||null,like:this.like,parentRelationType:this.parentRelationType,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toJSON()))||null,orChildrenGroup:((i=this.orChildrenGroup)==null?void 0:i.map(s=>s.toJSON()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+N.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,isList:this.isList,isNullable:this.isNullable,options:this.options,constant:this.constant,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference())||null,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toReference()))||null,orChildrenGroup:((i=this.orChildrenGroup)==null?void 0:i.map(s=>s.toReference()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var i,a,s,o;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((i=this.defaultValue)==null?void 0:i.toFlatJSON(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(l=>l.toFlatJSON(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(l=>l.toFlatJSON(e)))||[],...((o=this.entity)==null?void 0:o.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,like:this.like,parentRelationType:this.parentRelationType,asType:this.asType,entity:((e=this.entity)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var i,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((i=this.defaultValue)==null?void 0:i.toFlatGenerationTarget(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==n.CustomEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,i,a;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.andChildrenGroup)==null||t.forEach(s=>s.clearErrors()),(i=this.orChildrenGroup)==null||i.forEach(s=>s.clearErrors()),this.inferred&&((a=this.entity)==null||a.clearErrors()),this}validate(){const e=Qk(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){var b,v,D,O;const a=this.toJSON(),s=t||He(lu(this),n.DataType,this.project),o=s.split("-id"),l=o[o.length-1||0]||s;a.id=s;const p=xt(a,this.project);e&&p.setParent(e),i&&p.subscribe(),p.initChildren();const y=(b=this.defaultValue)==null?void 0:b.clone(p,l+"-default-value-id",i);p.defaultValue=y||null;const h=(v=this.andChildrenGroup)==null?void 0:v.map((S,x)=>S.clone(this,l+"-and-group-data-type-"+x+"-id",i)),m=(D=this.orChildrenGroup)==null?void 0:D.map((S,x)=>S.clone(this,l+"-or-group-data-type-"+x+"-id",i));if(p.andChildrenGroup=h||null,p.orChildrenGroup=m||null,this.entity&&this.entity.type===n.CustomEntity&&((O=this.entity)==null?void 0:O.parent)===this){const S=this.entity.clone(p,l+"-inferred-entity-id",i);p.setEntity(S)}else this.entity&&p.setEntity(this.entity);return p}merge(e){const t=[],i=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isNullable!==(e==null?void 0:e.isNullable)&&(this.sync({isNullable:e==null?void 0:e.isNullable}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),t.push(this)),this.constant!==(e==null?void 0:e.constant)&&(this.sync({constant:e==null?void 0:e.constant}),t.push(this)),this.like!==(e==null?void 0:e.like)&&(this.sync({like:e==null?void 0:e.like}),t.push(this)),e!=null&&e.inferred){if(e.entity&&e.entity.type===n.CustomEntity&&e.entity.parent===e){const s=e.entity.clone(this,this.id+"--inferred-entity-id",!0);this.setEntity(s),i.push(s)}else e.entity&&(this.setEntity(e.entity),t.push(this));this.inferred||(this.sync({inferred:!0}),t.push(this))}else if(this.inferred){if(this.sync({inferred:!1}),t.push(this),this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this))}else e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this));if(e.defaultValue)if(this.defaultValue){const{updated:s,added:o,removed:l}=this.defaultValue.merge(e.defaultValue);t.push(...s),i.push(...o),a.push(...l)}else{const s=e.defaultValue.clone(this,this.id+"--default-value-id",!0);this.setDefaultValue(s),i.push(s)}else if(this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}return{updated:g(t),added:g(i),removed:g(a),self:this}}addToAndGroup(e){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(e)||this.andChildrenGroup.push(e),this}addToOrGroup(e){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(e)||this.orChildrenGroup.push(e),this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}setEntity(e){return this.entity=e,this}isResolved(){return[n.BuiltInBaseEntity,n.ActionDescriptor].includes(this.parent.type)||er(this.parent)?!0:!(!this.entity&&(!this.andChildrenGroup||!this.andChildrenGroup.length)&&(!this.orChildrenGroup||!this.orChildrenGroup.length))}isObject(){return!!this.entity&&(this.entity.type===n.CustomEntity||this.entity.name===I.JSON)}hasStrictObjectStructure(){var e;return this.isObject()&&((e=this.entity)==null?void 0:e.type)===n.CustomEntity}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const i={id:this.id+"--infered-entity",type:n.CustomEntity,version:1,name:C(this,this.project),description:((t=this.parent)==null?void 0:t.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},a=R(i,this.project);a.sync(i),a.setParent(this),a.initChildren(),this.setEntity(a)}return this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(Ee,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(Ee,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(Ee,"BASE_PROPERTIES",[...Ee.MUTABLE_BASE_PROPERTIES,...Ee.INMUTABLE_BASE_PROPERTIES]),c(Ee,"MUTABLE_META_PROPERTIES",[...Ee.MUTABLE_BASE_PROPERTIES,"inferred"]),c(Ee,"INMUTABLE_META_PROPERTIES",[...Ee.INMUTABLE_BASE_PROPERTIES]),c(Ee,"META_PROPERTIES",[...Ee.MUTABLE_META_PROPERTIES,...Ee.INMUTABLE_META_PROPERTIES]),c(Ee,"MUTABLE_UPSTREAM_PROPERTIES",["entity","andChildrenGroup","orChildrenGroup","parent"]),c(Ee,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(Ee,"UPSTREAM_PROPERTIES",[...Ee.MUTABLE_UPSTREAM_PROPERTIES,...Ee.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ee,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),c(Ee,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ee,"DOWNSTREAM_PROPERTIES",[...Ee.MUTABLE_DOWNSTREAM_PROPERTIES,...Ee.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ee,"PROPERTIES",[...Ee.META_PROPERTIES,...Ee.UPSTREAM_PROPERTIES,...Ee.DOWNSTREAM_PROPERTIES]);let Di=Ee;function t2(r){var l;const e=E6(),t=r.toJSON();e.safeParse(t).success;const a=n2(r),s=Cn(r),o=[...a,...s];if(r.id==="exec-sequentially-operation-call-id"){const p=z({id:`${r.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(r,r.project)}" with id "${r.id}" implements a non-abstract property "${C(r,r.project)}" with id "${r.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:r});o.push(p.error)}return r.outputs.forEach(p=>p.validate()),(l=r.error)==null||l.validate(),ae(r.errors,o)}function n2(r){const e=[];return r.inputs.forEach(t=>{t.validate()}),ae(r.errors,e)}const le=class le{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Operation);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"process",null);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"error",null);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let i=t;if(e.parent){const m=w(e.parent);i=t.get(m)}const a=w(e.declaration),s=t.get(a),o=e.calledByEntry.map(m=>{const b=w(m);return t.get(b)}),l=e.calledBySuccess.map(m=>{const b=w(m);return t.get(b)}),p=e.calledByError.map(m=>{const b=w(m);return t.get(b)}),y={id:e.id,version:1,type:n.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:i},h=R(y,t);return h.setParent(i),h.initChildren(),h}static validateGenerationTarget(e,t){let i=JSON.parse(JSON.stringify(e));const a=[],s=Je(i,{parent:{list:!1,types:[...ct,n.Project],optional:!0}},t);i=s.modifiedData,a.push(...s.errors,...Ne(i));const o=w(i.declaration);if(o){const l=zA(o,t);a.push(...l)}else{const l=`
38
38
  All built-in 'action-descriptor' entity ids are:
39
39
  - ${t.operationDeclarations.map(p=>`${p.id} (${C(p,t)})`).join(`
40
40
  - `)}.
@@ -109,6 +109,8 @@ export declare class DataTypeState implements IDataType, UserManagedEntityStateF
109
109
  setDefaultValue(value: PrimitiveValueState): DataTypeState;
110
110
  setEntity(entity: CustomEntityState | PrimitiveEntityState | ActionDescriptorState | BuiltInBaseEntityState | null): DataTypeState;
111
111
  isResolved(): boolean;
112
+ isObject(): boolean;
113
+ hasStrictObjectStructure(): boolean;
112
114
  inferFromInputs(inputs: VariableInputMapState[]): DataTypeState;
113
115
  }
114
116
  export type DataTypePayloadUnion = DataTypeState | DataTypeTypesUnion;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6053",
3
+ "version": "0.0.6055",
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",