@elyx-code/project-logic-tree 0.0.6309 → 0.0.6310
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.d.ts +1 -0
- package/dist/index.js +7 -3
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1995,6 +1995,7 @@ export declare class DataTypeState extends VersionedState implements IDataType,
|
|
|
1995
1995
|
canBeObject(): boolean;
|
|
1996
1996
|
hasStrictObjectStructure(): boolean;
|
|
1997
1997
|
isInlineDeclaredEntity(): boolean;
|
|
1998
|
+
isIndependentlyUserDeclaredEntity(): boolean;
|
|
1998
1999
|
canModifyObjectStructure(): boolean;
|
|
1999
2000
|
inferFromInputs(inputs: VariableInputMapState[], changeSet?: ChangeSet | null): IChangeSet<DataTypeState>;
|
|
2000
2001
|
}
|
package/dist/index.js
CHANGED
|
@@ -35909,10 +35909,14 @@ Alternatively you can update the entity with 'update' action. Or replace it by f
|
|
|
35909
35909
|
var n, o;
|
|
35910
35910
|
return ((n = this.entity) == null ? void 0 : n.type) === c.DefinitionEntity && ((o = this.entity.parent) == null ? void 0 : o.id) === (this == null ? void 0 : this.id);
|
|
35911
35911
|
}
|
|
35912
|
+
isIndependentlyUserDeclaredEntity() {
|
|
35913
|
+
var n, o;
|
|
35914
|
+
return ((n = this.entity) == null ? void 0 : n.type) === c.DefinitionEntity && ((o = this.entity) == null ? void 0 : o.parent) !== this;
|
|
35915
|
+
}
|
|
35912
35916
|
canModifyObjectStructure() {
|
|
35913
|
-
var o
|
|
35914
|
-
const n =
|
|
35915
|
-
return (this.isInlineDeclaredEntity() || this.canBeObject() || ((
|
|
35917
|
+
var o;
|
|
35918
|
+
const n = this.isIndependentlyUserDeclaredEntity();
|
|
35919
|
+
return (this.isInlineDeclaredEntity() || this.canBeObject() || ((o = this.entity) == null ? void 0 : o.name) === te.KeyValue) && !n;
|
|
35916
35920
|
}
|
|
35917
35921
|
// Only for inferred data types,
|
|
35918
35922
|
// attempt to update the entity based on the inputs,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -60,7 +60,7 @@ ${xa}`,issue:null}))}}}const m=l.parent&&o.get(l.parent)||o.getBuiltIn(l.parent)
|
|
|
60
60
|
The entitities of type '${Ke(w,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property so no 'parentRelationType' is needed.`,issue:null})),m.dataType)){const V=(A=m.dataType)==null?void 0:A.id;f.push(new W({id:`${n.id}--${k.NewEntityWouldOverriteExisting}`,code:k.NewEntityWouldOverriteExisting,severity:S.Error,message:`The entity with id '${n.id}' and type '${n.type}', cannot be added as a child to the entity with id '${l.parent}' and type '${g}', because it already has a 'data-type' child with id '${V}'.
|
|
61
61
|
The entitities of type '${Ke(w,"', '","' and '")}' can only have one 'data-type' child under the 'dataType' property. You can inspect the existing data-type entity with the 'describe_entity' action. Like so:
|
|
62
62
|
${En({describe_entity:V})}
|
|
63
|
-
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}g===p.DataType&&(!l.parentRelationType||!(l.parentRelationType===Gr.AndDataTypeGroup||l.parentRelationType===Gr.OrDataTypeGroup))&&f.push(new W({id:`${n.id}--${k.InvalidParentRelationType}`,code:k.InvalidParentRelationType,severity:S.Error,message:`The entity with id '${n.id}' and type '${n.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`,issue:null}))}return{errors:f,modifiedData:l}}get isGroup(){const n=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(n.length>1){let o=0;for(const l of n)if(l.isResolved&&(o++,o>1))return!0}return!1}get isResolved(){return[p.BuiltInBaseEntity,p.ActionDescriptor].includes(this.parent.type)||Ka(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(n){return{errors:[],modifiedData:n}}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,L().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=[];return o==="entity"&&this.setEntity(n,l),{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}onDetachedDependencyRestored(n,o,l){const f=[],t=[],m=[],E=[];return o==="entity"&&this.setEntity(null,l),{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}unsubscribeFromDependencies(){var n,o;return(o=(n=this.entity)==null?void 0:n.unsubscribeDependents)==null||o.call(n,[{entity:this,field:"entity"}]),this}subscribeToDependencies(){var n,o;return(o=(n=this.entity)==null?void 0:n.subscribeDependents)==null||o.call(n,[{entity:this,field:"entity"}]),this}increaseVersion(n){if(n&&!L(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&L(n).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=L(n).toISOString()||L().toISOString(),this)}captureVersion(){var o;const n=((o=this.knownVersions)==null?void 0:o.get(this.version))||new pt(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.entity=this.entity,n.andChildrenGroup=this.andChildrenGroup?[...this.andChildrenGroup]:this.andChildrenGroup,n.orChildrenGroup=this.orChildrenGroup?[...this.orChildrenGroup]:this.orChildrenGroup,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[V,B]of w.knownVersions)A.set(V,B);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 pt(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.entity=m.entity,this.andChildrenGroup=m.andChildrenGroup,this.orChildrenGroup=m.orChildrenGroup,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.entity){const t=Q(this.initialData.entity),m=this.project.get(t);m&&(m.type===p.DefinitionEntity&&m.parent===this||(this.setEntity(m,null),m.type!==p.BuiltInBaseEntity&&m.type!==p.PrimitiveEntity&&n.push(m)))}return{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,L().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,L().toISOString(),this,!0,"add-self-to-project"))){const o=[this],l=[],f=[],t=[];return this.parent.type===p.DataType?this.parentRelationType===Gr.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===Gr.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this,n),o.push(this.parent),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,L().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}removeChildGroup(n){if(this.andChildrenGroup){const o=this.andChildrenGroup.findIndex(l=>l.id===n.id);o!==-1&&this.andChildrenGroup.splice(o,1)}if(this.orChildrenGroup){const o=this.orChildrenGroup.findIndex(l=>l.id===n.id);o!==-1&&this.orChildrenGroup.splice(o,1)}return this}initChildren(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"init-children"))){var o,l,f,t;if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.entity)if(this.initialData.entity.type===p.GenericReference){const m=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=m}else this.entity=Y(this.initialData.entity,this.project),((l=(o=this.initialData.entity)==null?void 0:o.parent)==null?void 0:l.id)===this.id&&this.entity.setParent(this,null),(t=(f=this.entity).initChildren)==null||t.call(f,n);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(m=>{const E=Y(m,this.project);return E.setParent(this,null),E.initChildren(n),E})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(m=>{const E=Y(m,this.project);return E.setParent(this,null),E.initChildren(n),E})),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",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,L().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),f=this.toMeta();return this.options=n.options||f.options,this.parentRelationType=n.parentRelationType||f.parentRelationType,this.isList=n.isList!==void 0?n.isList:f.isList,this.inferred=n.inferred!==void 0?n.inferred:f.inferred,this.like=n.like!==void 0?n.like:f.like,this.asType=n.asType!==void 0?n.asType:f.asType,this.implementationChooseOne=n.implementationChooseOne!==void 0?n.implementationChooseOne:f.implementationChooseOne,this.staticEntities=n.staticEntities!==void 0?n.staticEntities:f.staticEntities,this.interactiveEntities=n.interactiveEntities!==void 0?n.interactiveEntities:f.interactiveEntities,this.actionEntities=n.actionEntities!==void 0?n.actionEntities:f.actionEntities,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 pt.repository.APILoad(this.id,...o),this}async APICreate(n=oe,...o){return await pt.repository.APICreate(this.toShallowJSON(),...o),this}async APIUpdate(n=oe,...o){return await pt.repository.APIUpdate(this.toShallowJSON(),...o),this}async APIDelete(n=oe,...o){return await pt.repository.APIDelete(this.toShallowJSON(),...o),this}async APIClone(n=oe,...o){return await pt.repository.APIClone(this.id,...o),this}async APILoadVersion(n=oe,o,...l){return await pt.repository.APILoadVersion(this.id,o,...l)}remove({ignoreUpstream:n}={ignoreUpstream:!1},o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){var E;if(this.id==="iterate-over-string-loop-string-argument-declaration-data-type-id")throw new Error("You are trying to remove the iterate-over-string-loop-string-argument-declaration-data-type-id entity. This is not allowed.");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:V}=A.entity.onDetachedDependencyRemoved(this,A.field,o);l.push(...g),f.push(...w),t.push(...V)}),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:A,removed:g}=this.entity.remove({ignoreUpstream:!0},o);l.push(...A),f.push(...g)}if(!n){((E=this.parent)==null?void 0:E.type)===p.DataType&&this.parent.removeChildGroup(this);const A=this.parent;if((A==null?void 0:A.type)===p.DataType){if(this.parentRelationType===Gr.AndDataTypeGroup){if(Array.isArray(A.andChildrenGroup)){const g=A.andChildrenGroup.findIndex(w=>w.id===this.id);g!==-1&&A.andChildrenGroup.splice(g,1)}}else if(this.parentRelationType===Gr.OrDataTypeGroup&&Array.isArray(A.orChildrenGroup)){const g=A.orChildrenGroup.findIndex(w=>w.id===this.id);g!==-1&&A.orChildrenGroup.splice(g,1)}}else{const g=this.parent;g==null||g.removeDataType()}A&&l.push(A)}return 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,L().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.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:m}=this.entity.restore({},n);l.push(...m)}if(this.parent.type===p.DataType){const m=this.parent;Array.isArray(m.andChildrenGroup)&&m.andChildrenGroup.push(this)}if(this.parent.type===p.DataType){const m=this.parent;this.parentRelationType===Gr.AndDataTypeGroup?Array.isArray(m.andChildrenGroup)&&m.andChildrenGroup.push(this):this.parentRelationType===Gr.OrDataTypeGroup&&Array.isArray(m.orChildrenGroup)&&m.orChildrenGroup.push(this)}else{const m=this.parent;m.setDataType(this,n),l.push(m)}return 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){var l,f,t;return n.has(this.id)?[]:(n.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(m=>m.toFlat(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(m=>m.toFlat(n)))||[],...((t=this.entity)==null?void 0:t.toFlat(n))||[]])}toFlatIds(n=new Set){var l,f,t;return n.has(this.id)?[]:(n.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(m=>m.toFlatIds(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(m=>m.toFlatIds(n)))||[],...((t=this.entity)==null?void 0:t.toFlatIds(n))||[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,like:this.like,isList:this.isList,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,options:this.options,asType:this.asType,type:this.type}}toJSON(n=new Set){var o,l,f,t;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,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((o=this.andChildrenGroup)==null?void 0:o.map(m=>m.toJSON(n)))||null,orChildrenGroup:((l=this.orChildrenGroup)==null?void 0:l.map(m=>m.toJSON(n)))||null,entity:((f=this.entity)==null?void 0:f.parent)===this?this.entity.toJSON(n):((t=this.entity)==null?void 0:t.toReference())||null,parent:this.parent.toReference()})}toJSONClone(n=$e){var l,f,t,m,E,A,g,w,V;let o;return(l=n.seenEntityMaps)!=null&&l.has(this.id)?o=n.seenEntityMaps.get(this.id):(o=n.newId||hr(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||L().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((A=this.andChildrenGroup)==null?void 0:A.map(B=>B.toJSONClone({...n,newId:null})))||null,orChildrenGroup:((g=this.orChildrenGroup)==null?void 0:g.map(B=>B.toJSONClone({...n,newId:null})))||null,entity:((w=this.entity)==null?void 0:w.parent)===this?this.entity.toJSONClone({...n,newId:null}):((V=this.entity)==null?void 0:V.toReference({seenEntityMaps:n.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:n.seenEntityMaps})})}toReference(n=$e){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=$e){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,isList:this.isList,options:this.options,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((f=this.andChildrenGroup)==null?void 0:f.map(E=>E.toReference(n)))||null,orChildrenGroup:((t=this.orChildrenGroup)==null?void 0:t.map(E=>E.toReference(n)))||null,entity:((m=this.entity)==null?void 0:m.toReference(n))||null,parent:this.parent.toReference(n)}}toFlatJSON(n=new Set){var l,f,t;return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(m=>m.toFlatJSON(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(m=>m.toFlatJSON(n)))||[],...((t=this.entity)==null?void 0:t.toFlatJSON(n))||[]])}toGenerationTarget(){var n;return{id:this.id,type:this.type,options:this.options||void 0,isList:this.isList,like:this.like,parentRelationType:this.parentRelationType||void 0,asType:this.asType,entity:((n=this.entity)==null?void 0:n.id)||null,parent:this.parent.id}}toFlatGenerationTarget(n=new Set){var l,f;return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(t=>t.toFlatGenerationTarget(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(t=>t.toFlatGenerationTarget(n)))||[],...this.entity&&this.entity.type==p.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(n)||[]])}clearErrors(){var n,o,l,f;return this.errors=[],(n=this.andChildrenGroup)==null||n.forEach(t=>t.clearErrors()),(o=this.orChildrenGroup)==null||o.forEach(t=>t.clearErrors()),this.inferred&&this.entity&&this.entity.type===p.DefinitionEntity&&((l=this.entity)==null?void 0:l.parent)===this&&((f=this.entity)==null||f.clearErrors()),this}validate(){const n=nM(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),o=null,l=null,f=!0){var B,K,q;let t=yr(o,this),m=o||this.parent;const A={id:l||P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||L().toISOString(),author:(n==null?void 0:n.author)||"1",previousVersion:null,deleted:!1,type:p.DataType,isList:this.isList,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:m.toReference()},g=er(A,t);o&&g.setParent(o,null),f&&g.subscribe(),g.initChildren(n),n==null||n.add(g,G.Added);const w=(B=this.andChildrenGroup)==null?void 0:B.map(Z=>Z.clone(n,g,P.UUID.uuid(),f)),V=(K=this.orChildrenGroup)==null?void 0:K.map(Z=>Z.clone(n,g,P.UUID.uuid(),f));if(g.andChildrenGroup=w||null,g.orChildrenGroup=V||null,this.entity&&this.entity.type===p.DefinitionEntity&&((q=this.entity)==null?void 0:q.parent)===this){const Z=this.entity.clone(n,g,P.UUID.uuid(),f);g.setEntity(Z,n)}else this.entity&&g.setEntity(this.entity,n);return n==null||n.attemptAutoclose("clone-entity",this.id),g}merge(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"merge-entity"))){const l=[],f=[],t=[],m=[];if(this.asType!==(n==null?void 0:n.asType)&&(this.metaSync({asType:n==null?void 0:n.asType},o),o==null||o.add(this,G.Updated),l.push(this)),this.isList!==(n==null?void 0:n.isList)&&(this.metaSync({isList:n==null?void 0:n.isList},o),o==null||o.add(this,G.Updated),l.push(this)),this.like!==(n==null?void 0:n.like)&&(this.metaSync({like:n==null?void 0:n.like},o),o==null||o.add(this,G.Updated),l.push(this)),n!=null&&n.inferred){if(n.entity&&n.entity.type===p.DefinitionEntity&&n.entity.parent===n){const E=n.entity.clone(o,this,P.UUID.uuid(),!0);this.setEntity(E,o),f.push(E)}else n.entity&&(this.setEntity(n.entity,o),o==null||o.add(this,G.Updated),l.push(this));this.inferred||(this.metaSync({inferred:!0},o),o==null||o.add(this,G.Updated),l.push(this))}else if(this.inferred){if(this.metaSync({inferred:!1},o),o==null||o.add(this,G.Updated),l.push(this),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:E,removed:A}=this.entity.remove({ignoreUpstream:!0},o);t.push(...A),E.push(...E)}n.entity!==this.entity&&(this.setEntity(n.entity,o),o==null||o.add(this,G.Updated),l.push(this))}else n.entity!==this.entity&&(this.setEntity(n.entity,o),o==null||o.add(this,G.Updated),l.push(this));return o==null||o.attemptAutoclose("merge-entity",this.id),{updated:R(l),added:R(f),removed:R(t),affected:R(m),self:this}}addToAndGroup(n){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(n)||this.andChildrenGroup.push(n),this}addToOrGroup(n){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(n)||this.orChildrenGroup.push(n),this}setEntity(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"set-data-type-entity-value"))){var f;const l=this.entity;return(l==null?void 0:l.id)!==(n==null?void 0:n.id)&&(this.entity=n,o==null||o.add(this,G.Affected),l&&l.type===p.DefinitionEntity&&((f=l.parent)==null?void 0:f.id)===this.id&&(l==null||l.remove({ignoreUpstream:!0},o))),o==null||o.attemptAutoclose("set-data-type-entity-value",this.id),this}isObject(){return!!this.entity&&(this.entity.type===p.DefinitionEntity||this.entity.type===p.BuiltInBaseEntity||this.entity.name===re.KeyValue)&&!this.isList}canBeObject(){let n=!1;if(this.parent.type!==p.DataType){const o=this.project.requestActiveValue(this.parent);o?!o.valueAsType&&(o.value===""||o.value===null||js(o))&&(n=!0):n=!0}return(this.isObject()||!this.entity||this.entity.name===re.Untyped)&&n}hasStrictObjectStructure(){var n;return this.isObject()&&((n=this.entity)==null?void 0:n.type)===p.DefinitionEntity}isInlineDeclaredEntity(){var n,o;return((n=this.entity)==null?void 0:n.type)===p.DefinitionEntity&&((o=this.entity.parent)==null?void 0:o.id)===(this==null?void 0:this.id)}canModifyObjectStructure(){var o,l,f;const n=((o=this.entity)==null?void 0:o.type)===p.DefinitionEntity&&((l=this.entity)==null?void 0:l.parent)!==this;return(this.isInlineDeclaredEntity()||this.canBeObject()||((f=this.entity)==null?void 0:f.name)===re.KeyValue)&&!n}inferFromInputs(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"infer-data-type-from-inputs"))){var E;const l=[],f=[],t=[],m=[];if(!this.inferred)return o==null||o.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:[],added:[],removed:[],affected:[],self:this};if(!this.entity&&n.length){const A=ue(this.parent,this.project)+" data type definition",g={id:P.UUID.uuid(),type:p.DefinitionEntity,version:P.UUID.uuid(),createdAt:(o==null?void 0:o.timestamp)||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:A,description:((E=this.parent)==null?void 0:E.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},w=Y(g,this.project);w.setParent(this,o),w.initChildren(o),o==null||o.add(w,G.Added),w.metaSync(g,o),this.setEntity(w,o),o==null||o.add(this,G.Updated)}if(this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent!==this&&this.entity.setParent(this,o),this.entity){const{updated:A,added:g,removed:w,affected:V}=this.entity.inferFromInputs(n,o);f.push(...A),l.push(...g),t.push(...w),m.push(...V)}return this.like||this.metaSync({like:!0},o),o==null||o.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:R(f),added:R(l),removed:R(t),affected:R(m),self:this}}};D(pt,"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(pt,"type",p.DataType),D(pt,"USER_MANAGED_PARENT_TYPES",[p.Property,p.ArgumentDeclaration,p.ReturnDeclaration,p.VariableDeclaration,p.ValueDescriptor,p.InputMap,p.OutputMap,p.DataType]),D(pt,"PARENT_TYPES",[...pt.USER_MANAGED_PARENT_TYPES]),D(pt,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),D(pt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(pt,"BASE_PROPERTIES",[...pt.MUTABLE_BASE_PROPERTIES,...pt.INMUTABLE_BASE_PROPERTIES]),D(pt,"MUTABLE_META_PROPERTIES",[...pt.MUTABLE_BASE_PROPERTIES,"inferred"]),D(pt,"INMUTABLE_META_PROPERTIES",[...pt.INMUTABLE_BASE_PROPERTIES]),D(pt,"META_PROPERTIES",[...pt.MUTABLE_META_PROPERTIES,...pt.INMUTABLE_META_PROPERTIES]),D(pt,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),D(pt,"INMUTABLE_UPSTREAM_PROPERTIES",[]),D(pt,"UPSTREAM_PROPERTIES",[...pt.MUTABLE_UPSTREAM_PROPERTIES,...pt.INMUTABLE_UPSTREAM_PROPERTIES]),D(pt,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),D(pt,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),D(pt,"DOWNSTREAM_PROPERTIES",[...pt.MUTABLE_DOWNSTREAM_PROPERTIES,...pt.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(pt,"PROPERTIES",[...pt.META_PROPERTIES,...pt.UPSTREAM_PROPERTIES,...pt.DOWNSTREAM_PROPERTIES]);let ts=pt;function aM(u){var m;const d=Ple(),n=u.toJSON();d.safeParse(n).success;const l=lpe(u),f=ta(u),t=[...l,...f];if(u.id==="exec-sequentially-operation-call-id"){const E=et({id:`${u.id}--${fe.PropertyImplementsNonAbstact}`,message:`Property "${ue(u,u.project)}" with id "${u.id}" implements a non-abstract property "${ue(u,u.project)}" with id "${u.id}".`,issue:null,severity:S.Error,code:fe.PropertyImplementsNonAbstact,entity:u});t.push(E.error)}return u.outputs.forEach(E=>E.validate()),(m=u.error)==null||m.validate(),qt(u.errors,t)}function lpe(u){const d=[];return u.inputs.forEach(n=>{n.validate()}),qt(u.errors,d)}const dpe=Object.freeze(Object.defineProperty({__proto__:null,validate:aM},Symbol.toStringTag,{value:"Module"}));var oM=(u=>(u.Parent="parent",u))(oM||{});const ft=class ft extends nr{constructor(n,o){super(n);D(this,"initialData");D(this,"id");D(this,"x");D(this,"y");D(this,"type",p.Operation);D(this,"declaration");D(this,"inputs",[]);D(this,"outputs",[]);D(this,"process",null);D(this,"successCalls",[]);D(this,"errorCalls",[]);D(this,"error",null);D(this,"calledBySuccess",[]);D(this,"calledByError",[]);D(this,"calledByEntry",[]);D(this,"parent");D(this,"errors",[]);D(this,"project");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);this.initialData=n,this.project=o,this.id=n.id,this.x=n.x,this.y=n.y}static new(n=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||L().toISOString(),author:(n==null?void 0:n.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:p.Operation,declaration:null,inputs:[],outputs:[],process:null,error:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(n,o){let l=o;if(n.parent){const V=Q(n.parent);l=o.get(V)}const f=Q(n.declaration),t=o.get(f),m=n.calledByEntry.map(V=>{const B=Q(V);return o.get(B)}),E=n.calledBySuccess.map(V=>{const B=Q(V);return o.get(B)}),A=n.calledByError.map(V=>{const B=Q(V);return o.get(B)}),g={id:n.id,version:P.UUID.uuid(),createdAt:L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:p.Operation,declaration:t,calledByEntry:m,calledBySuccess:E,calledByError:A,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:l},w=Y(g,o);return w.setParent(l,null),w.initChildren(null),w}static validateGenerationTarget(n,o){let l=JSON.parse(JSON.stringify(n));const f=[],t=Cr(l,{parent:{list:!1,types:[...br,p.Project],optional:!0}},o);l=t.modifiedData,f.push(...t.errors,...ur(l));const m=Q(l.declaration);if(m){const E=sU(m,o);f.push(...E)}else{const E=`
|
|
63
|
+
Alternatively you can update the entity with 'update' action. Or replace it by first removing it and then creating a new one.`,issue:null}))}g===p.DataType&&(!l.parentRelationType||!(l.parentRelationType===Gr.AndDataTypeGroup||l.parentRelationType===Gr.OrDataTypeGroup))&&f.push(new W({id:`${n.id}--${k.InvalidParentRelationType}`,code:k.InvalidParentRelationType,severity:S.Error,message:`The entity with id '${n.id}' and type '${n.type}', must have a 'parentRelationType' property set to either 'or-data-type-group' or 'and-data-type-group' when being added as a child to an entity of type 'data-type'.`,issue:null}))}return{errors:f,modifiedData:l}}get isGroup(){const n=[...this.andChildrenGroup||[],...this.orChildrenGroup||[]];if(n.length>1){let o=0;for(const l of n)if(l.isResolved&&(o++,o>1))return!0}return!1}get isResolved(){return[p.BuiltInBaseEntity,p.ActionDescriptor].includes(this.parent.type)||Ka(this.parent)?!0:!(!this.entity&&!this.isGroup)}validateGeneratedUpdate(n){return{errors:[],modifiedData:n}}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,L().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=[];return o==="entity"&&this.setEntity(n,l),{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}onDetachedDependencyRestored(n,o,l){const f=[],t=[],m=[],E=[];return o==="entity"&&this.setEntity(null,l),{updated:R(f),added:R(t),removed:R(m),affected:R(E),self:this}}unsubscribeFromDependencies(){var n,o;return(o=(n=this.entity)==null?void 0:n.unsubscribeDependents)==null||o.call(n,[{entity:this,field:"entity"}]),this}subscribeToDependencies(){var n,o;return(o=(n=this.entity)==null?void 0:n.subscribeDependents)==null||o.call(n,[{entity:this,field:"entity"}]),this}increaseVersion(n){if(n&&!L(n).isValid())throw new Error(`The shared timestamp '${n}' is not a valid ISO 8601 date string.`);return n&&L(n).isSame(L(this.createdAt))?this:(this.previousVersion=this.version,this.version=P.UUID.uuid(),this.createdAt=L(n).toISOString()||L().toISOString(),this)}captureVersion(){var o;const n=((o=this.knownVersions)==null?void 0:o.get(this.version))||new pt(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.entity=this.entity,n.andChildrenGroup=this.andChildrenGroup?[...this.andChildrenGroup]:this.andChildrenGroup,n.orChildrenGroup=this.orChildrenGroup?[...this.orChildrenGroup]:this.orChildrenGroup,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[V,B]of w.knownVersions)A.set(V,B);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 pt(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.entity=m.entity,this.andChildrenGroup=m.andChildrenGroup,this.orChildrenGroup=m.orChildrenGroup,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.entity){const t=Q(this.initialData.entity),m=this.project.get(t);m&&(m.type===p.DefinitionEntity&&m.parent===this||(this.setEntity(m,null),m.type!==p.BuiltInBaseEntity&&m.type!==p.PrimitiveEntity&&n.push(m)))}return{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,L().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,L().toISOString(),this,!0,"add-self-to-project"))){const o=[this],l=[],f=[],t=[];return this.parent.type===p.DataType?this.parentRelationType===Gr.AndDataTypeGroup?this.parent.addToAndGroup(this):this.parentRelationType===Gr.OrDataTypeGroup&&this.parent.addToOrGroup(this):this.parent.setDataType(this,n),o.push(this.parent),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,L().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}removeChildGroup(n){if(this.andChildrenGroup){const o=this.andChildrenGroup.findIndex(l=>l.id===n.id);o!==-1&&this.andChildrenGroup.splice(o,1)}if(this.orChildrenGroup){const o=this.orChildrenGroup.findIndex(l=>l.id===n.id);o!==-1&&this.orChildrenGroup.splice(o,1)}return this}initChildren(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"init-children"))){var o,l,f,t;if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.entity)if(this.initialData.entity.type===p.GenericReference){const m=this.project.findSubscribedInstanceFromReference(this.initialData.entity);this.entity=m}else this.entity=Y(this.initialData.entity,this.project),((l=(o=this.initialData.entity)==null?void 0:o.parent)==null?void 0:l.id)===this.id&&this.entity.setParent(this,null),(t=(f=this.entity).initChildren)==null||t.call(f,n);return this.initialData.andChildrenGroup&&(this.andChildrenGroup=this.initialData.andChildrenGroup.map(m=>{const E=Y(m,this.project);return E.setParent(this,null),E.initChildren(n),E})),this.initialData.orChildrenGroup&&(this.orChildrenGroup=this.initialData.orChildrenGroup.map(m=>{const E=Y(m,this.project);return E.setParent(this,null),E.initChildren(n),E})),this.subscribeToDependencies(),this.afterAllChildrenInitialized(n),n==null||n.attemptAutoclose("init-children",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,L().toISOString(),this,!0,"meta-sync"))){const l=cr(this,n),f=this.toMeta();return this.options=n.options||f.options,this.parentRelationType=n.parentRelationType||f.parentRelationType,this.isList=n.isList!==void 0?n.isList:f.isList,this.inferred=n.inferred!==void 0?n.inferred:f.inferred,this.like=n.like!==void 0?n.like:f.like,this.asType=n.asType!==void 0?n.asType:f.asType,this.implementationChooseOne=n.implementationChooseOne!==void 0?n.implementationChooseOne:f.implementationChooseOne,this.staticEntities=n.staticEntities!==void 0?n.staticEntities:f.staticEntities,this.interactiveEntities=n.interactiveEntities!==void 0?n.interactiveEntities:f.interactiveEntities,this.actionEntities=n.actionEntities!==void 0?n.actionEntities:f.actionEntities,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 pt.repository.APILoad(this.id,...o),this}async APICreate(n=oe,...o){return await pt.repository.APICreate(this.toShallowJSON(),...o),this}async APIUpdate(n=oe,...o){return await pt.repository.APIUpdate(this.toShallowJSON(),...o),this}async APIDelete(n=oe,...o){return await pt.repository.APIDelete(this.toShallowJSON(),...o),this}async APIClone(n=oe,...o){return await pt.repository.APIClone(this.id,...o),this}async APILoadVersion(n=oe,o,...l){return await pt.repository.APILoadVersion(this.id,o,...l)}remove({ignoreUpstream:n}={ignoreUpstream:!1},o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"remove-entity"))){var E;if(this.id==="iterate-over-string-loop-string-argument-declaration-data-type-id")throw new Error("You are trying to remove the iterate-over-string-loop-string-argument-declaration-data-type-id entity. This is not allowed.");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:V}=A.entity.onDetachedDependencyRemoved(this,A.field,o);l.push(...g),f.push(...w),t.push(...V)}),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:A,removed:g}=this.entity.remove({ignoreUpstream:!0},o);l.push(...A),f.push(...g)}if(!n){((E=this.parent)==null?void 0:E.type)===p.DataType&&this.parent.removeChildGroup(this);const A=this.parent;if((A==null?void 0:A.type)===p.DataType){if(this.parentRelationType===Gr.AndDataTypeGroup){if(Array.isArray(A.andChildrenGroup)){const g=A.andChildrenGroup.findIndex(w=>w.id===this.id);g!==-1&&A.andChildrenGroup.splice(g,1)}}else if(this.parentRelationType===Gr.OrDataTypeGroup&&Array.isArray(A.orChildrenGroup)){const g=A.orChildrenGroup.findIndex(w=>w.id===this.id);g!==-1&&A.orChildrenGroup.splice(g,1)}}else{const g=this.parent;g==null||g.removeDataType()}A&&l.push(A)}return 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,L().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.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:m}=this.entity.restore({},n);l.push(...m)}if(this.parent.type===p.DataType){const m=this.parent;Array.isArray(m.andChildrenGroup)&&m.andChildrenGroup.push(this)}if(this.parent.type===p.DataType){const m=this.parent;this.parentRelationType===Gr.AndDataTypeGroup?Array.isArray(m.andChildrenGroup)&&m.andChildrenGroup.push(this):this.parentRelationType===Gr.OrDataTypeGroup&&Array.isArray(m.orChildrenGroup)&&m.orChildrenGroup.push(this)}else{const m=this.parent;m.setDataType(this,n),l.push(m)}return 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){var l,f,t;return n.has(this.id)?[]:(n.add(this.id),[this,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(m=>m.toFlat(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(m=>m.toFlat(n)))||[],...((t=this.entity)==null?void 0:t.toFlat(n))||[]])}toFlatIds(n=new Set){var l,f,t;return n.has(this.id)?[]:(n.add(this.id),[this.id,...((l=this.andChildrenGroup)==null?void 0:l.flatMap(m=>m.toFlatIds(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(m=>m.toFlatIds(n)))||[],...((t=this.entity)==null?void 0:t.toFlatIds(n))||[]])}toMeta(){return{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,like:this.like,isList:this.isList,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,options:this.options,asType:this.asType,type:this.type}}toJSON(n=new Set){var o,l,f,t;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,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((o=this.andChildrenGroup)==null?void 0:o.map(m=>m.toJSON(n)))||null,orChildrenGroup:((l=this.orChildrenGroup)==null?void 0:l.map(m=>m.toJSON(n)))||null,entity:((f=this.entity)==null?void 0:f.parent)===this?this.entity.toJSON(n):((t=this.entity)==null?void 0:t.toReference())||null,parent:this.parent.toReference()})}toJSONClone(n=$e){var l,f,t,m,E,A,g,w,V;let o;return(l=n.seenEntityMaps)!=null&&l.has(this.id)?o=n.seenEntityMaps.get(this.id):(o=n.newId||hr(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||L().toISOString(),previousVersion:null,author:this.author,deleted:this.deleted,type:this.type,options:this.options,isList:this.isList,asType:this.asType,like:this.like,inferred:this.inferred,parentRelationType:this.parentRelationType,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((A=this.andChildrenGroup)==null?void 0:A.map(B=>B.toJSONClone({...n,newId:null})))||null,orChildrenGroup:((g=this.orChildrenGroup)==null?void 0:g.map(B=>B.toJSONClone({...n,newId:null})))||null,entity:((w=this.entity)==null?void 0:w.parent)===this?this.entity.toJSONClone({...n,newId:null}):((V=this.entity)==null?void 0:V.toReference({seenEntityMaps:n.seenEntityMaps}))||null,parent:this.parent.toReference({seenEntityMaps:n.seenEntityMaps})})}toReference(n=$e){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=$e){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,isList:this.isList,options:this.options,asType:this.asType,parentRelationType:this.parentRelationType,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,andChildrenGroup:((f=this.andChildrenGroup)==null?void 0:f.map(E=>E.toReference(n)))||null,orChildrenGroup:((t=this.orChildrenGroup)==null?void 0:t.map(E=>E.toReference(n)))||null,entity:((m=this.entity)==null?void 0:m.toReference(n))||null,parent:this.parent.toReference(n)}}toFlatJSON(n=new Set){var l,f,t;return n.has(this.id)?[]:(n.add(this.id),[this.toShallowJSON(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(m=>m.toFlatJSON(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(m=>m.toFlatJSON(n)))||[],...((t=this.entity)==null?void 0:t.toFlatJSON(n))||[]])}toGenerationTarget(){var n;return{id:this.id,type:this.type,options:this.options||void 0,isList:this.isList,like:this.like,parentRelationType:this.parentRelationType||void 0,asType:this.asType,entity:((n=this.entity)==null?void 0:n.id)||null,parent:this.parent.id}}toFlatGenerationTarget(n=new Set){var l,f;return n.has(this.id)?[]:(n.add(this.id),[this.toGenerationTarget(),...((l=this.andChildrenGroup)==null?void 0:l.flatMap(t=>t.toFlatGenerationTarget(n)))||[],...((f=this.orChildrenGroup)==null?void 0:f.flatMap(t=>t.toFlatGenerationTarget(n)))||[],...this.entity&&this.entity.type==p.DefinitionEntity&&this.entity.parent===this&&this.entity.toFlatGenerationTarget(n)||[]])}clearErrors(){var n,o,l,f;return this.errors=[],(n=this.andChildrenGroup)==null||n.forEach(t=>t.clearErrors()),(o=this.orChildrenGroup)==null||o.forEach(t=>t.clearErrors()),this.inferred&&this.entity&&this.entity.type===p.DefinitionEntity&&((l=this.entity)==null?void 0:l.parent)===this&&((f=this.entity)==null||f.clearErrors()),this}validate(){const n=nM(this);return this.errors=n,{success:!0,error:null,data:this.toJSON()}}getErrors(){return[...this.errors]}getShallowErrors(){return this.errors}clone(n=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"clone-entity")),o=null,l=null,f=!0){var B,K,q;let t=yr(o,this),m=o||this.parent;const A={id:l||P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||L().toISOString(),author:(n==null?void 0:n.author)||"1",previousVersion:null,deleted:!1,type:p.DataType,isList:this.isList,asType:this.asType,options:this.options,parentRelationType:this.parentRelationType,staticEntities:this.staticEntities,interactiveEntities:this.interactiveEntities,actionEntities:this.actionEntities,like:this.like,inferred:this.inferred,implementationChooseOne:this.implementationChooseOne,andChildrenGroup:null,orChildrenGroup:null,entity:null,parent:m.toReference()},g=er(A,t);o&&g.setParent(o,null),f&&g.subscribe(),g.initChildren(n),n==null||n.add(g,G.Added);const w=(B=this.andChildrenGroup)==null?void 0:B.map(Z=>Z.clone(n,g,P.UUID.uuid(),f)),V=(K=this.orChildrenGroup)==null?void 0:K.map(Z=>Z.clone(n,g,P.UUID.uuid(),f));if(g.andChildrenGroup=w||null,g.orChildrenGroup=V||null,this.entity&&this.entity.type===p.DefinitionEntity&&((q=this.entity)==null?void 0:q.parent)===this){const Z=this.entity.clone(n,g,P.UUID.uuid(),f);g.setEntity(Z,n)}else this.entity&&g.setEntity(this.entity,n);return n==null||n.attemptAutoclose("clone-entity",this.id),g}merge(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"merge-entity"))){const l=[],f=[],t=[],m=[];if(this.asType!==(n==null?void 0:n.asType)&&(this.metaSync({asType:n==null?void 0:n.asType},o),o==null||o.add(this,G.Updated),l.push(this)),this.isList!==(n==null?void 0:n.isList)&&(this.metaSync({isList:n==null?void 0:n.isList},o),o==null||o.add(this,G.Updated),l.push(this)),this.like!==(n==null?void 0:n.like)&&(this.metaSync({like:n==null?void 0:n.like},o),o==null||o.add(this,G.Updated),l.push(this)),n!=null&&n.inferred){if(n.entity&&n.entity.type===p.DefinitionEntity&&n.entity.parent===n){const E=n.entity.clone(o,this,P.UUID.uuid(),!0);this.setEntity(E,o),f.push(E)}else n.entity&&(this.setEntity(n.entity,o),o==null||o.add(this,G.Updated),l.push(this));this.inferred||(this.metaSync({inferred:!0},o),o==null||o.add(this,G.Updated),l.push(this))}else if(this.inferred){if(this.metaSync({inferred:!1},o),o==null||o.add(this,G.Updated),l.push(this),this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent===this){const{updated:E,removed:A}=this.entity.remove({ignoreUpstream:!0},o);t.push(...A),E.push(...E)}n.entity!==this.entity&&(this.setEntity(n.entity,o),o==null||o.add(this,G.Updated),l.push(this))}else n.entity!==this.entity&&(this.setEntity(n.entity,o),o==null||o.add(this,G.Updated),l.push(this));return o==null||o.attemptAutoclose("merge-entity",this.id),{updated:R(l),added:R(f),removed:R(t),affected:R(m),self:this}}addToAndGroup(n){return this.andChildrenGroup||(this.andChildrenGroup=[]),this.andChildrenGroup.includes(n)||this.andChildrenGroup.push(n),this}addToOrGroup(n){return this.orChildrenGroup||(this.orChildrenGroup=[]),this.orChildrenGroup.includes(n)||this.orChildrenGroup.push(n),this}setEntity(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"set-data-type-entity-value"))){var f;const l=this.entity;return(l==null?void 0:l.id)!==(n==null?void 0:n.id)&&(this.entity=n,o==null||o.add(this,G.Affected),l&&l.type===p.DefinitionEntity&&((f=l.parent)==null?void 0:f.id)===this.id&&(l==null||l.remove({ignoreUpstream:!0},o))),o==null||o.attemptAutoclose("set-data-type-entity-value",this.id),this}isObject(){return!!this.entity&&(this.entity.type===p.DefinitionEntity||this.entity.type===p.BuiltInBaseEntity||this.entity.name===re.KeyValue)&&!this.isList}canBeObject(){let n=!1;if(this.parent.type!==p.DataType){const o=this.project.requestActiveValue(this.parent);o?!o.valueAsType&&(o.value===""||o.value===null||js(o))&&(n=!0):n=!0}return(this.isObject()||!this.entity||this.entity.name===re.Untyped)&&n}hasStrictObjectStructure(){var n;return this.isObject()&&((n=this.entity)==null?void 0:n.type)===p.DefinitionEntity}isInlineDeclaredEntity(){var n,o;return((n=this.entity)==null?void 0:n.type)===p.DefinitionEntity&&((o=this.entity.parent)==null?void 0:o.id)===(this==null?void 0:this.id)}isIndependentlyUserDeclaredEntity(){var n,o;return((n=this.entity)==null?void 0:n.type)===p.DefinitionEntity&&((o=this.entity)==null?void 0:o.parent)!==this}canModifyObjectStructure(){var o;const n=this.isIndependentlyUserDeclaredEntity();return(this.isInlineDeclaredEntity()||this.canBeObject()||((o=this.entity)==null?void 0:o.name)===re.KeyValue)&&!n}inferFromInputs(n,o=this.project.addChangeSet(new F(this.project,P.sessionAuthor,L().toISOString(),this,!0,"infer-data-type-from-inputs"))){var E;const l=[],f=[],t=[],m=[];if(!this.inferred)return o==null||o.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:[],added:[],removed:[],affected:[],self:this};if(!this.entity&&n.length){const A=ue(this.parent,this.project)+" data type definition",g={id:P.UUID.uuid(),type:p.DefinitionEntity,version:P.UUID.uuid(),createdAt:(o==null?void 0:o.timestamp)||L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,name:A,description:((E=this.parent)==null?void 0:E.description)||null,static:!0,abstract:!1,properties:[],methods:[],extends:[],implements:[],abstractMethods:[],x:0,y:0,parent:this.toReference()},w=Y(g,this.project);w.setParent(this,o),w.initChildren(o),o==null||o.add(w,G.Added),w.metaSync(g,o),this.setEntity(w,o),o==null||o.add(this,G.Updated)}if(this.entity&&this.entity.type===p.DefinitionEntity&&this.entity.parent!==this&&this.entity.setParent(this,o),this.entity){const{updated:A,added:g,removed:w,affected:V}=this.entity.inferFromInputs(n,o);f.push(...A),l.push(...g),t.push(...w),m.push(...V)}return this.like||this.metaSync({like:!0},o),o==null||o.attemptAutoclose("infer-data-type-from-inputs",this.id),{updated:R(f),added:R(l),removed:R(t),affected:R(m),self:this}}};D(pt,"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(pt,"type",p.DataType),D(pt,"USER_MANAGED_PARENT_TYPES",[p.Property,p.ArgumentDeclaration,p.ReturnDeclaration,p.VariableDeclaration,p.ValueDescriptor,p.InputMap,p.OutputMap,p.DataType]),D(pt,"PARENT_TYPES",[...pt.USER_MANAGED_PARENT_TYPES]),D(pt,"MUTABLE_BASE_PROPERTIES",["isList","asType","options","parentRelationType","like","implementationChooseOne","staticEntities","interactiveEntities","actionEntities"]),D(pt,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),D(pt,"BASE_PROPERTIES",[...pt.MUTABLE_BASE_PROPERTIES,...pt.INMUTABLE_BASE_PROPERTIES]),D(pt,"MUTABLE_META_PROPERTIES",[...pt.MUTABLE_BASE_PROPERTIES,"inferred"]),D(pt,"INMUTABLE_META_PROPERTIES",[...pt.INMUTABLE_BASE_PROPERTIES]),D(pt,"META_PROPERTIES",[...pt.MUTABLE_META_PROPERTIES,...pt.INMUTABLE_META_PROPERTIES]),D(pt,"MUTABLE_UPSTREAM_PROPERTIES",["entity","parent"]),D(pt,"INMUTABLE_UPSTREAM_PROPERTIES",[]),D(pt,"UPSTREAM_PROPERTIES",[...pt.MUTABLE_UPSTREAM_PROPERTIES,...pt.INMUTABLE_UPSTREAM_PROPERTIES]),D(pt,"MUTABLE_DOWNSTREAM_PROPERTIES",[]),D(pt,"INMUTABLE_DOWNSTREAM_PROPERTIES",["andChildrenGroup","orChildrenGroup"]),D(pt,"DOWNSTREAM_PROPERTIES",[...pt.MUTABLE_DOWNSTREAM_PROPERTIES,...pt.INMUTABLE_DOWNSTREAM_PROPERTIES]),D(pt,"PROPERTIES",[...pt.META_PROPERTIES,...pt.UPSTREAM_PROPERTIES,...pt.DOWNSTREAM_PROPERTIES]);let ts=pt;function aM(u){var m;const d=Ple(),n=u.toJSON();d.safeParse(n).success;const l=lpe(u),f=ta(u),t=[...l,...f];if(u.id==="exec-sequentially-operation-call-id"){const E=et({id:`${u.id}--${fe.PropertyImplementsNonAbstact}`,message:`Property "${ue(u,u.project)}" with id "${u.id}" implements a non-abstract property "${ue(u,u.project)}" with id "${u.id}".`,issue:null,severity:S.Error,code:fe.PropertyImplementsNonAbstact,entity:u});t.push(E.error)}return u.outputs.forEach(E=>E.validate()),(m=u.error)==null||m.validate(),qt(u.errors,t)}function lpe(u){const d=[];return u.inputs.forEach(n=>{n.validate()}),qt(u.errors,d)}const dpe=Object.freeze(Object.defineProperty({__proto__:null,validate:aM},Symbol.toStringTag,{value:"Module"}));var oM=(u=>(u.Parent="parent",u))(oM||{});const ft=class ft extends nr{constructor(n,o){super(n);D(this,"initialData");D(this,"id");D(this,"x");D(this,"y");D(this,"type",p.Operation);D(this,"declaration");D(this,"inputs",[]);D(this,"outputs",[]);D(this,"process",null);D(this,"successCalls",[]);D(this,"errorCalls",[]);D(this,"error",null);D(this,"calledBySuccess",[]);D(this,"calledByError",[]);D(this,"calledByEntry",[]);D(this,"parent");D(this,"errors",[]);D(this,"project");D(this,"detachedDependents",{});D(this,"knownVersions",null);D(this,"activeVersion",!1);D(this,"initialized",!1);D(this,"startedInitialization",!1);this.initialData=n,this.project=o,this.id=n.id,this.x=n.x,this.y=n.y}static new(n=null){return{id:P.UUID.uuid(),version:P.UUID.uuid(),createdAt:(n==null?void 0:n.timestamp)||L().toISOString(),author:(n==null?void 0:n.author)||P.sessionAuthor,previousVersion:null,deleted:!1,type:p.Operation,declaration:null,inputs:[],outputs:[],process:null,error:null,parent:null,calledByEntry:[],calledBySuccess:[],calledByError:[],errorCalls:[],successCalls:[],x:0,y:0}}static fromGenerationTarget(n,o){let l=o;if(n.parent){const V=Q(n.parent);l=o.get(V)}const f=Q(n.declaration),t=o.get(f),m=n.calledByEntry.map(V=>{const B=Q(V);return o.get(B)}),E=n.calledBySuccess.map(V=>{const B=Q(V);return o.get(B)}),A=n.calledByError.map(V=>{const B=Q(V);return o.get(B)}),g={id:n.id,version:P.UUID.uuid(),createdAt:L().toISOString(),author:P.sessionAuthor,previousVersion:null,deleted:!1,type:p.Operation,declaration:t,calledByEntry:m,calledBySuccess:E,calledByError:A,errorCalls:[],successCalls:[],inputs:[],outputs:[],process:null,error:null,x:0,y:0,parent:l},w=Y(g,o);return w.setParent(l,null),w.initChildren(null),w}static validateGenerationTarget(n,o){let l=JSON.parse(JSON.stringify(n));const f=[],t=Cr(l,{parent:{list:!1,types:[...br,p.Project],optional:!0}},o);l=t.modifiedData,f.push(...t.errors,...ur(l));const m=Q(l.declaration);if(m){const E=sU(m,o);f.push(...E)}else{const E=`
|
|
64
64
|
All built-in 'action-descriptor' entity ids are:
|
|
65
65
|
- ${o.operationDeclarations.map(A=>`${A.id} (${ue(A,o)})`).join(`
|
|
66
66
|
- `)}.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyx-code/project-logic-tree",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6310",
|
|
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",
|