@elyx-code/project-logic-tree 0.0.6231 → 0.0.6232

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 CHANGED
@@ -54024,6 +54024,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
54024
54024
  "remove-entity"
54025
54025
  )
54026
54026
  )) {
54027
+ var l;
54027
54028
  const r = [], s = [], d = [], o = [];
54028
54029
  if (t != null && t.hasRemoved(this.id))
54029
54030
  return t == null || t.attemptAutoclose("remove-entity", this.id), {
@@ -54033,27 +54034,42 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
54033
54034
  affected: [],
54034
54035
  self: this
54035
54036
  };
54036
- if (s.push(this), this.unsubscribe(), this.project.subscribeDeletedInstance(this), this.metaSync({ deleted: !0 }, t), Object.values(this.detachedDependents).forEach((l) => {
54037
+ if (s.push(this), this.unsubscribe(), this.project.subscribeDeletedInstance(this), this.metaSync({ deleted: !0 }, t), Object.values(this.detachedDependents).forEach((u) => {
54037
54038
  const {
54038
- updated: u,
54039
- removed: h,
54040
- added: c
54041
- } = l.entity.onDetachedDependencyRemoved(
54039
+ updated: h,
54040
+ removed: c,
54041
+ added: T
54042
+ } = u.entity.onDetachedDependencyRemoved(
54042
54043
  this,
54043
- l.field,
54044
+ u.field,
54044
54045
  t
54045
54046
  );
54046
- r.push(...u), s.push(...h), d.push(...c);
54047
+ r.push(...h), s.push(...c), d.push(...T);
54047
54048
  }), this.defaultValue) {
54048
- const { updated: l, removed: u } = this.defaultValue.remove(
54049
+ const { updated: u, removed: h } = this.defaultValue.remove(
54049
54050
  {
54050
54051
  ignoreUpstream: !0
54051
54052
  },
54052
54053
  t
54053
54054
  );
54054
- r.push(...l), s.push(...u);
54055
+ r.push(...u), s.push(...h);
54056
+ }
54057
+ if (this.readsValue && (r.push(this.readsValue), this.readsValue.removeValueReader(this, t)), this.defaultValue && (r.push(this.defaultValue), this.defaultValue.remove({ ignoreUpstream: !0 }, t)), this.declaration) {
54058
+ if (
54059
+ // If the declaration is a property, aprt of an inferred, dynamic data type entity, we delete the property too
54060
+ this.declaration.type === n.Property && this.declaration.parent.type === n.DefinitionEntity && this.declaration.parent.parent.type === n.DataType && !(t != null && t.hasRemoved(this.declaration.id)) && !this.declaration.deleted
54061
+ ) {
54062
+ const { updated: u, removed: h } = this.declaration.remove({ ignoreUpstream: !1 }, t);
54063
+ r.push(...u), s.push(...h);
54064
+ } else if (
54065
+ // If the declaraiton if a value-descriptor, part of a search statement, we delete the value-descriptor too
54066
+ this.declaration.type === n.ValueDescriptor && ((l = this.declaration.parent) == null ? void 0 : l.type) === n.Search && !(t != null && t.hasRemoved(this.declaration.id)) && !this.declaration.deleted
54067
+ ) {
54068
+ const { updated: u, removed: h } = this.declaration.remove({ ignoreUpstream: !1 }, t);
54069
+ r.push(...u), s.push(...h);
54070
+ }
54055
54071
  }
54056
- return this.readsValue && (r.push(this.readsValue), this.readsValue.removeValueReader(this, t)), this.defaultValue && (r.push(this.defaultValue), this.defaultValue.remove({ ignoreUpstream: !0 }, t)), e || (r.push(this.parent), this.parent.removeInput(
54072
+ return e || (r.push(this.parent), this.parent.removeInput(
54057
54073
  this,
54058
54074
  t
54059
54075
  )), t == null || t.attemptAutoclose("remove-entity", this.id), {
@@ -155,7 +155,7 @@ Input maps can only be added to variables which hold an entity with properties.`
155
155
  The entity of the data-type has the following properties that can be reads as input maps, ids: '${se(O.properties.map(V=>V.id),"', '","' and '")}'`,issue:null})))}else if(lt.filter(c=>it.includes(c)).includes(o.type)){const I=Kc(o),E=I.find(P=>P.id===i.declaration),O=`The parent entity has the following argument declarations that can be referenced by input-maps, ids: '${se(I.map(P=>P.id),"', '","' and '")}'`;E||s.push(new w({id:`${i.id}--${$.NoOverlapWithImplementedSignature}`,code:$.NoOverlapWithImplementedSignature,severity:D.Error,message:`Entity of type '${n.InputMap}' with id '${i.id}' cannot be added to the parent entity of type '${o.type}' with id '${o.id}'. The parent entity does not have an 'argument-declaration' with id '${i.declaration}'.
156
156
  You can't add an input-map to an entity that doesn't have a matching 'argument-declaration'.
157
157
  ${O}`,issue:null}))}}return s.push(...d.errors,...pt(i)),{errors:s,modifiedData:i}}get codeNativeValueValidation(){var e;return this._codeNativeValueValidation||((e=this.declaration)==null?void 0:e.codeNativeValueValidation)||null}validateGeneratedUpdate(e){const t=[];let i=JSON.parse(JSON.stringify(e));const s=_a(i,this);return i=s.modifiedData,t.push(...s.errors),i.parent&&t.push(new w({id:`${this.id}--${R.InvalidParentUpdate}`,code:R.InvalidParentUpdate,severity:D.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.
158
- 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:i}}subscribeDependents(e){return e.forEach(t=>{this.detachedDependents[t.entity.id]||(this.detachedDependents[t.entity.id]=t)}),this}syncDependents(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-dependents"))){const t=[],i=[],s=[],d=[];return Object.values(this.detachedDependents).forEach(o=>{const l=o.entity.afterAllChildrenInitialized(e);t.push(...l.updated),i.push(...l.added),s.push(...l.removed),d.push(...l.affected)}),e==null||e.attemptAutoclose("sync-dependents",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}onDetachedDependencyRemoved(e,t,i){const s=[],d=[],o=[],l=[];if(t==="declaration"){const{updated:u,added:y,removed:c}=this.remove({ignoreUpstream:!1},i);s.push(...u),d.push(...y),o.push(...c)}return{updated:p(s),added:p(d),removed:p(o),affected:p(l),self:this}}onDetachedDependencyRestored(e,t,i){const s=[],d=[],o=[],l=[];if(t==="declaration"){const{updated:u,added:y,removed:c}=this.restore({},i);s.push(...u),d.push(...y),o.push(...c)}return{updated:p(s),added:p(d),removed:p(o),affected:p(l),self:this}}subscribeToDependencies(){var e,t,i,s,d;return(t=(e=this.declaration)==null?void 0:e.subscribeDependents)==null||t.call(e,[{entity:this,field:"declaration"}]),(d=(s=(i=this.dataType)==null?void 0:i.entity)==null?void 0:s.subscribeDependents)==null||d.call(s,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(e){if(e&&!T(e).isValid())throw new Error(`The shared timestamp '${e}' is not a valid ISO 8601 date string.`);return e&&T(e).isSame(T(this.createdAt))?this:(this.previousVersion=this.version,this.version=m.UUID.uuid(),this.createdAt=T(e).toISOString()||T().toISOString(),this)}captureVersion(){var t;const e=((t=this.knownVersions)==null?void 0:t.get(this.version))||new _e(this,this.project);return e.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,e):new Map([[this.version,e]]),e.declaration=this.declaration,e.defaultValue=this.defaultValue,e.readsValue=this.readsValue,e.dataType=this.dataType,e.parent=this.parent,this}recursiveCaptureUpstreamVersions(e){const t=[],i=[],s=[],d=[];if(this.parent){this.parent.increaseVersion(e);const o=this.parent.recursiveCaptureUpstreamVersions(e);t.push(this.parent,...o.updated),i.push(...o.added),s.push(...o.removed)}return{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}async restoreVersion(e){var l;const t=[],i=[],s=[],d=[];if(this.version===e)return{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this};if(!this.knownVersions){const u=new Map;for(const[y,c]of this.knownVersions||new Map){if(u.set(y,c),c.activeVersion=!1,c.knownVersions)for(const[I,E]of c.knownVersions)u.set(I,E);c.knownVersions=null}}let o=(l=this.knownVersions)==null?void 0:l.get(e);if(!o){const u=await this.APILoadVersion({},e);if(!u)throw new Error(`Version with id '${e}' for entity with id '${this.id}' not found.`);o=new _e(u,this.project)}return this.metaSync(o.toShallowJSON(),null),this.declaration=o.declaration,this.defaultValue=o.defaultValue,this.readsValue=o.readsValue,this.dataType=o.dataType,this.parent=o.parent,{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}hydrateAncestors(){const e=[],t=[],i=[],s=[];if(this.initialData.parent){const d=_(this.initialData.parent),o=this.project.get(d);if(o)this.setParent(o,null),e.push(o);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${d}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.readsValue){const d=_(this.initialData.readsValue),o=this.project.get(d);o&&(this.setValueWriter(o,null),e.push(o))}if(this.initialData.declaration){const d=_(this.initialData.declaration),o=this.project.get(d);o&&(this.setDeclaration(o),e.push(o))}return Rr.hydrateReadsValue(this),{updated:p(e),added:p(t),removed:p(i),affected:p(s),self:this}}afterAllChildrenInitialized(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"after-all-children-initialized"))){const t=[],i=[],s=[],d=[];return this.initialized=!0,this.captureVersion(),e==null||e.attemptAutoclose("after-all-children-initialized",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}addSelfToProject(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-self-to-project"))){var o,l;const t=[this],i=[],s=[],d=[];if(this.parent.addInput(this,e),t.push(this.parent),(o=this.readsValue)==null||o.addValueReader(this,e),this.readsValue&&t.push(this.readsValue),it.includes(this.parent.type)&&((l=this.parent.getDataType(e))!=null&&l.inferred)){const u=this.parent.type===n.VariableDeclaration?this.parent:this.parent.declaration,{updated:y,added:c,removed:I,affected:E}=u.inferDataTypeAndSyncInstancesInputsAndOutputs(e);t.push(...y),i.push(...c),s.push(...I),d.push(...E),t.push(u,...u.variableInstances)}return this.subscribe(),this.subscribeToDependencies(),e==null||e.attemptAutoclose("add-self-to-project",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}setParent(e,t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"set-parent"))){var i;return((i=this.parent)==null?void 0:i.id)!==(e==null?void 0:e.id)&&(this.parent=e,t&&(t==null||t.add(this,b.Updated),t==null||t.attemptAutoclose("set-parent",this.id))),this}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}setDeclaration(e){return this.declaration=e,this}initChildren(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=C(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(e)),this.initialData.declaration&&(this.declaration=C(this.initialData.declaration,this.project)),Rr.initReadsValue(this),this.subscribeToDependencies(),this.afterAllChildrenInitialized(e),e==null||e.attemptAutoclose("init-children",this.id),this)}setValueWriter(e,t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"set-value-writer"))){return this.readsValue!==e&&(this.readsValue=e,t==null||t.add(this,b.Updated)),t==null||t.attemptAutoclose("set-value-writer",this.id),this}removeValueWriter(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-value-writer"))){return this.readsValue&&(this.readsValue=null,e==null||e.add(this,b.Updated)),e==null||e.attemptAutoclose("remove-value-writer",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(e,t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"meta-sync"))){const i=ct(this,e),s=this.toMeta();return this.index=e.index||(e.index!==0?s.index:0),this.name=e.name!==void 0?e.name:s.name,this.description=e.description!==void 0?e.description:s.description,super.metaSync(e),e.deleted===!0&&!s.deleted?t==null||t.add(this,b.Removed):e.deleted===!1&&s.deleted?t==null||t.add(this,b.Added):i&&(t==null||t.add(this,b.Updated)),t==null||t.attemptAutoclose("meta-sync",this.id),this}async APILoad(e=U,...t){return await _e.repository.APILoad(this.id,...t),this}async APICreate(e=U,...t){return await _e.repository.APICreate(this.toShallowJSON(),...t),this}async APIUpdate(e=U,...t){return await _e.repository.APIUpdate(this.toShallowJSON(),...t),this}async APIDelete(e=U,...t){return await _e.repository.APIDelete(this.toShallowJSON(),...t),this}async APIClone(e=U,...t){return await _e.repository.APIClone(this.id,...t),this}async APILoadVersion(e=U,t,...i){return await _e.repository.APILoadVersion(this.id,t,...i)}remove({ignoreUpstream:e}={ignoreUpstream:!1},t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-entity"))){const i=[],s=[],d=[],o=[];if(t!=null&&t.hasRemoved(this.id))return t==null||t.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(s.push(this),this.unsubscribe(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},t),Object.values(this.detachedDependents).forEach(l=>{const{updated:u,removed:y,added:c}=l.entity.onDetachedDependencyRemoved(this,l.field,t);i.push(...u),s.push(...y),d.push(...c)}),this.defaultValue){const{updated:l,removed:u}=this.defaultValue.remove({ignoreUpstream:!0},t);i.push(...l),s.push(...u)}return this.readsValue&&(i.push(this.readsValue),this.readsValue.removeValueReader(this,t)),this.defaultValue&&(i.push(this.defaultValue),this.defaultValue.remove({ignoreUpstream:!0},t)),e||(i.push(this.parent),this.parent.removeInput(this,t)),t==null||t.attemptAutoclose("remove-entity",this.id),{added:p(d),updated:p(i),removed:p(s),affected:p(o),self:this}}restore({}={},e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"restore-entity"))){const t=[],i=[],s=[],d=[];if(e!=null&&e.hasAdded(this.id))return e==null||e.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},e),Object.values(this.detachedDependents).forEach(o=>{const{updated:l,removed:u,added:y}=o.entity.onDetachedDependencyRestored(this,o.field,e);i.push(...l),s.push(...u),t.push(...y)}),this.defaultValue){const{updated:o}=this.defaultValue.restore({},e);i.push(...o)}return this.readsValue&&(i.push(this.readsValue),this.readsValue.addValueReader(this,e)),this.defaultValue&&(i.push(this.defaultValue),this.defaultValue.restore({},e)),i.push(this.parent),this.parent.addInput(this,e),e==null||e.attemptAutoclose("restore-entity",this.id),{added:p(t),updated:p(i),removed:p(s),affected:p(d),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.defaultValue?this.defaultValue.toFlat(e):[],...this.dataType?this.dataType.toFlat(e):[],...this.declaration?this.declaration.toFlat(e):[],...this.readsValue?this.readsValue.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.defaultValue?this.defaultValue.toFlatIds(e):[],...this.dataType?this.dataType.toFlatIds(e):[],...this.declaration?this.declaration.toFlatIds(e):[],...this.readsValue?this.readsValue.toFlatIds(e):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,index:this.index,type:this.type,name:this.name}}toJSON(e=new Set){var t,i,s;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,index:this.index,name:this.name,description:this.description,defaultValue:((t=this.defaultValue)==null?void 0:t.toJSON(e))||null,declaration:((i=this.declaration)==null?void 0:i.toJSON(e))||null,readsValue:((s=this.readsValue)==null?void 0:s.toReference())||null,parent:this.parent.toReference()})}toJSONClone(e=J){var i,s,d,o,l,u,y,c,I,E,O;let t;return(i=e.seenEntityMaps)!=null&&i.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||ht(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(s=e.seenEntities)!=null&&s.has(t)||(d=e.seenEntities)!=null&&d.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:m.UUID.uuid(),createdAt:e.timestamp||T().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,index:this.index,name:this.name,description:this.description,defaultValue:((u=this.defaultValue)==null?void 0:u.toJSONClone({...e,newId:null}))||null,declaration:(y=this.declaration)!=null&&y.id&&this.project.getBuiltIn((c=this.declaration)==null?void 0:c.id)?(I=this.declaration)==null?void 0:I.toJSON(e.seenEntities):((E=this.declaration)==null?void 0:E.toJSONClone({...e,newId:null}))||null,readsValue:((O=this.readsValue)==null?void 0:O.toReference({seenEntityMaps:e.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=J){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+m.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=J){var i,s,d,o;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,index:this.index,defaultValue:((s=this.defaultValue)==null?void 0:s.toReference(e))||null,declaration:((d=this.declaration)==null?void 0:d.toReference(e))||null,readsValue:((o=this.readsValue)==null?void 0:o.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.defaultValue?this.defaultValue.toFlatJSON(e):[],...this.dataType?this.dataType.toFlatJSON(e):[],...this.declaration?this.declaration.toFlatJSON(e):[],...this.readsValue?this.readsValue.toFlatJSON(e):[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name||void 0,description:this.description||void 0,type:this.type,declaration:((e=this.declaration)==null?void 0:e.id)||null,parent:this.parent.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):[],...this.readsValue?this.readsValue.toFlatGenerationTarget(e):[],...this.declaration?this.declaration.toFlatGenerationTarget(e):[]])}clearErrors(){var e;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),this}validate(){const e=B1(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t;return[...this.errors,...((t=this.defaultValue)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return this.defaultValue||((e=this.declaration)==null?void 0:e.defaultValue)||null}setDefaultValue(e){return this.defaultValue=e,this}clone(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"clone-entity")),t=null,i=null,s=!0){var c;let d=mt(t,this);const o=this.toJSON(),l=i||m.UUID.uuid();o.defaultValue=null,o.id=l,o.version=m.UUID.uuid(),o.createdAt=(e==null?void 0:e.timestamp)||T().toISOString(),o.author=(e==null?void 0:e.author)||"1",o.previousVersion=null,o.deleted=!1;const u=nt(o,d);t?u.setParent(t,null):u.setParent(this.parent,null),s&&u.subscribe(),u.initChildren(e),e==null||e.add(u,b.Added);const y=(c=this.defaultValue)==null?void 0:c.clone(e,u,m.UUID.uuid(),s);return u.defaultValue=y||null,e==null||e.attemptAutoclose("clone-entity",this.id),u}getDataType(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"get-data-type"))){var i;if(this.parent.type===n.Operation)return this.parent.declaration.inferInputMapDataType(this,e).self;if(it.includes(this.parent.type)){const s=Un(this.parent),d=s.getDataType(e);(!d||d.inferred)&&s.inferDataTypeAndSyncInstancesInputsAndOutputs(e)}const t=(i=this.declaration)==null?void 0:i.getDataType(e);if(!t){const s=Hi(this,e);if(s)return s}return t||null}};f(_e,"repository",{APICreate:async(e,...t)=>e,APIUpdate:async(e,...t)=>e,APIDelete:async(e,...t)=>e,APIClone:async(e,...t)=>{},APILoad:async(e,...t)=>null,APILoadVersion:async(e,t,...i)=>null}),f(_e,"type",n.InputMap),f(_e,"USER_MANAGED_PARENT_TYPES",[...lt]),f(_e,"PARENT_TYPES",[..._e.USER_MANAGED_PARENT_TYPES]),f(_e,"MUTABLE_BASE_PROPERTIES",["name","description"]),f(_e,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),f(_e,"BASE_PROPERTIES",[..._e.MUTABLE_BASE_PROPERTIES,..._e.INMUTABLE_BASE_PROPERTIES]),f(_e,"MUTABLE_META_PROPERTIES",[..._e.MUTABLE_BASE_PROPERTIES,"index"]),f(_e,"INMUTABLE_META_PROPERTIES",[..._e.INMUTABLE_BASE_PROPERTIES]),f(_e,"META_PROPERTIES",[..._e.MUTABLE_META_PROPERTIES,..._e.INMUTABLE_META_PROPERTIES]),f(_e,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),f(_e,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),f(_e,"UPSTREAM_PROPERTIES",[..._e.MUTABLE_UPSTREAM_PROPERTIES,..._e.INMUTABLE_UPSTREAM_PROPERTIES]),f(_e,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),f(_e,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),f(_e,"DOWNSTREAM_PROPERTIES",[..._e.MUTABLE_DOWNSTREAM_PROPERTIES,..._e.INMUTABLE_DOWNSTREAM_PROPERTIES]),f(_e,"PROPERTIES",[..._e.META_PROPERTIES,..._e.UPSTREAM_PROPERTIES,..._e.DOWNSTREAM_PROPERTIES]);let Ki=_e;class HJ extends Ki{constructor(e,t){super(e,t);f(this,"declaration",null);f(this,"parent");f(this,"errors",[])}toJSON(e=new Set){return super.toJSON(e)}}class KJ extends Ki{constructor(e,t){super(e,t);f(this,"name",null);f(this,"description",null);f(this,"declaration");f(this,"parent");f(this,"errors",[])}toJSON(e=new Set){return super.toJSON(e)}}function M1(r){const a=M5(),e=r.toJSON();a.safeParse(e).success;const i=[];if(r.id==="exec-sequentially-return-map-id"){const s=le({id:`${r.id}--${F.PropertyImplementsNonAbstact}`,message:`Property "${x(r,r.project)}" with id "${r.id}" implements a non-abstract property "${x(r,r.project)}" with id "${r.id}".`,issue:null,severity:D.Error,code:F.PropertyImplementsNonAbstact,entity:r});i.push(s.error)}return Ke(r.errors,i)}const XJ=Object.freeze(Object.defineProperty({__proto__:null,validate:M1},Symbol.toStringTag,{value:"Module"}));var N1=(r=>(r.Declaration="declaration",r.DataTypeEntity="data-type-entity",r))(N1||{});const Me=class Me extends dt{constructor(e,t){super(e);f(this,"initialData");f(this,"id");f(this,"index");f(this,"type",n.OutputMap);f(this,"parentRelationType");f(this,"defaultValue",null);f(this,"declaration");f(this,"writesValues",[]);f(this,"dataType");f(this,"project");f(this,"errors",[]);f(this,"parent");f(this,"detachedDependents",{});f(this,"knownVersions",null);f(this,"activeVersion",!1);f(this,"initialized",!1);f(this,"startedInitialization",!1);f(this,"suggestion",!1);f(this,"_codeNativeValueValidation",null);this.initialData=e,this.project=t,this.id=e.id,this.index=e.index,this.parentRelationType=e.parentRelationType}static new(e=null){return{id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:(e==null?void 0:e.author)||m.sessionAuthor,previousVersion:null,deleted:!1,type:n.OutputMap,declaration:null,writesValues:[],index:0,defaultValue:null,parent:null}}static fromGenerationTarget(e,t){const i=_(e.parent),s=t.get(i);let d;if(e.declaration){const u=_(e.declaration);d=t.get(u)}const o={id:e.id,version:m.UUID.uuid(),createdAt:T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.OutputMap,index:(s.outputs||[]).length,defaultValue:null,declaration:d,writesValues:[],parent:s},l=C(o,t);return l.setParent(s,null),l.initChildren(null),l}static validateGenerationTarget(e,t){var l;let i=JSON.parse(JSON.stringify(e));const s=[],d=bt(i,{parent:{list:!1,types:lt.filter(u=>u!==n.Condition)},declaration:{list:!1,types:[n.ReturnDeclaration,n.Property]}},t);i=d.modifiedData;const o=t.get(i.parent);if(o&&lt.filter(u=>u!==n.Condition).includes(o.type)){const u=o.outputs.find(y=>y.declaration.id===(i.declaration?_(i.declaration):null));if(u)s.push(new w({id:`${i.id}--${R.OutputOverwrite}`,code:R.OutputOverwrite,severity:D.Error,message:`Entity of type '${n.OutputMap}' with id '${i.id}' cannot be added to the parent entity of type '${o.type}' with id '${o.id}'. The parent already has an output-map with id '${u.id}' that points to the same base 'return-declaration'.
158
+ 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:i}}subscribeDependents(e){return e.forEach(t=>{this.detachedDependents[t.entity.id]||(this.detachedDependents[t.entity.id]=t)}),this}syncDependents(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"sync-dependents"))){const t=[],i=[],s=[],d=[];return Object.values(this.detachedDependents).forEach(o=>{const l=o.entity.afterAllChildrenInitialized(e);t.push(...l.updated),i.push(...l.added),s.push(...l.removed),d.push(...l.affected)}),e==null||e.attemptAutoclose("sync-dependents",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}onDetachedDependencyRemoved(e,t,i){const s=[],d=[],o=[],l=[];if(t==="declaration"){const{updated:u,added:y,removed:c}=this.remove({ignoreUpstream:!1},i);s.push(...u),d.push(...y),o.push(...c)}return{updated:p(s),added:p(d),removed:p(o),affected:p(l),self:this}}onDetachedDependencyRestored(e,t,i){const s=[],d=[],o=[],l=[];if(t==="declaration"){const{updated:u,added:y,removed:c}=this.restore({},i);s.push(...u),d.push(...y),o.push(...c)}return{updated:p(s),added:p(d),removed:p(o),affected:p(l),self:this}}subscribeToDependencies(){var e,t,i,s,d;return(t=(e=this.declaration)==null?void 0:e.subscribeDependents)==null||t.call(e,[{entity:this,field:"declaration"}]),(d=(s=(i=this.dataType)==null?void 0:i.entity)==null?void 0:s.subscribeDependents)==null||d.call(s,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(e){if(e&&!T(e).isValid())throw new Error(`The shared timestamp '${e}' is not a valid ISO 8601 date string.`);return e&&T(e).isSame(T(this.createdAt))?this:(this.previousVersion=this.version,this.version=m.UUID.uuid(),this.createdAt=T(e).toISOString()||T().toISOString(),this)}captureVersion(){var t;const e=((t=this.knownVersions)==null?void 0:t.get(this.version))||new _e(this,this.project);return e.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,e):new Map([[this.version,e]]),e.declaration=this.declaration,e.defaultValue=this.defaultValue,e.readsValue=this.readsValue,e.dataType=this.dataType,e.parent=this.parent,this}recursiveCaptureUpstreamVersions(e){const t=[],i=[],s=[],d=[];if(this.parent){this.parent.increaseVersion(e);const o=this.parent.recursiveCaptureUpstreamVersions(e);t.push(this.parent,...o.updated),i.push(...o.added),s.push(...o.removed)}return{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}async restoreVersion(e){var l;const t=[],i=[],s=[],d=[];if(this.version===e)return{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this};if(!this.knownVersions){const u=new Map;for(const[y,c]of this.knownVersions||new Map){if(u.set(y,c),c.activeVersion=!1,c.knownVersions)for(const[I,E]of c.knownVersions)u.set(I,E);c.knownVersions=null}}let o=(l=this.knownVersions)==null?void 0:l.get(e);if(!o){const u=await this.APILoadVersion({},e);if(!u)throw new Error(`Version with id '${e}' for entity with id '${this.id}' not found.`);o=new _e(u,this.project)}return this.metaSync(o.toShallowJSON(),null),this.declaration=o.declaration,this.defaultValue=o.defaultValue,this.readsValue=o.readsValue,this.dataType=o.dataType,this.parent=o.parent,{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}hydrateAncestors(){const e=[],t=[],i=[],s=[];if(this.initialData.parent){const d=_(this.initialData.parent),o=this.project.get(d);if(o)this.setParent(o,null),e.push(o);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${d}' that isn't found in the project`)}else throw new Error(`${this.type} with id '${this.id}' must have a 'parent'`);if(this.initialData.readsValue){const d=_(this.initialData.readsValue),o=this.project.get(d);o&&(this.setValueWriter(o,null),e.push(o))}if(this.initialData.declaration){const d=_(this.initialData.declaration),o=this.project.get(d);o&&(this.setDeclaration(o),e.push(o))}return Rr.hydrateReadsValue(this),{updated:p(e),added:p(t),removed:p(i),affected:p(s),self:this}}afterAllChildrenInitialized(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"after-all-children-initialized"))){const t=[],i=[],s=[],d=[];return this.initialized=!0,this.captureVersion(),e==null||e.attemptAutoclose("after-all-children-initialized",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}addSelfToProject(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"add-self-to-project"))){var o,l;const t=[this],i=[],s=[],d=[];if(this.parent.addInput(this,e),t.push(this.parent),(o=this.readsValue)==null||o.addValueReader(this,e),this.readsValue&&t.push(this.readsValue),it.includes(this.parent.type)&&((l=this.parent.getDataType(e))!=null&&l.inferred)){const u=this.parent.type===n.VariableDeclaration?this.parent:this.parent.declaration,{updated:y,added:c,removed:I,affected:E}=u.inferDataTypeAndSyncInstancesInputsAndOutputs(e);t.push(...y),i.push(...c),s.push(...I),d.push(...E),t.push(u,...u.variableInstances)}return this.subscribe(),this.subscribeToDependencies(),e==null||e.attemptAutoclose("add-self-to-project",this.id),{updated:p(t),added:p(i),removed:p(s),affected:p(d),self:this}}setParent(e,t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"set-parent"))){var i;return((i=this.parent)==null?void 0:i.id)!==(e==null?void 0:e.id)&&(this.parent=e,t&&(t==null||t.add(this,b.Updated),t==null||t.attemptAutoclose("set-parent",this.id))),this}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}setDeclaration(e){return this.declaration=e,this}initChildren(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=C(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(e)),this.initialData.declaration&&(this.declaration=C(this.initialData.declaration,this.project)),Rr.initReadsValue(this),this.subscribeToDependencies(),this.afterAllChildrenInitialized(e),e==null||e.attemptAutoclose("init-children",this.id),this)}setValueWriter(e,t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"set-value-writer"))){return this.readsValue!==e&&(this.readsValue=e,t==null||t.add(this,b.Updated)),t==null||t.attemptAutoclose("set-value-writer",this.id),this}removeValueWriter(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-value-writer"))){return this.readsValue&&(this.readsValue=null,e==null||e.add(this,b.Updated)),e==null||e.attemptAutoclose("remove-value-writer",this.id),this}subscribe(){return this.activeVersion=!0,this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(e,t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"meta-sync"))){const i=ct(this,e),s=this.toMeta();return this.index=e.index||(e.index!==0?s.index:0),this.name=e.name!==void 0?e.name:s.name,this.description=e.description!==void 0?e.description:s.description,super.metaSync(e),e.deleted===!0&&!s.deleted?t==null||t.add(this,b.Removed):e.deleted===!1&&s.deleted?t==null||t.add(this,b.Added):i&&(t==null||t.add(this,b.Updated)),t==null||t.attemptAutoclose("meta-sync",this.id),this}async APILoad(e=U,...t){return await _e.repository.APILoad(this.id,...t),this}async APICreate(e=U,...t){return await _e.repository.APICreate(this.toShallowJSON(),...t),this}async APIUpdate(e=U,...t){return await _e.repository.APIUpdate(this.toShallowJSON(),...t),this}async APIDelete(e=U,...t){return await _e.repository.APIDelete(this.toShallowJSON(),...t),this}async APIClone(e=U,...t){return await _e.repository.APIClone(this.id,...t),this}async APILoadVersion(e=U,t,...i){return await _e.repository.APILoadVersion(this.id,t,...i)}remove({ignoreUpstream:e}={ignoreUpstream:!1},t=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"remove-entity"))){var l;const i=[],s=[],d=[],o=[];if(t!=null&&t.hasRemoved(this.id))return t==null||t.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(s.push(this),this.unsubscribe(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},t),Object.values(this.detachedDependents).forEach(u=>{const{updated:y,removed:c,added:I}=u.entity.onDetachedDependencyRemoved(this,u.field,t);i.push(...y),s.push(...c),d.push(...I)}),this.defaultValue){const{updated:u,removed:y}=this.defaultValue.remove({ignoreUpstream:!0},t);i.push(...u),s.push(...y)}if(this.readsValue&&(i.push(this.readsValue),this.readsValue.removeValueReader(this,t)),this.defaultValue&&(i.push(this.defaultValue),this.defaultValue.remove({ignoreUpstream:!0},t)),this.declaration){if(this.declaration.type===n.Property&&this.declaration.parent.type===n.DefinitionEntity&&this.declaration.parent.parent.type===n.DataType&&!(t!=null&&t.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:u,removed:y}=this.declaration.remove({ignoreUpstream:!1},t);i.push(...u),s.push(...y)}else if(this.declaration.type===n.ValueDescriptor&&((l=this.declaration.parent)==null?void 0:l.type)===n.Search&&!(t!=null&&t.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:u,removed:y}=this.declaration.remove({ignoreUpstream:!1},t);i.push(...u),s.push(...y)}}return e||(i.push(this.parent),this.parent.removeInput(this,t)),t==null||t.attemptAutoclose("remove-entity",this.id),{added:p(d),updated:p(i),removed:p(s),affected:p(o),self:this}}restore({}={},e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"restore-entity"))){const t=[],i=[],s=[],d=[];if(e!=null&&e.hasAdded(this.id))return e==null||e.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},e),Object.values(this.detachedDependents).forEach(o=>{const{updated:l,removed:u,added:y}=o.entity.onDetachedDependencyRestored(this,o.field,e);i.push(...l),s.push(...u),t.push(...y)}),this.defaultValue){const{updated:o}=this.defaultValue.restore({},e);i.push(...o)}return this.readsValue&&(i.push(this.readsValue),this.readsValue.addValueReader(this,e)),this.defaultValue&&(i.push(this.defaultValue),this.defaultValue.restore({},e)),i.push(this.parent),this.parent.addInput(this,e),e==null||e.attemptAutoclose("restore-entity",this.id),{added:p(t),updated:p(i),removed:p(s),affected:p(d),self:this}}toFlat(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this,...this.defaultValue?this.defaultValue.toFlat(e):[],...this.dataType?this.dataType.toFlat(e):[],...this.declaration?this.declaration.toFlat(e):[],...this.readsValue?this.readsValue.toFlat(e):[]])}toFlatIds(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.id,...this.defaultValue?this.defaultValue.toFlatIds(e):[],...this.dataType?this.dataType.toFlatIds(e):[],...this.declaration?this.declaration.toFlatIds(e):[],...this.readsValue?this.readsValue.toFlatIds(e):[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,description:this.description,index:this.index,type:this.type,name:this.name}}toJSON(e=new Set){var t,i,s;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,index:this.index,name:this.name,description:this.description,defaultValue:((t=this.defaultValue)==null?void 0:t.toJSON(e))||null,declaration:((i=this.declaration)==null?void 0:i.toJSON(e))||null,readsValue:((s=this.readsValue)==null?void 0:s.toReference())||null,parent:this.parent.toReference()})}toJSONClone(e=J){var i,s,d,o,l,u,y,c,I,E,O;let t;return(i=e.seenEntityMaps)!=null&&i.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||ht(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(s=e.seenEntities)!=null&&s.has(t)||(d=e.seenEntities)!=null&&d.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:m.UUID.uuid(),createdAt:e.timestamp||T().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,index:this.index,name:this.name,description:this.description,defaultValue:((u=this.defaultValue)==null?void 0:u.toJSONClone({...e,newId:null}))||null,declaration:(y=this.declaration)!=null&&y.id&&this.project.getBuiltIn((c=this.declaration)==null?void 0:c.id)?(I=this.declaration)==null?void 0:I.toJSON(e.seenEntities):((E=this.declaration)==null?void 0:E.toJSONClone({...e,newId:null}))||null,readsValue:((O=this.readsValue)==null?void 0:O.toReference({seenEntityMaps:e.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=J){var i;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+m.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=J){var i,s,d,o;let t=this.id;return(i=e.seenEntityMaps)!=null&&i.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,index:this.index,defaultValue:((s=this.defaultValue)==null?void 0:s.toReference(e))||null,declaration:((d=this.declaration)==null?void 0:d.toReference(e))||null,readsValue:((o=this.readsValue)==null?void 0:o.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...this.defaultValue?this.defaultValue.toFlatJSON(e):[],...this.dataType?this.dataType.toFlatJSON(e):[],...this.declaration?this.declaration.toFlatJSON(e):[],...this.readsValue?this.readsValue.toFlatJSON(e):[]])}toGenerationTarget(){var e;return{id:this.id,name:this.name||void 0,description:this.description||void 0,type:this.type,declaration:((e=this.declaration)==null?void 0:e.id)||null,parent:this.parent.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):[],...this.readsValue?this.readsValue.toFlatGenerationTarget(e):[],...this.declaration?this.declaration.toFlatGenerationTarget(e):[]])}clearErrors(){var e;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),this}validate(){const e=B1(this);return this.errors=e,{success:!0,error:null,data:this.toJSON()}}getErrors(){var t;return[...this.errors,...((t=this.defaultValue)==null?void 0:t.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var e;return this.defaultValue||((e=this.declaration)==null?void 0:e.defaultValue)||null}setDefaultValue(e){return this.defaultValue=e,this}clone(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"clone-entity")),t=null,i=null,s=!0){var c;let d=mt(t,this);const o=this.toJSON(),l=i||m.UUID.uuid();o.defaultValue=null,o.id=l,o.version=m.UUID.uuid(),o.createdAt=(e==null?void 0:e.timestamp)||T().toISOString(),o.author=(e==null?void 0:e.author)||"1",o.previousVersion=null,o.deleted=!1;const u=nt(o,d);t?u.setParent(t,null):u.setParent(this.parent,null),s&&u.subscribe(),u.initChildren(e),e==null||e.add(u,b.Added);const y=(c=this.defaultValue)==null?void 0:c.clone(e,u,m.UUID.uuid(),s);return u.defaultValue=y||null,e==null||e.attemptAutoclose("clone-entity",this.id),u}getDataType(e=this.project.addChangeSet(new A(this.project,m.sessionAuthor,T().toISOString(),this,!0,"get-data-type"))){var i;if(this.parent.type===n.Operation)return this.parent.declaration.inferInputMapDataType(this,e).self;if(it.includes(this.parent.type)){const s=Un(this.parent),d=s.getDataType(e);(!d||d.inferred)&&s.inferDataTypeAndSyncInstancesInputsAndOutputs(e)}const t=(i=this.declaration)==null?void 0:i.getDataType(e);if(!t){const s=Hi(this,e);if(s)return s}return t||null}};f(_e,"repository",{APICreate:async(e,...t)=>e,APIUpdate:async(e,...t)=>e,APIDelete:async(e,...t)=>e,APIClone:async(e,...t)=>{},APILoad:async(e,...t)=>null,APILoadVersion:async(e,t,...i)=>null}),f(_e,"type",n.InputMap),f(_e,"USER_MANAGED_PARENT_TYPES",[...lt]),f(_e,"PARENT_TYPES",[..._e.USER_MANAGED_PARENT_TYPES]),f(_e,"MUTABLE_BASE_PROPERTIES",["name","description"]),f(_e,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),f(_e,"BASE_PROPERTIES",[..._e.MUTABLE_BASE_PROPERTIES,..._e.INMUTABLE_BASE_PROPERTIES]),f(_e,"MUTABLE_META_PROPERTIES",[..._e.MUTABLE_BASE_PROPERTIES,"index"]),f(_e,"INMUTABLE_META_PROPERTIES",[..._e.INMUTABLE_BASE_PROPERTIES]),f(_e,"META_PROPERTIES",[..._e.MUTABLE_META_PROPERTIES,..._e.INMUTABLE_META_PROPERTIES]),f(_e,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),f(_e,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),f(_e,"UPSTREAM_PROPERTIES",[..._e.MUTABLE_UPSTREAM_PROPERTIES,..._e.INMUTABLE_UPSTREAM_PROPERTIES]),f(_e,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),f(_e,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),f(_e,"DOWNSTREAM_PROPERTIES",[..._e.MUTABLE_DOWNSTREAM_PROPERTIES,..._e.INMUTABLE_DOWNSTREAM_PROPERTIES]),f(_e,"PROPERTIES",[..._e.META_PROPERTIES,..._e.UPSTREAM_PROPERTIES,..._e.DOWNSTREAM_PROPERTIES]);let Ki=_e;class HJ extends Ki{constructor(e,t){super(e,t);f(this,"declaration",null);f(this,"parent");f(this,"errors",[])}toJSON(e=new Set){return super.toJSON(e)}}class KJ extends Ki{constructor(e,t){super(e,t);f(this,"name",null);f(this,"description",null);f(this,"declaration");f(this,"parent");f(this,"errors",[])}toJSON(e=new Set){return super.toJSON(e)}}function M1(r){const a=M5(),e=r.toJSON();a.safeParse(e).success;const i=[];if(r.id==="exec-sequentially-return-map-id"){const s=le({id:`${r.id}--${F.PropertyImplementsNonAbstact}`,message:`Property "${x(r,r.project)}" with id "${r.id}" implements a non-abstract property "${x(r,r.project)}" with id "${r.id}".`,issue:null,severity:D.Error,code:F.PropertyImplementsNonAbstact,entity:r});i.push(s.error)}return Ke(r.errors,i)}const XJ=Object.freeze(Object.defineProperty({__proto__:null,validate:M1},Symbol.toStringTag,{value:"Module"}));var N1=(r=>(r.Declaration="declaration",r.DataTypeEntity="data-type-entity",r))(N1||{});const Me=class Me extends dt{constructor(e,t){super(e);f(this,"initialData");f(this,"id");f(this,"index");f(this,"type",n.OutputMap);f(this,"parentRelationType");f(this,"defaultValue",null);f(this,"declaration");f(this,"writesValues",[]);f(this,"dataType");f(this,"project");f(this,"errors",[]);f(this,"parent");f(this,"detachedDependents",{});f(this,"knownVersions",null);f(this,"activeVersion",!1);f(this,"initialized",!1);f(this,"startedInitialization",!1);f(this,"suggestion",!1);f(this,"_codeNativeValueValidation",null);this.initialData=e,this.project=t,this.id=e.id,this.index=e.index,this.parentRelationType=e.parentRelationType}static new(e=null){return{id:m.UUID.uuid(),version:m.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:(e==null?void 0:e.author)||m.sessionAuthor,previousVersion:null,deleted:!1,type:n.OutputMap,declaration:null,writesValues:[],index:0,defaultValue:null,parent:null}}static fromGenerationTarget(e,t){const i=_(e.parent),s=t.get(i);let d;if(e.declaration){const u=_(e.declaration);d=t.get(u)}const o={id:e.id,version:m.UUID.uuid(),createdAt:T().toISOString(),author:m.sessionAuthor,previousVersion:null,deleted:!1,type:n.OutputMap,index:(s.outputs||[]).length,defaultValue:null,declaration:d,writesValues:[],parent:s},l=C(o,t);return l.setParent(s,null),l.initChildren(null),l}static validateGenerationTarget(e,t){var l;let i=JSON.parse(JSON.stringify(e));const s=[],d=bt(i,{parent:{list:!1,types:lt.filter(u=>u!==n.Condition)},declaration:{list:!1,types:[n.ReturnDeclaration,n.Property]}},t);i=d.modifiedData;const o=t.get(i.parent);if(o&&lt.filter(u=>u!==n.Condition).includes(o.type)){const u=o.outputs.find(y=>y.declaration.id===(i.declaration?_(i.declaration):null));if(u)s.push(new w({id:`${i.id}--${R.OutputOverwrite}`,code:R.OutputOverwrite,severity:D.Error,message:`Entity of type '${n.OutputMap}' with id '${i.id}' cannot be added to the parent entity of type '${o.type}' with id '${o.id}'. The parent already has an output-map with id '${u.id}' that points to the same base 'return-declaration'.
159
159
  Any value reads can be done with that output-map instead.
160
160
  You can't edit output-map entities as they need to match their return declarations, so you can only choose to read their outputted value if you need it.`,issue:null}));else{const y=i.declaration?t.get(i.declaration):null;if(y&&it.includes(o.type)){const c=Un(o),I=c.dataType,E=(l=c.dataType)==null?void 0:l.entity;I?E?E.type===n.ActionDescriptor?s.push(new w({id:`${i.id}--${$.NoOverlapWithImplementedSignature}`,code:$.NoOverlapWithImplementedSignature,severity:D.Error,message:`Entity of type '${n.OutputMap}' with id '${i.id}' cannot be added to the parent entity of type '${o.type}' with id '${o.id}'. The data type of the 'variable-declaration' is a 'action-descriptor' entity.
161
161
  This means it can hold a function-call or operation as its value, to be executed programatically.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.6231",
3
+ "version": "0.0.6232",
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",