@elyx-code/project-logic-tree 0.0.6138 → 0.0.6139
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -6
- package/dist/index.umd.cjs +2 -2
- 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);
|
|
@@ -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.
|
|
@@ -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.6139",
|
|
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",
|