@elyx-code/project-logic-tree 0.0.6102 → 0.0.6103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26193,7 +26193,7 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
26193
26193
|
return this.project.unsubscribeInstance(this), this;
|
|
26194
26194
|
}
|
|
26195
26195
|
sync(e) {
|
|
26196
|
-
return this.version = e.version || this.version, this.
|
|
26196
|
+
return this.version = e.version || this.version, this.options = e.options || this.options, this.parentRelationType = e.parentRelationType || this.parentRelationType, this.isList = e.isList !== void 0 ? e.isList : this.isList, this.inferred = e.inferred !== void 0 ? e.inferred : this.inferred, this.like = e.like !== void 0 ? e.like : this.like, this.asType = e.asType !== void 0 ? e.asType : this.asType, this.implementationChooseOne = e.implementationChooseOne !== void 0 ? e.implementationChooseOne : this.implementationChooseOne, this.constant = e.constant !== void 0 ? e.constant : this.constant, this.isNullable = e.isNullable !== void 0 ? e.isNullable : this.isNullable, this;
|
|
26197
26197
|
}
|
|
26198
26198
|
async load() {
|
|
26199
26199
|
return this;
|
package/dist/index.umd.cjs
CHANGED
|
@@ -34,7 +34,7 @@ ${Qn}`,issue:null}))}}}const o=r.parent&&t.get(r.parent)||t.getBuiltIn(r.parent)
|
|
|
34
34
|
The entitities of type '${U(f,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property so no 'parentRelationType' is needed.`,issue:null})),o.dataType)){const m=(p=o.dataType)==null?void 0:p.id;a.push(new b({id:`${e.id}--${h.NewEntityWouldOverriteExisting}`,code:h.NewEntityWouldOverriteExisting,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.type}', cannot be added as a child to the entity with id '${r.parent}' and type '${y}', because it already has a 'data-type' child with id '${m}'.
|
|
35
35
|
The entitities of type '${U(f,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property. You can inspect the existing data-type entity with the 'describe_entity' action. Like so:
|
|
36
36
|
${un({describe_entity:m})}
|
|
37
|
-
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}y===n.DataType&&(!r.parentRelationType||!(r.parentRelationType===We.AndDataTypeGroup||r.parentRelationType===We.OrDataTypeGroup))&&a.push(new b({id:`${e.id}--${h.InvalidParentRelationType}`,code:h.InvalidParentRelationType,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`,issue:null}))}return{errors:a,modifiedData:r}}get isGroup(){const e=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(e.length>1){let t=0;for(const r of e)if(r.isResolved&&(t++,t>1))return!0}return!1}get isResolved(){return[n.BuiltInBaseEntity,n.ActionDescriptor].includes(this.parent.type)||nr(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent.type===n.DataType?this.parentRelationType===We.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===We.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.defaultValue&&(this.defaultValue=g(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this),this.defaultValue.initChildren()),this.initialData.entity)if(this.initialData.entity.type===n.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=e}else this.entity=g(this.initialData.entity,this.project);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.isNullable=e.isNullable||this.isNullable,this.isList=e.isList||this.isList,this.constant=e.constant||this.constant,this.asType=e.asType||this.asType,this.options=e.options||this.options,this.parentRelationType=e.parentRelationType||this.parentRelationType,this.like=e.like||this.like,this.inferred=e.inferred||this.inferred,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(!e){this.parent.type===n.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===n.DataType){if(this.parentRelationType===We.AndDataTypeGroup){if(Array.isArray(s.andChildrenGroup)){const o=s.andChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.andChildrenGroup.splice(o,1)}}else if(this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(s.orChildrenGroup)){const o=s.orChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.orChildrenGroup.splice(o,1)}}else this.parent.removeDataType();r.push(s)}return{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.defaultValue){const{affected:r}=this.defaultValue.restore({seenEntities:e});t.push(...r)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:r}=this.entity.restore({seenEntities:e});t.push(...r)}if(this.parent.type===n.DataType){const r=this.parent;Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this)}if(this.parent.type===n.DataType){const r=this.parent;this.parentRelationType===We.AndDataTypeGroup?Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this):this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(r.orChildrenGroup)&&r.orChildrenGroup.push(this)}else{const r=this.parent;r.setDataType(this),t.push(r)}return{affected:t,self:this}}toFlat(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlat(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlat(e)))||[],...((s=this.entity)==null?void 0:s.toFlat(e))||[]])}toFlatIds(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlatIds(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatIds(e)))||[],...((s=this.entity)==null?void 0:s.toFlatIds(e))||[]])}toJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,asType:this.asType,defaultValue:((e=this.defaultValue)==null?void 0:e.toJSON())||null,like:this.like,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toJSON()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toJSON()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isList:this.isList,isNullable:this.isNullable,options:this.options,constant:this.constant,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference())||null,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toReference()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toReference()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r,a,s,o;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.defaultValue)==null?void 0:r.toFlatJSON(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(l=>l.toFlatJSON(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(l=>l.toFlatJSON(e)))||[],...((o=this.entity)==null?void 0:o.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,like:this.like,parentRelationType:this.parentRelationType,asType:this.asType,entity:((e=this.entity)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.defaultValue)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==n.CustomEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,r,a;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.andChildrenGroup)==null||t.forEach(s=>s.clearErrors()),(r=this.orChildrenGroup)==null||r.forEach(s=>s.clearErrors()),this.inferred&&((a=this.entity)==null||a.clearErrors()),this}validate(){const e=B2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(e=null,t=null,r=!0){var v,P,A,D;let a=e||this.parent;const s=t||Ze(ka(this),n.DataType,this.project),o=s.split("-id"),l=o[o.length-1||0]||s,p={id:s,version:1,type:n.DataType,isNullable:this.isNullable,isList:this.isList,constant:this.constant,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,defaultValue:null,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:a.toReference()},y=qt(p,this.project);e&&y.setParent(e),r&&y.subscribe(),y.initChildren();const f=(v=this.defaultValue)==null?void 0:v.clone(y,l+"-default-value-id",r);y.defaultValue=f||null;const m=(P=this.andChildrenGroup)==null?void 0:P.map((F,k)=>F.clone(this,l+"-and-group-data-type-"+k+"-id",r)),R=(A=this.orChildrenGroup)==null?void 0:A.map((F,k)=>F.clone(this,l+"-or-group-data-type-"+k+"-id",r));if(y.andChildrenGroup=m||null,y.orChildrenGroup=R||null,this.entity&&this.entity.type===n.CustomEntity&&((D=this.entity)==null?void 0:D.parent)===this){const F=this.entity.clone(y,l+"-inferred-entity-id",r);y.setEntity(F)}else this.entity&&y.setEntity(this.entity);return y}merge(e){const t=[],r=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isNullable!==(e==null?void 0:e.isNullable)&&(this.sync({isNullable:e==null?void 0:e.isNullable}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),t.push(this)),this.constant!==(e==null?void 0:e.constant)&&(this.sync({constant:e==null?void 0:e.constant}),t.push(this)),this.like!==(e==null?void 0:e.like)&&(this.sync({like:e==null?void 0:e.like}),t.push(this)),e!=null&&e.inferred){if(e.entity&&e.entity.type===n.CustomEntity&&e.entity.parent===e){const s=e.entity.clone(this,this.id+"--inferred-entity-id",!0);this.setEntity(s),r.push(s)}else e.entity&&(this.setEntity(e.entity),t.push(this));this.inferred||(this.sync({inferred:!0}),t.push(this))}else if(this.inferred){if(this.sync({inferred:!1}),t.push(this),this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this))}else e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this));if(e.defaultValue)if(this.defaultValue){const{updated:s,added:o,removed:l}=this.defaultValue.merge(e.defaultValue);t.push(...s),r.push(...o),a.push(...l)}else{const s=e.defaultValue.clone(this,this.id+"--default-value-id",!0);this.setDefaultValue(s),r.push(s)}else if(this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}return{updated:E(t),added:E(r),removed:E(a),self:this}}addToAndGroup(e){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(e)||this.andChildrenGroup.push(e),this}addToOrGroup(e){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(e)||this.orChildrenGroup.push(e),this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}setEntity(e){return this.entity=e,this}isObject(){return!!this.entity&&(this.entity.type===n.CustomEntity||this.entity.name===I.KeyValue)}hasStrictObjectStructure(){var e;return this.isObject()&&((e=this.entity)==null?void 0:e.type)===n.CustomEntity}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const r={id:this.id+"--infered-entity",type:n.CustomEntity,version:1,name:C(this,this.project),description:((t=this.parent)==null?void 0:t.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},a=g(r,this.project);a.sync(r),a.setParent(this),a.initChildren(),this.setEntity(a)}return this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(ge,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(ge,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(ge,"BASE_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"MUTABLE_META_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,"inferred"]),c(ge,"INMUTABLE_META_PROPERTIES",[...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"META_PROPERTIES",[...ge.MUTABLE_META_PROPERTIES,...ge.INMUTABLE_META_PROPERTIES]),c(ge,"MUTABLE_UPSTREAM_PROPERTIES",["entity","andChildrenGroup","orChildrenGroup","parent"]),c(ge,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(ge,"UPSTREAM_PROPERTIES",[...ge.MUTABLE_UPSTREAM_PROPERTIES,...ge.INMUTABLE_UPSTREAM_PROPERTIES]),c(ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),c(ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ge,"DOWNSTREAM_PROPERTIES",[...ge.MUTABLE_DOWNSTREAM_PROPERTIES,...ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ge,"PROPERTIES",[...ge.META_PROPERTIES,...ge.UPSTREAM_PROPERTIES,...ge.DOWNSTREAM_PROPERTIES]);let wi=ge;function _2(i){var l;const e=H6(),t=i.toJSON();e.safeParse(t).success;const a=N2(i),s=wn(i),o=[...a,...s];if(i.id==="exec-sequentially-operation-call-id"){const p=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});o.push(p.error)}return i.outputs.forEach(p=>p.validate()),(l=i.error)==null||l.validate(),ie(i.errors,o)}function N2(i){const e=[];return i.inputs.forEach(t=>{t.validate()}),ie(i.errors,e)}const de=class de{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Operation);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"process",null);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"error",null);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const m=N(e.parent);r=t.get(m)}const a=N(e.declaration),s=t.get(a),o=e.calledByEntry.map(m=>{const R=N(m);return t.get(R)}),l=e.calledBySuccess.map(m=>{const R=N(m);return t.get(R)}),p=e.calledByError.map(m=>{const R=N(m);return t.get(R)}),y={id:e.id,version:1,type:n.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:r},f=g(y,t);return f.setParent(r),f.initChildren(),f}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=Ye(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);r=s.modifiedData,a.push(...s.errors,...Le(r));const o=N(r.declaration);if(o){const l=kP(o,t);a.push(...l)}else{const l=`
|
|
37
|
+
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}y===n.DataType&&(!r.parentRelationType||!(r.parentRelationType===We.AndDataTypeGroup||r.parentRelationType===We.OrDataTypeGroup))&&a.push(new b({id:`${e.id}--${h.InvalidParentRelationType}`,code:h.InvalidParentRelationType,severity:T.Error,message:`The entity with id '${e.id}' and type '${e.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`,issue:null}))}return{errors:a,modifiedData:r}}get isGroup(){const e=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(e.length>1){let t=0;for(const r of e)if(r.isResolved&&(t++,t>1))return!0}return!1}get isResolved(){return[n.BuiltInBaseEntity,n.ActionDescriptor].includes(this.parent.type)||nr(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}addSelfToProject(){const e=[this],t=[],r=[];return this.parent.type===n.DataType?this.parentRelationType===We.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===We.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:E(e),added:E(t),removed:E(r),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(r=>r.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.defaultValue&&(this.defaultValue=g(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this),this.defaultValue.initChildren()),this.initialData.entity)if(this.initialData.entity.type===n.GenericReference){const e=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=e}else this.entity=g(this.initialData.entity,this.project);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(e=>{const t=g(e,this.project);return t.setParent(this),t.initChildren(),t})),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.version=e.version||this.version,this.options=e.options||this.options,this.parentRelationType=e.parentRelationType||this.parentRelationType,this.isList=e.isList!==void 0?e.isList:this.isList,this.inferred=e.inferred!==void 0?e.inferred:this.inferred,this.like=e.like!==void 0?e.like:this.like,this.asType=e.asType!==void 0?e.asType:this.asType,this.implementationChooseOne=e.implementationChooseOne!==void 0?e.implementationChooseOne:this.implementationChooseOne,this.constant=e.constant!==void 0?e.constant:this.constant,this.isNullable=e.isNullable!==void 0?e.isNullable:this.isNullable,this}async load(){return this}async create(){return this}async update(e){return this}async delete(){return this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const r=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});r.push(...s),a.push(...o)}if(!e){this.parent.type===n.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===n.DataType){if(this.parentRelationType===We.AndDataTypeGroup){if(Array.isArray(s.andChildrenGroup)){const o=s.andChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.andChildrenGroup.splice(o,1)}}else if(this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(s.orChildrenGroup)){const o=s.orChildrenGroup.findIndex(l=>l.id===this.id);o!==-1&&s.orChildrenGroup.splice(o,1)}}else this.parent.removeDataType();r.push(s)}return{affected:E(r),removed:E(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.defaultValue){const{affected:r}=this.defaultValue.restore({seenEntities:e});t.push(...r)}if(this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:r}=this.entity.restore({seenEntities:e});t.push(...r)}if(this.parent.type===n.DataType){const r=this.parent;Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this)}if(this.parent.type===n.DataType){const r=this.parent;this.parentRelationType===We.AndDataTypeGroup?Array.isArray(r.andChildrenGroup)&&r.andChildrenGroup.push(this):this.parentRelationType===We.OrDataTypeGroup&&Array.isArray(r.orChildrenGroup)&&r.orChildrenGroup.push(this)}else{const r=this.parent;r.setDataType(this),t.push(r)}return{affected:t,self:this}}toFlat(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlat(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlat(e)))||[],...((s=this.entity)==null?void 0:s.toFlat(e))||[]])}toFlatIds(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.andChildrenGroup)==null?void 0:r.flatMap(o=>o.toFlatIds(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatIds(e)))||[],...((s=this.entity)==null?void 0:s.toFlatIds(e))||[]])}toJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,asType:this.asType,defaultValue:((e=this.defaultValue)==null?void 0:e.toJSON())||null,like:this.like,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toJSON()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toJSON()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toReference(){return{id:this.id+"--"+_.UUID.uuid()+"--ref",type:n.GenericReference,entityId:this.id,entityType:this.type}}toShallowJSON(){var e,t,r,a;return{id:this.id,version:this.version,type:this.type,isList:this.isList,isNullable:this.isNullable,options:this.options,constant:this.constant,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,defaultValue:((e=this.defaultValue)==null?void 0:e.toReference())||null,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(s=>s.toReference()))||null,orChildrenGroup:((r=this.orChildrenGroup)==null?void 0:r.map(s=>s.toReference()))||null,entity:((a=this.entity)==null?void 0:a.toReference())||null,parent:this.parent.toReference()}}toFlatJSON(e=new Set){var r,a,s,o;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.defaultValue)==null?void 0:r.toFlatJSON(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(l=>l.toFlatJSON(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(l=>l.toFlatJSON(e)))||[],...((o=this.entity)==null?void 0:o.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,isNullable:this.isNullable,options:this.options,isList:this.isList,constant:this.constant,like:this.like,parentRelationType:this.parentRelationType,asType:this.asType,entity:((e=this.entity)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.defaultValue)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.andChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...((s=this.orChildrenGroup)==null?void 0:s.flatMap(o=>o.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==n.CustomEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,r,a;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.andChildrenGroup)==null||t.forEach(s=>s.clearErrors()),(r=this.orChildrenGroup)==null||r.forEach(s=>s.clearErrors()),this.inferred&&((a=this.entity)==null||a.clearErrors()),this}validate(){const e=B2(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(e=null,t=null,r=!0){var v,P,A,D;let a=e||this.parent;const s=t||Ze(ka(this),n.DataType,this.project),o=s.split("-id"),l=o[o.length-1||0]||s,p={id:s,version:1,type:n.DataType,isNullable:this.isNullable,isList:this.isList,constant:this.constant,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,defaultValue:null,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:a.toReference()},y=qt(p,this.project);e&&y.setParent(e),r&&y.subscribe(),y.initChildren();const f=(v=this.defaultValue)==null?void 0:v.clone(y,l+"-default-value-id",r);y.defaultValue=f||null;const m=(P=this.andChildrenGroup)==null?void 0:P.map((F,k)=>F.clone(this,l+"-and-group-data-type-"+k+"-id",r)),R=(A=this.orChildrenGroup)==null?void 0:A.map((F,k)=>F.clone(this,l+"-or-group-data-type-"+k+"-id",r));if(y.andChildrenGroup=m||null,y.orChildrenGroup=R||null,this.entity&&this.entity.type===n.CustomEntity&&((D=this.entity)==null?void 0:D.parent)===this){const F=this.entity.clone(y,l+"-inferred-entity-id",r);y.setEntity(F)}else this.entity&&y.setEntity(this.entity);return y}merge(e){const t=[],r=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isNullable!==(e==null?void 0:e.isNullable)&&(this.sync({isNullable:e==null?void 0:e.isNullable}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),t.push(this)),this.constant!==(e==null?void 0:e.constant)&&(this.sync({constant:e==null?void 0:e.constant}),t.push(this)),this.like!==(e==null?void 0:e.like)&&(this.sync({like:e==null?void 0:e.like}),t.push(this)),e!=null&&e.inferred){if(e.entity&&e.entity.type===n.CustomEntity&&e.entity.parent===e){const s=e.entity.clone(this,this.id+"--inferred-entity-id",!0);this.setEntity(s),r.push(s)}else e.entity&&(this.setEntity(e.entity),t.push(this));this.inferred||(this.sync({inferred:!0}),t.push(this))}else if(this.inferred){if(this.sync({inferred:!1}),t.push(this),this.entity&&this.entity.type===n.CustomEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this))}else e.entity!==this.entity&&(this.setEntity(e.entity),t.push(this));if(e.defaultValue)if(this.defaultValue){const{updated:s,added:o,removed:l}=this.defaultValue.merge(e.defaultValue);t.push(...s),r.push(...o),a.push(...l)}else{const s=e.defaultValue.clone(this,this.id+"--default-value-id",!0);this.setDefaultValue(s),r.push(s)}else if(this.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:new Set});a.push(...o),s.push(...s)}return{updated:E(t),added:E(r),removed:E(a),self:this}}addToAndGroup(e){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(e)||this.andChildrenGroup.push(e),this}addToOrGroup(e){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(e)||this.orChildrenGroup.push(e),this}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}setEntity(e){return this.entity=e,this}isObject(){return!!this.entity&&(this.entity.type===n.CustomEntity||this.entity.name===I.KeyValue)}hasStrictObjectStructure(){var e;return this.isObject()&&((e=this.entity)==null?void 0:e.type)===n.CustomEntity}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const r={id:this.id+"--infered-entity",type:n.CustomEntity,version:1,name:C(this,this.project),description:((t=this.parent)==null?void 0:t.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},a=g(r,this.project);a.sync(r),a.setParent(this),a.initChildren(),this.setEntity(a)}return this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(ge,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(ge,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(ge,"BASE_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"MUTABLE_META_PROPERTIES",[...ge.MUTABLE_BASE_PROPERTIES,"inferred"]),c(ge,"INMUTABLE_META_PROPERTIES",[...ge.INMUTABLE_BASE_PROPERTIES]),c(ge,"META_PROPERTIES",[...ge.MUTABLE_META_PROPERTIES,...ge.INMUTABLE_META_PROPERTIES]),c(ge,"MUTABLE_UPSTREAM_PROPERTIES",["entity","andChildrenGroup","orChildrenGroup","parent"]),c(ge,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(ge,"UPSTREAM_PROPERTIES",[...ge.MUTABLE_UPSTREAM_PROPERTIES,...ge.INMUTABLE_UPSTREAM_PROPERTIES]),c(ge,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),c(ge,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ge,"DOWNSTREAM_PROPERTIES",[...ge.MUTABLE_DOWNSTREAM_PROPERTIES,...ge.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ge,"PROPERTIES",[...ge.META_PROPERTIES,...ge.UPSTREAM_PROPERTIES,...ge.DOWNSTREAM_PROPERTIES]);let wi=ge;function _2(i){var l;const e=H6(),t=i.toJSON();e.safeParse(t).success;const a=N2(i),s=wn(i),o=[...a,...s];if(i.id==="exec-sequentially-operation-call-id"){const p=H({id:`${i.id}--${M.PropertyImplementsNonAbstact}`,message:`Property "${C(i,i.project)}" with id "${i.id}" implements a non-abstract property "${C(i,i.project)}" with id "${i.id}".`,issue:null,severity:T.Error,code:M.PropertyImplementsNonAbstact,entity:i});o.push(p.error)}return i.outputs.forEach(p=>p.validate()),(l=i.error)==null||l.validate(),ie(i.errors,o)}function N2(i){const e=[];return i.inputs.forEach(t=>{t.validate()}),ie(i.errors,e)}const de=class de{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",n.Operation);c(this,"declaration");c(this,"inputs",[]);c(this,"outputs",[]);c(this,"process",null);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"error",null);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"parent");c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.x=e.x,this.y=e.y}static fromGenerationTarget(e,t){let r=t;if(e.parent){const m=N(e.parent);r=t.get(m)}const a=N(e.declaration),s=t.get(a),o=e.calledByEntry.map(m=>{const R=N(m);return t.get(R)}),l=e.calledBySuccess.map(m=>{const R=N(m);return t.get(R)}),p=e.calledByError.map(m=>{const R=N(m);return t.get(R)}),y={id:e.id,version:1,type:n.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:r},f=g(y,t);return f.setParent(r),f.initChildren(),f}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],s=Ye(r,{parent:{list:!1,types:[...ut,n.Project],optional:!0}},t);r=s.modifiedData,a.push(...s.errors,...Le(r));const o=N(r.declaration);if(o){const l=kP(o,t);a.push(...l)}else{const l=`
|
|
38
38
|
All built-in 'action-descriptor' entity ids are:
|
|
39
39
|
- ${t.operationDeclarations.map(p=>`${p.id} (${C(p,t)})`).join(`
|
|
40
40
|
- `)}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyx-code/project-logic-tree",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6103",
|
|
4
4
|
"author": "Sergio Herrero",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"description": "An installable module which contains the type definitions and ephemeral state management for a projects' logic tree data structure",
|