@elyx-code/project-logic-tree 0.0.6131 → 0.0.6132
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 +2 -2
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26583,7 +26583,7 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
26583
26583
|
if (y.andChildrenGroup = h || null, y.orChildrenGroup = E || null, this.entity && this.entity.type === i.DefinitionEntity && ((I = this.entity) == null ? void 0 : I.parent) === this) {
|
|
26584
26584
|
const S = this.entity.clone(
|
|
26585
26585
|
y,
|
|
26586
|
-
|
|
26586
|
+
B.UUID.uuid(),
|
|
26587
26587
|
n
|
|
26588
26588
|
);
|
|
26589
26589
|
y.setEntity(S);
|
|
@@ -26606,7 +26606,7 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
26606
26606
|
if (e.entity && e.entity.type === i.DefinitionEntity && e.entity.parent === e) {
|
|
26607
26607
|
const s = e.entity.clone(
|
|
26608
26608
|
this,
|
|
26609
|
-
|
|
26609
|
+
B.UUID.uuid(),
|
|
26610
26610
|
!0
|
|
26611
26611
|
);
|
|
26612
26612
|
this.setEntity(s), n.push(s);
|
package/dist/index.umd.cjs
CHANGED
|
@@ -57,7 +57,7 @@ ${dr}`,issue:null}))}}}const o=n.parent&&t.get(n.parent)||t.getBuiltIn(n.parent)
|
|
|
57
57
|
The entitities of type '${q(h,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property so no 'parentRelationType' is needed.`,issue:null})),o.dataType)){const f=(p=o.dataType)==null?void 0:p.id;a.push(new g({id:`${e.id}--${T.NewEntityWouldOverriteExisting}`,code:T.NewEntityWouldOverriteExisting,severity:E.Error,message:`The entity with id '${e.id}' and type '${e.type}', cannot be added as a child to the entity with id '${n.parent}' and type '${u}', because it already has a 'data-type' child with id '${f}'.
|
|
58
58
|
The entitities of type '${q(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:
|
|
59
59
|
${bn({describe_entity:f})}
|
|
60
|
-
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}u===i.DataType&&(!n.parentRelationType||!(n.parentRelationType===et.AndDataTypeGroup||n.parentRelationType===et.OrDataTypeGroup))&&a.push(new g({id:`${e.id}--${T.InvalidParentRelationType}`,code:T.InvalidParentRelationType,severity:E.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:n}}get isGroup(){const e=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(e.length>1){let t=0;for(const n of e)if(n.isResolved&&(t++,t>1))return!0}return!1}get isResolved(){return[i.BuiltInBaseEntity,i.ActionDescriptor].includes(this.parent.type)||pr(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}hydrateAncestors(){const e=[],t=[],n=[];if(this.initialData.parent){const a=A(this.initialData.parent),s=this.project.get(a);s&&(this.setParent(s),e.push(s))}if(this.initialData.entity){const a=A(this.initialData.entity),s=this.project.get(a);s&&(s.type===i.DefinitionEntity&&s.parent===this||(this.setEntity(s),e.push(s)))}return{updated:m(e),added:m(t),removed:m(n),self:this}}afterAllChildrenInitialized(){const e=[],t=[],n=[];return this.initialized=!0,{updated:m(e),added:m(t),removed:m(n),self:this}}addSelfToProject(){const e=[this],t=[],n=[];return this.parent.type===i.DataType?this.parentRelationType===et.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===et.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:m(e),added:m(t),removed:m(n),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(n=>n.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(n=>n.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){var e,t;if(this.initialized)return this;if(this.initialized=!0,this.initialData.entity)if(this.initialData.entity.type===i.GenericReference){const n=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=n}else this.entity=b(this.initialData.entity,this.project),((t=(e=this.initialData.entity)==null?void 0:e.parent)==null?void 0:t.id)===this.id&&this.entity.setParent(this),this.entity.type===i.DefinitionEntity&&this.entity.initChildren();return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(n=>{const a=b(n,this.project);return a.setParent(this),a.initChildren(),a})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(n=>{const a=b(n,this.project);return a.setParent(this),a.initChildren(),a})),this.afterAllChildrenInitialized(),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}async load(e=V,...t){return await pe.repository.load(this.id,...t),this}async create(e=V,...t){return await pe.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await pe.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await pe.repository.delete(this.id,...t),this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const n=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.entity&&this.entity.type===i.DefinitionEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s),a.push(...o)}if(!e){this.parent.type===i.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===i.DataType){if(this.parentRelationType===et.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===et.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();n.push(s)}return{affected:m(n),removed:m(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.entity&&this.entity.type===i.DefinitionEntity&&this.entity.parent===this){const{affected:n}=this.entity.restore({seenEntities:e});t.push(...n)}if(this.parent.type===i.DataType){const n=this.parent;Array.isArray(n.andChildrenGroup)&&n.andChildrenGroup.push(this)}if(this.parent.type===i.DataType){const n=this.parent;this.parentRelationType===et.AndDataTypeGroup?Array.isArray(n.andChildrenGroup)&&n.andChildrenGroup.push(this):this.parentRelationType===et.OrDataTypeGroup&&Array.isArray(n.orChildrenGroup)&&n.orChildrenGroup.push(this)}else{const n=this.parent;n.setDataType(this),t.push(n)}return{affected:t,self:this}}toFlat(e=new Set){var n,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((n=this.andChildrenGroup)==null?void 0:n.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 n,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((n=this.andChildrenGroup)==null?void 0:n.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(e=new Set){var t,n,a,s;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,type:this.type,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(o=>o.toJSON(e)))||null,orChildrenGroup:((n=this.orChildrenGroup)==null?void 0:n.map(o=>o.toJSON(e)))||null,entity:((a=this.entity)==null?void 0:a.parent)===this?this.entity.toJSON(e):((s=this.entity)==null?void 0:s.toReference())||null,parent:this.parent.toReference()})}toJSONClone(e=L){var n,a,s,o,l,p,u,h,f;let t;return(n=e.seenEntityMaps)!=null&&n.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||Ye(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(a=e.seenEntities)!=null&&a.has(t)||(s=e.seenEntities)!=null&&s.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((o=e.seenEntities)==null||o.add(t),(l=e.seenEntities)==null||l.add(this.id),{id:t,version:this.version,type:this.type,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((p=this.andChildrenGroup)==null?void 0:p.map(R=>R.toJSONClone({...e,newId:null})))||null,orChildrenGroup:((u=this.orChildrenGroup)==null?void 0:u.map(R=>R.toJSONClone({...e,newId:null})))||null,entity:((h=this.entity)==null?void 0:h.parent)===this?this.entity.toJSONClone({...e,newId:null}):((f=this.entity)==null?void 0:f.toReference({seenEntityMaps:e.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=L){var n;let t=this.id;return(n=e.seenEntityMaps)!=null&&n.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+M.UUID.uuid()+"--ref",type:i.GenericReference,entityId:t,entityType:this.type}}toShallowJSON(e=L){var n,a,s,o;let t=this.id;return(n=e.seenEntityMaps)!=null&&n.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,type:this.type,isList:this.isList,options:this.options,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((a=this.andChildrenGroup)==null?void 0:a.map(l=>l.toReference(e)))||null,orChildrenGroup:((s=this.orChildrenGroup)==null?void 0:s.map(l=>l.toReference(e)))||null,entity:((o=this.entity)==null?void 0:o.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){var n,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((n=this.andChildrenGroup)==null?void 0:n.flatMap(o=>o.toFlatJSON(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatJSON(e)))||[],...((s=this.entity)==null?void 0:s.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,options:this.options,isList:this.isList,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 n,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((n=this.andChildrenGroup)==null?void 0:n.flatMap(s=>s.toFlatGenerationTarget(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(s=>s.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==i.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,n;return this.errors=[],(e=this.andChildrenGroup)==null||e.forEach(a=>a.clearErrors()),(t=this.orChildrenGroup)==null||t.forEach(a=>a.clearErrors()),this.inferred&&((n=this.entity)==null||n.clearErrors()),this}validate(){const e=_7(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,n=!0){var v,I,D;let a=He(e,this),s=e||this.parent;const o=t||de(Xa(this),i.DataType,a),l=o.split("-id"),p=l[l.length-1||0]||o,u={id:o,version:1,type:i.DataType,isList:this.isList,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:s.toReference()},h=ke(u,a);e&&h.setParent(e),n&&h.subscribe(),h.initChildren();const f=(v=this.andChildrenGroup)==null?void 0:v.map((S,$)=>S.clone(h,p+"-and-group-data-type-"+$+"-id",n)),R=(I=this.orChildrenGroup)==null?void 0:I.map((S,$)=>S.clone(h,p+"-or-group-data-type-"+$+"-id",n));if(h.andChildrenGroup=f||null,h.orChildrenGroup=R||null,this.entity&&this.entity.type===i.DefinitionEntity&&((D=this.entity)==null?void 0:D.parent)===this){const S=this.entity.clone(h,p+"-inferred-entity-id",n);h.setEntity(S)}else this.entity&&h.setEntity(this.entity);return h}merge(e){const t=[],n=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),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===i.DefinitionEntity&&e.entity.parent===e){const s=e.entity.clone(this,this.id+"--"+M.UUID.uuid()+"--inferred-entity-id",!0);this.setEntity(s),n.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===i.DefinitionEntity&&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));return{updated:m(t),added:m(n),removed:m(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}setEntity(e){return this.entity=e,this}isObject(){return!!this.entity&&(this.entity.type===i.DefinitionEntity||this.entity.name===C.KeyValue)}hasStrictObjectStructure(){var e;return this.isObject()&&((e=this.entity)==null?void 0:e.type)===i.DefinitionEntity}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const n={id:this.id+"--"+M.UUID.uuid()+"--infered-entity",type:i.DefinitionEntity,version:1,name:w(this.parent,this.project)+" data type definition",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=b(n,this.project);a.setParent(this),a.initChildren(),a.sync(n),this.setEntity(a)}return this.entity&&this.entity.type===i.DefinitionEntity&&this.entity.parent!==this&&this.entity.setParent(this),this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(pe,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(pe,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(pe,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(pe,"BASE_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"MUTABLE_META_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,"inferred"]),c(pe,"INMUTABLE_META_PROPERTIES",[...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"META_PROPERTIES",[...pe.MUTABLE_META_PROPERTIES,...pe.INMUTABLE_META_PROPERTIES]),c(pe,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),c(pe,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(pe,"UPSTREAM_PROPERTIES",[...pe.MUTABLE_UPSTREAM_PROPERTIES,...pe.INMUTABLE_UPSTREAM_PROPERTIES]),c(pe,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),c(pe,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),c(pe,"DOWNSTREAM_PROPERTIES",[...pe.MUTABLE_DOWNSTREAM_PROPERTIES,...pe.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(pe,"PROPERTIES",[...pe.META_PROPERTIES,...pe.UPSTREAM_PROPERTIES,...pe.DOWNSTREAM_PROPERTIES]);let ki=pe;function N7(r){var l;const e=K6(),t=r.toJSON();e.safeParse(t).success;const a=L7(r),s=kn(r),o=[...a,...s];if(r.id==="exec-sequentially-operation-call-id"){const p=Q({id:`${r.id}--${G.PropertyImplementsNonAbstact}`,message:`Property "${w(r,r.project)}" with id "${r.id}" implements a non-abstract property "${w(r,r.project)}" with id "${r.id}".`,issue:null,severity:E.Error,code:G.PropertyImplementsNonAbstact,entity:r});o.push(p.error)}return r.outputs.forEach(p=>p.validate()),(l=r.error)==null||l.validate(),Be(r.errors,o)}function L7(r){const e=[];return r.inputs.forEach(t=>{t.validate()}),Be(r.errors,e)}const ye=class ye{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",i.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 n=t;if(e.parent){const f=A(e.parent);n=t.get(f)}const a=A(e.declaration),s=t.get(a),o=e.calledByEntry.map(f=>{const R=A(f);return t.get(R)}),l=e.calledBySuccess.map(f=>{const R=A(f);return t.get(R)}),p=e.calledByError.map(f=>{const R=A(f);return t.get(R)}),u={id:e.id,version:1,type:i.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:n},h=b(u,t);return h.setParent(n),h.initChildren(),h}static validateGenerationTarget(e,t){let n=JSON.parse(JSON.stringify(e));const a=[],s=tt(n,{parent:{list:!1,types:[...pt,i.Project],optional:!0}},t);n=s.modifiedData,a.push(...s.errors,...je(n));const o=A(n.declaration);if(o){const l=SS(o,t);a.push(...l)}else{const l=`
|
|
60
|
+
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}u===i.DataType&&(!n.parentRelationType||!(n.parentRelationType===et.AndDataTypeGroup||n.parentRelationType===et.OrDataTypeGroup))&&a.push(new g({id:`${e.id}--${T.InvalidParentRelationType}`,code:T.InvalidParentRelationType,severity:E.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:n}}get isGroup(){const e=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(e.length>1){let t=0;for(const n of e)if(n.isResolved&&(t++,t>1))return!0}return!1}get isResolved(){return[i.BuiltInBaseEntity,i.ActionDescriptor].includes(this.parent.type)||pr(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(e){return{errors:[],modifiedData:e}}hydrateAncestors(){const e=[],t=[],n=[];if(this.initialData.parent){const a=A(this.initialData.parent),s=this.project.get(a);s&&(this.setParent(s),e.push(s))}if(this.initialData.entity){const a=A(this.initialData.entity),s=this.project.get(a);s&&(s.type===i.DefinitionEntity&&s.parent===this||(this.setEntity(s),e.push(s)))}return{updated:m(e),added:m(t),removed:m(n),self:this}}afterAllChildrenInitialized(){const e=[],t=[],n=[];return this.initialized=!0,{updated:m(e),added:m(t),removed:m(n),self:this}}addSelfToProject(){const e=[this],t=[],n=[];return this.parent.type===i.DataType?this.parentRelationType===et.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===et.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this),e.push(this.parent),{updated:m(e),added:m(t),removed:m(n),self:this}}setParent(e){return this.parent=e,this}removeChildGroup(e){if(this.andChildrenGroup){const t=this.andChildrenGroup.findIndex(n=>n.id===e.id);t!==-1&&this.andChildrenGroup.splice(t,1)}if(this.orChildrenGroup){const t=this.orChildrenGroup.findIndex(n=>n.id===e.id);t!==-1&&this.orChildrenGroup.splice(t,1)}return this}initChildren(){var e,t;if(this.initialized)return this;if(this.initialized=!0,this.initialData.entity)if(this.initialData.entity.type===i.GenericReference){const n=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=n}else this.entity=b(this.initialData.entity,this.project),((t=(e=this.initialData.entity)==null?void 0:e.parent)==null?void 0:t.id)===this.id&&this.entity.setParent(this),this.entity.type===i.DefinitionEntity&&this.entity.initChildren();return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(n=>{const a=b(n,this.project);return a.setParent(this),a.initChildren(),a})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(n=>{const a=b(n,this.project);return a.setParent(this),a.initChildren(),a})),this.afterAllChildrenInitialized(),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}async load(e=V,...t){return await pe.repository.load(this.id,...t),this}async create(e=V,...t){return await pe.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await pe.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await pe.repository.delete(this.id,...t),this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){const n=[],a=[];if(t.has(this.id))return{affected:[],removed:[]};if(t.add(this.id),a.push(this),this.unsubscribe(),this.entity&&this.entity.type===i.DefinitionEntity&&this.entity.parent===this){const{affected:s,removed:o}=this.entity.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s),a.push(...o)}if(!e){this.parent.type===i.DataType&&this.parent.removeChildGroup(this);const s=this.parent;if(s.type===i.DataType){if(this.parentRelationType===et.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===et.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();n.push(s)}return{affected:m(n),removed:m(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.entity&&this.entity.type===i.DefinitionEntity&&this.entity.parent===this){const{affected:n}=this.entity.restore({seenEntities:e});t.push(...n)}if(this.parent.type===i.DataType){const n=this.parent;Array.isArray(n.andChildrenGroup)&&n.andChildrenGroup.push(this)}if(this.parent.type===i.DataType){const n=this.parent;this.parentRelationType===et.AndDataTypeGroup?Array.isArray(n.andChildrenGroup)&&n.andChildrenGroup.push(this):this.parentRelationType===et.OrDataTypeGroup&&Array.isArray(n.orChildrenGroup)&&n.orChildrenGroup.push(this)}else{const n=this.parent;n.setDataType(this),t.push(n)}return{affected:t,self:this}}toFlat(e=new Set){var n,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((n=this.andChildrenGroup)==null?void 0:n.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 n,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((n=this.andChildrenGroup)==null?void 0:n.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(e=new Set){var t,n,a,s;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,type:this.type,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((t=this.andChildrenGroup)==null?void 0:t.map(o=>o.toJSON(e)))||null,orChildrenGroup:((n=this.orChildrenGroup)==null?void 0:n.map(o=>o.toJSON(e)))||null,entity:((a=this.entity)==null?void 0:a.parent)===this?this.entity.toJSON(e):((s=this.entity)==null?void 0:s.toReference())||null,parent:this.parent.toReference()})}toJSONClone(e=L){var n,a,s,o,l,p,u,h,f;let t;return(n=e.seenEntityMaps)!=null&&n.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||Ye(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(a=e.seenEntities)!=null&&a.has(t)||(s=e.seenEntities)!=null&&s.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((o=e.seenEntities)==null||o.add(t),(l=e.seenEntities)==null||l.add(this.id),{id:t,version:this.version,type:this.type,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((p=this.andChildrenGroup)==null?void 0:p.map(R=>R.toJSONClone({...e,newId:null})))||null,orChildrenGroup:((u=this.orChildrenGroup)==null?void 0:u.map(R=>R.toJSONClone({...e,newId:null})))||null,entity:((h=this.entity)==null?void 0:h.parent)===this?this.entity.toJSONClone({...e,newId:null}):((f=this.entity)==null?void 0:f.toReference({seenEntityMaps:e.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=L){var n;let t=this.id;return(n=e.seenEntityMaps)!=null&&n.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+M.UUID.uuid()+"--ref",type:i.GenericReference,entityId:t,entityType:this.type}}toShallowJSON(e=L){var n,a,s,o;let t=this.id;return(n=e.seenEntityMaps)!=null&&n.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,type:this.type,isList:this.isList,options:this.options,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:((a=this.andChildrenGroup)==null?void 0:a.map(l=>l.toReference(e)))||null,orChildrenGroup:((s=this.orChildrenGroup)==null?void 0:s.map(l=>l.toReference(e)))||null,entity:((o=this.entity)==null?void 0:o.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){var n,a,s;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((n=this.andChildrenGroup)==null?void 0:n.flatMap(o=>o.toFlatJSON(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(o=>o.toFlatJSON(e)))||[],...((s=this.entity)==null?void 0:s.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,type:this.type,options:this.options,isList:this.isList,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 n,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((n=this.andChildrenGroup)==null?void 0:n.flatMap(s=>s.toFlatGenerationTarget(e)))||[],...((a=this.orChildrenGroup)==null?void 0:a.flatMap(s=>s.toFlatGenerationTarget(e)))||[],...this.entity&&this.entity.type==i.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(e)||[]])}clearErrors(){var e,t,n;return this.errors=[],(e=this.andChildrenGroup)==null||e.forEach(a=>a.clearErrors()),(t=this.orChildrenGroup)==null||t.forEach(a=>a.clearErrors()),this.inferred&&((n=this.entity)==null||n.clearErrors()),this}validate(){const e=_7(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,n=!0){var v,I,D;let a=He(e,this),s=e||this.parent;const o=t||de(Xa(this),i.DataType,a),l=o.split("-id"),p=l[l.length-1||0]||o,u={id:o,version:1,type:i.DataType,isList:this.isList,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:s.toReference()},h=ke(u,a);e&&h.setParent(e),n&&h.subscribe(),h.initChildren();const f=(v=this.andChildrenGroup)==null?void 0:v.map((S,$)=>S.clone(h,p+"-and-group-data-type-"+$+"-id",n)),R=(I=this.orChildrenGroup)==null?void 0:I.map((S,$)=>S.clone(h,p+"-or-group-data-type-"+$+"-id",n));if(h.andChildrenGroup=f||null,h.orChildrenGroup=R||null,this.entity&&this.entity.type===i.DefinitionEntity&&((D=this.entity)==null?void 0:D.parent)===this){const S=this.entity.clone(h,M.UUID.uuid(),n);h.setEntity(S)}else this.entity&&h.setEntity(this.entity);return h}merge(e){const t=[],n=[],a=[];if(this.asType!==(e==null?void 0:e.asType)&&(this.sync({asType:e==null?void 0:e.asType}),t.push(this)),this.isList!==!(e!=null&&e.isList)&&(this.sync({isList:e==null?void 0:e.isList}),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===i.DefinitionEntity&&e.entity.parent===e){const s=e.entity.clone(this,M.UUID.uuid(),!0);this.setEntity(s),n.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===i.DefinitionEntity&&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));return{updated:m(t),added:m(n),removed:m(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}setEntity(e){return this.entity=e,this}isObject(){return!!this.entity&&(this.entity.type===i.DefinitionEntity||this.entity.name===C.KeyValue)}hasStrictObjectStructure(){var e;return this.isObject()&&((e=this.entity)==null?void 0:e.type)===i.DefinitionEntity}inferFromInputs(e){var t;if(!this.inferred)return this;if(!this.entity&&e.length){const n={id:this.id+"--"+M.UUID.uuid()+"--infered-entity",type:i.DefinitionEntity,version:1,name:w(this.parent,this.project)+" data type definition",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=b(n,this.project);a.setParent(this),a.initChildren(),a.sync(n),this.setEntity(a)}return this.entity&&this.entity.type===i.DefinitionEntity&&this.entity.parent!==this&&this.entity.setParent(this),this.entity&&this.entity.inferFromInputs(e),this.like||this.sync({like:!0}),this}};c(pe,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(pe,"MUTABLE_BASE_PROPERTIES",["isNullable","isList","constant","asType","options","parentRelationType","like"]),c(pe,"INMUTABLE_BASE_PROPERTIES",["id","version","type"]),c(pe,"BASE_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"MUTABLE_META_PROPERTIES",[...pe.MUTABLE_BASE_PROPERTIES,"inferred"]),c(pe,"INMUTABLE_META_PROPERTIES",[...pe.INMUTABLE_BASE_PROPERTIES]),c(pe,"META_PROPERTIES",[...pe.MUTABLE_META_PROPERTIES,...pe.INMUTABLE_META_PROPERTIES]),c(pe,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),c(pe,"INMUTABLE_UPSTREAM_PROPERTIES",[]),c(pe,"UPSTREAM_PROPERTIES",[...pe.MUTABLE_UPSTREAM_PROPERTIES,...pe.INMUTABLE_UPSTREAM_PROPERTIES]),c(pe,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),c(pe,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),c(pe,"DOWNSTREAM_PROPERTIES",[...pe.MUTABLE_DOWNSTREAM_PROPERTIES,...pe.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(pe,"PROPERTIES",[...pe.META_PROPERTIES,...pe.UPSTREAM_PROPERTIES,...pe.DOWNSTREAM_PROPERTIES]);let ki=pe;function N7(r){var l;const e=K6(),t=r.toJSON();e.safeParse(t).success;const a=L7(r),s=kn(r),o=[...a,...s];if(r.id==="exec-sequentially-operation-call-id"){const p=Q({id:`${r.id}--${G.PropertyImplementsNonAbstact}`,message:`Property "${w(r,r.project)}" with id "${r.id}" implements a non-abstract property "${w(r,r.project)}" with id "${r.id}".`,issue:null,severity:E.Error,code:G.PropertyImplementsNonAbstact,entity:r});o.push(p.error)}return r.outputs.forEach(p=>p.validate()),(l=r.error)==null||l.validate(),Be(r.errors,o)}function L7(r){const e=[];return r.inputs.forEach(t=>{t.validate()}),Be(r.errors,e)}const ye=class ye{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"x");c(this,"y");c(this,"type",i.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 n=t;if(e.parent){const f=A(e.parent);n=t.get(f)}const a=A(e.declaration),s=t.get(a),o=e.calledByEntry.map(f=>{const R=A(f);return t.get(R)}),l=e.calledBySuccess.map(f=>{const R=A(f);return t.get(R)}),p=e.calledByError.map(f=>{const R=A(f);return t.get(R)}),u={id:e.id,version:1,type:i.Operation,declaration:s,calledByEntry:o,calledBySuccess:l,calledByError:p,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:n},h=b(u,t);return h.setParent(n),h.initChildren(),h}static validateGenerationTarget(e,t){let n=JSON.parse(JSON.stringify(e));const a=[],s=tt(n,{parent:{list:!1,types:[...pt,i.Project],optional:!0}},t);n=s.modifiedData,a.push(...s.errors,...je(n));const o=A(n.declaration);if(o){const l=SS(o,t);a.push(...l)}else{const l=`
|
|
61
61
|
All built-in 'action-descriptor' entity ids are:
|
|
62
62
|
- ${t.operationDeclarations.map(p=>`${p.id} (${w(p,t)})`).join(`
|
|
63
63
|
- `)}.
|
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.6132",
|
|
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",
|