@elyx-code/project-logic-tree 0.0.6139 → 0.0.6140
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
|
@@ -34582,7 +34582,7 @@ You shouldn't have to manually update a 'parent' property. The equivalent result
|
|
|
34582
34582
|
}
|
|
34583
34583
|
)) {
|
|
34584
34584
|
const o = {
|
|
34585
|
-
id:
|
|
34585
|
+
id: B.UUID.uuid(),
|
|
34586
34586
|
version: 1,
|
|
34587
34587
|
type: i.InputMap,
|
|
34588
34588
|
declaration: a.toJSON(),
|
package/dist/index.umd.cjs
CHANGED
|
@@ -94,7 +94,7 @@ ${S}
|
|
|
94
94
|
${x}`,issue:null}))}}}}return a.push(...s.errors,...o,...je(n)),{errors:a,modifiedData:n}}validateGeneratedUpdate(e){const t=[];let n=JSON.parse(JSON.stringify(e));const a=es(n,this);return n=a.modifiedData,t.push(...a.errors),n.parent&&t.push(new g({id:`${this.id}--${T.InvalidParentUpdate}`,code:T.InvalidParentUpdate,severity:E.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
95
95
|
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),{errors:t,modifiedData:n}}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.readsValue){const a=A(this.initialData.readsValue),s=this.project.get(a);s&&(this.setValueWriter(s),e.push(s))}if(this.initialData.implements){const a=A(this.initialData.implements),s=this.project.get(a);s&&(this.setImplements(s),e.push(s))}return kn.hydrateReadsValue(this),{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(){var a;const e=[this],t=[],n=[];return this.isError?this.parent.throws=this:this.parent.addOutputDeclaration(this),e.push(this.parent),(a=this.readsValue)==null||a.addValueReader(this),this.readsValue&&e.push(this.readsValue),{updated:m(e),added:m(t),removed:m(n),self:this}}propagateChanges(){const e=[this],t=[],n=[];if(this.parent&&[i.BreakStatement,i.ContinueStatement].includes(this.parent.type)){const a=this.parent.parent,{updated:s,added:o,removed:l}=a.syncChildren();e.push(...s),t.push(...o),n.push(...l)}return{updated:m(e),added:m(t),removed:m(n),self:this}}setParent(e){return this.parent=e,this}setImplements(e){return this.implements=e,this}initChildren(){if(this.initialized)return this;if(this.initialized=!0,this.initialData.defaultValue&&(this.defaultValue=b(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this),this.defaultValue.initChildren()),this.initialData.dataType&&(this.dataType=b(this.initialData.dataType,this.project),this.dataType.setParent(this),this.dataType.initChildren()),this.initialData.implements){const e=b(this.initialData.implements,this.project);this.implements=e}return kn.initReadsValue(this),this.afterAllChildrenInitialized(),this}setValueWriter(e){return this.readsValue=e,this}removeValueWriter(){return this.readsValue=null,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.index=e.index||(e.index!==0?this.index:0),this.name=e.name||this.name,this.description=e.description||this.description,this.required=e.required||this.required,this.isError=e.isError||this.isError,this.constant=e.constant!==void 0?e.constant:this.constant,this.required=e.required!==void 0?e.required:this.required,this}async load(e=V,...t){return await Te.repository.load(this.id,...t),this}async create(e=V,...t){return await Te.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await Te.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await Te.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.defaultValue){const{affected:s,removed:o}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s),a.push(...o)}if(this.dataType){const s=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s.affected),a.push(...s.removed)}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.defaultValue){const{affected:n}=this.defaultValue.restore({seenEntities:e});t.push(...n)}if(this.dataType){const n=this.dataType.restore({seenEntities:e});t.push(...n.affected)}return{affected:[],self:this}}toFlat(e=new Set){var n,a,s;return e.has(this.id)?[]:(e.add(this.id),[this,...((n=this.defaultValue)==null?void 0:n.toFlat(e))||[],...((a=this.readsValue)==null?void 0:a.toFlat(e))||[],...((s=this.dataType)==null?void 0:s.toFlat(e))||[]])}toFlatIds(e=new Set){var n,a;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((n=this.defaultValue)==null?void 0:n.toFlatIds(e))||[],...((a=this.dataType)==null?void 0:a.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,name:this.name,description:this.description,type:this.type,index:this.index,required:this.required,constant:!0,isError:this.isError,defaultValue:((t=this.defaultValue)==null?void 0:t.toJSON(e))||null,dataType:((n=this.dataType)==null?void 0:n.toJSON(e))||null,implements:((a=this.implements)==null?void 0:a.toJSON(e))||null,readsValue:((s=this.readsValue)==null?void 0:s.toJSON(e))||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,name:this.name,description:this.description,type:this.type,index:this.index,required:this.required,constant:!0,isError:this.isError,defaultValue:((p=this.defaultValue)==null?void 0:p.toJSONClone({...e,newId:null}))||null,dataType:((u=this.dataType)==null?void 0:u.toJSONClone({...e,newId:null}))||null,implements:((h=this.implements)==null?void 0:h.toJSONClone({...e,newId:null}))||null,readsValue:((f=this.readsValue)==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,l;let t=this.id;return(n=e.seenEntityMaps)!=null&&n.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,name:this.name,description:this.description,type:this.type,index:this.index,required:this.required,constant:!0,isError:this.isError,defaultValue:((a=this.defaultValue)==null?void 0:a.toReference(e))||null,readsValue:((s=this.readsValue)==null?void 0:s.toReference(e))||null,implements:((o=this.implements)==null?void 0:o.toReference(e))||null,dataType:((l=this.dataType)==null?void 0:l.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){var n,a;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((n=this.defaultValue)==null?void 0:n.toFlatJSON(e))||[],...((a=this.dataType)==null?void 0:a.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,isError:this.isError,readsValue:(e=this.readsValue)==null?void 0:e.id,required:this.required,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var n,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((n=this.defaultValue)==null?void 0:n.toFlatGenerationTarget(e))||[],...((a=this.dataType)==null?void 0:a.toFlatGenerationTarget(e))||[]])}clearErrors(){var e,t;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.dataType)==null||t.clearErrors(),this}validate(){const e=j7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t,n;return[...this.errors,...((t=this.defaultValue)==null?void 0:t.getErrors())||[],...((n=this.dataType)==null?void 0:n.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){return this.defaultValue||null}setDefaultValue(e){return this.defaultValue=e,this}clone(e=null,t=null,n=!0){var R,v;let a=He(e,this);const s=this.toJSON(),o=t||de(w(this,this.project),i.ReturnDeclaration,a);s.dataType=null;const l=o.split("-id"),p=l[l.length-1||0]||o;s.id=o;const u=ke(s,a);e?u.setParent(e):u.setParent(this.parent),n&&u.subscribe(),u.initChildren();const h=(R=this.dataType)==null?void 0:R.clone(u,M.UUID.uuid(),n);u.dataType=h||null;const f=(v=this.defaultValue)==null?void 0:v.clone(u,p+"-default-value-id",n);return u.defaultValue=f||null,u}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}inferDataType(){const e=Mu(this);if(e){const t=e.clone(this);t&&(t.inferred=!0,this.setDataType(t))}return this}getCounterparts(){let e=[];if([i.BreakStatement,i.ContinueStatement].includes(this.parent.type)){const t=this.parent.parent;e=[...t.breakStatements,...t.continueStatements].flatMap(s=>s.outputs).filter(s=>w(s,this.project)===w(this,this.project)&&s.id!==this.id)}else if(this.parent.type===i.ReturnStatement&&[i.FunctionDeclaration,i.GlobalEvent].includes(this.parent.parent.type)&&this.parent.parent.implements){const n=this.parent.parent.returnStatements.flatMap(a=>a.outputs);this.implements?e=n.filter(s=>{var o;return this.implements.id===((o=s.implements)==null?void 0:o.id)}):e=n.filter(s=>w(s,this.project)===w(this,this.project)&&s.id!==this.id)}return e}inferDataTypeFromCounterparts(){var n,a;const e=this.getCounterparts(),t=e.find(s=>{var o;return(o=s.dataType)==null?void 0:o.isResolved});if(t)this.setDataType(t.dataType);else for(let s=0;s<e.length;s++){const o=e[s];if((!o.dataType||!o.dataType.isResolved||(n=o.dataType)!=null&&n.inferred)&&o.readsValue&&o.inferDataType(),(a=o.dataType)!=null&&a.isResolved){this.setDataType(o.dataType);break}}return this}getDataType(){var e;return(!this.dataType||!this.dataType.isResolved||(e=this.dataType)!=null&&e.inferred)&&this.readsValue?this.inferDataType():this.inferDataTypeFromCounterparts(),this.dataType}};c(Te,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(Te,"MUTABLE_BASE_PROPERTIES",["name","description","required","isError"]),c(Te,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(Te,"BASE_PROPERTIES",[...Te.MUTABLE_BASE_PROPERTIES,...Te.INMUTABLE_BASE_PROPERTIES]),c(Te,"MUTABLE_META_PROPERTIES",[...Te.MUTABLE_BASE_PROPERTIES,"index"]),c(Te,"INMUTABLE_META_PROPERTIES",[...Te.INMUTABLE_BASE_PROPERTIES]),c(Te,"META_PROPERTIES",[...Te.MUTABLE_META_PROPERTIES,...Te.INMUTABLE_META_PROPERTIES]),c(Te,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),c(Te,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(Te,"UPSTREAM_PROPERTIES",[...Te.MUTABLE_UPSTREAM_PROPERTIES,...Te.INMUTABLE_UPSTREAM_PROPERTIES]),c(Te,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),c(Te,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Te,"DOWNSTREAM_PROPERTIES",[...Te.MUTABLE_DOWNSTREAM_PROPERTIES,...Te.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Te,"PROPERTIES",[...Te.META_PROPERTIES,...Te.UPSTREAM_PROPERTIES,...Te.DOWNSTREAM_PROPERTIES]);let kt=Te;function k7(r){var o;const e=F6(),t=r.toJSON();e.safeParse(t).success,r.inputsDeclarations.forEach(l=>l.validate()),r.inputs.forEach(l=>l.validate()),r.outputsDeclarations.forEach(l=>l.validate()),r.outputs.forEach(l=>l.validate()),(o=r.error)==null||o.validate();const s=[...jn(r)];if(r.id==="search-person-by-id-id"){const l=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});s.push(l.error)}return Me(r.errors,s)}const Ve=class Ve{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"query","");c(this,"type",i.Search);c(this,"successCalls",[]);c(this,"errorCalls",[]);c(this,"inputsDeclarations",[]);c(this,"inputs",[]);c(this,"outputsDeclarations",[]);c(this,"outputs",[]);c(this,"calledBySuccess",[]);c(this,"calledByError",[]);c(this,"calledByEntry",[]);c(this,"error",null);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,this.name=e.name,this.query=e.query,this.description=e.description}static fromGenerationTarget(e,t){let n=t;if(e.parent){const u=A(e.parent);n=t.get(u)}const a=e.calledByEntry.map(u=>{const h=A(u);return t.get(h)}),s=e.calledBySuccess.map(u=>{const h=A(u);return t.get(h)}),o=e.calledByError.map(u=>{const h=A(u);return t.get(h)}),l={id:e.id,version:1,type:i.Search,name:e.name,description:e.description,query:e.query,calledByEntry:a,calledBySuccess:s,calledByError:o,errorCalls:[],successCalls:[],inputsDeclarations:[],inputs:[],outputsDeclarations:[],outputs:[],error:null,x:0,y:0,parent:n},p=b(l,t);return p.setParent(n),p.initChildren(),p}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);return n=s.modifiedData,a.push(...s.errors,...je(n)),{errors:a,modifiedData:n}}get resultsAsList(){const e=this.outputsDeclarations[0];if(e){const t=e.getDataType();return t?t.isList===!0:!0}return!0}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new g({id:`${this.id}--${T.InvalidParentUpdate}`,code:T.InvalidParentUpdate,severity:E.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on a callable entity, is its scope. It scope is auto-calculated implicitly by the its caller.
|
|
96
96
|
If an entity is called by another, they must be in the same scope, which means they have the same parent.
|
|
97
|
-
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}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))}return this.initialData.calledByEntry.forEach(a=>{const s=A(a),o=this.project.get(s);o&&(this.addEntryCaller(o),e.push(o))}),this.initialData.calledBySuccess.forEach(a=>{const s=A(a),o=this.project.get(s);o&&(this.addSuccessCaller(o),e.push(o))}),this.initialData.calledByError.forEach(a=>{const s=A(a),o=this.project.get(s);o&&(this.addErrorCaller(o),e.push(o))}),{updated:m(e),added:m(t),removed:m(n),self:this}}afterAllChildrenInitialized(){const e=[],t=[],n=[];this.initialized=!0;const{updated:a,added:s,removed:o}=this.syncInputMaps();return e.push(...a),t.push(...s),n.push(...o),{updated:m(e),added:m(t),removed:m(n),self:this}}addSelfToProject(){const e=[this],t=[],n=[];return this.parent===this.project&&this.project.addSearch(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:m(e),added:m(t),removed:m(n),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(a=>a.id===e.id);t>-1&&this.inputs.splice(t,1);const n=this.inputsDeclarations.findIndex(a=>{var s;return a.id===((s=e.declaration)==null?void 0:s.id)});return n>-1&&this.inputsDeclarations.splice(n,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addInputDeclaration(e){return this.inputsDeclarations.includes(e)?this:(this.inputsDeclarations.push(e),this.syncInputMaps(),this)}removeInputDeclaration(e){const t=this.inputsDeclarations.findIndex(n=>n.id===e.id);return t>-1&&this.inputsDeclarations.splice(t,1),this}addOutputDeclaration(e){return this.outputsDeclarations.includes(e)?this:(this.outputsDeclarations.push(e),this)}removeOutputDeclaration(e){const t=this.outputsDeclarations.findIndex(n=>n.id===e.id);return t>-1&&this.outputsDeclarations.splice(t,1),this}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(n=>n.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const n=this.errorCalls.findIndex(a=>a.id===e.id);return n>-1&&this.errorCalls.splice(n,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.successCalls=this.initialData.successCalls.map(e=>{const t=b(e,this.project);return[i.BreakStatement,i.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==i.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=b(e,this.project);return t.addErrorCaller(this),[i.BreakStatement,i.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==i.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputsDeclarations=this.initialData.inputsDeclarations.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.inputs=this.initialData.inputs.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputsDeclarations=this.initialData.outputsDeclarations.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=b(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),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.x=e.x||this.x,this.y=e.y||this.y,this.name=e.name||this.name,this.description=e.description||this.description,e.query!==void 0&&(this.query=e.query),this}async load(e=V,...t){return await Ve.repository.load(this.id,...t),this}async create(e=V,...t){return await Ve.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await Ve.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await Ve.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.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.inputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.outputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.error){const{affected:s,removed:o}=this.error.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s),a.push(...o)}return this.successCalls.forEach(s=>{n.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{n.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{n.push(s),s.removeCall(this)}),{affected:m(n),removed:m(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputsDeclarations.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.inputs.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.outputsDeclarations.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(n=>{t.push(n),n.addSuccessCaller(this)}),this.errorCalls.forEach(n=>{t.push(n),n.addErrorCaller(this)}),this.calledBySuccess.forEach(n=>{t.push(n),n.addSuccessCall(this)}),this.calledByError.forEach(n=>{t.push(n),n.addErrorCall(this)}),this.calledByEntry.forEach(n=>{t.push(n),n.addCall(this)}),{affected:m(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(n=>n.toFlat(e)),...this.errorCalls.flatMap(n=>n.toFlat(e)),...this.inputs.flatMap(n=>n.toFlat(e)),...this.inputsDeclarations.flatMap(n=>n.toFlat(e)),...this.outputs.flatMap(n=>n.toFlat(e)),...this.outputsDeclarations.flatMap(n=>n.toFlat(e)),...this.calledBy.flatMap(n=>n.toFlat(e)),...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(n=>n.toFlatIds(e)),...this.errorCalls.flatMap(n=>n.toFlatIds(e)),...this.inputs.flatMap(n=>n.toFlatIds(e)),...this.inputsDeclarations.flatMap(n=>n.toFlatIds(e)),...this.outputs.flatMap(n=>n.toFlatIds(e)),...this.outputsDeclarations.flatMap(n=>n.toFlatIds(e)),...this.calledBy.flatMap(n=>n.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[]])}toJSON(e=new Set){var t;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,type:this.type,name:this.name,query:this.query,description:this.description,x:this.x,y:this.y,successCalls:this.successCalls.map(n=>n.toJSON()),errorCalls:this.errorCalls.map(n=>n.toJSON()),calledBySuccess:this.calledBySuccess.map(n=>n.toReference()),calledByError:this.calledByError.map(n=>n.toReference()),calledByEntry:this.calledByEntry.map(n=>n.toReference()),inputsDeclarations:this.inputsDeclarations.map(n=>n.toJSON()),inputs:this.inputs.map(n=>n.toJSON()),outputsDeclarations:this.outputsDeclarations.map(n=>n.toJSON()),outputs:this.outputs.map(n=>n.toJSON()),error:((t=this.error)==null?void 0:t.toJSON())||null,parent:this.parent.toReference()})}toJSONClone(e=L){var n,a,s,o,l,p;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:1,type:i.Search,name:this.name,query:this.query,description:this.description,x:this.x,y:this.y,successCalls:this.successCalls.map(u=>u.toJSONClone({...e,newId:null})),errorCalls:this.errorCalls.map(u=>u.toJSONClone({...e,newId:null})),calledBySuccess:this.calledBySuccess.map(u=>u.toReference({seenEntityMaps:e.seenEntityMaps})),calledByError:this.calledByError.map(u=>u.toReference({seenEntityMaps:e.seenEntityMaps})),calledByEntry:this.calledByEntry.map(u=>u.toReference({seenEntityMaps:e.seenEntityMaps})),inputsDeclarations:this.inputsDeclarations.map(u=>u.toJSONClone({...e,newId:null})),inputs:this.inputs.map(u=>u.toJSONClone({...e,newId:null})),outputsDeclarations:this.outputsDeclarations.map(u=>u.toJSONClone({...e,newId:null})),outputs:this.outputs.map(u=>u.toJSONClone({...e,newId:null})),error:((p=this.error)==null?void 0:p.toJSONClone({...e,newId:null}))||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;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,name:this.name,description:this.description,query:this.query,x:this.x,y:this.y,inputs:this.inputs.map(a=>a.toReference(e)),inputsDeclarations:this.inputsDeclarations.map(a=>a.toReference(e)),outputs:this.outputs.map(a=>a.toReference(e)),outputsDeclarations:this.outputsDeclarations.map(a=>a.toReference(e)),successCalls:this.successCalls.map(a=>a.toReference(e)),errorCalls:this.errorCalls.map(a=>a.toReference(e)),calledBySuccess:this.calledBySuccess.map(a=>a.toReference(e)),calledByError:this.calledByError.map(a=>a.toReference(e)),calledByEntry:this.calledByEntry.map(a=>a.toReference(e)),error:this.error?this.error.toReference(e):null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(n=>n.toFlatJSON(e)),...this.errorCalls.flatMap(n=>n.toFlatJSON(e)),...this.inputs.flatMap(n=>n.toFlatJSON(e)),...this.inputsDeclarations.flatMap(n=>n.toFlatJSON(e)),...this.outputs.flatMap(n=>n.toFlatJSON(e)),...this.outputsDeclarations.flatMap(n=>n.toFlatJSON(e)),...this.calledBy.flatMap(n=>n.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===i.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,query:this.query,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(n=>n.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(n=>n.toFlatGenerationTarget(e)),...this.inputs.flatMap(n=>n.toFlatGenerationTarget(e)),...this.inputsDeclarations.flatMap(n=>n.toFlatGenerationTarget(e)),...this.outputs.flatMap(n=>n.toFlatGenerationTarget(e)),...this.outputsDeclarations.flatMap(n=>n.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e;return this.errors=[],this.inputsDeclarations.forEach(t=>t.clearErrors()),this.inputs.forEach(t=>t.clearErrors()),this.outputs.forEach(t=>t.clearErrors()),this.successCalls.forEach(t=>t.clearErrors()),this.errorCalls.forEach(t=>t.clearErrors()),(e=this.error)==null||e.clearErrors(),this}validate(){const e=k7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputsDeclarations.flatMap(t=>t.getErrors()),...this.inputs.flatMap(t=>t.getErrors()),...this.outputsDeclarations.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[]]}getShallowErrors(){return this.errors}clone(e=null,t=null,n=!0){var I,D,S,x;let a=He(e,this);const s=this.toJSON(),o=t||de(w(this,this.project),i.Search,a);s.inputs=[];const l=o.split("-id"),p=l[l.length-1||0]||o;s.id=o;const u=ke(s,a);e?u.setParent(e):u.setParent(this.parent),n&&u.subscribe(),u.initChildren();const h=(I=this.inputsDeclarations)==null?void 0:I.map((k,K)=>k.clone(this,p+"-input-declaration-"+K+"-id",n));u.inputsDeclarations=h;const f=(D=this.outputsDeclarations)==null?void 0:D.map((k,K)=>k.clone(this,p+"-output-declaration-"+K+"-id",n));u.outputsDeclarations=f;const R=(S=this.inputs)==null?void 0:S.map((k,K)=>k.clone(u,p+"-input-map-"+K+"-id",n));u.inputs=R;const v=(x=this.outputs)==null?void 0:x.map((k,K)=>k.clone(u,p+"-output-map-"+K+"-id",n));return u.outputs=v,this.error&&(u.error=this.error.clone(u,p+"-error-map-id",n)),u}syncInputMaps(){const e=[],t=[],n=[];return this.inputsDeclarations.forEach(a=>{if(!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===a.id})){const o={id:this.id+"--"+M.UUID.uuid(),version:1,type:i.InputMap,declaration:a.toJSON(),readsValue:null,defaultValue:null,index:this.inputs.length,name:null,description:null,parent:this.toReference()},l=b(o,this.project);l.setParent(this),l.initChildren(),l.addSelfToProject(),e.push(this),t.push(l)}}),this.inputs.forEach(a=>{if(!this.inputsDeclarations.find(o=>{var l;return o.id===((l=a.declaration)==null?void 0:l.id)})){const{affected:o,removed:l}=a.remove();e.push(...o),n.push(...l)}}),{updated:m(e),added:m(t),removed:m(n),self:this}}};c(Ve,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(Ve,"MUTABLE_BASE_PROPERTIES",["name","description","query"]),c(Ve,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(Ve,"BASE_PROPERTIES",[...Ve.MUTABLE_BASE_PROPERTIES,...Ve.INMUTABLE_BASE_PROPERTIES]),c(Ve,"MUTABLE_META_PROPERTIES",[...Ve.MUTABLE_BASE_PROPERTIES,"x","y"]),c(Ve,"INMUTABLE_META_PROPERTIES",[...Ve.INMUTABLE_BASE_PROPERTIES]),c(Ve,"META_PROPERTIES",[...Ve.MUTABLE_META_PROPERTIES,...Ve.INMUTABLE_META_PROPERTIES]),c(Ve,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(Ve,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(Ve,"UPSTREAM_PROPERTIES",[...Ve.MUTABLE_UPSTREAM_PROPERTIES,...Ve.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ve,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","inputsDeclarations","inputs","outputsDeclarations","outputs","error"]),c(Ve,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ve,"DOWNSTREAM_PROPERTIES",[...Ve.MUTABLE_DOWNSTREAM_PROPERTIES,...Ve.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ve,"PROPERTIES",[...kt.META_PROPERTIES,...kt.UPSTREAM_PROPERTIES,...kt.DOWNSTREAM_PROPERTIES]);let Yr=Ve;function q7(r){const e=B3(),t=r.toJSON();e.safeParse(t).success,r.functions.forEach(s=>s.validate()),r.events.forEach(s=>s.validate());const a=[];return Me(r.errors,a)}const Pe=class Pe{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"type",i.InstalledProject);c(this,"implements");c(this,"functions",[]);c(this,"events",[]);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.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y,this.implements=e.implements}static fromGenerationTarget(e,t){const n=t,a={id:e.id,version:1,name:e.name,type:i.InstalledProject,description:e.description,functions:[],events:[],implements:{entityId:e.implements,entityType:i.Project,type:i.GenericReference,id:M.UUID.uuid()},x:0,y:0,parent:n},s=b(a,t);return s.setParent(n),s.initChildren(),s}static validateGenerationTarget(e,t){let n=JSON.parse(JSON.stringify(e));const a=[];return a.push(...je(n)),{errors:a,modifiedData:n}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new g({id:`${this.id}--${T.InvalidParentUpdate}`,code:T.InvalidParentUpdate,severity:E.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an installed project, must be the root project as it is a globally declared entity.`,issue:null})),{errors:t,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))}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{updated:m(e),added:m(t),removed:m(n),self:this}}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.functions=this.initialData.functions.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.events=this.initialData.events.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.afterAllChildrenInitialized(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.x=e.x||this.x,this.y=e.y||this.y,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=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.functions.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});n.push(...o),a.push(...l)}),this.events.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});n.push(...o),a.push(...l)}),{affected:[],removed:[]})}restore({seenEntities:e}={seenEntities:new Set}){return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.functions.forEach(t=>{t.restore({seenEntities:e})}),this.events.forEach(t=>{t.restore({seenEntities:e})}),{affected:[],self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.functions.flatMap(n=>n.toFlat(e)),...this.events.flatMap(n=>n.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.functions.flatMap(n=>n.toFlatIds(e)),...this.events.flatMap(n=>n.toFlatIds(e))])}toJSON(e=new Set){return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,implements:this.implements,functions:this.functions.map(t=>t.toJSON(e)),events:this.events.map(t=>t.toJSON(e)),parent:this.parent.toReference(),x:this.x,y:this.y})}toJSONClone(e=L){var n,a,s,o,l;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,name:this.name,description:this.description,implements:this.implements,functions:this.functions.map(p=>p.toJSONClone({...e,newId:null})),events:this.events.map(p=>p.toJSONClone({...e,newId:null})),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps}),x:this.x,y:this.y})}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;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,name:this.name,description:this.description,x:this.x,y:this.y,implements:this.implements,functions:this.functions.map(a=>a.toReference(e)),events:this.events.map(a=>a.toReference(e)),parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.functions.flatMap(n=>n.toFlatJSON(e)),...this.events.flatMap(n=>n.toFlatJSON(e))])}toGenerationTarget(){return{id:this.id,name:this.name,description:this.description,type:this.type,implements:this.implements.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.functions.flatMap(n=>n.toFlatGenerationTarget(e)),...this.events.flatMap(n=>n.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.functions.forEach(e=>e.clearErrors()),this.events.forEach(e=>e.clearErrors()),this}validate(){const e=q7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.functions.flatMap(t=>t.getErrors()),...this.events.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(e=null,t=null,n=!0){var R,v;let a=He(e,this);const s=this.toJSON(),o=t||de(w(this,this.project),i.InstalledProject,a);s.functions=[],s.events=[];const l=o.split("-id"),p=l[l.length-1||0]||o;s.id=o;const u=ke(s,a);e&&u.setParent(e),n&&u.subscribe(),u.initChildren();const h=(R=this.functions)==null?void 0:R.map((I,D)=>I.clone(u,p+"-exported-function-declaration-"+D+"-id",n));u.functions=h;const f=(v=this.events)==null?void 0:v.map((I,D)=>I.clone(u,p+"-exported-event-"+D+"-id",n));return u.events=f,u}};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",[]),c(Pe,"INMUTABLE_BASE_PROPERTIES",["id","version","name","description","type"]),c(Pe,"BASE_PROPERTIES",[...Pe.MUTABLE_BASE_PROPERTIES,...Pe.INMUTABLE_BASE_PROPERTIES]),c(Pe,"MUTABLE_META_PROPERTIES",["x","y"]),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",[]),c(Pe,"INMUTABLE_UPSTREAM_PROPERTIES",["implements","parent"]),c(Pe,"UPSTREAM_PROPERTIES",[...Pe.MUTABLE_UPSTREAM_PROPERTIES,...Pe.INMUTABLE_UPSTREAM_PROPERTIES]),c(Pe,"MUTABLE_DOWNSTREAM_PROPERTIES",["functions","events"]),c(Pe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),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 Hr=Pe;function J7(r){var l;const e=k6(),t=r.toJSON();e.safeParse(t).success,r.inputs.forEach(p=>p.validate()),r.outputs.forEach(p=>p.validate()),(l=r.error)==null||l.validate();const a=jn(r),s=W7(r),o=[...a,...s];return Me(r.errors,o)}function W7(r){const e=[],t=Zo(r.parent),n=t==null?void 0:t.entity;if(!n)e.push(Q({id:`${r.id}--${B.InternalCallParentMissingDataType}`,code:B.InternalCallParentMissingDataType,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", belongs to a variable whose data type entity doesn't contain its declaration method (function-declaration) its id "${r.declaration}".`,issue:null,entity:r}).error);else if(![i.DefinitionEntity,i.BuiltInBaseEntity,i.PrimitiveEntity].includes(n.type))e.push(Q({id:`${r.id}--${B.InternalCallParentDeclarationEntityInvalidType}`,code:B.InternalCallParentDeclarationEntityInvalidType,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", belongs to a variable whose data type 'entity' is not a definition entity, built-in base entity or primitive entity.
|
|
97
|
+
You shouldn't have to manually update a 'parent' property. The equivalent result is to change its callers, the value writters of its inputs, or the value readers of its outputs.`,issue:null})),{errors:t,modifiedData:e}}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))}return this.initialData.calledByEntry.forEach(a=>{const s=A(a),o=this.project.get(s);o&&(this.addEntryCaller(o),e.push(o))}),this.initialData.calledBySuccess.forEach(a=>{const s=A(a),o=this.project.get(s);o&&(this.addSuccessCaller(o),e.push(o))}),this.initialData.calledByError.forEach(a=>{const s=A(a),o=this.project.get(s);o&&(this.addErrorCaller(o),e.push(o))}),{updated:m(e),added:m(t),removed:m(n),self:this}}afterAllChildrenInitialized(){const e=[],t=[],n=[];this.initialized=!0;const{updated:a,added:s,removed:o}=this.syncInputMaps();return e.push(...a),t.push(...s),n.push(...o),{updated:m(e),added:m(t),removed:m(n),self:this}}addSelfToProject(){const e=[this],t=[],n=[];return this.parent===this.project&&this.project.addSearch(this),this.successCalls.forEach(a=>{a.addSuccessCaller(this),e.push(a)}),this.errorCalls.forEach(a=>{a.addErrorCaller(this),e.push(a)}),this.calledByEntry.forEach(a=>{a.addCall(this),e.push(a)}),this.calledBySuccess.forEach(a=>{a.addSuccessCall(this),e.push(a)}),this.calledByError.forEach(a=>{a.addErrorCall(this),e.push(a)}),{updated:m(e),added:m(t),removed:m(n),self:this}}get calledBy(){return[...this.calledByEntry,...this.calledBySuccess,...this.calledByError]}removeInput(e){const t=this.inputs.findIndex(a=>a.id===e.id);t>-1&&this.inputs.splice(t,1);const n=this.inputsDeclarations.findIndex(a=>{var s;return a.id===((s=e.declaration)==null?void 0:s.id)});return n>-1&&this.inputsDeclarations.splice(n,1),this}addInput(e){return this.inputs.includes(e)?this:(this.inputs.push(e),this)}addInputDeclaration(e){return this.inputsDeclarations.includes(e)?this:(this.inputsDeclarations.push(e),this.syncInputMaps(),this)}removeInputDeclaration(e){const t=this.inputsDeclarations.findIndex(n=>n.id===e.id);return t>-1&&this.inputsDeclarations.splice(t,1),this}addOutputDeclaration(e){return this.outputsDeclarations.includes(e)?this:(this.outputsDeclarations.push(e),this)}removeOutputDeclaration(e){const t=this.outputsDeclarations.findIndex(n=>n.id===e.id);return t>-1&&this.outputsDeclarations.splice(t,1),this}addOutput(e){return this.outputs.includes(e)?this:(this.outputs.push(e),this)}removeOutput(e){const t=this.outputs.findIndex(n=>n.id===e.id);return t>-1&&this.outputs.splice(t,1),this}addSuccessCaller(e){return this.calledBySuccess.find(t=>t.id===e.id)||this.calledBySuccess.push(e),this}addErrorCaller(e){return this.calledByError.find(t=>t.id===e.id)||this.calledByError.push(e),this}addEntryCaller(e){return this.calledByEntry.find(t=>t.id===e.id)||this.calledByEntry.push(e),this}addErrorCall(e){return this.errorCalls.find(t=>t.id===e.id)||this.errorCalls.push(e),this}addSuccessCall(e){return this.successCalls.find(t=>t.id===e.id)||this.successCalls.push(e),this}removeCall(e){const t=this.successCalls.findIndex(a=>a.id===e.id);t>-1&&this.successCalls.splice(t,1);const n=this.errorCalls.findIndex(a=>a.id===e.id);return n>-1&&this.errorCalls.splice(n,1),this}removeCaller(e){return this.calledBySuccess=this.calledBySuccess.filter(t=>t.id!==e.id),this.calledByError=this.calledByError.filter(t=>t.id!==e.id),this.calledByEntry=this.calledByEntry.filter(t=>t.id!==e.id),this}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.successCalls=this.initialData.successCalls.map(e=>{const t=b(e,this.project);return[i.BreakStatement,i.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==i.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.errorCalls=this.initialData.errorCalls.map(e=>{const t=b(e,this.project);return t.addErrorCaller(this),[i.BreakStatement,i.ContinueStatement].includes(t.type)?(t.setParent(this.parent.parent),t.initChildren()):t.type!==i.InternalCall&&(t.setParent(this.parent),t.initChildren()),t}),this.inputsDeclarations=this.initialData.inputsDeclarations.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.inputs=this.initialData.inputs.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputsDeclarations=this.initialData.outputsDeclarations.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.outputs=this.initialData.outputs.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.initialData.error&&(this.error=b(this.initialData.error,this.project),this.error.setParent(this),this.error.initChildren()),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.x=e.x||this.x,this.y=e.y||this.y,this.name=e.name||this.name,this.description=e.description||this.description,e.query!==void 0&&(this.query=e.query),this}async load(e=V,...t){return await Ve.repository.load(this.id,...t),this}async create(e=V,...t){return await Ve.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await Ve.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await Ve.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.inputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.inputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.outputs.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.outputsDeclarations.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!0,seenEntities:t});n.push(...o),a.push(...l)}),this.error){const{affected:s,removed:o}=this.error.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s),a.push(...o)}return this.successCalls.forEach(s=>{n.push(s),s.removeCaller(this)}),this.errorCalls.forEach(s=>{n.push(s),s.removeCaller(this)}),e||this.calledBy.forEach(s=>{n.push(s),s.removeCall(this)}),{affected:m(n),removed:m(a)}}restore({seenEntities:e}={seenEntities:new Set}){const t=[];return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.inputsDeclarations.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.inputs.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.outputsDeclarations.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.outputs.forEach(n=>{const{affected:a}=n.restore({seenEntities:e});t.push(...a)}),this.successCalls.forEach(n=>{t.push(n),n.addSuccessCaller(this)}),this.errorCalls.forEach(n=>{t.push(n),n.addErrorCaller(this)}),this.calledBySuccess.forEach(n=>{t.push(n),n.addSuccessCall(this)}),this.calledByError.forEach(n=>{t.push(n),n.addErrorCall(this)}),this.calledByEntry.forEach(n=>{t.push(n),n.addCall(this)}),{affected:m(t),self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.successCalls.flatMap(n=>n.toFlat(e)),...this.errorCalls.flatMap(n=>n.toFlat(e)),...this.inputs.flatMap(n=>n.toFlat(e)),...this.inputsDeclarations.flatMap(n=>n.toFlat(e)),...this.outputs.flatMap(n=>n.toFlat(e)),...this.outputsDeclarations.flatMap(n=>n.toFlat(e)),...this.calledBy.flatMap(n=>n.toFlat(e)),...this.error?this.error.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.successCalls.flatMap(n=>n.toFlatIds(e)),...this.errorCalls.flatMap(n=>n.toFlatIds(e)),...this.inputs.flatMap(n=>n.toFlatIds(e)),...this.inputsDeclarations.flatMap(n=>n.toFlatIds(e)),...this.outputs.flatMap(n=>n.toFlatIds(e)),...this.outputsDeclarations.flatMap(n=>n.toFlatIds(e)),...this.calledBy.flatMap(n=>n.toFlatIds(e)),...this.error?this.error.toFlatIds(e):[]])}toJSON(e=new Set){var t;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,type:this.type,name:this.name,query:this.query,description:this.description,x:this.x,y:this.y,successCalls:this.successCalls.map(n=>n.toJSON()),errorCalls:this.errorCalls.map(n=>n.toJSON()),calledBySuccess:this.calledBySuccess.map(n=>n.toReference()),calledByError:this.calledByError.map(n=>n.toReference()),calledByEntry:this.calledByEntry.map(n=>n.toReference()),inputsDeclarations:this.inputsDeclarations.map(n=>n.toJSON()),inputs:this.inputs.map(n=>n.toJSON()),outputsDeclarations:this.outputsDeclarations.map(n=>n.toJSON()),outputs:this.outputs.map(n=>n.toJSON()),error:((t=this.error)==null?void 0:t.toJSON())||null,parent:this.parent.toReference()})}toJSONClone(e=L){var n,a,s,o,l,p;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:1,type:i.Search,name:this.name,query:this.query,description:this.description,x:this.x,y:this.y,successCalls:this.successCalls.map(u=>u.toJSONClone({...e,newId:null})),errorCalls:this.errorCalls.map(u=>u.toJSONClone({...e,newId:null})),calledBySuccess:this.calledBySuccess.map(u=>u.toReference({seenEntityMaps:e.seenEntityMaps})),calledByError:this.calledByError.map(u=>u.toReference({seenEntityMaps:e.seenEntityMaps})),calledByEntry:this.calledByEntry.map(u=>u.toReference({seenEntityMaps:e.seenEntityMaps})),inputsDeclarations:this.inputsDeclarations.map(u=>u.toJSONClone({...e,newId:null})),inputs:this.inputs.map(u=>u.toJSONClone({...e,newId:null})),outputsDeclarations:this.outputsDeclarations.map(u=>u.toJSONClone({...e,newId:null})),outputs:this.outputs.map(u=>u.toJSONClone({...e,newId:null})),error:((p=this.error)==null?void 0:p.toJSONClone({...e,newId:null}))||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;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,name:this.name,description:this.description,query:this.query,x:this.x,y:this.y,inputs:this.inputs.map(a=>a.toReference(e)),inputsDeclarations:this.inputsDeclarations.map(a=>a.toReference(e)),outputs:this.outputs.map(a=>a.toReference(e)),outputsDeclarations:this.outputsDeclarations.map(a=>a.toReference(e)),successCalls:this.successCalls.map(a=>a.toReference(e)),errorCalls:this.errorCalls.map(a=>a.toReference(e)),calledBySuccess:this.calledBySuccess.map(a=>a.toReference(e)),calledByError:this.calledByError.map(a=>a.toReference(e)),calledByEntry:this.calledByEntry.map(a=>a.toReference(e)),error:this.error?this.error.toReference(e):null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.successCalls.flatMap(n=>n.toFlatJSON(e)),...this.errorCalls.flatMap(n=>n.toFlatJSON(e)),...this.inputs.flatMap(n=>n.toFlatJSON(e)),...this.inputsDeclarations.flatMap(n=>n.toFlatJSON(e)),...this.outputs.flatMap(n=>n.toFlatJSON(e)),...this.outputsDeclarations.flatMap(n=>n.toFlatJSON(e)),...this.calledBy.flatMap(n=>n.toFlatJSON(e)),...this.error?this.error.toFlatJSON(e):[]])}toGenerationTarget(){const e=this.parent.type===i.Project?void 0:this.parent.id;return{id:this.id,name:this.name,description:this.description,type:this.type,query:this.query,calledByEntry:this.calledByEntry.map(t=>t.id),calledBySuccess:this.calledBySuccess.map(t=>t.id),calledByError:this.calledByError.map(t=>t.id),parent:e}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.successCalls.flatMap(n=>n.toFlatGenerationTarget(e)),...this.errorCalls.flatMap(n=>n.toFlatGenerationTarget(e)),...this.inputs.flatMap(n=>n.toFlatGenerationTarget(e)),...this.inputsDeclarations.flatMap(n=>n.toFlatGenerationTarget(e)),...this.outputs.flatMap(n=>n.toFlatGenerationTarget(e)),...this.outputsDeclarations.flatMap(n=>n.toFlatGenerationTarget(e)),...this.error?this.error.toFlatGenerationTarget(e):[]])}clearErrors(){var e;return this.errors=[],this.inputsDeclarations.forEach(t=>t.clearErrors()),this.inputs.forEach(t=>t.clearErrors()),this.outputs.forEach(t=>t.clearErrors()),this.successCalls.forEach(t=>t.clearErrors()),this.errorCalls.forEach(t=>t.clearErrors()),(e=this.error)==null||e.clearErrors(),this}validate(){const e=k7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.inputsDeclarations.flatMap(t=>t.getErrors()),...this.inputs.flatMap(t=>t.getErrors()),...this.outputsDeclarations.flatMap(t=>t.getErrors()),...this.outputs.flatMap(t=>t.getErrors()),...this.error?this.error.getErrors():[]]}getShallowErrors(){return this.errors}clone(e=null,t=null,n=!0){var I,D,S,x;let a=He(e,this);const s=this.toJSON(),o=t||de(w(this,this.project),i.Search,a);s.inputs=[];const l=o.split("-id"),p=l[l.length-1||0]||o;s.id=o;const u=ke(s,a);e?u.setParent(e):u.setParent(this.parent),n&&u.subscribe(),u.initChildren();const h=(I=this.inputsDeclarations)==null?void 0:I.map((k,K)=>k.clone(this,p+"-input-declaration-"+K+"-id",n));u.inputsDeclarations=h;const f=(D=this.outputsDeclarations)==null?void 0:D.map((k,K)=>k.clone(this,p+"-output-declaration-"+K+"-id",n));u.outputsDeclarations=f;const R=(S=this.inputs)==null?void 0:S.map((k,K)=>k.clone(u,p+"-input-map-"+K+"-id",n));u.inputs=R;const v=(x=this.outputs)==null?void 0:x.map((k,K)=>k.clone(u,p+"-output-map-"+K+"-id",n));return u.outputs=v,this.error&&(u.error=this.error.clone(u,p+"-error-map-id",n)),u}syncInputMaps(){const e=[],t=[],n=[];return this.inputsDeclarations.forEach(a=>{if(!this.inputs.find(o=>{var l;return((l=o.declaration)==null?void 0:l.id)===a.id})){const o={id:M.UUID.uuid(),version:1,type:i.InputMap,declaration:a.toJSON(),readsValue:null,defaultValue:null,index:this.inputs.length,name:null,description:null,parent:this.toReference()},l=b(o,this.project);l.setParent(this),l.initChildren(),l.addSelfToProject(),e.push(this),t.push(l)}}),this.inputs.forEach(a=>{if(!this.inputsDeclarations.find(o=>{var l;return o.id===((l=a.declaration)==null?void 0:l.id)})){const{affected:o,removed:l}=a.remove();e.push(...o),n.push(...l)}}),{updated:m(e),added:m(t),removed:m(n),self:this}}};c(Ve,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(Ve,"MUTABLE_BASE_PROPERTIES",["name","description","query"]),c(Ve,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(Ve,"BASE_PROPERTIES",[...Ve.MUTABLE_BASE_PROPERTIES,...Ve.INMUTABLE_BASE_PROPERTIES]),c(Ve,"MUTABLE_META_PROPERTIES",[...Ve.MUTABLE_BASE_PROPERTIES,"x","y"]),c(Ve,"INMUTABLE_META_PROPERTIES",[...Ve.INMUTABLE_BASE_PROPERTIES]),c(Ve,"META_PROPERTIES",[...Ve.MUTABLE_META_PROPERTIES,...Ve.INMUTABLE_META_PROPERTIES]),c(Ve,"MUTABLE_UPSTREAM_PROPERTIES",["calledBySuccess","calledByError","calledByEntry"]),c(Ve,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(Ve,"UPSTREAM_PROPERTIES",[...Ve.MUTABLE_UPSTREAM_PROPERTIES,...Ve.INMUTABLE_UPSTREAM_PROPERTIES]),c(Ve,"MUTABLE_DOWNSTREAM_PROPERTIES",["successCalls","errorCalls","inputsDeclarations","inputs","outputsDeclarations","outputs","error"]),c(Ve,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(Ve,"DOWNSTREAM_PROPERTIES",[...Ve.MUTABLE_DOWNSTREAM_PROPERTIES,...Ve.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(Ve,"PROPERTIES",[...kt.META_PROPERTIES,...kt.UPSTREAM_PROPERTIES,...kt.DOWNSTREAM_PROPERTIES]);let Yr=Ve;function q7(r){const e=B3(),t=r.toJSON();e.safeParse(t).success,r.functions.forEach(s=>s.validate()),r.events.forEach(s=>s.validate());const a=[];return Me(r.errors,a)}const Pe=class Pe{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"x");c(this,"y");c(this,"type",i.InstalledProject);c(this,"implements");c(this,"functions",[]);c(this,"events",[]);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.name=e.name,this.description=e.description,this.x=e.x,this.y=e.y,this.implements=e.implements}static fromGenerationTarget(e,t){const n=t,a={id:e.id,version:1,name:e.name,type:i.InstalledProject,description:e.description,functions:[],events:[],implements:{entityId:e.implements,entityType:i.Project,type:i.GenericReference,id:M.UUID.uuid()},x:0,y:0,parent:n},s=b(a,t);return s.setParent(n),s.initChildren(),s}static validateGenerationTarget(e,t){let n=JSON.parse(JSON.stringify(e));const a=[];return a.push(...je(n)),{errors:a,modifiedData:n}}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new g({id:`${this.id}--${T.InvalidParentUpdate}`,code:T.InvalidParentUpdate,severity:E.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated. The 'parent' on an installed project, must be the root project as it is a globally declared entity.`,issue:null})),{errors:t,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))}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{updated:m(e),added:m(t),removed:m(n),self:this}}setParent(e){return this.parent=e,this}initChildren(){return this.initialized?this:(this.initialized=!0,this.functions=this.initialData.functions.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.events=this.initialData.events.map(e=>{const t=b(e,this.project);return t.setParent(this),t.initChildren(),t}),this.afterAllChildrenInitialized(),this)}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}sync(e){return this.x=e.x||this.x,this.y=e.y||this.y,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=[];return t.has(this.id)?{affected:[],removed:[]}:(t.add(this.id),a.push(this),this.unsubscribe(),this.functions.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});n.push(...o),a.push(...l)}),this.events.forEach(s=>{const{affected:o,removed:l}=s.remove({ignoreUpstream:!1,seenEntities:t});n.push(...o),a.push(...l)}),{affected:[],removed:[]})}restore({seenEntities:e}={seenEntities:new Set}){return e.has(this.id)?{affected:[],self:this}:(e.add(this.id),this.subscribe(),this.functions.forEach(t=>{t.restore({seenEntities:e})}),this.events.forEach(t=>{t.restore({seenEntities:e})}),{affected:[],self:this})}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.functions.flatMap(n=>n.toFlat(e)),...this.events.flatMap(n=>n.toFlat(e))])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.functions.flatMap(n=>n.toFlatIds(e)),...this.events.flatMap(n=>n.toFlatIds(e))])}toJSON(e=new Set){return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,type:this.type,name:this.name,description:this.description,implements:this.implements,functions:this.functions.map(t=>t.toJSON(e)),events:this.events.map(t=>t.toJSON(e)),parent:this.parent.toReference(),x:this.x,y:this.y})}toJSONClone(e=L){var n,a,s,o,l;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,name:this.name,description:this.description,implements:this.implements,functions:this.functions.map(p=>p.toJSONClone({...e,newId:null})),events:this.events.map(p=>p.toJSONClone({...e,newId:null})),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps}),x:this.x,y:this.y})}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;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,name:this.name,description:this.description,x:this.x,y:this.y,implements:this.implements,functions:this.functions.map(a=>a.toReference(e)),events:this.events.map(a=>a.toReference(e)),parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.functions.flatMap(n=>n.toFlatJSON(e)),...this.events.flatMap(n=>n.toFlatJSON(e))])}toGenerationTarget(){return{id:this.id,name:this.name,description:this.description,type:this.type,implements:this.implements.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.functions.flatMap(n=>n.toFlatGenerationTarget(e)),...this.events.flatMap(n=>n.toFlatGenerationTarget(e))])}clearErrors(){return this.errors=[],this.functions.forEach(e=>e.clearErrors()),this.events.forEach(e=>e.clearErrors()),this}validate(){const e=q7(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.functions.flatMap(t=>t.getErrors()),...this.events.flatMap(t=>t.getErrors())]}getShallowErrors(){return this.errors}clone(e=null,t=null,n=!0){var R,v;let a=He(e,this);const s=this.toJSON(),o=t||de(w(this,this.project),i.InstalledProject,a);s.functions=[],s.events=[];const l=o.split("-id"),p=l[l.length-1||0]||o;s.id=o;const u=ke(s,a);e&&u.setParent(e),n&&u.subscribe(),u.initChildren();const h=(R=this.functions)==null?void 0:R.map((I,D)=>I.clone(u,p+"-exported-function-declaration-"+D+"-id",n));u.functions=h;const f=(v=this.events)==null?void 0:v.map((I,D)=>I.clone(u,p+"-exported-event-"+D+"-id",n));return u.events=f,u}};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",[]),c(Pe,"INMUTABLE_BASE_PROPERTIES",["id","version","name","description","type"]),c(Pe,"BASE_PROPERTIES",[...Pe.MUTABLE_BASE_PROPERTIES,...Pe.INMUTABLE_BASE_PROPERTIES]),c(Pe,"MUTABLE_META_PROPERTIES",["x","y"]),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",[]),c(Pe,"INMUTABLE_UPSTREAM_PROPERTIES",["implements","parent"]),c(Pe,"UPSTREAM_PROPERTIES",[...Pe.MUTABLE_UPSTREAM_PROPERTIES,...Pe.INMUTABLE_UPSTREAM_PROPERTIES]),c(Pe,"MUTABLE_DOWNSTREAM_PROPERTIES",["functions","events"]),c(Pe,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),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 Hr=Pe;function J7(r){var l;const e=k6(),t=r.toJSON();e.safeParse(t).success,r.inputs.forEach(p=>p.validate()),r.outputs.forEach(p=>p.validate()),(l=r.error)==null||l.validate();const a=jn(r),s=W7(r),o=[...a,...s];return Me(r.errors,o)}function W7(r){const e=[],t=Zo(r.parent),n=t==null?void 0:t.entity;if(!n)e.push(Q({id:`${r.id}--${B.InternalCallParentMissingDataType}`,code:B.InternalCallParentMissingDataType,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", belongs to a variable whose data type entity doesn't contain its declaration method (function-declaration) its id "${r.declaration}".`,issue:null,entity:r}).error);else if(![i.DefinitionEntity,i.BuiltInBaseEntity,i.PrimitiveEntity].includes(n.type))e.push(Q({id:`${r.id}--${B.InternalCallParentDeclarationEntityInvalidType}`,code:B.InternalCallParentDeclarationEntityInvalidType,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", belongs to a variable whose data type 'entity' is not a definition entity, built-in base entity or primitive entity.
|
|
98
98
|
This variable's data-type has an 'entity' field that references an entity with id '${n.id}' and of type '${n.type}'.`,issue:null,entity:r}).error);else{const a=cp(n),s=[];[i.DefinitionEntity,i.BuiltInBaseEntity,i.PrimitiveEntity].includes(n.type)&&s.push(...n.getAllInteractiveMethods());let o="";a?n.methods.length?o=`
|
|
99
99
|
All 'function-declaration' entities attached as methods to the parent data-type 'entity' field, available to be called as 'internal-calls' in this variable are:
|
|
100
100
|
- ${n.methods.map(u=>u.id).join(`
|
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.6140",
|
|
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",
|