@elyx-code/project-logic-tree 0.0.6138 → 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 +3 -7
- package/dist/index.umd.cjs +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25025,7 +25025,7 @@ ${zo}`,
|
|
|
25025
25025
|
n && y.subscribe(), y.setParent(u), y.initChildren();
|
|
25026
25026
|
const h = ((R = this.dataType) == null ? void 0 : R.clone(
|
|
25027
25027
|
y,
|
|
25028
|
-
|
|
25028
|
+
B.UUID.uuid(),
|
|
25029
25029
|
n
|
|
25030
25030
|
)) || null;
|
|
25031
25031
|
h && y.setDataType(h);
|
|
@@ -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(),
|
|
@@ -41306,11 +41306,7 @@ ${mn(
|
|
|
41306
41306
|
a
|
|
41307
41307
|
);
|
|
41308
41308
|
e && c.setParent(e), n && c.subscribe();
|
|
41309
|
-
const y = ((E = this.dataType) == null ? void 0 : E.clone(
|
|
41310
|
-
c,
|
|
41311
|
-
l + "-data-type-id",
|
|
41312
|
-
n
|
|
41313
|
-
)) || null;
|
|
41309
|
+
const y = ((E = this.dataType) == null ? void 0 : E.clone(c, B.UUID.uuid(), n)) || null;
|
|
41314
41310
|
y && c.setDataType(y);
|
|
41315
41311
|
const h = (R = this.defaultValue) == null ? void 0 : R.clone(
|
|
41316
41312
|
c,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -42,7 +42,7 @@ Please provide a unique 'name' string.`,severity:E.Error,code:B.NameNotUniqueInS
|
|
|
42
42
|
Please provide a unique 'name' string.`,severity:E.Error,code:B.NameNotUniqueInScope,issue:null}))}}return t}function S7(r,e){switch(r.type){case i.DefinitionEntity:return Qo(r,e);case i.FunctionDeclaration:return Nu(r,e);case i.VariableDeclaration:return Lu(r,e);case i.Property:return Gu(r,e);case i.ArgumentDeclaration:return $u(r,e);case i.ReturnDeclaration:return Fu(r,e);default:return[]}}function de(r,e,t){const a=`${Ko(r)}-${e}-id`;return t.instances[a]?M.UUID.uuid():a}function Uu(r,e){let t="",n=null;if(r.parent){const s=e.get(r.parent);s&&(n=s)}let a="";return n&&(a=`${Ko(w(n,e))}-`),t=`${a}${Ko(w(r,e))}-id`,e.instances[t]?M.UUID.uuid():t}function Ye(r,e,t="uuid"){return t==="semantic"?de(w(r,e),r.type,e):M.UUID.uuid()}function O7(r){var o;const e=H9(),t=r.toJSON();e.safeParse(t).success;const a=P7(r);(o=r.dataType)==null||o.validate();const s=[...a];if(r.id==="80c86e1b-caca-4ba5-9b1f-38f72d10e4a3"){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 s}function P7(r){const e=[];if(!r.implements)return e;const t=r.implements;if(!t.abstract){const a=Q({id:`${r.id}--${G.PropertyImplementsNonAbstact}`,message:`Property "${w(r,r.project)}" with id "${r.id}" implements a non-abstract property "${w(t,r.project)}" with id "${t.id}".`,issue:null,severity:E.Error,code:G.PropertyImplementsNonAbstact,entity:r});e.push(a.error)}if(r.static&&!t.static){const a=Q({id:`${r.id}--${G.NonStaticPropertyImplementsStatic}`,message:`Static property "${w(r,r.project)}" with id "${r.id}" implements a non-static property "${w(t,r.project)}" with id "${t.id}".`,issue:null,severity:E.Error,code:G.NonStaticPropertyImplementsStatic,entity:r});e.push(a.error)}if(!r.static&&t.static){const a=Q({id:`${r.id}--${G.StaticPropertyImplementsNonStatic}`,message:`Non-static property "${w(r,r.project)}" with id "${r.id}" implements a static property "${w(t,r.project)}" with id "${t.id}".`,issue:null,severity:E.Error,code:G.StaticPropertyImplementsNonStatic,entity:r});e.push(a.error)}if(!Zt(r.dataType,t.dataType)){const a=Q({id:`${r.id}--${G.PropertyImplementsIncompatibleType}`,message:`Property "${w(r,r.project)}" with id "${r.id}" implements a property "${w(t,r.project)}" with id "${t.id}" that has an incompatible data type.`,issue:null,severity:E.Error,code:G.PropertyImplementsIncompatibleType,entity:r});e.push(a.error)}return Me(r.errors,e)}function C7(r,e){const t=[];if(r.parent){const a=e.get(r.parent);if(!a)t.push(new g({id:`${r.id}--${r.parent}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${r.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const s=ur(a);if(s){const o=a!==s?`The entity of type '${r.type}' with id '${r.id}' have 'parent' with id '${r.parent}' because the entity belongs to a built-in '${s.type}' entity with id '${s.id}' (${w(s,a.project)}) higher up in the tree.`:`The entity of type '${r.type}' with id '${r.id}' have 'parent' with id '${r.parent}' because it is a built-in entity of type ${s.type}.`;t.push(new g({id:`${r.id}--${T.InvalidBuiltInEntityReference}`,code:T.InvalidBuiltInEntityReference,severity:E.Error,message:o,issue:null}))}else if(![i.DefinitionEntity].includes(a.type))t.push(new g({id:`${r.id}--${r.parent}--${T.InvalidParentReference}`,code:T.InvalidParentReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has a parent reference that isn't pointing to an entity of type 'definition-entity'.`,issue:null}));else{const l=cr(a).filter(p=>!p.interactive);if(l.length){let p=l.length>1?`The entity of type '${r.type}' with id '${r.id}' can't be added to the 'parent' entity with id '${a.id}' because it extends or implements multiple '${i.BuiltInBaseEntity}' entities that are non-interactive ("${q(l.map(u=>w(u,u.project)),'", "','" and "')}").`:`The entity of type '${r.type}' with id '${r.id}' can't be added to the 'parent' entity with id '${a.id}' because it extends or implements a '${i.BuiltInBaseEntity}' entity that is non-interactive ("${w(l[0],l[0].project)}").`;p+=`
|
|
43
43
|
${lr}`,t.push(new g({id:`${r.id}--${T.NonInteractiveEntityReferenced}`,code:T.NonInteractiveEntityReferenced,severity:E.Error,message:p,issue:null}))}else if(r.implements){const p=e.get(r.implements);if(r.id===r.implements)return t.push(new g({id:`${r.id}--${r.implements}--${T.SelfReference}`,code:T.SelfReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has a reference to itself at 'implements'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null})),t;if(!p)t.push(new g({id:`${r.id}--${r.implements}--${T.ReferencedEntityNotFound}`,code:T.ReferencedEntityNotFound,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", is referencing an entity with id "${r.implements}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const u=a.properties.find(h=>{var f;return((f=h.implements)==null?void 0:f.id)===r.implements});u?t.push(new g({id:`${r.id}--${B.PropertyOverwrite}`,code:B.PropertyOverwrite,severity:E.Error,message:`The property with id "${r.id}" is trying to implement the property with id "${r.implements}", but the parent entity already has a property with id '${u.id}' that implements the same base property.`,issue:null})):[i.Property].includes(p.type)?p.abstract||t.push(new g({id:`${r.id}--${r.implements}--${T.InvalidImplementsReference}`,code:T.InvalidImplementsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):t.push(new g({id:`${r.id}--${r.implements}--${T.InvalidImplementsReference}`,code:T.InvalidImplementsReference,severity:E.Error,message:`Entity of type "${r.type}" with id "${r.id}", has an 'implements' reference that isn't pointing to an entity of type 'property'.`,issue:null}))}}}}}const n=tt(r,{},e);return t.push(...n.errors),t}const ce=class ce{constructor(e,t){c(this,"initialData");c(this,"id");c(this,"version");c(this,"name");c(this,"description",null);c(this,"private");c(this,"abstract");c(this,"index");c(this,"static");c(this,"required");c(this,"constant",!1);c(this,"type",i.Property);c(this,"hidden",!1);c(this,"defaultValue",null);c(this,"dataType",null);c(this,"implements",null);c(this,"project");c(this,"errors",[]);c(this,"parent");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.private=e.private,this.abstract=e.abstract,this.index=e.index,this.static=e.static,this.required=e.required||!1,this.hidden=e.hidden||!1,this.constant=e.constant||!1}static fromGenerationTarget(e,t){const n=A(e.parent),a=t.get(n);let s=null;if(e.implements){const p=A(e.implements);s=t.get(p)}const o={id:e.id,version:1,name:e.name,type:i.Property,index:a.properties.length,private:e.private||!1,abstract:e.abstract||!1,static:e.static||!1,required:e.required||!1,constant:e.constant||!1,hidden:!1,description:e.description,defaultValue:null,implements:s,dataType:null,parent:a},l=b(o,t);return l.setParent(a),l.initChildren(),l}static validateGenerationTarget(e,t){let n=JSON.parse(JSON.stringify(e));const a=[],s=C7(n,t),o=Gu(n,t);return a.push(...s,...o,...je(n)),{errors:a,modifiedData:n}}get isExtendedProperty(){const e=this.parent.allBasePropertiesFromExtendedAndImplementedEntities.find(t=>t.name===this.name);return!!e&&e.id!==this.id&&!e.abstract}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, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
44
44
|
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})),(e.readsValue||e.writesValue)&&t.push(new g({id:`${this.id}--${B.InvalidObjectStructure}`,code:B.InvalidObjectStructure,severity:E.Error,message:`Entity of type '${this.type}' with id '${this.id}' is not a value reading or writing entity.
|
|
45
|
-
${rl}`,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))}if(this.initialData.implements){const a=A(this.initialData.implements),s=this.project.get(a);s&&(this.setImplements(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.addProperty(this),e.push(this.parent),{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){const e=b(this.initialData.dataType,this.project);e.setParent(this),e.initChildren(),this.dataType=e}if(this.initialData.implements){const e=b(this.initialData.implements,this.project);this.implements=e}return 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.name=e.name||this.name,this.description=e.description||this.description,this.abstract=e.abstract!==void 0?e.abstract:this.abstract,this.private=e.private!==void 0?e.private:this.private,this.index=e.index||(e.index!==0?this.index:0),this.static=e.static!==void 0?e.static:this.static,this.hidden=e.hidden!==void 0?e.hidden:this.hidden,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 ce.repository.load(this.id,...t),this}async create(e=V,...t){return await ce.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await ce.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await ce.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{affected:s,removed:o}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s),a.push(...o)}return e||this.parent.type===i.DefinitionEntity&&(this.parent.removeProperty(this),n.push(this.parent)),{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{affected:n}=this.dataType.restore({seenEntities:e});t.push(...n)}return this.parent.type===i.DefinitionEntity&&(this.parent.addProperty(this),t.push(this.parent)),{affected:t,self:this}}toFlat(e=new Set){var n,a;return e.has(this.id)?[]:(e.add(this.id),[this,...((n=this.defaultValue)==null?void 0:n.toFlat(e))||[],...((a=this.dataType)==null?void 0:a.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;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,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,abstract:this.abstract,hidden:this.hidden,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,parent:this.parent.toReference()})}toJSONClone(e=L){var n,a,s,o,l,p,u;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:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,abstract:this.abstract,hidden:this.hidden,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:(()=>{var h;return this.implements&&this.project.getBuiltIn(this.implements.id)?this.implements.toJSON():((h=this.implements)==null?void 0:h.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,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,name:this.name,description:this.description,type:this.type,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,constant:this.constant,hidden:this.hidden,defaultValue:((a=this.defaultValue)==null?void 0:a.toReference(e))||null,dataType:((s=this.dataType)==null?void 0:s.toReference(e))||null,implements:((o=this.implements)==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.defaultValue)==null?void 0:n.toFlatJSON(e))||[],...((a=this.dataType)==null?void 0:a.toFlatJSON(e))||[],...((s=this.implements)==null?void 0:s.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,implements:((e=this.implements)==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.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(){return this.errors=O7(this),this.errors.length,{success:!0,error:null,data:null}}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}clone(e=null,t=null,n=!0){var v,I;let a=He(e,this);const s=t||de(w(this,this.project),i.Property,a),o=s.split("-id"),l=o[o.length-1||0]||s;let p=e||this.parent;const u={hidden:!1,id:s,version:this.version,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,constant:this.constant,required:this.required,abstract:this.abstract,static:this.static,defaultValue:null,dataType:null,implements:this.implements,parent:p},h=ke(u,a);n&&h.subscribe(),h.setParent(p),h.initChildren();const f=((v=this.dataType)==null?void 0:v.clone(h,l+"-data-type-id",n))||null;f&&h.setDataType(f);const R=(I=this.defaultValue)==null?void 0:I.clone(h,l+"-default-value-id",n);return h.defaultValue=R||null,this.implements&&(h.implements=this.implements),h.addSelfToProject(),h}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(){return this.dataType}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}};c(ce,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(ce,"MUTABLE_BASE_PROPERTIES",["name","description","private","abstract","static","required"]),c(ce,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(ce,"BASE_PROPERTIES",[...ce.MUTABLE_BASE_PROPERTIES,...ce.INMUTABLE_BASE_PROPERTIES]),c(ce,"MUTABLE_META_PROPERTIES",[...ce.MUTABLE_BASE_PROPERTIES,"index"]),c(ce,"INMUTABLE_META_PROPERTIES",[...ce.INMUTABLE_BASE_PROPERTIES]),c(ce,"META_PROPERTIES",[...ce.MUTABLE_META_PROPERTIES,...ce.INMUTABLE_META_PROPERTIES]),c(ce,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(ce,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements"]),c(ce,"UPSTREAM_PROPERTIES",[...ce.MUTABLE_UPSTREAM_PROPERTIES,...ce.INMUTABLE_UPSTREAM_PROPERTIES]),c(ce,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),c(ce,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ce,"DOWNSTREAM_PROPERTIES",[...ce.MUTABLE_DOWNSTREAM_PROPERTIES,...ce.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ce,"PROPERTIES",[...ce.META_PROPERTIES,...ce.UPSTREAM_PROPERTIES,...ce.DOWNSTREAM_PROPERTIES]);let Ur=ce;function w7(r){const e=u5(),t=r.toJSON();e.safeParse(t).success;const a=B7(r),s=M7(r),o=Nt(r);r.inputs.forEach(p=>p.validate()),o.forEach(p=>p.validate());const l=[...a,...s];if(r.id==="getCompanyByIdEndpointReachedEntityEvent"){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});l.push(p.error)}return Me(r.errors,l)}function B7(r){const e=[];if(!r.calls.length){const t=Q({id:`${r.id}--${G.ScopeWithoutLogic}`,message:`Action "${w(r,r.project)}" with id "${r.id}" does not have any logic defined. So it doesn't do anything.`,issue:null,severity:E.Warning,code:G.ScopeWithoutLogic,entity:r});e.push(t.error)}return Me(r.errors,e)}function M7(r){const e=[];return r.implements,Me(r.errors,e)}const ue=class ue{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,"collapsed");c(this,"private");c(this,"index",null);c(this,"type",i.FunctionDeclaration);c(this,"implements",null);c(this,"inputs",[]);c(this,"returnStatements",[]);c(this,"calls",[]);c(this,"parent");c(this,"detachedChildren",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.private=e.private,this.collapsed=e.collapsed,this.x=e.x,this.y=e.y,this.index=e.index}static fromGenerationTarget(e,t){let n=t;if(e.parent){const l=A(e.parent);n=t.get(l)}let a=null;if(e.implements){const l=A(e.implements);a=t.get(l)}const s={id:e.id,version:1,name:e.name,type:i.FunctionDeclaration,index:n.type===i.DefinitionEntity?n.methods.length:null,description:e.description,collapsed:!1,private:!1,returnStatements:[],calls:[],inputs:[],implements:a,x:0,y:0,parent:n},o=b(s,t);return o.setParent(n),o.initChildren(),o}static validateGenerationTarget(e,t){var h;let n=JSON.parse(JSON.stringify(e));const a=[],s=tt(n,{parent:{list:!1,types:[i.Project,i.InstalledProject,i.DefinitionEntity,i.Loop],optional:!0},implements:{list:!1,types:[i.ActionDescriptor],optional:!0}},t);n=s.modifiedData;const o=Nu(n,t),l=n.parent?t.get(n.parent):null;if(l&&l.type===i.DefinitionEntity){const f=l,v=cr(f).filter(I=>!I.interactive);if(v.length){let I=v.length>1?`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${f.id}' because it extends or implements multiple '${i.BuiltInBaseEntity}' entities that are non-interactive ("${q(v.map(D=>w(D,D.project)),'", "','" and "')}").`:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${f.id}' because it extends or implements a '${i.BuiltInBaseEntity}' entity that is non-interactive ("${w(v[0],v[0].project)}").`;I+=`
|
|
45
|
+
${rl}`,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))}if(this.initialData.implements){const a=A(this.initialData.implements),s=this.project.get(a);s&&(this.setImplements(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.addProperty(this),e.push(this.parent),{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){const e=b(this.initialData.dataType,this.project);e.setParent(this),e.initChildren(),this.dataType=e}if(this.initialData.implements){const e=b(this.initialData.implements,this.project);this.implements=e}return 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.name=e.name||this.name,this.description=e.description||this.description,this.abstract=e.abstract!==void 0?e.abstract:this.abstract,this.private=e.private!==void 0?e.private:this.private,this.index=e.index||(e.index!==0?this.index:0),this.static=e.static!==void 0?e.static:this.static,this.hidden=e.hidden!==void 0?e.hidden:this.hidden,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 ce.repository.load(this.id,...t),this}async create(e=V,...t){return await ce.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await ce.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await ce.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{affected:s,removed:o}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});n.push(...s),a.push(...o)}return e||this.parent.type===i.DefinitionEntity&&(this.parent.removeProperty(this),n.push(this.parent)),{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{affected:n}=this.dataType.restore({seenEntities:e});t.push(...n)}return this.parent.type===i.DefinitionEntity&&(this.parent.addProperty(this),t.push(this.parent)),{affected:t,self:this}}toFlat(e=new Set){var n,a;return e.has(this.id)?[]:(e.add(this.id),[this,...((n=this.defaultValue)==null?void 0:n.toFlat(e))||[],...((a=this.dataType)==null?void 0:a.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;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,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,abstract:this.abstract,hidden:this.hidden,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,parent:this.parent.toReference()})}toJSONClone(e=L){var n,a,s,o,l,p,u;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:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,abstract:this.abstract,hidden:this.hidden,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:(()=>{var h;return this.implements&&this.project.getBuiltIn(this.implements.id)?this.implements.toJSON():((h=this.implements)==null?void 0:h.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,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,name:this.name,description:this.description,type:this.type,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,constant:this.constant,hidden:this.hidden,defaultValue:((a=this.defaultValue)==null?void 0:a.toReference(e))||null,dataType:((s=this.dataType)==null?void 0:s.toReference(e))||null,implements:((o=this.implements)==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.defaultValue)==null?void 0:n.toFlatJSON(e))||[],...((a=this.dataType)==null?void 0:a.toFlatJSON(e))||[],...((s=this.implements)==null?void 0:s.toFlatJSON(e))||[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,implements:((e=this.implements)==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.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(){return this.errors=O7(this),this.errors.length,{success:!0,error:null,data:null}}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}clone(e=null,t=null,n=!0){var v,I;let a=He(e,this);const s=t||de(w(this,this.project),i.Property,a),o=s.split("-id"),l=o[o.length-1||0]||s;let p=e||this.parent;const u={hidden:!1,id:s,version:this.version,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,constant:this.constant,required:this.required,abstract:this.abstract,static:this.static,defaultValue:null,dataType:null,implements:this.implements,parent:p},h=ke(u,a);n&&h.subscribe(),h.setParent(p),h.initChildren();const f=((v=this.dataType)==null?void 0:v.clone(h,M.UUID.uuid(),n))||null;f&&h.setDataType(f);const R=(I=this.defaultValue)==null?void 0:I.clone(h,l+"-default-value-id",n);return h.defaultValue=R||null,this.implements&&(h.implements=this.implements),h.addSelfToProject(),h}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(){return this.dataType}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}};c(ce,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(ce,"MUTABLE_BASE_PROPERTIES",["name","description","private","abstract","static","required"]),c(ce,"INMUTABLE_BASE_PROPERTIES",["id","type","version"]),c(ce,"BASE_PROPERTIES",[...ce.MUTABLE_BASE_PROPERTIES,...ce.INMUTABLE_BASE_PROPERTIES]),c(ce,"MUTABLE_META_PROPERTIES",[...ce.MUTABLE_BASE_PROPERTIES,"index"]),c(ce,"INMUTABLE_META_PROPERTIES",[...ce.INMUTABLE_BASE_PROPERTIES]),c(ce,"META_PROPERTIES",[...ce.MUTABLE_META_PROPERTIES,...ce.INMUTABLE_META_PROPERTIES]),c(ce,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(ce,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements"]),c(ce,"UPSTREAM_PROPERTIES",[...ce.MUTABLE_UPSTREAM_PROPERTIES,...ce.INMUTABLE_UPSTREAM_PROPERTIES]),c(ce,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),c(ce,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(ce,"DOWNSTREAM_PROPERTIES",[...ce.MUTABLE_DOWNSTREAM_PROPERTIES,...ce.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(ce,"PROPERTIES",[...ce.META_PROPERTIES,...ce.UPSTREAM_PROPERTIES,...ce.DOWNSTREAM_PROPERTIES]);let Ur=ce;function w7(r){const e=u5(),t=r.toJSON();e.safeParse(t).success;const a=B7(r),s=M7(r),o=Nt(r);r.inputs.forEach(p=>p.validate()),o.forEach(p=>p.validate());const l=[...a,...s];if(r.id==="getCompanyByIdEndpointReachedEntityEvent"){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});l.push(p.error)}return Me(r.errors,l)}function B7(r){const e=[];if(!r.calls.length){const t=Q({id:`${r.id}--${G.ScopeWithoutLogic}`,message:`Action "${w(r,r.project)}" with id "${r.id}" does not have any logic defined. So it doesn't do anything.`,issue:null,severity:E.Warning,code:G.ScopeWithoutLogic,entity:r});e.push(t.error)}return Me(r.errors,e)}function M7(r){const e=[];return r.implements,Me(r.errors,e)}const ue=class ue{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,"collapsed");c(this,"private");c(this,"index",null);c(this,"type",i.FunctionDeclaration);c(this,"implements",null);c(this,"inputs",[]);c(this,"returnStatements",[]);c(this,"calls",[]);c(this,"parent");c(this,"detachedChildren",[]);c(this,"errors",[]);c(this,"project");c(this,"initialized",!1);c(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.version=e.version,this.name=e.name,this.description=e.description,this.private=e.private,this.collapsed=e.collapsed,this.x=e.x,this.y=e.y,this.index=e.index}static fromGenerationTarget(e,t){let n=t;if(e.parent){const l=A(e.parent);n=t.get(l)}let a=null;if(e.implements){const l=A(e.implements);a=t.get(l)}const s={id:e.id,version:1,name:e.name,type:i.FunctionDeclaration,index:n.type===i.DefinitionEntity?n.methods.length:null,description:e.description,collapsed:!1,private:!1,returnStatements:[],calls:[],inputs:[],implements:a,x:0,y:0,parent:n},o=b(s,t);return o.setParent(n),o.initChildren(),o}static validateGenerationTarget(e,t){var h;let n=JSON.parse(JSON.stringify(e));const a=[],s=tt(n,{parent:{list:!1,types:[i.Project,i.InstalledProject,i.DefinitionEntity,i.Loop],optional:!0},implements:{list:!1,types:[i.ActionDescriptor],optional:!0}},t);n=s.modifiedData;const o=Nu(n,t),l=n.parent?t.get(n.parent):null;if(l&&l.type===i.DefinitionEntity){const f=l,v=cr(f).filter(I=>!I.interactive);if(v.length){let I=v.length>1?`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${f.id}' because it extends or implements multiple '${i.BuiltInBaseEntity}' entities that are non-interactive ("${q(v.map(D=>w(D,D.project)),'", "','" and "')}").`:`The entity of type '${e.type}' with id '${e.id}' can't be added to the 'parent' entity with id '${f.id}' because it extends or implements a '${i.BuiltInBaseEntity}' entity that is non-interactive ("${w(v[0],v[0].project)}").`;I+=`
|
|
46
46
|
${lr}`,a.push(new g({id:`${e.id}--${T.NonInteractiveEntityReferenced}`,code:T.NonInteractiveEntityReferenced,severity:E.Error,message:I,issue:null}))}else{const I=f.methods.find(x=>{var k;return((k=x.implements)==null?void 0:k.id)===n.implements});I&&a.push(new g({id:`${n.id}--${B.MethodOverwrite}`,code:B.MethodOverwrite,severity:E.Error,message:`The '${i.FunctionDeclaration}' with id "${n.id}" is trying to implement the '${i.ActionDescriptor}' with id "${n.implements}", but the parent definition-entity already has a ${i.FunctionDeclaration} with id '${I.id}' that implements the same base method.
|
|
47
47
|
A ${i.FunctionDeclaration} that has a parent of type '${i.DefinitionEntity}' is considered a method of that entity, and cannot implement the same '${i.ActionDescriptor}' more than once.
|
|
48
48
|
${i.ActionDescriptor} entities inside a ${i.DefinitionEntity} are considered abstract methods that can be implemented by ${i.FunctionDeclaration} entities inside the same parent.
|
|
@@ -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(`
|
|
@@ -202,7 +202,7 @@ You can't modify system entities that are built-in.`,issue:null})),o&&o.type===i
|
|
|
202
202
|
An action descriptor can only have one error value descriptor child.
|
|
203
203
|
Either remove the existing error value descriptor or update it with the 'update' action.
|
|
204
204
|
You can use the 'describe_entity' action to get more information about the existing error value descriptor like so:
|
|
205
|
-
${gn({describe_entity:o.error.id})}`,issue:null}))),{errors:a,modifiedData:n}}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))}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(){var a,s,o,l,p,u,h,f;const e=[this],t=[],n=[];return this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument?((a=this.parent)==null?void 0:a.type)===i.Search||((s=this.parent)==null?void 0:s.type)===i.Loop?(this.parent.addInputDeclaration(this),e.push(this.parent)):((l=(o=this.parent)==null?void 0:o.addInput)==null||l.call(o,this),e.push(this.parent)):this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?((p=this.parent)==null?void 0:p.type)===i.Search||((u=this.parent)==null?void 0:u.type)===i.Loop?(this.parent.addOutputDeclaration(this),e.push(this.parent)):((f=(h=this.parent)==null?void 0:h.addOutput)==null||f.call(h,this),e.push(this.parent)):this.parentRelationType===P.ReturnedError&&this.parent&&(this.parent.error=this,e.push(this.parent)),{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.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.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.name=e.name||this.name,this.description=e.description||this.description,this.index=e.index||(e.index!==0?this.index:0),this.required=e.required||this.required,this.parentRelationType=e.parentRelationType||this.parentRelationType,this}async load(e=V,...t){return await De.repository.load(this.id,...t),this}async create(e=V,...t){return await De.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await De.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await De.repository.delete(this.id,...t),this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s,o,l,p,u,h,f;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:R,removed:v}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});n.push(...R),a.push(...v)}if(this.dataType){const{affected:R,removed:v}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});n.push(...R),a.push(...v)}return e||(((s=this.parent)==null?void 0:s.type)===i.Search?this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(o=this.parent)==null||o.removeOutputDeclaration(this):this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument?(l=this.parent)==null||l.removeInputDeclaration(this):this.parentRelationType===P.ReturnedError&&(this.parent.error=null):((p=this.parent)==null?void 0:p.type)===i.Loop?this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(u=this.parent)==null||u.removeOutputDeclaration(this):this.parentRelationType===P.ReturnedError&&(this.parent.error=null):this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(h=this.parent)==null||h.removeOutput(this):(this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument)&&((f=this.parent)==null||f.removeInput(this))),{affected:m(n),removed:m(a)}}restore({seenEntities:e}={seenEntities:new Set}){var n,a,s,o,l,p,u;const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.defaultValue){const{affected:h}=this.defaultValue.restore({seenEntities:e});t.push(...h)}if(this.dataType){const{affected:h}=this.dataType.restore({seenEntities:e});t.push(...h)}return((n=this.parent)==null?void 0:n.type)===i.Search?this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(a=this.parent)==null||a.addOutputDeclaration(this):(this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument)&&((s=this.parent)==null||s.addInputDeclaration(this)):((o=this.parent)==null?void 0:o.type)===i.Loop?(this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn)&&((l=this.parent)==null||l.addOutputDeclaration(this)):this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(p=this.parent)==null||p.addOutput(this):(this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument)&&((u=this.parent)==null||u.addInput(this)),{affected:m(t),self:this}}toFlat(e=new Set){var n;return e.has(this.id)?[]:(e.add(this.id),[this,...((n=this.defaultValue)==null?void 0:n.toFlat(e))||[],...this.dataType?this.dataType.toFlat(e):[]])}toFlatIds(e=new Set){var n;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((n=this.defaultValue)==null?void 0:n.toFlatIds(e))||[],...this.dataType?this.dataType.toFlatIds(e):[]])}toJSON(e=new Set){var t,n,a;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,index:this.index,required:this.required,defaultValue:((t=this.defaultValue)==null?void 0:t.toJSON(e))||null,parentRelationType:this.parentRelationType,dataType:((n=this.dataType)==null?void 0:n.toJSON(e))||null,parent:((a=this.parent)==null?void 0:a.toReference())||null})}toJSONClone(e=L){var n,a,s,o,l,p,u,h;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:this.type,name:this.name,description:this.description,index:this.index,required:this.required,defaultValue:((p=this.defaultValue)==null?void 0:p.toJSONClone({...e,newId:null}))||null,parentRelationType:this.parentRelationType,dataType:((u=this.dataType)==null?void 0:u.toJSONClone({...e,newId:null}))||null,parent:((h=this.parent)==null?void 0:h.toReference({seenEntityMaps:e.seenEntityMaps}))||null})}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,name:this.name,description:this.description,index:this.index,required:this.required,parentRelationType:this.parentRelationType,defaultValue:((a=this.defaultValue)==null?void 0:a.toReference(e))||null,dataType:((s=this.dataType)==null?void 0:s.toReference(e))||null,parent:((o=this.parent)==null?void 0:o.toReference(e))||null}}toFlatJSON(e=new Set){var n;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((n=this.defaultValue)==null?void 0:n.toFlatJSON(e))||[],...this.dataType?this.dataType.toFlatJSON(e):[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,required:this.required,parentRelationType:this.parentRelationType,parent:(e=this.parent)==null?void 0:e.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(e):[],...this.dataType?this.dataType.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=sq(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.dataType?this.dataType.getErrors():[]]}getShallowErrors(){return this.errors}clone(e=null,t=null,n=!0){var R,v;let a=He(e,this);const s=t||de(w(this,this.project),i.ValueDescriptor,a),o=s.split("-id"),l=o[o.length-1||0]||s,p=this.toJSON();p.id=s;const u=ke(p,a);e&&u.setParent(e),n&&u.subscribe();const h=((R=this.dataType)==null?void 0:R.clone(u,l+"-data-type-id",n))||null;h&&u.setDataType(h);const f=(v=this.defaultValue)==null?void 0:v.clone(u,l+"-default-value-id",n);return u.defaultValue=f||null,u}getDataType(){return this.dataType||null}setDataType(e){return this.dataType=e,this}getDefaultValue(){return this.defaultValue||null}setDefaultValue(e){return this.defaultValue=e,this}removeDataType(){return this.dataType=null,this}};c(De,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(De,"MUTABLE_BASE_PROPERTIES",["name","description","required"]),c(De,"INMUTABLE_BASE_PROPERTIES",["id","version","type","parentRelationType"]),c(De,"BASE_PROPERTIES",[...De.MUTABLE_BASE_PROPERTIES,...De.INMUTABLE_BASE_PROPERTIES]),c(De,"MUTABLE_META_PROPERTIES",[...De.MUTABLE_BASE_PROPERTIES,"index"]),c(De,"INMUTABLE_META_PROPERTIES",[...De.INMUTABLE_BASE_PROPERTIES]),c(De,"META_PROPERTIES",[...De.MUTABLE_META_PROPERTIES,...De.INMUTABLE_META_PROPERTIES]),c(De,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(De,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(De,"UPSTREAM_PROPERTIES",[...De.MUTABLE_UPSTREAM_PROPERTIES,...De.INMUTABLE_UPSTREAM_PROPERTIES]),c(De,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),c(De,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(De,"DOWNSTREAM_PROPERTIES",[...De.MUTABLE_DOWNSTREAM_PROPERTIES,...De.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(De,"PROPERTIES",[...De.META_PROPERTIES,...De.UPSTREAM_PROPERTIES,...De.DOWNSTREAM_PROPERTIES]);let Kr=De;function oq(r,e){if(!r.type&&!r.id)return{errors:[new g({id:`last-generated-entity-payload--${T.MissingTypeProperty}`,message:"Last generated entity payload is missing a 'type' property.",severity:E.Error,code:T.MissingTypeProperty,issue:null}),new g({id:`last-generated-entity-payload--${T.MissingIdProperty}`,message:"Last generated entity payload is missing an 'id' property.",severity:E.Error,code:T.MissingIdProperty,issue:null})],modifiedData:null};if(r.type){if(!r.id)return{errors:[new g({id:`last-generated-entity-payload--${T.MissingIdProperty}`,message:`Last generated entity, with type "${r.type}" is missing an 'id' property.`,severity:E.Error,code:T.MissingIdProperty,issue:null})],modifiedData:null}}else return{errors:[new g({id:`${r.id}--${T.MissingTypeProperty}`,message:`Entity with id "${r.id}" is missing a 'type' property.`,severity:E.Error,code:T.MissingTypeProperty,issue:null})],modifiedData:null};if(r.type===i.GenericReference)return{errors:[new g({id:`${r.id}--${T.RootReference}`,message:`Generic reference entity with id "${r.id}". A generic reference cannot be generated as a standalone entity. Only in the body of another entity.`,severity:E.Error,code:T.RootReference,issue:null})],modifiedData:null};const t=r,n=e.instances[t.id],a=e.builtInInstances[t.id];if(n&&!a&&t.type!==i.GenericReference){let s=`A previously generated entity with id "${t.id}" already exists in the project state.
|
|
205
|
+
${gn({describe_entity:o.error.id})}`,issue:null}))),{errors:a,modifiedData:n}}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))}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(){var a,s,o,l,p,u,h,f;const e=[this],t=[],n=[];return this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument?((a=this.parent)==null?void 0:a.type)===i.Search||((s=this.parent)==null?void 0:s.type)===i.Loop?(this.parent.addInputDeclaration(this),e.push(this.parent)):((l=(o=this.parent)==null?void 0:o.addInput)==null||l.call(o,this),e.push(this.parent)):this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?((p=this.parent)==null?void 0:p.type)===i.Search||((u=this.parent)==null?void 0:u.type)===i.Loop?(this.parent.addOutputDeclaration(this),e.push(this.parent)):((f=(h=this.parent)==null?void 0:h.addOutput)==null||f.call(h,this),e.push(this.parent)):this.parentRelationType===P.ReturnedError&&this.parent&&(this.parent.error=this,e.push(this.parent)),{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.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.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.name=e.name||this.name,this.description=e.description||this.description,this.index=e.index||(e.index!==0?this.index:0),this.required=e.required||this.required,this.parentRelationType=e.parentRelationType||this.parentRelationType,this}async load(e=V,...t){return await De.repository.load(this.id,...t),this}async create(e=V,...t){return await De.repository.create(this.toShallowJSON(),...t),this}async update(e=V,...t){return await De.repository.update(this.toShallowJSON(),...t),this}async delete(e=V,...t){return await De.repository.delete(this.id,...t),this}remove({ignoreUpstream:e,seenEntities:t}={ignoreUpstream:!1,seenEntities:new Set}){var s,o,l,p,u,h,f;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:R,removed:v}=this.defaultValue.remove({ignoreUpstream:!0,seenEntities:t});n.push(...R),a.push(...v)}if(this.dataType){const{affected:R,removed:v}=this.dataType.remove({ignoreUpstream:!0,seenEntities:t});n.push(...R),a.push(...v)}return e||(((s=this.parent)==null?void 0:s.type)===i.Search?this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(o=this.parent)==null||o.removeOutputDeclaration(this):this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument?(l=this.parent)==null||l.removeInputDeclaration(this):this.parentRelationType===P.ReturnedError&&(this.parent.error=null):((p=this.parent)==null?void 0:p.type)===i.Loop?this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(u=this.parent)==null||u.removeOutputDeclaration(this):this.parentRelationType===P.ReturnedError&&(this.parent.error=null):this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(h=this.parent)==null||h.removeOutput(this):(this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument)&&((f=this.parent)==null||f.removeInput(this))),{affected:m(n),removed:m(a)}}restore({seenEntities:e}={seenEntities:new Set}){var n,a,s,o,l,p,u;const t=[];if(e.has(this.id))return{affected:[],self:this};if(e.add(this.id),this.subscribe(),this.defaultValue){const{affected:h}=this.defaultValue.restore({seenEntities:e});t.push(...h)}if(this.dataType){const{affected:h}=this.dataType.restore({seenEntities:e});t.push(...h)}return((n=this.parent)==null?void 0:n.type)===i.Search?this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(a=this.parent)==null||a.addOutputDeclaration(this):(this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument)&&((s=this.parent)==null||s.addInputDeclaration(this)):((o=this.parent)==null?void 0:o.type)===i.Loop?(this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn)&&((l=this.parent)==null||l.addOutputDeclaration(this)):this.parentRelationType===P.FixedReturns||this.parentRelationType===P.DynamicReturn?(p=this.parent)==null||p.addOutput(this):(this.parentRelationType===P.FixedArguments||this.parentRelationType===P.DynamicArgument)&&((u=this.parent)==null||u.addInput(this)),{affected:m(t),self:this}}toFlat(e=new Set){var n;return e.has(this.id)?[]:(e.add(this.id),[this,...((n=this.defaultValue)==null?void 0:n.toFlat(e))||[],...this.dataType?this.dataType.toFlat(e):[]])}toFlatIds(e=new Set){var n;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((n=this.defaultValue)==null?void 0:n.toFlatIds(e))||[],...this.dataType?this.dataType.toFlatIds(e):[]])}toJSON(e=new Set){var t,n,a;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,index:this.index,required:this.required,defaultValue:((t=this.defaultValue)==null?void 0:t.toJSON(e))||null,parentRelationType:this.parentRelationType,dataType:((n=this.dataType)==null?void 0:n.toJSON(e))||null,parent:((a=this.parent)==null?void 0:a.toReference())||null})}toJSONClone(e=L){var n,a,s,o,l,p,u,h;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:this.type,name:this.name,description:this.description,index:this.index,required:this.required,defaultValue:((p=this.defaultValue)==null?void 0:p.toJSONClone({...e,newId:null}))||null,parentRelationType:this.parentRelationType,dataType:((u=this.dataType)==null?void 0:u.toJSONClone({...e,newId:null}))||null,parent:((h=this.parent)==null?void 0:h.toReference({seenEntityMaps:e.seenEntityMaps}))||null})}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,name:this.name,description:this.description,index:this.index,required:this.required,parentRelationType:this.parentRelationType,defaultValue:((a=this.defaultValue)==null?void 0:a.toReference(e))||null,dataType:((s=this.dataType)==null?void 0:s.toReference(e))||null,parent:((o=this.parent)==null?void 0:o.toReference(e))||null}}toFlatJSON(e=new Set){var n;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((n=this.defaultValue)==null?void 0:n.toFlatJSON(e))||[],...this.dataType?this.dataType.toFlatJSON(e):[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,required:this.required,parentRelationType:this.parentRelationType,parent:(e=this.parent)==null?void 0:e.id}}toFlatGenerationTarget(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(e):[],...this.dataType?this.dataType.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=sq(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors,...this.dataType?this.dataType.getErrors():[]]}getShallowErrors(){return this.errors}clone(e=null,t=null,n=!0){var R,v;let a=He(e,this);const s=t||de(w(this,this.project),i.ValueDescriptor,a),o=s.split("-id"),l=o[o.length-1||0]||s,p=this.toJSON();p.id=s;const u=ke(p,a);e&&u.setParent(e),n&&u.subscribe();const h=((R=this.dataType)==null?void 0:R.clone(u,M.UUID.uuid(),n))||null;h&&u.setDataType(h);const f=(v=this.defaultValue)==null?void 0:v.clone(u,l+"-default-value-id",n);return u.defaultValue=f||null,u}getDataType(){return this.dataType||null}setDataType(e){return this.dataType=e,this}getDefaultValue(){return this.defaultValue||null}setDefaultValue(e){return this.defaultValue=e,this}removeDataType(){return this.dataType=null,this}};c(De,"repository",{create:async(e,...t)=>e,update:async(e,...t)=>e,delete:async(e,...t)=>{},load:async(e,...t)=>null}),c(De,"MUTABLE_BASE_PROPERTIES",["name","description","required"]),c(De,"INMUTABLE_BASE_PROPERTIES",["id","version","type","parentRelationType"]),c(De,"BASE_PROPERTIES",[...De.MUTABLE_BASE_PROPERTIES,...De.INMUTABLE_BASE_PROPERTIES]),c(De,"MUTABLE_META_PROPERTIES",[...De.MUTABLE_BASE_PROPERTIES,"index"]),c(De,"INMUTABLE_META_PROPERTIES",[...De.INMUTABLE_BASE_PROPERTIES]),c(De,"META_PROPERTIES",[...De.MUTABLE_META_PROPERTIES,...De.INMUTABLE_META_PROPERTIES]),c(De,"MUTABLE_UPSTREAM_PROPERTIES",[]),c(De,"INMUTABLE_UPSTREAM_PROPERTIES",["parent"]),c(De,"UPSTREAM_PROPERTIES",[...De.MUTABLE_UPSTREAM_PROPERTIES,...De.INMUTABLE_UPSTREAM_PROPERTIES]),c(De,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType","defaultValue"]),c(De,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),c(De,"DOWNSTREAM_PROPERTIES",[...De.MUTABLE_DOWNSTREAM_PROPERTIES,...De.INMUTABLE_DOWNSTREAM_PROPERTIES]),c(De,"PROPERTIES",[...De.META_PROPERTIES,...De.UPSTREAM_PROPERTIES,...De.DOWNSTREAM_PROPERTIES]);let Kr=De;function oq(r,e){if(!r.type&&!r.id)return{errors:[new g({id:`last-generated-entity-payload--${T.MissingTypeProperty}`,message:"Last generated entity payload is missing a 'type' property.",severity:E.Error,code:T.MissingTypeProperty,issue:null}),new g({id:`last-generated-entity-payload--${T.MissingIdProperty}`,message:"Last generated entity payload is missing an 'id' property.",severity:E.Error,code:T.MissingIdProperty,issue:null})],modifiedData:null};if(r.type){if(!r.id)return{errors:[new g({id:`last-generated-entity-payload--${T.MissingIdProperty}`,message:`Last generated entity, with type "${r.type}" is missing an 'id' property.`,severity:E.Error,code:T.MissingIdProperty,issue:null})],modifiedData:null}}else return{errors:[new g({id:`${r.id}--${T.MissingTypeProperty}`,message:`Entity with id "${r.id}" is missing a 'type' property.`,severity:E.Error,code:T.MissingTypeProperty,issue:null})],modifiedData:null};if(r.type===i.GenericReference)return{errors:[new g({id:`${r.id}--${T.RootReference}`,message:`Generic reference entity with id "${r.id}". A generic reference cannot be generated as a standalone entity. Only in the body of another entity.`,severity:E.Error,code:T.RootReference,issue:null})],modifiedData:null};const t=r,n=e.instances[t.id],a=e.builtInInstances[t.id];if(n&&!a&&t.type!==i.GenericReference){let s=`A previously generated entity with id "${t.id}" already exists in the project state.
|
|
206
206
|
Are you trying to update that entity?
|
|
207
207
|
If so, you should use the 'update' action for core mutable metadata properties, or 'delete' and then 'post' again to replace it.
|
|
208
208
|
If you are trying to create a new entity, please use a different id, for example: "${Uu(t,e)}".`;return{errors:[new g({id:`duplicate--${t.id}--${T.EntityIdNotUnique}`,message:s,severity:E.Error,code:T.EntityIdNotUnique,issue:null})],modifiedData:r}}else if(n&&t.type!==i.GenericReference)return{errors:[new g({id:`${t.id}--${T.EntityIdNotUnique}`,message:`A built in entity with id "${t.id}" already exists. You cannot modify built in entities. If you are trying to create a new entity, please use a different id, for example: "${Uu(t,e)}".`,severity:E.Error,code:T.EntityIdNotUnique,issue:null})],modifiedData:r};switch(t.type){case i.Project:return M.validateGenerationTarget(t,e);case i.DefinitionEntity:return ei.validateGenerationTarget(t,e);case i.Property:return Ur.validateGenerationTarget(t,e);case i.FunctionDeclaration:return xr.validateGenerationTarget(t,e);case i.DataType:return ki.validateGenerationTarget(t,e);case i.Operation:return jr.validateGenerationTarget(t,e);case i.FunctionCall:return Xr.validateGenerationTarget(t,e);case i.VariableDeclaration:return Jr.validateGenerationTarget(t,e);case i.VariableInstance:return Wr.validateGenerationTarget(t,e);case i.GlobalEvent:return qi.validateGenerationTarget(t,e);case i.InputMap:return Un.validateGenerationTarget(t,e);case i.OutputMap:return xn.validateGenerationTarget(t,e);case i.ArgumentDeclaration:return zr.validateGenerationTarget(t,e);case i.ReturnDeclaration:return kt.validateGenerationTarget(t,e);case i.Loop:return kr.validateGenerationTarget(t,e);case i.Condition:return qr.validateGenerationTarget(t,e);case i.Search:return Yr.validateGenerationTarget(t,e);case i.InstalledProject:return Hr.validateGenerationTarget(t,e);case i.InternalCall:return Ji.validateGenerationTarget(t,e);case i.LiteralValue:return Wi.validateGenerationTarget(t,e);case i.ReturnStatement:return Zr.validateGenerationTarget(t,e);case i.BreakStatement:return Yi.validateGenerationTarget(t,e);case i.ContinueStatement:return St.validateGenerationTarget(t,e);case i.ActionDescriptor:return se.validateGenerationTarget(t,e);case i.ValueDescriptor:return Kr.validateGenerationTarget(t,e);case i.BuiltInBaseEntity:case i.PrimitiveEntity:{const s="Did you mean to generate a",l={[i.BuiltInBaseEntity]:`${s} '${i.DefinitionEntity}' instead?`,[i.PrimitiveEntity]:`${s} '${i.DefinitionEntity}' instead?`}[t.type]||"";return{errors:[new g({id:`${t.id}--${T.BuiltInEntityGenerated}`,message:`Entity with id "${t.id} is of "${t.type}" type and should not be generated. Built in entities can only be referenced by user created entities.
|
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",
|