@elyx-code/project-logic-tree 0.0.6186 → 0.0.6187
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 +1 -1
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29129,7 +29129,7 @@ class A {
|
|
|
29129
29129
|
return this.autoclose && this.autoCloseActionName && this.autoCloseActionName === a && (this.self && e === ((t = this.self) == null ? void 0 : t.id) || !this.self) && await this.closeAsync(), this;
|
|
29130
29130
|
}
|
|
29131
29131
|
async closeAsync() {
|
|
29132
|
-
return this.open = !1, !this.isValid && this.self && !this.added[this.self.id] && !this.updated[this.self.id] && this.removed[this.self.id], this.isEmpty ? (this.project.discardChangeSet(this), this) : (
|
|
29132
|
+
return this.open = !1, !this.isValid && this.self && !this.added[this.self.id] && !this.updated[this.self.id] && this.removed[this.self.id], this.discardOrphans(), this.isEmpty ? (console.warn(`Empty change-set (${this.id}) discarded upon closing.`), this.project.discardChangeSet(this), this) : (await this.project.closeChangeSet(this), this);
|
|
29133
29133
|
}
|
|
29134
29134
|
attemptAutoclose(a, e) {
|
|
29135
29135
|
var t;
|
package/dist/index.umd.cjs
CHANGED
|
@@ -40,7 +40,7 @@ Please provide a unique 'name' string.`,severity:D.Error,code:j.NameNotUniqueInS
|
|
|
40
40
|
Please provide a unique 'name' string.`,severity:D.Error,code:j.NameNotUniqueInScope,issue:null}))}}return e}function Tc(i,s){const e=[];i.name||e.push(new P({id:`${i.id}--${j.EmptyName}`,message:`Entity with id "${i.id}" and type "${i.type}" has an empty name. Please provide a 'name' string.`,severity:D.Error,code:j.EmptyName,issue:null}));const t=B(i.parent);if(!t)e.push(new P({id:`${i.id}--parent-reference--${A.InvalidReferenceObjectStructure}`,message:`Reference object at 'parent' property for entity with id "${i.id}" and type "${i.type}" is not a valid reference. A reference needs to be a 'id' string of an existing entity in the project.`,severity:D.Error,code:A.InvalidReferenceObjectStructure,issue:null}));else{const r=s.get(t);if(!r)e.push(new P({id:`${i.id}--parent-reference--${A.ReferencedEntityNotFound}`,message:`The entity with id '${t}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:D.Error,code:A.ReferencedEntityNotFound,issue:null}));else{const d=xc(r).filter(o=>o.name===i.name);d.length&&e.push(new P({id:`${i.id}--${j.NameNotUniqueInScope}`,message:`Entity with id "${i.id}" and type "${i.type}" has a name "${i.name}" that is not unique among all inputs declared in the parent entity. Entity with id "${d[0].id}" has the same name.
|
|
41
41
|
Please provide a unique 'name' string.`,severity:D.Error,code:j.NameNotUniqueInScope,issue:null}))}}return e}function Ec(i,s){const e=[];i.name||e.push(new P({id:`${i.id}--${j.EmptyName}`,message:`Entity with id "${i.id}" and type "${i.type}" has an empty name. Please provide a 'name' string.`,severity:D.Error,code:j.EmptyName,issue:null}));const t=B(i.parent);if(!t)e.push(new P({id:`${i.id}--parent-reference--${A.InvalidReferenceObjectStructure}`,message:`Reference object at 'parent' property for entity with id "${i.id}" and type "${i.type}" is not a valid reference. A reference needs to be a 'id' string of an existing entity in the project.`,severity:D.Error,code:A.InvalidReferenceObjectStructure,issue:null}));else{const r=s.get(t);if(!r)e.push(new P({id:`${i.id}--parent-reference--${A.ReferencedEntityNotFound}`,message:`The entity with id '${t}' that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,severity:D.Error,code:A.ReferencedEntityNotFound,issue:null}));else{const d=fP(r).filter(o=>o.name===i.name);d.length&&e.push(new P({id:`${i.id}--${j.NameNotUniqueInScope}`,message:`Entity with id "${i.id}" and type "${i.type}" has a name "${i.name}" that is not unique among all outputs declared in the parent entity. Entity with id "${d[0].id}" has the same name.
|
|
42
42
|
Please provide a unique 'name' string.`,severity:D.Error,code:j.NameNotUniqueInScope,issue:null}))}}return e}function F7(i,s){switch(i.type){case n.DefinitionEntity:return yc(i,s);case n.FunctionDeclaration:return hc(i,s);case n.VariableDeclaration:return mc(i,s);case n.Property:return vc(i,s);case n.ArgumentDeclaration:return Tc(i,s);case n.ReturnDeclaration:return Ec(i,s);default:return[]}}function q1(i,s,e){const r=`${Vd(i)}-${s}-id`;return e.instances[r]?I.UUID.uuid():r}function Ic(i,s){let e="",t=null;if(i.parent){const a=s.get(i.parent);a&&(t=a)}let r="";return t&&(r=`${Vd(F(t,s))}-`),e=`${r}${Vd(F(i,s))}-id`,s.instances[e]?I.UUID.uuid():e}function ct(i,s,e="uuid"){return e==="semantic"?q1(F(i,s),i.type,s):I.UUID.uuid()}function x7(i){var d;const s=l6(),e=i.toJSON();s.safeParse(e).success;const r=S7(i);(d=i.dataType)==null||d.validate();const a=[...r];if(i.id==="80c86e1b-caca-4ba5-9b1f-38f72d10e4a3"){const o=ye({id:`${i.id}--${q.PropertyImplementsNonAbstact}`,message:`Property "${F(i,i.project)}" with id "${i.id}" implements a non-abstract property "${F(i,i.project)}" with id "${i.id}".`,issue:null,severity:D.Error,code:q.PropertyImplementsNonAbstact,entity:i});a.push(o.error)}return a}function S7(i){const s=[];if(!i.implements)return s;const e=i.implements;if(!e.abstract){const r=ye({id:`${i.id}--${q.PropertyImplementsNonAbstact}`,message:`Property "${F(i,i.project)}" with id "${i.id}" implements a non-abstract property "${F(e,i.project)}" with id "${e.id}".`,issue:null,severity:D.Error,code:q.PropertyImplementsNonAbstact,entity:i});s.push(r.error)}if(i.static&&!e.static){const r=ye({id:`${i.id}--${q.NonStaticPropertyImplementsStatic}`,message:`Static property "${F(i,i.project)}" with id "${i.id}" implements a non-static property "${F(e,i.project)}" with id "${e.id}".`,issue:null,severity:D.Error,code:q.NonStaticPropertyImplementsStatic,entity:i});s.push(r.error)}if(!i.static&&e.static){const r=ye({id:`${i.id}--${q.StaticPropertyImplementsNonStatic}`,message:`Non-static property "${F(i,i.project)}" with id "${i.id}" implements a static property "${F(e,i.project)}" with id "${e.id}".`,issue:null,severity:D.Error,code:q.StaticPropertyImplementsNonStatic,entity:i});s.push(r.error)}if(!Ir(i.dataType,e.dataType)){const r=ye({id:`${i.id}--${q.PropertyImplementsIncompatibleType}`,message:`Property "${F(i,i.project)}" with id "${i.id}" implements a property "${F(e,i.project)}" with id "${e.id}" that has an incompatible data type.`,issue:null,severity:D.Error,code:q.PropertyImplementsIncompatibleType,entity:i});s.push(r.error)}return ze(i.errors,s)}function k7(i,s){const e=[];if(i.parent){const r=s.get(i.parent);if(!r)e.push(new P({id:`${i.id}--${i.parent}--${A.ReferencedEntityNotFound}`,code:A.ReferencedEntityNotFound,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${i.parent}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const a=zi(r);if(a){const d=r!==a?`The entity of type '${i.type}' with id '${i.id}' have 'parent' with id '${i.parent}' because the entity belongs to a built-in '${a.type}' entity with id '${a.id}' (${F(a,r.project)}) higher up in the tree.`:`The entity of type '${i.type}' with id '${i.id}' have 'parent' with id '${i.parent}' because it is a built-in entity of type ${a.type}.`;e.push(new P({id:`${i.id}--${A.InvalidBuiltInEntityReference}`,code:A.InvalidBuiltInEntityReference,severity:D.Error,message:d,issue:null}))}else if(![n.DefinitionEntity].includes(r.type))e.push(new P({id:`${i.id}--${i.parent}--${A.InvalidParentReference}`,code:A.InvalidParentReference,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a parent reference that isn't pointing to an entity of type 'definition-entity'.`,issue:null}));else{const o=Wi(r).filter(l=>!l.interactive);if(o.length){let l=o.length>1?`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${r.id}' because it extends or implements multiple '${n.BuiltInBaseEntity}' entities that are non-interactive ("${ie(o.map(u=>F(u,u.project)),'", "','" and "')}").`:`The entity of type '${i.type}' with id '${i.id}' can't be added to the 'parent' entity with id '${r.id}' because it extends or implements a '${n.BuiltInBaseEntity}' entity that is non-interactive ("${F(o[0],o[0].project)}").`;l+=`
|
|
43
|
-
${Zi}`,e.push(new P({id:`${i.id}--${A.NonInteractiveEntityReferenced}`,code:A.NonInteractiveEntityReferenced,severity:D.Error,message:l,issue:null}))}else if(i.implements){const l=s.get(i.implements);if(i.id===i.implements)return e.push(new P({id:`${i.id}--${i.implements}--${A.SelfReference}`,code:A.SelfReference,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a reference to itself at 'implements'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null})),e;if(!l)e.push(new P({id:`${i.id}--${i.implements}--${A.ReferencedEntityNotFound}`,code:A.ReferencedEntityNotFound,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${i.implements}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const u=r.properties.find(h=>{var c;return((c=h.implements)==null?void 0:c.id)===i.implements});u?e.push(new P({id:`${i.id}--${j.PropertyOverwrite}`,code:j.PropertyOverwrite,severity:D.Error,message:`The property with id "${i.id}" is trying to implement the property with id "${i.implements}", but the parent entity already has a property with id '${u.id}' that implements the same base property.`,issue:null})):[n.Property].includes(l.type)?l.abstract||e.push(new P({id:`${i.id}--${i.implements}--${A.InvalidImplementsReference}`,code:A.InvalidImplementsReference,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):e.push(new P({id:`${i.id}--${i.implements}--${A.InvalidImplementsReference}`,code:A.InvalidImplementsReference,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an entity of type 'property'.`,issue:null}))}}}}}const t=Et(i,{},s);return e.push(...t.errors),e}class rt{constructor(s){f(this,"version");f(this,"previousVersion",null);f(this,"createdAt");f(this,"deleted",!1);f(this,"author");this.version=s.version,this.previousVersion=s.previousVersion,this.createdAt=T(s.createdAt).toISOString(),this.deleted=s.deleted,this.author=s.author}metaSync(s){this.deleted=s.deleted!==void 0?s.deleted:this.deleted}}var Ac=(i=>(i.Manual="manual",i.Automatic="automatic",i))(Ac||{}),b=(i=>(i.Added="added",i.Updated="updated",i.Removed="removed",i.Affected="affected",i))(b||{});class R{constructor(s,e,t,r,a=!1,d=""){f(this,"id",I.UUID.uuid());f(this,"seenEntities",[]);f(this,"added",{});f(this,"updated",{});f(this,"removed",{});f(this,"affected",{});f(this,"self",null);f(this,"author");f(this,"timestamp");f(this,"open",!0);f(this,"dirty",!0);f(this,"type","manual");f(this,"autoclose",!1);f(this,"autoCloseActionName","");f(this,"project");if(this.project=s,this.author=e||I.sessionAuthor||"",this.timestamp=t,this.self=r,this.autoclose=a,this.autoCloseActionName=d,this.autoclose&&!this.autoCloseActionName)throw new Error("Auto-close change-set must have an auto-close action name.")}get isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.updated).length===0&&Object.keys(this.removed).length===0}get isValid(){var s;return!(this.isEmpty&&this.self&&!this.affected[(s=this.self)==null?void 0:s.id])}get list(){return[...Object.values(this.added),...Object.values(this.updated),...Object.values(this.removed)]}get listAdded(){return Object.values(this.added)}get listUpdated(){return Object.values(this.updated)}get listRemoved(){return Object.values(this.removed)}get listAffected(){return Object.values(this.affected)}get addedIds(){return Object.keys(this.added)}get updatedIds(){return Object.keys(this.updated)}get removedIds(){return Object.keys(this.removed)}get affectedIds(){return Object.keys(this.affected)}discardOrphans(){const s=[...this.addedIds,...this.updatedIds],e=this.project.toFlatIds(),t=Vr(),r=e.filter(d=>!t.includes(d));s.filter(d=>!r.includes(d)).forEach(d=>{this.remove(d)})}async attemptAutocloseAsync(s,e){var t;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===s&&(this.self&&e===((t=this.self)==null?void 0:t.id)||!this.self)&&await this.closeAsync(),this}async closeAsync(){return this.open=!1,!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.isEmpty?(this.project.discardChangeSet(this),this):(this.discardOrphans(),await this.project.closeChangeSet(this),this)}attemptAutoclose(s,e){var t;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===s&&(this.self&&e===((t=this.self)==null?void 0:t.id)||!this.self)&&this.close(),this}close(){return this.open=!1,!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.isEmpty?(this.project.discardChangeSet(this),this):(this.discardOrphans(),this.project.closeChangeSet(this),this)}get(s){return this.added[s]?this.added[s]:this.updated[s]?this.updated[s]:this.removed[s]?this.removed[s]:null}remove(s){return this.has(s)&&(delete this.added[s],delete this.updated[s],delete this.removed[s],delete this.affected[s],this.seenEntities=this.seenEntities.filter(e=>e!==s)),this}add(s,e){if(!this.open||!this.dirty)return this;const t=Array.from(new Set([...this.project.getAllBuiltInIds(),...Vr()]));if(t.includes(s.id))return this;if(!Xd(s,{...this.project.instances,...this.project.builtInInstances}).every(d=>!t.includes(d)))return this;if(this.seenEntities.indexOf(s.id)===-1&&this.seenEntities.push(s.id),(e==="updated"||e==="removed")&&!this.has(s.id)&&s.createdAt!==this.timestamp){s.increaseVersion(this.timestamp);const{added:d,updated:o,removed:l,affected:u}=s.recursiveCaptureUpstreamVersions(this.timestamp);for(const h of d)this.add(h,"added");for(const h of o)this.add(h,"updated");for(const h of l)this.add(h,"removed");for(const h of u)this.add(h,"affected")}if(e==="added"&&!this.has(s.id)&&s.createdAt!==this.timestamp){const{added:d,updated:o,removed:l,affected:u}=s.recursiveCaptureUpstreamVersions(this.timestamp);for(const h of d)this.add(h,"added");for(const h of o)this.add(h,"updated");for(const h of l)this.add(h,"removed");for(const h of u)this.add(h,"affected")}if(e==="removed"){if(this.added[s.id])return delete this.added[s.id],this.seenEntities=this.seenEntities.filter(d=>d!==s.id),delete this.project.deletedInstances[s.id],this;this.updated[s.id]&&delete this.updated[s.id],this.affected[s.id]&&delete this.affected[s.id],this.removed[s.id]=s}if(e==="added"){if(this.removed[s.id])return this;this.updated[s.id]&&delete this.updated[s.id],this.affected[s.id]&&delete this.affected[s.id],this.added[s.id]=s}if(e==="updated"){if(this.removed[s.id])return this;if(this.added[s.id])return this;this.affected[s.id]&&delete this.affected[s.id],this.updated[s.id]=s}if(e==="affected"){if(this.removed[s.id])return this;if(this.added[s.id])return this;if(this.updated[s.id])return this;this.affected[s.id]=s}return this}toJSON(){const s={},e={},t={},r=new Set;for(const a of Object.values(this.added))s[a.id]=a.toShallowJSON();for(const a of Object.values(this.updated))e[a.id]=a.toShallowJSON();for(const a of Object.values(this.removed))t[a.id]=a.toShallowJSON();for(const a of Object.values(this.affected))r.add(a.id);return{added:s,updated:e,removed:t,affected:Array.from(r),self:this.self?this.self.toShallowJSON():null,seenEntities:this.seenEntities}}has(s){return!!this.added[s]||!!this.removed[s]||!!this.updated[s]||!!this.affected[s]}hasAdded(s){return!!this.added[s]}hasUpdated(s){return!!this.updated[s]}hasRemoved(s){return!!this.removed[s]}hasAffected(s){return!!this.affected[s]}}function Z7(i){return new Set([...Object.keys(i.added),...Object.keys(i.updated),...Object.keys(i.removed),...Array.from(i.affected)])}var J1=(i=>(i.Implements="implements",i.DataTypeEntity="data-type-entity",i))(J1||{});const Ie=class Ie extends rt{constructor(e,t){super(e);f(this,"initialData");f(this,"id");f(this,"name");f(this,"description",null);f(this,"private");f(this,"abstract");f(this,"index");f(this,"static");f(this,"required");f(this,"constant",!1);f(this,"type",n.Property);f(this,"hidden",!1);f(this,"defaultValue",null);f(this,"dataType",null);f(this,"implements",null);f(this,"project");f(this,"errors",[]);f(this,"parent");f(this,"detachedDependents",{});f(this,"knownVersions",null);f(this,"activeVersion",!1);f(this,"initialized",!1);f(this,"startedInitialization",!1);f(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.name=e.name,this.description=e.description,this.private=e.private,this.abstract=e.abstract,this.index=e.index,this.static=e.static,this.required=e.required||!1,this.hidden=e.hidden||!1,this.constant=e.constant||!1}static fromGenerationTarget(e,t){const r=B(e.parent),a=t.get(r);let d=null;if(e.implements){const u=B(e.implements);d=t.get(u)}const o={id:e.id,version:I.UUID.uuid(),createdAt:T().toISOString(),author:I.sessionAuthor,previousVersion:null,deleted:!1,name:e.name,type:n.Property,index:a.properties.length,private:e.private||!1,abstract:e.abstract||!1,static:e.static||!1,required:e.required||!1,constant:e.constant||!1,hidden:!1,description:e.description,defaultValue:null,implements:d,dataType:null,parent:a},l=V(o,t);return l.setParent(a,null),l.initChildren(null),l}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],d=k7(r,t),o=vc(r,t);return a.push(...d,...o,...ot(r)),{errors:a,modifiedData:r}}get isExtendedProperty(){const e=this.parent.allBasePropertiesFromExtendedAndImplementedEntities.find(t=>t.name===this.name);return!!e&&e.id!==this.id&&!e.abstract}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new P({id:`${this.id}--${A.InvalidParentUpdate}`,code:A.InvalidParentUpdate,severity:D.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
43
|
+
${Zi}`,e.push(new P({id:`${i.id}--${A.NonInteractiveEntityReferenced}`,code:A.NonInteractiveEntityReferenced,severity:D.Error,message:l,issue:null}))}else if(i.implements){const l=s.get(i.implements);if(i.id===i.implements)return e.push(new P({id:`${i.id}--${i.implements}--${A.SelfReference}`,code:A.SelfReference,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", has a reference to itself at 'implements'. This is not allowed. Change the reference string or the 'entityId' property of the reference object.`,issue:null})),e;if(!l)e.push(new P({id:`${i.id}--${i.implements}--${A.ReferencedEntityNotFound}`,code:A.ReferencedEntityNotFound,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", is referencing an entity with id "${i.implements}" that isn't yet found in the project. Perhaps it should be created first. Or perhaps the ID is incorrect.`,issue:null}));else{const u=r.properties.find(h=>{var c;return((c=h.implements)==null?void 0:c.id)===i.implements});u?e.push(new P({id:`${i.id}--${j.PropertyOverwrite}`,code:j.PropertyOverwrite,severity:D.Error,message:`The property with id "${i.id}" is trying to implement the property with id "${i.implements}", but the parent entity already has a property with id '${u.id}' that implements the same base property.`,issue:null})):[n.Property].includes(l.type)?l.abstract||e.push(new P({id:`${i.id}--${i.implements}--${A.InvalidImplementsReference}`,code:A.InvalidImplementsReference,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an abstract entity.`,issue:null})):e.push(new P({id:`${i.id}--${i.implements}--${A.InvalidImplementsReference}`,code:A.InvalidImplementsReference,severity:D.Error,message:`Entity of type "${i.type}" with id "${i.id}", has an 'implements' reference that isn't pointing to an entity of type 'property'.`,issue:null}))}}}}}const t=Et(i,{},s);return e.push(...t.errors),e}class rt{constructor(s){f(this,"version");f(this,"previousVersion",null);f(this,"createdAt");f(this,"deleted",!1);f(this,"author");this.version=s.version,this.previousVersion=s.previousVersion,this.createdAt=T(s.createdAt).toISOString(),this.deleted=s.deleted,this.author=s.author}metaSync(s){this.deleted=s.deleted!==void 0?s.deleted:this.deleted}}var Ac=(i=>(i.Manual="manual",i.Automatic="automatic",i))(Ac||{}),b=(i=>(i.Added="added",i.Updated="updated",i.Removed="removed",i.Affected="affected",i))(b||{});class R{constructor(s,e,t,r,a=!1,d=""){f(this,"id",I.UUID.uuid());f(this,"seenEntities",[]);f(this,"added",{});f(this,"updated",{});f(this,"removed",{});f(this,"affected",{});f(this,"self",null);f(this,"author");f(this,"timestamp");f(this,"open",!0);f(this,"dirty",!0);f(this,"type","manual");f(this,"autoclose",!1);f(this,"autoCloseActionName","");f(this,"project");if(this.project=s,this.author=e||I.sessionAuthor||"",this.timestamp=t,this.self=r,this.autoclose=a,this.autoCloseActionName=d,this.autoclose&&!this.autoCloseActionName)throw new Error("Auto-close change-set must have an auto-close action name.")}get isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.updated).length===0&&Object.keys(this.removed).length===0}get isValid(){var s;return!(this.isEmpty&&this.self&&!this.affected[(s=this.self)==null?void 0:s.id])}get list(){return[...Object.values(this.added),...Object.values(this.updated),...Object.values(this.removed)]}get listAdded(){return Object.values(this.added)}get listUpdated(){return Object.values(this.updated)}get listRemoved(){return Object.values(this.removed)}get listAffected(){return Object.values(this.affected)}get addedIds(){return Object.keys(this.added)}get updatedIds(){return Object.keys(this.updated)}get removedIds(){return Object.keys(this.removed)}get affectedIds(){return Object.keys(this.affected)}discardOrphans(){const s=[...this.addedIds,...this.updatedIds],e=this.project.toFlatIds(),t=Vr(),r=e.filter(d=>!t.includes(d));s.filter(d=>!r.includes(d)).forEach(d=>{this.remove(d)})}async attemptAutocloseAsync(s,e){var t;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===s&&(this.self&&e===((t=this.self)==null?void 0:t.id)||!this.self)&&await this.closeAsync(),this}async closeAsync(){return this.open=!1,!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.isEmpty?(console.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this):(await this.project.closeChangeSet(this),this)}attemptAutoclose(s,e){var t;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===s&&(this.self&&e===((t=this.self)==null?void 0:t.id)||!this.self)&&this.close(),this}close(){return this.open=!1,!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.isEmpty?(this.project.discardChangeSet(this),this):(this.discardOrphans(),this.project.closeChangeSet(this),this)}get(s){return this.added[s]?this.added[s]:this.updated[s]?this.updated[s]:this.removed[s]?this.removed[s]:null}remove(s){return this.has(s)&&(delete this.added[s],delete this.updated[s],delete this.removed[s],delete this.affected[s],this.seenEntities=this.seenEntities.filter(e=>e!==s)),this}add(s,e){if(!this.open||!this.dirty)return this;const t=Array.from(new Set([...this.project.getAllBuiltInIds(),...Vr()]));if(t.includes(s.id))return this;if(!Xd(s,{...this.project.instances,...this.project.builtInInstances}).every(d=>!t.includes(d)))return this;if(this.seenEntities.indexOf(s.id)===-1&&this.seenEntities.push(s.id),(e==="updated"||e==="removed")&&!this.has(s.id)&&s.createdAt!==this.timestamp){s.increaseVersion(this.timestamp);const{added:d,updated:o,removed:l,affected:u}=s.recursiveCaptureUpstreamVersions(this.timestamp);for(const h of d)this.add(h,"added");for(const h of o)this.add(h,"updated");for(const h of l)this.add(h,"removed");for(const h of u)this.add(h,"affected")}if(e==="added"&&!this.has(s.id)&&s.createdAt!==this.timestamp){const{added:d,updated:o,removed:l,affected:u}=s.recursiveCaptureUpstreamVersions(this.timestamp);for(const h of d)this.add(h,"added");for(const h of o)this.add(h,"updated");for(const h of l)this.add(h,"removed");for(const h of u)this.add(h,"affected")}if(e==="removed"){if(this.added[s.id])return delete this.added[s.id],this.seenEntities=this.seenEntities.filter(d=>d!==s.id),delete this.project.deletedInstances[s.id],this;this.updated[s.id]&&delete this.updated[s.id],this.affected[s.id]&&delete this.affected[s.id],this.removed[s.id]=s}if(e==="added"){if(this.removed[s.id])return this;this.updated[s.id]&&delete this.updated[s.id],this.affected[s.id]&&delete this.affected[s.id],this.added[s.id]=s}if(e==="updated"){if(this.removed[s.id])return this;if(this.added[s.id])return this;this.affected[s.id]&&delete this.affected[s.id],this.updated[s.id]=s}if(e==="affected"){if(this.removed[s.id])return this;if(this.added[s.id])return this;if(this.updated[s.id])return this;this.affected[s.id]=s}return this}toJSON(){const s={},e={},t={},r=new Set;for(const a of Object.values(this.added))s[a.id]=a.toShallowJSON();for(const a of Object.values(this.updated))e[a.id]=a.toShallowJSON();for(const a of Object.values(this.removed))t[a.id]=a.toShallowJSON();for(const a of Object.values(this.affected))r.add(a.id);return{added:s,updated:e,removed:t,affected:Array.from(r),self:this.self?this.self.toShallowJSON():null,seenEntities:this.seenEntities}}has(s){return!!this.added[s]||!!this.removed[s]||!!this.updated[s]||!!this.affected[s]}hasAdded(s){return!!this.added[s]}hasUpdated(s){return!!this.updated[s]}hasRemoved(s){return!!this.removed[s]}hasAffected(s){return!!this.affected[s]}}function Z7(i){return new Set([...Object.keys(i.added),...Object.keys(i.updated),...Object.keys(i.removed),...Array.from(i.affected)])}var J1=(i=>(i.Implements="implements",i.DataTypeEntity="data-type-entity",i))(J1||{});const Ie=class Ie extends rt{constructor(e,t){super(e);f(this,"initialData");f(this,"id");f(this,"name");f(this,"description",null);f(this,"private");f(this,"abstract");f(this,"index");f(this,"static");f(this,"required");f(this,"constant",!1);f(this,"type",n.Property);f(this,"hidden",!1);f(this,"defaultValue",null);f(this,"dataType",null);f(this,"implements",null);f(this,"project");f(this,"errors",[]);f(this,"parent");f(this,"detachedDependents",{});f(this,"knownVersions",null);f(this,"activeVersion",!1);f(this,"initialized",!1);f(this,"startedInitialization",!1);f(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.name=e.name,this.description=e.description,this.private=e.private,this.abstract=e.abstract,this.index=e.index,this.static=e.static,this.required=e.required||!1,this.hidden=e.hidden||!1,this.constant=e.constant||!1}static fromGenerationTarget(e,t){const r=B(e.parent),a=t.get(r);let d=null;if(e.implements){const u=B(e.implements);d=t.get(u)}const o={id:e.id,version:I.UUID.uuid(),createdAt:T().toISOString(),author:I.sessionAuthor,previousVersion:null,deleted:!1,name:e.name,type:n.Property,index:a.properties.length,private:e.private||!1,abstract:e.abstract||!1,static:e.static||!1,required:e.required||!1,constant:e.constant||!1,hidden:!1,description:e.description,defaultValue:null,implements:d,dataType:null,parent:a},l=V(o,t);return l.setParent(a,null),l.initChildren(null),l}static validateGenerationTarget(e,t){let r=JSON.parse(JSON.stringify(e));const a=[],d=k7(r,t),o=vc(r,t);return a.push(...d,...o,...ot(r)),{errors:a,modifiedData:r}}get isExtendedProperty(){const e=this.parent.allBasePropertiesFromExtendedAndImplementedEntities.find(t=>t.name===this.name);return!!e&&e.id!==this.id&&!e.abstract}validateGeneratedUpdate(e){const t=[];return e.parent&&t.push(new P({id:`${this.id}--${A.InvalidParentUpdate}`,code:A.InvalidParentUpdate,severity:D.Error,message:`Entity of type '${this.type}' with id '${this.id}' cannot have the 'parent' property updated, as it would mean moving the '${this.type}' entity to another parent entity.
|
|
44
44
|
This is likely an incorrect strategy, either the '${this.type}' entity doesn't need to be updated or it should be deleted and a new one created in the desired parent.`,issue:null})),(e.readsValue||e.writesValue)&&t.push(new P({id:`${this.id}--${j.InvalidObjectStructure}`,code:j.InvalidObjectStructure,severity:D.Error,message:`Entity of type '${this.type}' with id '${this.id}' is not a value reading or writing entity.
|
|
45
45
|
${Ld}`,issue:null})),{errors:t,modifiedData:e}}subscribeDependents(e){return e.forEach(t=>{this.detachedDependents[t.entity.id]||(this.detachedDependents[t.entity.id]=t)}),this}syncDependents(){const e=[],t=[],r=[],a=[];return Object.values(this.detachedDependents).forEach(d=>{const o=d.entity.afterAllChildrenInitialized();e.push(...o.updated),t.push(...o.added),r.push(...o.removed),a.push(...o.affected)}),{updated:p(e),added:p(t),removed:p(r),affected:p(a),self:this}}onDetachedDependencyRemoved(e,t,r){const a=[],d=[],o=[],l=[];return t==="implements"&&(this.setImplements(null,r),a.push(this)),{updated:p(a),added:p(d),removed:p(o),affected:p(l),self:this}}onDetachedDependencyRestored(e,t,r){const a=[],d=[],o=[],l=[];return t==="implements"&&(this.setImplements(e,r),a.push(this)),{updated:p(a),added:p(d),removed:p(o),affected:p(l),self:this}}subscribeToDependencies(){var e,t,r,a,d;return(t=(e=this.implements)==null?void 0:e.subscribeDependents)==null||t.call(e,[{entity:this,field:"implements"}]),(d=(a=(r=this.dataType)==null?void 0:r.entity)==null?void 0:a.subscribeDependents)==null||d.call(a,[{entity:this,field:"data-type-entity"}]),this}increaseVersion(e){if(e&&!T(e).isValid())throw new Error(`The shared timestamp '${e}' is not a valid ISO 8601 date string.`);return e&&T(e).isSame(T(this.createdAt))?this:(this.previousVersion=this.version,this.version=I.UUID.uuid(),this.createdAt=T(e).toISOString()||T().toISOString(),this)}captureVersion(){var t,r;const e=((t=this.knownVersions)==null?void 0:t.get(this.version))||new Ie(this,this.project);return(r=this.knownVersions)==null||r.set(this.version,e),e.defaultValue=this.defaultValue,e.dataType=this.dataType,e.implements=this.implements,e.parent=this.parent,this}recursiveCaptureUpstreamVersions(e){const t=[],r=[],a=[],d=[];if(this.parent&&this.parent.type!==n.PrimitiveEntity&&this.parent.type!==n.BuiltInBaseEntity){this.parent.increaseVersion(e);const o=this.parent.recursiveCaptureUpstreamVersions(e);t.push(this.parent,...o.updated),r.push(...o.added),a.push(...o.removed)}return{updated:p(t),added:p(r),removed:p(a),affected:p(d),self:this}}async restoreVersion(e){var l;const t=[],r=[],a=[],d=[];if(this.version===e)return{updated:p(t),added:p(r),removed:p(a),affected:p(d),self:this};if(!this.knownVersions){const u=new Map;for(const[h,c]of this.knownVersions||new Map){if(u.set(h,c),c.activeVersion=!1,c.knownVersions)for(const[v,E]of c.knownVersions)u.set(v,E);c.knownVersions=null}}let o=(l=this.knownVersions)==null?void 0:l.get(e);if(!o){const u=await this.APILoadVersion({},e);if(!u)throw new Error(`Version with id '${e}' for entity with id '${this.id}' not found.`);o=new Ie(u,this.project)}return this.metaSync(o.toShallowJSON(),null),this.defaultValue=o.defaultValue,this.dataType=o.dataType,this.implements=o.implements,this.parent=o.parent,{updated:p(t),added:p(r),removed:p(a),affected:p(d),self:this}}hydrateAncestors(){const e=[],t=[],r=[],a=[];if(this.initialData.parent){const d=B(this.initialData.parent),o=this.project.get(d);if(o)this.setParent(o,null),e.push(o);else throw new Error(`${Wt(this.type)} with id '${this.id}' has a parent reference "${d}" which is missing in the project`)}else throw new Error(`${Wt(this.type)} with id '${this.id}' is missing a parent reference`);if(this.initialData.implements){const d=B(this.initialData.implements),o=this.project.get(d);o&&(this.setImplements(o,null),e.push(o))}return{updated:p(e),added:p(t),removed:p(r),affected:p(a),self:this}}afterAllChildrenInitialized(e=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"after-all-children-initialized"))){const t=[],r=[],a=[],d=[];return this.initialized=!0,this.captureVersion(),e==null||e.attemptAutoclose("after-all-children-initialized",this.id),{updated:p(t),added:p(r),removed:p(a),affected:p(d),self:this}}addSelfToProject(e=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"add-self-to-project"))){const t=[this],r=[],a=[],d=[];return this.parent.addProperty(this),t.push(this.parent),this.subscribe(),this.subscribeToDependencies(),e==null||e.attemptAutoclose("add-self-to-project",this.id),{updated:p(t),added:p(r),removed:p(a),affected:p(d),self:this}}setParent(e,t=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"set-parent"))){var r;return((r=this.parent)==null?void 0:r.id)!==(e==null?void 0:e.id)&&(this.parent=e,t&&(t==null||t.add(this,b.Updated),t==null||t.attemptAutoclose("set-parent",this.id))),this}setImplements(e,t=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"set-implements"))){var r;return((r=this.implements)==null?void 0:r.id)!==(e==null?void 0:e.id)&&(this.implements=e,t&&(t==null||t.add(this,b.Updated),t==null||t.attemptAutoclose("set-implements",this.id))),this}initChildren(e=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"init-children"))){if(this.initialized||this.startedInitialization)return this;if(this.startedInitialization=!0,this.initialData.defaultValue&&(this.defaultValue=V(this.initialData.defaultValue,this.project),this.defaultValue.setParent(this,null),this.defaultValue.initChildren(e)),this.initialData.dataType){const t=V(this.initialData.dataType,this.project);t.setParent(this,null),t.initChildren(e),this.dataType=t}if(this.initialData.implements){const t=V(this.initialData.implements,this.project);this.setImplements(t,null)}return this.subscribeToDependencies(),this.afterAllChildrenInitialized(e),e==null||e.attemptAutoclose("init-children",this.id),this}subscribe(){return this.project.subscribeInstance(this),this}unsubscribe(){return this.project.unsubscribeInstance(this),this}metaSync(e,t=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"sync-meta"))){const r=dt(this,e);return e.deleted===!0&&!this.deleted?t==null||t.add(this,b.Removed):e.deleted===!1&&this.deleted?t==null||t.add(this,b.Added):r&&(t==null||t.add(this,b.Updated)),super.metaSync(e),this.name=e.name||this.name,this.description=e.description||this.description,this.abstract=e.abstract!==void 0?e.abstract:this.abstract,this.private=e.private!==void 0?e.private:this.private,this.index=e.index||(e.index!==0?this.index:0),this.static=e.static!==void 0?e.static:this.static,this.hidden=e.hidden!==void 0?e.hidden:this.hidden,this.constant=e.constant!==void 0?e.constant:this.constant,this.required=e.required!==void 0?e.required:this.required,t==null||t.attemptAutoclose("sync-meta",this.id),this}async APILoad(e=L,...t){return await Ie.repository.APILoad(this.id,...t),this}async APICreate(e=L,...t){return await Ie.repository.APICreate(this.toShallowJSON(),...t),this}async APIUpdate(e=L,...t){return await Ie.repository.APIUpdate(this.toShallowJSON(),...t),this}async APIDelete(e=L,...t){return await Ie.repository.APIDelete(this.toShallowJSON(),...t),this}async APIClone(e=L,...t){return await Ie.repository.APIClone(this.id,...t),this}async APILoadVersion(e=L,t,...r){return await Ie.repository.APILoadVersion(this.id,t,...r)}remove({ignoreUpstream:e}={ignoreUpstream:!1},t=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"remove-entity"))){const r=[],a=[],d=[],o=[];if(t!=null&&t.hasRemoved(this.id))return t==null||t.attemptAutoclose("remove-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(a.push(this),this.unsubscribe(),this.project.subscribeDeletedInstance(this),this.metaSync({deleted:!0},t),Object.values(this.detachedDependents).forEach(l=>{const{updated:u,removed:h,added:c}=l.entity.onDetachedDependencyRemoved(this,l.field,t);r.push(...u),a.push(...h),d.push(...c)}),this.defaultValue){const{updated:l,removed:u}=this.defaultValue.remove({ignoreUpstream:!0},t);r.push(...l),a.push(...u)}if(this.dataType){const{updated:l,removed:u}=this.dataType.remove({ignoreUpstream:!0},t);r.push(...l),a.push(...u)}return e||this.parent.type===n.DefinitionEntity&&(this.parent.removeProperty(this),r.push(this.parent)),t==null||t.attemptAutoclose("remove-entity",this.id),{added:p(d),updated:p(r),removed:p(a),affected:p(o),self:this}}restore({}={},e=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"restore-entity"))){const t=[],r=[],a=[],d=[];if(e!=null&&e.hasAdded(this.id))return e==null||e.attemptAutoclose("restore-entity",this.id),{added:[],updated:[],removed:[],affected:[],self:this};if(this.subscribe(),this.project.unsubscribeDeletedInstance(this),this.metaSync({deleted:!1},e),this.defaultValue){const{updated:o}=this.defaultValue.restore({},e);r.push(...o)}if(this.dataType){const{updated:o}=this.dataType.restore({},e);r.push(...o)}return this.parent.type===n.DefinitionEntity&&(this.parent.addProperty(this),r.push(this.parent)),e==null||e.attemptAutoclose("restore-entity",this.id),{added:p(t),updated:p(r),removed:p(a),affected:p(d),self:this}}toFlat(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this,...((r=this.defaultValue)==null?void 0:r.toFlat(e))||[],...((a=this.dataType)==null?void 0:a.toFlat(e))||[],...this.parent.toFlat(e)])}toFlatIds(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this.id,...((r=this.defaultValue)==null?void 0:r.toFlatIds(e))||[],...((a=this.dataType)==null?void 0:a.toFlatIds(e))||[],...this.parent.toFlatIds(e)])}toJSON(e=new Set){var t,r,a;return e.has(this.id)?this.toReference():(e.add(this.id),{id:this.id,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,abstract:this.abstract,hidden:this.hidden,defaultValue:((t=this.defaultValue)==null?void 0:t.toJSON(e))||null,dataType:((r=this.dataType)==null?void 0:r.toJSON(e))||null,implements:((a=this.implements)==null?void 0:a.toJSON(e))||null,parent:this.parent.toReference()})}toJSONClone(e=Z){var r,a,d,o,l,u,h;let t;return(r=e.seenEntityMaps)!=null&&r.has(this.id)?t=e.seenEntityMaps.get(this.id):(t=e.newId||ct(this,this.project,e.uuidStrategy),e.seenEntityMaps&&e.seenEntityMaps.set(this.id,t)),(a=e.seenEntities)!=null&&a.has(t)||(d=e.seenEntities)!=null&&d.has(this.id)?this.toReference({seenEntityMaps:e.seenEntityMaps}):((o=e.seenEntities)==null||o.add(t),(l=e.seenEntities)==null||l.add(this.id),{id:t,version:I.UUID.uuid(),createdAt:e.timestamp||T().toISOString(),author:I.sessionAuthor,previousVersion:null,deleted:!1,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,required:this.required,static:this.static,constant:this.constant,abstract:this.abstract,hidden:this.hidden,defaultValue:((u=this.defaultValue)==null?void 0:u.toJSONClone({...e,newId:null}))||null,dataType:((h=this.dataType)==null?void 0:h.toJSONClone({...e,newId:null}))||null,implements:(()=>{var c;return this.implements&&this.project.getBuiltIn(this.implements.id)?this.implements.toJSON():((c=this.implements)==null?void 0:c.toJSONClone({...e,newId:null}))||null})(),parent:this.parent.toReference({seenEntityMaps:e.seenEntityMaps})})}toReference(e=Z){var r;let t=this.id;return(r=e.seenEntityMaps)!=null&&r.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t+"--"+I.UUID.uuid()+"--ref",type:n.GenericReference,entityId:t,version:this.version,entityType:this.type}}toShallowJSON(e=Z){var r,a,d,o;let t=this.id;return(r=e.seenEntityMaps)!=null&&r.has(this.id)&&(t=e.seenEntityMaps.get(this.id)),{id:t,version:this.version,createdAt:this.createdAt,previousVersion:this.previousVersion,author:this.author,deleted:this.deleted,name:this.name,description:this.description,type:this.type,index:this.index,private:this.private,required:this.required,abstract:this.abstract,static:this.static,constant:this.constant,hidden:this.hidden,defaultValue:((a=this.defaultValue)==null?void 0:a.toReference(e))||null,dataType:((d=this.dataType)==null?void 0:d.toReference(e))||null,implements:((o=this.implements)==null?void 0:o.toReference(e))||null,parent:this.parent.toReference(e)}}toFlatJSON(e=new Set){var r,a,d;return e.has(this.id)?[]:(e.add(this.id),[this.toShallowJSON(),...((r=this.defaultValue)==null?void 0:r.toFlatJSON(e))||[],...((a=this.dataType)==null?void 0:a.toFlatJSON(e))||[],...((d=this.implements)==null?void 0:d.toFlatJSON(e))||[],...this.parent.toFlatJSON(e)])}toGenerationTarget(){var e;return{id:this.id,name:this.name,description:this.description,type:this.type,private:this.private,required:this.required,abstract:this.abstract,static:this.static,implements:((e=this.implements)==null?void 0:e.id)||null,parent:this.parent.id}}toFlatGenerationTarget(e=new Set){var r,a;return e.has(this.id)?[]:(e.add(this.id),[this.toGenerationTarget(),...((r=this.defaultValue)==null?void 0:r.toFlatGenerationTarget(e))||[],...((a=this.dataType)==null?void 0:a.toFlatGenerationTarget(e))||[]])}clearErrors(){var e,t;return this.errors=[],(e=this.defaultValue)==null||e.clearErrors(),(t=this.dataType)==null||t.clearErrors(),this}validate(){return this.errors=x7(this),this.errors.length,{success:!0,error:null,data:null}}getErrors(){var t,r;return[...this.errors,...((t=this.defaultValue)==null?void 0:t.getErrors())||[],...((r=this.dataType)==null?void 0:r.getErrors())||[]]}getShallowErrors(){return this.errors}clone(e=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"clone-entity")),t=null,r=null,a=!0){var E,O;let d=ft(t,this);const o=r||I.UUID.uuid();let l=t||this.parent;const u={hidden:!1,id:o,version:I.UUID.uuid(),createdAt:(e==null?void 0:e.timestamp)||T().toISOString(),author:(e==null?void 0:e.author)||"1",previousVersion:null,deleted:!1,type:this.type,name:this.name,description:this.description,index:this.index,private:this.private,constant:this.constant,required:this.required,abstract:this.abstract,static:this.static,defaultValue:null,dataType:null,implements:this.implements,parent:l},h=lt(u,d);a&&h.subscribe(),h.setParent(l,null),h.initChildren(e),e==null||e.add(h,b.Added);const c=((E=this.dataType)==null?void 0:E.clone(e,h,I.UUID.uuid(),a))||null;c&&h.setDataType(c);const v=(O=this.defaultValue)==null?void 0:O.clone(e,h,I.UUID.uuid(),a);return h.defaultValue=v||null,this.implements&&(h.implements=this.implements),h.addSelfToProject(null),e==null||e.attemptAutoclose("clone-entity",this.id),h}setDataType(e){return this.dataType=e,this}removeDataType(){return this.dataType=null,this}getDataType(e=this.project.addChangeSet(new R(this.project,"",T().toISOString(),this,!0,"get-data-type"))){return this.dataType}getDefaultValue(){return this.defaultValue}setDefaultValue(e){return this.defaultValue=e,this}};f(Ie,"repository",{APICreate:async(e,...t)=>e,APIUpdate:async(e,...t)=>e,APIDelete:async(e,...t)=>e,APIClone:async(e,...t)=>{},APILoad:async(e,...t)=>null,APILoadVersion:async(e,t,...r)=>null}),f(Ie,"type",n.Property),f(Ie,"USER_MANAGED_PARENT_TYPES",[n.DefinitionEntity]),f(Ie,"PARENT_TYPES",[...Ie.USER_MANAGED_PARENT_TYPES,n.PrimitiveEntity,n.BuiltInBaseEntity]),f(Ie,"MUTABLE_BASE_PROPERTIES",["name","description","private","abstract","static","required","constant"]),f(Ie,"INMUTABLE_BASE_PROPERTIES",["id","type","version","createdAt","author","previousVersion"]),f(Ie,"BASE_PROPERTIES",[...Ie.MUTABLE_BASE_PROPERTIES,...Ie.INMUTABLE_BASE_PROPERTIES]),f(Ie,"MUTABLE_META_PROPERTIES",[...Ie.MUTABLE_BASE_PROPERTIES,"index"]),f(Ie,"INMUTABLE_META_PROPERTIES",[...Ie.INMUTABLE_BASE_PROPERTIES]),f(Ie,"META_PROPERTIES",[...Ie.MUTABLE_META_PROPERTIES,...Ie.INMUTABLE_META_PROPERTIES]),f(Ie,"MUTABLE_UPSTREAM_PROPERTIES",[]),f(Ie,"INMUTABLE_UPSTREAM_PROPERTIES",["parent","implements"]),f(Ie,"UPSTREAM_PROPERTIES",[...Ie.MUTABLE_UPSTREAM_PROPERTIES,...Ie.INMUTABLE_UPSTREAM_PROPERTIES]),f(Ie,"MUTABLE_DOWNSTREAM_PROPERTIES",["dataType"]),f(Ie,"INMUTABLE_DOWNSTREAM_PROPERTIES",[]),f(Ie,"DOWNSTREAM_PROPERTIES",[...Ie.MUTABLE_DOWNSTREAM_PROPERTIES,...Ie.INMUTABLE_DOWNSTREAM_PROPERTIES]),f(Ie,"PROPERTIES",[...Ie.META_PROPERTIES,...Ie.UPSTREAM_PROPERTIES,...Ie.DOWNSTREAM_PROPERTIES]);let Bi=Ie;function q7(i){var a;const s=g6(),e=i.toJSON();s.safeParse(e).success,(a=i.dataType)==null||a.validate();const r=[];if(i.id==="iterate-over-employee-list-continue-statement-employee-dto-output-decl-id"){const d=ye({id:`${i.id}--${q.PropertyImplementsNonAbstact}`,message:`Property "${F(i,i.project)}" with id "${i.id}" implements a non-abstract property "${F(i,i.project)}" with id "${i.id}".`,issue:null,severity:D.Error,code:q.PropertyImplementsNonAbstact,entity:i});r.push(d.error)}return ze(i.errors,r)}var W1=(i=>(i.Implements="implements",i.DataTypeEntity="data-type-entity",i))(W1||{});const Ae=class Ae extends rt{constructor(e,t){super(e);f(this,"initialData");f(this,"id");f(this,"name");f(this,"description",null);f(this,"index");f(this,"required");f(this,"constant",!0);f(this,"isError");f(this,"type",n.ReturnDeclaration);f(this,"defaultValue",null);f(this,"dataType",null);f(this,"readsValue",null);f(this,"implements",null);f(this,"project");f(this,"errors",[]);f(this,"parent");f(this,"detachedDependents",{});f(this,"knownVersions",null);f(this,"activeVersion",!1);f(this,"initialized",!1);f(this,"startedInitialization",!1);f(this,"suggestion",!1);this.initialData=e,this.project=t,this.id=e.id,this.index=e.index,this.name=e.name,this.description=e.description,this.required=e.required,this.constant=!0,this.isError=e.isError}static fromGenerationTarget(e,t){const r=B(e.parent),a=t.get(r);let d=null;if(e.readsValue){const u=B(e.readsValue);d=t.get(u)}const o={id:e.id,version:I.UUID.uuid(),createdAt:T().toISOString(),author:I.sessionAuthor,previousVersion:null,deleted:!1,name:e.name,type:n.ReturnDeclaration,index:a.outputs.length,isError:!1,description:e.description,defaultValue:null,implements:null,required:e.required,constant:!0,readsValue:d,dataType:null,parent:a},l=V(o,t);return l.setParent(a,null),l.initChildren(null),l}static validateGenerationTarget(e,t){var l,u;let r=JSON.parse(JSON.stringify(e));const a=[],d=Et(r,{parent:{list:!1,types:[n.ReturnStatement,n.Search,n.BreakStatement,n.ContinueStatement]}},t),o=Ec(r,t);if(r=d.modifiedData,r.parent){const h=t.get(B(r.parent));if(h&&[n.BreakStatement,n.ContinueStatement].includes(h.type)){const c=h,v=c.parent,E=[...v.breakStatements.filter(w=>w.id!==h.id),...v.continueStatements.filter(w=>w.id!==h.id)];if(c.outputs.length)a.push(new P({id:`${r.id}--${j.NoOverlapWithImplementedSignature}`,code:j.NoOverlapWithImplementedSignature,severity:D.Error,message:`Entity of type '${n.ReturnDeclaration}' with id '${r.id}' cannot be added to the parent entity of type '${c.type}' with id '${c.id}'. This '${c.type}' already has return declarations.
|
|
46
46
|
${Vc}`,issue:null}));else{const w=(u=(l=E[0])==null?void 0:l.outputs[0])==null?void 0:u.name;w!==r.name&&a.push(new P({id:`${r.id}--${j.NoOverlapWithImplementedSignature}`,code:j.NoOverlapWithImplementedSignature,severity:D.Error,message:`Entity of type '${n.ReturnDeclaration}' with id '${r.id}' cannot be added to the parent entity of type '${c.type}' with id '${c.id}'. This new 'return-declaration' doesn't have the same name "${w}" as the return declarations on the other statements in the same scope.
|
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.6187",
|
|
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",
|