@elyx-code/project-logic-tree 0.0.6289 → 0.0.6290

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
@@ -77534,7 +77534,7 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
77534
77534
  "remove-entity"
77535
77535
  )
77536
77536
  )) {
77537
- var E;
77537
+ var E, A, g, I;
77538
77538
  const l = [], f = [], t = [], m = [];
77539
77539
  if (o != null && o.hasRemoved(this.id))
77540
77540
  return o == null || o.attemptAutoclose("remove-entity", this.id), {
@@ -77544,39 +77544,39 @@ This is likely an incorrect strategy, either the '${this.type}' entity doesn't n
77544
77544
  affected: [],
77545
77545
  self: this
77546
77546
  };
77547
- if (f.push(this), this.unsubscribe(), this.unsubscribeFromDependencies(), this.project.subscribeDeletedInstance(this), this.metaSync({ deleted: !0 }, o), Object.values(this.detachedDependents).forEach((A) => {
77547
+ if (f.push(this), this.unsubscribe(), this.unsubscribeFromDependencies(), this.project.subscribeDeletedInstance(this), this.metaSync({ deleted: !0 }, o), Object.values(this.detachedDependents).forEach((V) => {
77548
77548
  const {
77549
- updated: g,
77550
- removed: I,
77551
- added: V
77552
- } = A.entity.onDetachedDependencyRemoved(
77549
+ updated: B,
77550
+ removed: K,
77551
+ added: k
77552
+ } = V.entity.onDetachedDependencyRemoved(
77553
77553
  this,
77554
- A.field,
77554
+ V.field,
77555
77555
  o
77556
77556
  );
77557
- l.push(...g), f.push(...I), t.push(...V);
77557
+ l.push(...B), f.push(...K), t.push(...k);
77558
77558
  }), this.defaultValue) {
77559
- const { updated: A, removed: g } = this.defaultValue.remove(
77559
+ const { updated: V, removed: B } = this.defaultValue.remove(
77560
77560
  {
77561
77561
  ignoreUpstream: !0
77562
77562
  },
77563
77563
  o
77564
77564
  );
77565
- l.push(...A), f.push(...g);
77565
+ l.push(...V), f.push(...B);
77566
77566
  }
77567
77567
  if (this.readsValue && (l.push(this.readsValue), this.readsValue.removeValueReader(this, o)), this.defaultValue && (l.push(this.defaultValue), this.defaultValue.remove({ ignoreUpstream: !0 }, o)), this.declaration) {
77568
77568
  if (
77569
77569
  // If the declaration is a property, aprt of an inferred, dynamic data type entity, we delete the property too
77570
- this.declaration.type === c.Property && this.declaration.parent.type === c.DefinitionEntity && this.declaration.parent.parent.type === c.DataType && !(o != null && o.hasRemoved(this.declaration.id)) && !this.declaration.deleted
77570
+ this.declaration.type === c.Property && ((E = this.declaration.parent) == null ? void 0 : E.type) === c.DefinitionEntity && ((g = (A = this.declaration.parent) == null ? void 0 : A.parent) == null ? void 0 : g.type) === c.DataType && !(o != null && o.hasRemoved(this.declaration.id)) && !this.declaration.deleted
77571
77571
  ) {
77572
- const { updated: A, removed: g } = this.declaration.remove({ ignoreUpstream: !1 }, o);
77573
- l.push(...A), f.push(...g);
77572
+ const { updated: V, removed: B } = this.declaration.remove({ ignoreUpstream: !1 }, o);
77573
+ l.push(...V), f.push(...B);
77574
77574
  } else if (
77575
77575
  // If the declaraiton if a value-descriptor, part of a search statement, we delete the value-descriptor too
77576
- this.declaration.type === c.ValueDescriptor && ((E = this.declaration.parent) == null ? void 0 : E.type) === c.Search && !(o != null && o.hasRemoved(this.declaration.id)) && !this.declaration.deleted
77576
+ this.declaration.type === c.ValueDescriptor && ((I = this.declaration.parent) == null ? void 0 : I.type) === c.Search && !(o != null && o.hasRemoved(this.declaration.id)) && !this.declaration.deleted
77577
77577
  ) {
77578
- const { updated: A, removed: g } = this.declaration.remove({ ignoreUpstream: !1 }, o);
77579
- l.push(...A), f.push(...g);
77578
+ const { updated: V, removed: B } = this.declaration.remove({ ignoreUpstream: !1 }, o);
77579
+ l.push(...V), f.push(...B);
77580
77580
  }
77581
77581
  }
77582
77582
  return n || (l.push(this.parent), this.parent.removeInput(
@@ -171,7 +171,7 @@ Input maps can only be added to variables which hold an entity with properties.`
171
171
  The entity of the data-type has the following properties that can be reads as input maps, ids: '${Ke(K.properties.map(Z=>Z.id),"', '","' and '")}'`,issue:null})))}else if(dr.filter(w=>Xt.includes(w)).includes(m.type)){const N=Ib(m),U=N.find(S=>S.id===l.declaration),K=`The parent entity has the following argument declarations that can be referenced by input-maps, ids: '${Ke(N.map(S=>S.id),"', '","' and '")}'`;U||f.push(new W({id:`${l.id}--${de.NoOverlapWithImplementedSignature}`,code:de.NoOverlapWithImplementedSignature,severity:q.Error,message:`Entity of type '${p.InputMap}' with id '${l.id}' cannot be added to the parent entity of type '${m.type}' with id '${m.id}'. The parent entity does not have an 'argument-declaration' with id '${l.declaration}'.
172
172
  You can't add an input-map to an entity that doesn't have a matching 'argument-declaration'.
173
173
  ${K}`,issue:null}))}}return f.push(...t.errors,...ur(l)),{errors:f,modifiedData:l}}get codeNativeValueValidation(){var n;return this._codeNativeValueValidation||((n=this.declaration)==null?void 0:n.codeNativeValueValidation)||null}validateGeneratedUpdate(n){const o=[];let l=JSON.parse(JSON.stringify(n));const f=Xc(l,this);return l=f.modifiedData,o.push(...f.errors),l.parent&&o.push(new W({id:`${this.id}--${k.InvalidParentUpdate}`,code:k.InvalidParentUpdate,severity:q.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.
174
- 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:o,modifiedData:l}}subscribeDependents(n){return n.forEach(o=>{this.detachedDependents[o.entity.id]||(this.detachedDependents[o.entity.id]=o)}),this}unsubscribeDependents(n){return n.forEach(o=>{this.detachedDependents[o.entity.id]&&delete this.detachedDependents[o.entity.id]}),this}syncDependents(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const o=[],l=[],f=[],t=[];return Object.values(this.detachedDependents).forEach(m=>{const E=m.entity.afterAllChildrenInitialized(n);o.push(...E.updated),l.push(...E.added),f.push(...E.removed),t.push(...E.affected)}),n==null||n.attemptAutoclose("sync-dependents",this.id),{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}onDetachedDependencyRemoved(n,o,l){const f=[],t=[],m=[],E=[];if(o==="declaration"){const{updated:A,added:g,removed:w}=this.remove({ignoreUpstream:!1},l);f.push(...A),t.push(...g),m.push(...w)}return{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}onDetachedDependencyRestored(n,o,l){const f=[],t=[],m=[],E=[];if(o==="declaration"){const{updated:A,added:g,removed:w}=this.restore({},l);f.push(...A),t.push(...g),m.push(...w)}return{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}unsubscribeFromDependencies(){var n,o,l,f,t;return(o=(n=this.declaration)==null?void 0:n.unsubscribeDependents)==null||o.call(n,[{entity:this,field:"declaration"}]),(t=(f=(l=this.dataType)==null?void 0:l.entity)==null?void 0:f.unsubscribeDependents)==null||t.call(f,[{entity:this,field:"data-type-entity"}]),this}subscribeToDependencies(){var n,o,l,f,t;return(o=(n=this.declaration)==null?void 0:n.subscribeDependents)==null||o.call(n,[{entity:this,field:"declaration"}]),(t=(f=(l=this.dataType)==null?void 0:l.entity)==null?void 0:f.subscribeDependents)==null||t.call(f,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(n){if(n&&!M(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&M(n).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=M(n).toISOString()||M().toISOString(),this)}captureVersion(){var o;const n=((o=this.knownVersions)==null?void 0:o.get(this.version))||new bt(this,this.project);return n.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,n):new Map([[this.version,n]]),n.declaration=this.declaration,n.defaultValue=this.defaultValue,n.readsValue=this.readsValue,n.dataType=this.dataType,n.parent=this.parent,this}recursiveCaptureUpstreamVersions(n){const o=[],l=[],f=[],t=[];if(this.parent){this.parent.increaseVersion(n);const m=this.parent.recursiveCaptureUpstreamVersions(n);o.push(this.parent,...m.updated),l.push(...m.added),f.push(...m.removed)}return{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}async restoreVersion(n){var E;const o=[],l=[],f=[],t=[];if(this.version===n)return{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this};if(!this.knownVersions){const A=new Map;for(const[g,w]of this.knownVersions||new Map){if(A.set(g,w),w.activeVersion=!1,w.knownVersions)for(const[N,U]of w.knownVersions)A.set(N,U);w.knownVersions=null}}let m=(E=this.knownVersions)==null?void 0:E.get(n);if(!m){const A=await this.APILoadVersion({},n);if(!A)throw new Error(`Version with id '${n}' for entity with id '${this.id}' not found.`);m=new bt(A,this.project)}return this.metaSync(m.toShallowJSON(),null),this.previousVersion=m.previousVersion,this.version=m.version,this.createdAt=m.createdAt,this.author=m.author,this.deleted=m.deleted,this.declaration=m.declaration,this.defaultValue=m.defaultValue,this.readsValue=m.readsValue,this.dataType=m.dataType,this.parent=m.parent,{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}hydrateAncestors(){const n=[],o=[],l=[],f=[];if(this.initialData.parent){const t=Q(this.initialData.parent),m=this.project.get(t);if(m)this.setParent(m,null),n.push(m);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' 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 t=Q(this.initialData.readsValue),m=this.project.get(t);m&&(this.setValueWriter(m,null),n.push(m))}if(this.initialData.declaration){const t=Q(this.initialData.declaration),m=this.project.get(t);m&&(this.setDeclaration(m),n.push(m))}return sa.hydrateReadsValue(this),{updated:R(n),added:R(o),removed:R(l),affected:R(f),self:this}}afterAllChildrenInitialized(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"after-all-children-initialized"))){const o=[],l=[],f=[],t=[];return this.initialized=!0,this.captureVersion(),n==null||n.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}addSelfToProject(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var m,E;const o=[this],l=[],f=[],t=[];if(this.parent.addInput(this,n),o.push(this.parent),(m=this.readsValue)==null||m.addValueReader(this,n),this.readsValue&&o.push(this.readsValue),Xt.includes(this.parent.type)&&((E=this.parent.getDataType(n))!=null&&E.inferred)){const A=this.parent.type===p.VariableDeclaration?this.parent:this.parent.declaration,{updated:g,added:w,removed:N,affected:U}=A.inferDataTypeAndSyncInstancesInputsAndOutputs(n);o.push(...g),l.push(...w),f.push(...N),t.push(...U),o.push(A,...A.variableInstances)}return this.subscribe(),this.subscribeToDependencies(),n==null||n.attemptAutoclose("add-self-to-project",this.id),{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}setParent(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(n==null?void 0:n.id)&&(this.parent=n,o&&(o==null||o.add(this,G.Updated))),o==null||o.attemptAutoclose("set-parent",this.id),this}setDataType(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"set-data-type"))){const l=this.dataType;return(l==null?void 0:l.id)!==(n==null?void 0:n.id)&&(l==null||l.remove({ignoreUpstream:!0},o),this.dataType=n,o==null||o.add(this,G.Affected)),o==null||o.attemptAutoclose("set-data-type",this.id),this}removeDataType(){return this.dataType=null,this}setDeclaration(n){return this.declaration=n,this}initChildren(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=Y(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(n)),this.initialData.declaration&&(this.declaration=Y(this.initialData.declaration,this.project)),sa.initReadsValue(this),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",this.id),this)}setValueWriter(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"set-value-writer"))){return this.readsValue!==n&&(this.readsValue=n,o==null||o.add(this,G.Updated)),o==null||o.attemptAutoclose("set-value-writer",this.id),this}removeValueWriter(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"remove-value-writer"))){return this.readsValue&&(this.readsValue=null,n==null||n.add(this,G.Updated)),n==null||n.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(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),f=this.toMeta();return this.index=n.index||(n.index!==0?f.index:0),this.name=n.name!==void 0?n.name:f.name,this.description=n.description!==void 0?n.description:f.description,super.metaSync(n),n.deleted===!0&&!f.deleted?o==null||o.add(this,G.Removed):n.deleted===!1&&f.deleted?o==null||o.add(this,G.Added):l&&(o==null||o.add(this,G.Updated)),o==null||o.attemptAutoclose("meta-sync",this.id),this}async APILoad(n=oe,...o){return await bt.repository.APILoad(this.id,...o),this}async APICreate(n=oe,...o){return await bt.repository.APICreate(this.toShallowJSON(),...o),this}async APIUpdate(n=oe,...o){return await bt.repository.APIUpdate(this.toShallowJSON(),...o),this}async APIDelete(n=oe,...o){return await bt.repository.APIDelete(this.toShallowJSON(),...o),this}async APIClone(n=oe,...o){return await bt.repository.APIClone(this.id,...o),this}async APILoadVersion(n=oe,o,...l){return await bt.repository.APILoadVersion(this.id,o,...l)}remove({ignoreUpstream:n}={ignoreUpstream:!1},o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"remove-entity"))){var E;const l=[],f=[],t=[],m=[];if(o!=null&&o.hasRemoved(this.id))return o==null||o.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(f.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},o),Object.values(this.detachedDependents).forEach(A=>{const{updated:g,removed:w,added:N}=A.entity.onDetachedDependencyRemoved(this,A.field,o);l.push(...g),f.push(...w),t.push(...N)}),this.defaultValue){const{updated:A,removed:g}=this.defaultValue.remove({ignoreUpstream:!0},o);l.push(...A),f.push(...g)}if(this.readsValue&&(l.push(this.readsValue),this.readsValue.removeValueReader(this,o)),this.defaultValue&&(l.push(this.defaultValue),this.defaultValue.remove({ignoreUpstream:!0},o)),this.declaration){if(this.declaration.type===p.Property&&this.declaration.parent.type===p.DefinitionEntity&&this.declaration.parent.parent.type===p.DataType&&!(o!=null&&o.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:A,removed:g}=this.declaration.remove({ignoreUpstream:!1},o);l.push(...A),f.push(...g)}else if(this.declaration.type===p.ValueDescriptor&&((E=this.declaration.parent)==null?void 0:E.type)===p.Search&&!(o!=null&&o.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:A,removed:g}=this.declaration.remove({ignoreUpstream:!1},o);l.push(...A),f.push(...g)}}return n||(l.push(this.parent),this.parent.removeInput(this,o)),o==null||o.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(f),affected:R(m),self:this}}restore({}={},n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"restore-entity"))){const o=[],l=[],f=[],t=[];if(n!=null&&n.hasAdded(this.id))return n==null||n.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},n),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:A,added:g}=m.entity.onDetachedDependencyRestored(this,m.field,n);l.push(...E),f.push(...A),o.push(...g)}),this.defaultValue){const{updated:m}=this.defaultValue.restore({},n);l.push(...m)}return this.readsValue&&(l.push(this.readsValue),this.readsValue.addValueReader(this,n)),this.defaultValue&&(l.push(this.defaultValue),this.defaultValue.restore({},n)),l.push(this.parent),this.parent.addInput(this,n),n==null||n.attemptAutoclose("restore-entity",this.id),{added:R(o),updated:R(l),removed:R(f),affected:R(t),self:this}}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.defaultValue?this.defaultValue.toFlat(n):[],...this.dataType?this.dataType.toFlat(n):[],...this.declaration?this.declaration.toFlat(n):[],...this.readsValue?this.readsValue.toFlat(n):[]])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.defaultValue?this.defaultValue.toFlatIds(n):[],...this.dataType?this.dataType.toFlatIds(n):[],...this.declaration?this.declaration.toFlatIds(n):[],...this.readsValue?this.readsValue.toFlatIds(n):[]])}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(n=new Set){var o,l,f;return n.has(this.id)?this.toReference():(n.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:((o=this.defaultValue)==null?void 0:o.toJSON(n))||null,declaration:((l=this.declaration)==null?void 0:l.toJSON(n))||null,readsValue:((f=this.readsValue)==null?void 0:f.toReference())||null,parent:this.parent.toReference()})}toJSONClone(n=Oe){var l,f,t,m,E,A,g,w,N,U,K;let o;return(l=n.seenEntityMaps)!=null&&l.has(this.id)?o=n.seenEntityMaps.get(this.id):(o=n.newId||yr(this,this.project,n.uuidStrategy),n.seenEntityMaps&&n.seenEntityMaps.set(this.id,o)),(f=n.seenEntities)!=null&&f.has(o)||(t=n.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:n.seenEntityMaps}):((m=n.seenEntities)==null||m.add(o),(E=n.seenEntities)==null||E.add(this.id),{id:o,version:P.UUID.uuid(),createdAt:n.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,index:this.index,name:this.name,description:this.description,defaultValue:((A=this.defaultValue)==null?void 0:A.toJSONClone({...n,newId:null}))||null,declaration:(g=this.declaration)!=null&&g.id&&this.project.getBuiltIn((w=this.declaration)==null?void 0:w.id)?(N=this.declaration)==null?void 0:N.toJSON(n.seenEntities):((U=this.declaration)==null?void 0:U.toJSONClone({...n,newId:null}))||null,readsValue:((K=this.readsValue)==null?void 0:K.toReference({seenEntityMaps:n.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:n.seenEntityMaps})})}toReference(n=Oe){var l;let o=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(o=n.seenEntityMaps.get(this.id)),{id:o+"--"+P.UUID.uuid()+"--ref",type:p.GenericReference,entityId:o,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){var l,f,t,m;let o=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(o=n.seenEntityMaps.get(this.id)),{id:o,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:((f=this.defaultValue)==null?void 0:f.toReference(n))||null,declaration:((t=this.declaration)==null?void 0:t.toReference(n))||null,readsValue:((m=this.readsValue)==null?void 0:m.toReference(n))||null,parent:this.parent.toReference(n)}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.defaultValue?this.defaultValue.toFlatJSON(n):[],...this.dataType?this.dataType.toFlatJSON(n):[],...this.declaration?this.declaration.toFlatJSON(n):[],...this.readsValue?this.readsValue.toFlatJSON(n):[]])}toGenerationTarget(){var n;return{id:this.id,name:this.name||void 0,description:this.description||void 0,type:this.type,declaration:((n=this.declaration)==null?void 0:n.id)||null,parent:this.parent.id}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(n):[],...this.dataType?this.dataType.toFlatGenerationTarget(n):[],...this.readsValue?this.readsValue.toFlatGenerationTarget(n):[],...this.declaration?this.declaration.toFlatGenerationTarget(n):[]])}clearErrors(){var n;return this.errors=[],(n=this.defaultValue)==null||n.clearErrors(),this}validate(){const n=B3(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){var o;return[...this.errors,...((o=this.defaultValue)==null?void 0:o.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var n;return this.defaultValue||((n=this.declaration)==null?void 0:n.defaultValue)||null}setDefaultValue(n){return this.defaultValue=n,this}clone(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"clone-entity")),o=null,l=null,f=!0){var w;let t=mr(o,this);const m=this.toJSON(),E=l||P.UUID.uuid();m.defaultValue=null,m.id=E,m.version=P.UUID.uuid(),m.createdAt=(n==null?void 0:n.timestamp)||M().toISOString(),m.author=(n==null?void 0:n.author)||"1",m.previousVersion=null,m.deleted=!1;const A=tr(m,t);o?A.setParent(o,null):A.setParent(this.parent,null),f&&A.subscribe(),A.initChildren(n),n==null||n.add(A,G.Added);const g=(w=this.defaultValue)==null?void 0:w.clone(n,A,P.UUID.uuid(),f);return A.defaultValue=g||null,n==null||n.attemptAutoclose("clone-entity",this.id),A}getDataType(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var l;if(this.parent.type===p.Operation)return this.parent.declaration.inferInputMapDataType(this,n).self;if(Xt.includes(this.parent.type)){const f=Lo(this.parent),t=f.getDataType(n);(!t||t.inferred)&&f.inferDataTypeAndSyncInstancesInputsAndOutputs(n)}const o=(l=this.declaration)==null?void 0:l.getDataType(n);if(!o){const f=Us(this,n);if(f)return f}return o||null}};D(bt,"repository",{APICreate:async(n,...o)=>n,APIUpdate:async(n,...o)=>n,APIDelete:async(n,...o)=>n,APIClone:async(n,...o)=>{},APILoad:async(n,...o)=>null,APILoadVersion:async(n,o,...l)=>null}),D(bt,"type",p.InputMap),D(bt,"USER_MANAGED_PARENT_TYPES",[...dr]),D(bt,"PARENT_TYPES",[...bt.USER_MANAGED_PARENT_TYPES]),D(bt,"MUTABLE_BASE_PROPERTIES",["name","description"]),D(bt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(bt,"BASE_PROPERTIES",[...bt.MUTABLE_BASE_PROPERTIES,...bt.INMUTABLE_BASE_PROPERTIES]),D(bt,"MUTABLE_META_PROPERTIES",[...bt.MUTABLE_BASE_PROPERTIES,"index"]),D(bt,"INMUTABLE_META_PROPERTIES",[...bt.INMUTABLE_BASE_PROPERTIES]),D(bt,"META_PROPERTIES",[...bt.MUTABLE_META_PROPERTIES,...bt.INMUTABLE_META_PROPERTIES]),D(bt,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),D(bt,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),D(bt,"UPSTREAM_PROPERTIES",[...bt.MUTABLE_UPSTREAM_PROPERTIES,...bt.INMUTABLE_UPSTREAM_PROPERTIES]),D(bt,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),D(bt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(bt,"DOWNSTREAM_PROPERTIES",[...bt.MUTABLE_DOWNSTREAM_PROPERTIES,...bt.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(bt,"PROPERTIES",[...bt.META_PROPERTIES,...bt.UPSTREAM_PROPERTIES,...bt.DOWNSTREAM_PROPERTIES]);let Es=bt;class uhe extends Es{constructor(n,o){super(n,o);D(this,"declaration",null);D(this,"parent");D(this,"errors",[])}toJSON(n=new Set){return super.toJSON(n)}}class che extends Es{constructor(n,o){super(n,o);D(this,"name",null);D(this,"description",null);D(this,"declaration");D(this,"parent");D(this,"errors",[])}toJSON(n=new Set){return super.toJSON(n)}}function j3(u){const d=rle(),n=u.toJSON();d.safeParse(n).success;const l=[];if(u.id==="exec-sequentially-return-map-id"){const f=Xe({id:`${u.id}--${ye.PropertyImplementsNonAbstact}`,message:`Property "${ce(u,u.project)}" with id "${u.id}" implements a non-abstract property "${ce(u,u.project)}" with id "${u.id}".`,issue:null,severity:q.Error,code:ye.PropertyImplementsNonAbstact,entity:u});l.push(f.error)}return St(u.errors,l)}const phe=Object.freeze(Object.defineProperty({__proto__:null,validate:j3},Symbol.toStringTag,{value:"Module"}));var x3=(u=>(u.Declaration="declaration",u.DataTypeEntity="data-type-entity",u))(x3||{});const At=class At extends ar{constructor(n,o){super(n);D(this,"initialData");D(this,"id");D(this,"index");D(this,"type",p.OutputMap);D(this,"parentRelationType");D(this,"defaultValue",null);D(this,"declaration");D(this,"writesValues",[]);D(this,"dataType",null);D(this,"project");D(this,"errors",[]);D(this,"parent");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"suggestion",!1);D(this,"_codeNativeValueValidation",null);this.initialData=n,this.project=o,this.id=n.id,this.index=n.index,this.parentRelationType=n.parentRelationType}static new(n=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||M().toISOString(),author:(n==null?void 0:n.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:p.OutputMap,declaration:null,writesValues:[],index:0,defaultValue:null,parent:null}}static fromGenerationTarget(n,o){const l=Q(n.parent),f=o.get(l);let t;if(n.declaration){const A=Q(n.declaration);t=o.get(A)}const m={id:n.id,version:P.UUID.uuid(),createdAt:M().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:p.OutputMap,index:(f.outputs||[]).length,defaultValue:null,declaration:t,writesValues:[],parent:f},E=Y(m,o);return E.setParent(f,null),E.initChildren(null),E}static validateGenerationTarget(n,o){var E;let l=JSON.parse(JSON.stringify(n));const f=[],t=Cr(l,{parent:{list:!1,types:dr.filter(A=>A!==p.Condition)},declaration:{list:!1,types:[p.ReturnDeclaration,p.Property]}},o);l=t.modifiedData;const m=o.get(l.parent);if(m&&dr.filter(A=>A!==p.Condition).includes(m.type)){const A=m.outputs.find(g=>g.declaration.id===(l.declaration?Q(l.declaration):null));if(A)f.push(new W({id:`${l.id}--${k.OutputOverwrite}`,code:k.OutputOverwrite,severity:q.Error,message:`Entity of type '${p.OutputMap}' with id '${l.id}' cannot be added to the parent entity of type '${m.type}' with id '${m.id}'. The parent already has an output-map with id '${A.id}' that points to the same base 'return-declaration'.
174
+ 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:o,modifiedData:l}}subscribeDependents(n){return n.forEach(o=>{this.detachedDependents[o.entity.id]||(this.detachedDependents[o.entity.id]=o)}),this}unsubscribeDependents(n){return n.forEach(o=>{this.detachedDependents[o.entity.id]&&delete this.detachedDependents[o.entity.id]}),this}syncDependents(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"sync-dependents"))){const o=[],l=[],f=[],t=[];return Object.values(this.detachedDependents).forEach(m=>{const E=m.entity.afterAllChildrenInitialized(n);o.push(...E.updated),l.push(...E.added),f.push(...E.removed),t.push(...E.affected)}),n==null||n.attemptAutoclose("sync-dependents",this.id),{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}onDetachedDependencyRemoved(n,o,l){const f=[],t=[],m=[],E=[];if(o==="declaration"){const{updated:A,added:g,removed:w}=this.remove({ignoreUpstream:!1},l);f.push(...A),t.push(...g),m.push(...w)}return{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}onDetachedDependencyRestored(n,o,l){const f=[],t=[],m=[],E=[];if(o==="declaration"){const{updated:A,added:g,removed:w}=this.restore({},l);f.push(...A),t.push(...g),m.push(...w)}return{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}unsubscribeFromDependencies(){var n,o,l,f,t;return(o=(n=this.declaration)==null?void 0:n.unsubscribeDependents)==null||o.call(n,[{entity:this,field:"declaration"}]),(t=(f=(l=this.dataType)==null?void 0:l.entity)==null?void 0:f.unsubscribeDependents)==null||t.call(f,[{entity:this,field:"data-type-entity"}]),this}subscribeToDependencies(){var n,o,l,f,t;return(o=(n=this.declaration)==null?void 0:n.subscribeDependents)==null||o.call(n,[{entity:this,field:"declaration"}]),(t=(f=(l=this.dataType)==null?void 0:l.entity)==null?void 0:f.subscribeDependents)==null||t.call(f,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(n){if(n&&!M(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&M(n).isSame(M(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=M(n).toISOString()||M().toISOString(),this)}captureVersion(){var o;const n=((o=this.knownVersions)==null?void 0:o.get(this.version))||new bt(this,this.project);return n.metaSync(this.toMeta(),null),this.knownVersions=this.knownVersions?this.knownVersions.set(this.version,n):new Map([[this.version,n]]),n.declaration=this.declaration,n.defaultValue=this.defaultValue,n.readsValue=this.readsValue,n.dataType=this.dataType,n.parent=this.parent,this}recursiveCaptureUpstreamVersions(n){const o=[],l=[],f=[],t=[];if(this.parent){this.parent.increaseVersion(n);const m=this.parent.recursiveCaptureUpstreamVersions(n);o.push(this.parent,...m.updated),l.push(...m.added),f.push(...m.removed)}return{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}async restoreVersion(n){var E;const o=[],l=[],f=[],t=[];if(this.version===n)return{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this};if(!this.knownVersions){const A=new Map;for(const[g,w]of this.knownVersions||new Map){if(A.set(g,w),w.activeVersion=!1,w.knownVersions)for(const[N,U]of w.knownVersions)A.set(N,U);w.knownVersions=null}}let m=(E=this.knownVersions)==null?void 0:E.get(n);if(!m){const A=await this.APILoadVersion({},n);if(!A)throw new Error(`Version with id '${n}' for entity with id '${this.id}' not found.`);m=new bt(A,this.project)}return this.metaSync(m.toShallowJSON(),null),this.previousVersion=m.previousVersion,this.version=m.version,this.createdAt=m.createdAt,this.author=m.author,this.deleted=m.deleted,this.declaration=m.declaration,this.defaultValue=m.defaultValue,this.readsValue=m.readsValue,this.dataType=m.dataType,this.parent=m.parent,{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}hydrateAncestors(){const n=[],o=[],l=[],f=[];if(this.initialData.parent){const t=Q(this.initialData.parent),m=this.project.get(t);if(m)this.setParent(m,null),n.push(m);else throw new Error(`${this.type} with id '${this.id}' has a 'parent' reference '${t}' 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 t=Q(this.initialData.readsValue),m=this.project.get(t);m&&(this.setValueWriter(m,null),n.push(m))}if(this.initialData.declaration){const t=Q(this.initialData.declaration),m=this.project.get(t);m&&(this.setDeclaration(m),n.push(m))}return sa.hydrateReadsValue(this),{updated:R(n),added:R(o),removed:R(l),affected:R(f),self:this}}afterAllChildrenInitialized(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"after-all-children-initialized"))){const o=[],l=[],f=[],t=[];return this.initialized=!0,this.captureVersion(),n==null||n.attemptAutoclose("after-all-children-initialized",this.id),{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}addSelfToProject(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"add-self-to-project"))){var m,E;const o=[this],l=[],f=[],t=[];if(this.parent.addInput(this,n),o.push(this.parent),(m=this.readsValue)==null||m.addValueReader(this,n),this.readsValue&&o.push(this.readsValue),Xt.includes(this.parent.type)&&((E=this.parent.getDataType(n))!=null&&E.inferred)){const A=this.parent.type===p.VariableDeclaration?this.parent:this.parent.declaration,{updated:g,added:w,removed:N,affected:U}=A.inferDataTypeAndSyncInstancesInputsAndOutputs(n);o.push(...g),l.push(...w),f.push(...N),t.push(...U),o.push(A,...A.variableInstances)}return this.subscribe(),this.subscribeToDependencies(),n==null||n.attemptAutoclose("add-self-to-project",this.id),{updated:R(o),added:R(l),removed:R(f),affected:R(t),self:this}}setParent(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"set-parent"))){var l;return((l=this.parent)==null?void 0:l.id)!==(n==null?void 0:n.id)&&(this.parent=n,o&&(o==null||o.add(this,G.Updated))),o==null||o.attemptAutoclose("set-parent",this.id),this}setDataType(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"set-data-type"))){const l=this.dataType;return(l==null?void 0:l.id)!==(n==null?void 0:n.id)&&(l==null||l.remove({ignoreUpstream:!0},o),this.dataType=n,o==null||o.add(this,G.Affected)),o==null||o.attemptAutoclose("set-data-type",this.id),this}removeDataType(){return this.dataType=null,this}setDeclaration(n){return this.declaration=n,this}initChildren(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"init-children"))){return this.initialized||this.startedInitialization?this:(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=Y(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(n)),this.initialData.declaration&&(this.declaration=Y(this.initialData.declaration,this.project)),sa.initReadsValue(this),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",this.id),this)}setValueWriter(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"set-value-writer"))){return this.readsValue!==n&&(this.readsValue=n,o==null||o.add(this,G.Updated)),o==null||o.attemptAutoclose("set-value-writer",this.id),this}removeValueWriter(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"remove-value-writer"))){return this.readsValue&&(this.readsValue=null,n==null||n.add(this,G.Updated)),n==null||n.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(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),f=this.toMeta();return this.index=n.index||(n.index!==0?f.index:0),this.name=n.name!==void 0?n.name:f.name,this.description=n.description!==void 0?n.description:f.description,super.metaSync(n),n.deleted===!0&&!f.deleted?o==null||o.add(this,G.Removed):n.deleted===!1&&f.deleted?o==null||o.add(this,G.Added):l&&(o==null||o.add(this,G.Updated)),o==null||o.attemptAutoclose("meta-sync",this.id),this}async APILoad(n=oe,...o){return await bt.repository.APILoad(this.id,...o),this}async APICreate(n=oe,...o){return await bt.repository.APICreate(this.toShallowJSON(),...o),this}async APIUpdate(n=oe,...o){return await bt.repository.APIUpdate(this.toShallowJSON(),...o),this}async APIDelete(n=oe,...o){return await bt.repository.APIDelete(this.toShallowJSON(),...o),this}async APIClone(n=oe,...o){return await bt.repository.APIClone(this.id,...o),this}async APILoadVersion(n=oe,o,...l){return await bt.repository.APILoadVersion(this.id,o,...l)}remove({ignoreUpstream:n}={ignoreUpstream:!1},o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"remove-entity"))){var E,A,g,w;const l=[],f=[],t=[],m=[];if(o!=null&&o.hasRemoved(this.id))return o==null||o.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(f.push(this),this.unsubscribe(),this.unsubscribeFromDependencies(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},o),Object.values(this.detachedDependents).forEach(N=>{const{updated:U,removed:K,added:S}=N.entity.onDetachedDependencyRemoved(this,N.field,o);l.push(...U),f.push(...K),t.push(...S)}),this.defaultValue){const{updated:N,removed:U}=this.defaultValue.remove({ignoreUpstream:!0},o);l.push(...N),f.push(...U)}if(this.readsValue&&(l.push(this.readsValue),this.readsValue.removeValueReader(this,o)),this.defaultValue&&(l.push(this.defaultValue),this.defaultValue.remove({ignoreUpstream:!0},o)),this.declaration){if(this.declaration.type===p.Property&&((E=this.declaration.parent)==null?void 0:E.type)===p.DefinitionEntity&&((g=(A=this.declaration.parent)==null?void 0:A.parent)==null?void 0:g.type)===p.DataType&&!(o!=null&&o.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:N,removed:U}=this.declaration.remove({ignoreUpstream:!1},o);l.push(...N),f.push(...U)}else if(this.declaration.type===p.ValueDescriptor&&((w=this.declaration.parent)==null?void 0:w.type)===p.Search&&!(o!=null&&o.hasRemoved(this.declaration.id))&&!this.declaration.deleted){const{updated:N,removed:U}=this.declaration.remove({ignoreUpstream:!1},o);l.push(...N),f.push(...U)}}return n||(l.push(this.parent),this.parent.removeInput(this,o)),o==null||o.attemptAutoclose("remove-entity",this.id),{added:R(t),updated:R(l),removed:R(f),affected:R(m),self:this}}restore({}={},n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"restore-entity"))){const o=[],l=[],f=[],t=[];if(n!=null&&n.hasAdded(this.id))return n==null||n.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},n),Object.values(this.detachedDependents).forEach(m=>{const{updated:E,removed:A,added:g}=m.entity.onDetachedDependencyRestored(this,m.field,n);l.push(...E),f.push(...A),o.push(...g)}),this.defaultValue){const{updated:m}=this.defaultValue.restore({},n);l.push(...m)}return this.readsValue&&(l.push(this.readsValue),this.readsValue.addValueReader(this,n)),this.defaultValue&&(l.push(this.defaultValue),this.defaultValue.restore({},n)),l.push(this.parent),this.parent.addInput(this,n),n==null||n.attemptAutoclose("restore-entity",this.id),{added:R(o),updated:R(l),removed:R(f),affected:R(t),self:this}}toFlat(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this,...this.defaultValue?this.defaultValue.toFlat(n):[],...this.dataType?this.dataType.toFlat(n):[],...this.declaration?this.declaration.toFlat(n):[],...this.readsValue?this.readsValue.toFlat(n):[]])}toFlatIds(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.id,...this.defaultValue?this.defaultValue.toFlatIds(n):[],...this.dataType?this.dataType.toFlatIds(n):[],...this.declaration?this.declaration.toFlatIds(n):[],...this.readsValue?this.readsValue.toFlatIds(n):[]])}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(n=new Set){var o,l,f;return n.has(this.id)?this.toReference():(n.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:((o=this.defaultValue)==null?void 0:o.toJSON(n))||null,declaration:((l=this.declaration)==null?void 0:l.toJSON(n))||null,readsValue:((f=this.readsValue)==null?void 0:f.toReference())||null,parent:this.parent.toReference()})}toJSONClone(n=Oe){var l,f,t,m,E,A,g,w,N,U,K;let o;return(l=n.seenEntityMaps)!=null&&l.has(this.id)?o=n.seenEntityMaps.get(this.id):(o=n.newId||yr(this,this.project,n.uuidStrategy),n.seenEntityMaps&&n.seenEntityMaps.set(this.id,o)),(f=n.seenEntities)!=null&&f.has(o)||(t=n.seenEntities)!=null&&t.has(this.id)?this.toReference({seenEntityMaps:n.seenEntityMaps}):((m=n.seenEntities)==null||m.add(o),(E=n.seenEntities)==null||E.add(this.id),{id:o,version:P.UUID.uuid(),createdAt:n.timestamp||M().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,index:this.index,name:this.name,description:this.description,defaultValue:((A=this.defaultValue)==null?void 0:A.toJSONClone({...n,newId:null}))||null,declaration:(g=this.declaration)!=null&&g.id&&this.project.getBuiltIn((w=this.declaration)==null?void 0:w.id)?(N=this.declaration)==null?void 0:N.toJSON(n.seenEntities):((U=this.declaration)==null?void 0:U.toJSONClone({...n,newId:null}))||null,readsValue:((K=this.readsValue)==null?void 0:K.toReference({seenEntityMaps:n.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:n.seenEntityMaps})})}toReference(n=Oe){var l;let o=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(o=n.seenEntityMaps.get(this.id)),{id:o+"--"+P.UUID.uuid()+"--ref",type:p.GenericReference,entityId:o,version:this.version,entityType:this.type}}toShallowJSON(n=Oe){var l,f,t,m;let o=this.id;return(l=n.seenEntityMaps)!=null&&l.has(this.id)&&(o=n.seenEntityMaps.get(this.id)),{id:o,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:((f=this.defaultValue)==null?void 0:f.toReference(n))||null,declaration:((t=this.declaration)==null?void 0:t.toReference(n))||null,readsValue:((m=this.readsValue)==null?void 0:m.toReference(n))||null,parent:this.parent.toReference(n)}}toFlatJSON(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...this.defaultValue?this.defaultValue.toFlatJSON(n):[],...this.dataType?this.dataType.toFlatJSON(n):[],...this.declaration?this.declaration.toFlatJSON(n):[],...this.readsValue?this.readsValue.toFlatJSON(n):[]])}toGenerationTarget(){var n;return{id:this.id,name:this.name||void 0,description:this.description||void 0,type:this.type,declaration:((n=this.declaration)==null?void 0:n.id)||null,parent:this.parent.id}}toFlatGenerationTarget(n=new Set){return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...this.defaultValue?this.defaultValue.toFlatGenerationTarget(n):[],...this.dataType?this.dataType.toFlatGenerationTarget(n):[],...this.readsValue?this.readsValue.toFlatGenerationTarget(n):[],...this.declaration?this.declaration.toFlatGenerationTarget(n):[]])}clearErrors(){var n;return this.errors=[],(n=this.defaultValue)==null||n.clearErrors(),this}validate(){const n=B3(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){var o;return[...this.errors,...((o=this.defaultValue)==null?void 0:o.getErrors())||[]]}getShallowErrors(){return this.errors}getDefaultValue(){var n;return this.defaultValue||((n=this.declaration)==null?void 0:n.defaultValue)||null}setDefaultValue(n){return this.defaultValue=n,this}clone(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"clone-entity")),o=null,l=null,f=!0){var w;let t=mr(o,this);const m=this.toJSON(),E=l||P.UUID.uuid();m.defaultValue=null,m.id=E,m.version=P.UUID.uuid(),m.createdAt=(n==null?void 0:n.timestamp)||M().toISOString(),m.author=(n==null?void 0:n.author)||"1",m.previousVersion=null,m.deleted=!1;const A=tr(m,t);o?A.setParent(o,null):A.setParent(this.parent,null),f&&A.subscribe(),A.initChildren(n),n==null||n.add(A,G.Added);const g=(w=this.defaultValue)==null?void 0:w.clone(n,A,P.UUID.uuid(),f);return A.defaultValue=g||null,n==null||n.attemptAutoclose("clone-entity",this.id),A}getDataType(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,M().toISOString(),this,!0,"get-data-type"))){var l;if(this.parent.type===p.Operation)return this.parent.declaration.inferInputMapDataType(this,n).self;if(Xt.includes(this.parent.type)){const f=Lo(this.parent),t=f.getDataType(n);(!t||t.inferred)&&f.inferDataTypeAndSyncInstancesInputsAndOutputs(n)}const o=(l=this.declaration)==null?void 0:l.getDataType(n);if(!o){const f=Us(this,n);if(f)return f}return o||null}};D(bt,"repository",{APICreate:async(n,...o)=>n,APIUpdate:async(n,...o)=>n,APIDelete:async(n,...o)=>n,APIClone:async(n,...o)=>{},APILoad:async(n,...o)=>null,APILoadVersion:async(n,o,...l)=>null}),D(bt,"type",p.InputMap),D(bt,"USER_MANAGED_PARENT_TYPES",[...dr]),D(bt,"PARENT_TYPES",[...bt.USER_MANAGED_PARENT_TYPES]),D(bt,"MUTABLE_BASE_PROPERTIES",["name","description"]),D(bt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(bt,"BASE_PROPERTIES",[...bt.MUTABLE_BASE_PROPERTIES,...bt.INMUTABLE_BASE_PROPERTIES]),D(bt,"MUTABLE_META_PROPERTIES",[...bt.MUTABLE_BASE_PROPERTIES,"index"]),D(bt,"INMUTABLE_META_PROPERTIES",[...bt.INMUTABLE_BASE_PROPERTIES]),D(bt,"META_PROPERTIES",[...bt.MUTABLE_META_PROPERTIES,...bt.INMUTABLE_META_PROPERTIES]),D(bt,"MUTABLE_UPSTREAM_PROPERTIES",["readsValue"]),D(bt,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","declaration"]),D(bt,"UPSTREAM_PROPERTIES",[...bt.MUTABLE_UPSTREAM_PROPERTIES,...bt.INMUTABLE_UPSTREAM_PROPERTIES]),D(bt,"MUTABLE_DOWNSTREAM_PROPERTIES",["defaultValue"]),D(bt,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),D(bt,"DOWNSTREAM_PROPERTIES",[...bt.MUTABLE_DOWNSTREAM_PROPERTIES,...bt.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(bt,"PROPERTIES",[...bt.META_PROPERTIES,...bt.UPSTREAM_PROPERTIES,...bt.DOWNSTREAM_PROPERTIES]);let Es=bt;class uhe extends Es{constructor(n,o){super(n,o);D(this,"declaration",null);D(this,"parent");D(this,"errors",[])}toJSON(n=new Set){return super.toJSON(n)}}class che extends Es{constructor(n,o){super(n,o);D(this,"name",null);D(this,"description",null);D(this,"declaration");D(this,"parent");D(this,"errors",[])}toJSON(n=new Set){return super.toJSON(n)}}function j3(u){const d=rle(),n=u.toJSON();d.safeParse(n).success;const l=[];if(u.id==="exec-sequentially-return-map-id"){const f=Xe({id:`${u.id}--${ye.PropertyImplementsNonAbstact}`,message:`Property "${ce(u,u.project)}" with id "${u.id}" implements a non-abstract property "${ce(u,u.project)}" with id "${u.id}".`,issue:null,severity:q.Error,code:ye.PropertyImplementsNonAbstact,entity:u});l.push(f.error)}return St(u.errors,l)}const phe=Object.freeze(Object.defineProperty({__proto__:null,validate:j3},Symbol.toStringTag,{value:"Module"}));var x3=(u=>(u.Declaration="declaration",u.DataTypeEntity="data-type-entity",u))(x3||{});const At=class At extends ar{constructor(n,o){super(n);D(this,"initialData");D(this,"id");D(this,"index");D(this,"type",p.OutputMap);D(this,"parentRelationType");D(this,"defaultValue",null);D(this,"declaration");D(this,"writesValues",[]);D(this,"dataType",null);D(this,"project");D(this,"errors",[]);D(this,"parent");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);D(this,"suggestion",!1);D(this,"_codeNativeValueValidation",null);this.initialData=n,this.project=o,this.id=n.id,this.index=n.index,this.parentRelationType=n.parentRelationType}static new(n=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||M().toISOString(),author:(n==null?void 0:n.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:p.OutputMap,declaration:null,writesValues:[],index:0,defaultValue:null,parent:null}}static fromGenerationTarget(n,o){const l=Q(n.parent),f=o.get(l);let t;if(n.declaration){const A=Q(n.declaration);t=o.get(A)}const m={id:n.id,version:P.UUID.uuid(),createdAt:M().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:p.OutputMap,index:(f.outputs||[]).length,defaultValue:null,declaration:t,writesValues:[],parent:f},E=Y(m,o);return E.setParent(f,null),E.initChildren(null),E}static validateGenerationTarget(n,o){var E;let l=JSON.parse(JSON.stringify(n));const f=[],t=Cr(l,{parent:{list:!1,types:dr.filter(A=>A!==p.Condition)},declaration:{list:!1,types:[p.ReturnDeclaration,p.Property]}},o);l=t.modifiedData;const m=o.get(l.parent);if(m&&dr.filter(A=>A!==p.Condition).includes(m.type)){const A=m.outputs.find(g=>g.declaration.id===(l.declaration?Q(l.declaration):null));if(A)f.push(new W({id:`${l.id}--${k.OutputOverwrite}`,code:k.OutputOverwrite,severity:q.Error,message:`Entity of type '${p.OutputMap}' with id '${l.id}' cannot be added to the parent entity of type '${m.type}' with id '${m.id}'. The parent already has an output-map with id '${A.id}' that points to the same base 'return-declaration'.
175
175
  Any value reads can be done with that output-map instead.
176
176
  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 g=l.declaration?o.get(l.declaration):null;if(g&&Xt.includes(m.type)){const w=Lo(m),N=w.dataType,U=(E=w.dataType)==null?void 0:E.entity;N?U?U.type===p.ActionDescriptor?f.push(new W({id:`${l.id}--${de.NoOverlapWithImplementedSignature}`,code:de.NoOverlapWithImplementedSignature,severity:q.Error,message:`Entity of type '${p.OutputMap}' with id '${l.id}' cannot be added to the parent entity of type '${m.type}' with id '${m.id}'. The data type of the 'variable-declaration' is a 'action-descriptor' entity.
177
177
  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.6289",
3
+ "version": "0.0.6290",
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",