@elyx-code/project-logic-tree 0.0.6598 → 0.0.6599
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 +4 -1
- package/dist/index.js +3 -2
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3713,7 +3713,10 @@ export declare class ChangeSet extends Events {
|
|
|
3713
3713
|
discardOrphans(): void;
|
|
3714
3714
|
captureAllChangesInVersionInstances(): void;
|
|
3715
3715
|
attemptAutocloseAsync(knownAutoCloseActionName: string, closingEntityId: EntityId): Promise<ChangeSet>;
|
|
3716
|
-
closeAsync(
|
|
3716
|
+
closeAsync(options?: {
|
|
3717
|
+
awaitBeforeClose?: boolean;
|
|
3718
|
+
awaitExtenalClosing?: boolean;
|
|
3719
|
+
}): Promise<ChangeSet>;
|
|
3717
3720
|
attemptAutoclose(knownAutoCloseActionName: string, closingEntityId: EntityId): ChangeSet;
|
|
3718
3721
|
recursiveCaptureUpstreamVersions(): void;
|
|
3719
3722
|
sanitize(): void;
|
package/dist/index.js
CHANGED
|
@@ -47023,8 +47023,9 @@ class G extends Zu {
|
|
|
47023
47023
|
var l;
|
|
47024
47024
|
return this.autoclose && this.autoCloseActionName && this.autoCloseActionName === i && (this.self && a === ((l = this.self) == null ? void 0 : l.id) || !this.self) && await this.closeAsync(), this;
|
|
47025
47025
|
}
|
|
47026
|
-
async closeAsync() {
|
|
47027
|
-
|
|
47026
|
+
async closeAsync(i = {}) {
|
|
47027
|
+
const a = i.awaitBeforeClose ?? !0, l = i.awaitExtenalClosing ?? !0;
|
|
47028
|
+
return this.startedClose || (this.startedClose = !0, a ? await this.beforeCloseAsync() : this.beforeCloseAsync()), !this.isValid && this.self && !this.added[this.self.id] && !this.updated[this.self.id] && this.removed[this.self.id], this.discardOrphans(), this.sanitize(), this.recursiveCaptureUpstreamVersions(), this.captureAllChangesInVersionInstances(), this.recursiveCaptureUpstreamVersions(), this.open = !1, this.isEmpty ? (Y.warn(`Empty change-set (${this.id}) discarded upon closing.`), this.project.discardChangeSet(this), this.project.closePendingChangeSets(), this) : (l ? await this.project.closeChangeSet(this) : this.project.closeChangeSet(this), this);
|
|
47028
47029
|
}
|
|
47029
47030
|
attemptAutoclose(i, a) {
|
|
47030
47031
|
var l;
|
package/dist/index.umd.cjs
CHANGED
|
@@ -10,7 +10,7 @@ __p+='`),T}),c+=`';
|
|
|
10
10
|
`,e="obj";c=`var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};
|
|
11
11
|
`+c+`return __p;
|
|
12
12
|
`;var y;try{y=new Function(e,"_",c)}catch(T){throw T.source=c,T}var v=function(T){return y.call(this,T,ji)};return v.source="function("+e+`){
|
|
13
|
-
`+c+"}",v}function Y1e(d,u,i){u=Gc(u);var a=u.length;if(!a)return wn(i)?i.call(d):i;for(var l=0;l<a;l++){var c=d==null?void 0:d[u[l]];c===void 0&&(c=i,l=a),d=wn(c)?c.call(d):c}return d}var S1e=0;function X1e(d){var u=++S1e+"";return d?d+u:u}function Q1e(d){var u=ji(d);return u._chain=!0,u}function X6(d,u,i,a,l){if(!(a instanceof u))return d.apply(i,l);var c=Z6(d.prototype),e=d.apply(c,l);return bi(e)?e:c}var Gu=xn(function(d,u){var i=Gu.placeholder,a=function(){for(var l=0,c=u.length,e=Array(c),y=0;y<c;y++)e[y]=u[y]===i?arguments[l++]:u[y];for(;l<arguments.length;)e.push(arguments[l++]);return X6(d,a,this,this,e)};return a});Gu.placeholder=ji;const Q6=xn(function(d,u,i){if(!wn(d))throw new TypeError("Bind must be called on a function");var a=xn(function(l){return X6(d,a,u,this,i.concat(l))});return a}),is=$6(Un);function yd(d,u,i,a){if(a=a||[],!u&&u!==0)u=1/0;else if(u<=0)return a.concat(d);for(var l=a.length,c=0,e=Un(d);c<e;c++){var y=d[c];if(is(y)&&(fd(y)||UI(y)))if(u>1)yd(y,u-1,i,a),l=a.length;else for(var v=0,T=y.length;v<T;)a[l++]=y[v++];else i||(a[l++]=y)}return a}const eCe=xn(function(d,u){u=yd(u,!1,!1);var i=u.length;if(i<1)throw new Error("bindAll must be passed function names");for(;i--;){var a=u[i];d[a]=Q6(d[a],d)}return d});function tCe(d,u){var i=function(a){var l=i.cache,c=""+(u?u.apply(this,arguments):a);return eo(l,c)||(l[c]=d.apply(this,arguments)),l[c]};return i.cache={},i}const eK=xn(function(d,u,i){return setTimeout(function(){return d.apply(null,i)},u)}),iCe=Gu(eK,ji,1);function rCe(d,u,i){var a,l,c,e,y=0;i||(i={});var v=function(){y=i.leading===!1?0:Kc(),a=null,e=d.apply(l,c),a||(l=c=null)},T=function(){var I=Kc();!y&&i.leading===!1&&(y=I);var b=u-(I-y);return l=this,c=arguments,b<=0||b>u?(a&&(clearTimeout(a),a=null),y=I,e=d.apply(l,c),a||(l=c=null)):!a&&i.trailing!==!1&&(a=setTimeout(v,b)),e};return T.cancel=function(){clearTimeout(a),y=0,a=l=c=null},T}function nCe(d,u,i){var a,l,c,e,y,v=function(){var I=Kc()-l;u>I?a=setTimeout(v,u-I):(a=null,i||(e=d.apply(y,c)),a||(c=y=null))},T=xn(function(I){return y=this,c=I,l=Kc(),a||(a=setTimeout(v,u),i&&(e=d.apply(y,c))),e});return T.cancel=function(){clearTimeout(a),a=c=y=null},T}function sCe(d,u){return Gu(u,d)}function SI(d){return function(){return!d.apply(this,arguments)}}function aCe(){var d=arguments,u=d.length-1;return function(){for(var i=u,a=d[u].apply(this,arguments);i--;)a=d[i].call(this,a);return a}}function lCe(d,u){return function(){if(--d<1)return u.apply(this,arguments)}}function tK(d,u){var i;return function(){return--d>0&&(i=u.apply(this,arguments)),d<=1&&(u=null),i}}const oCe=Gu(tK,2);function iK(d,u,i){u=jn(u,i);for(var a=Xr(d),l,c=0,e=a.length;c<e;c++)if(l=a[c],u(d[l],l,d))return l}function rK(d){return function(u,i,a){i=jn(i,a);for(var l=Un(u),c=d>0?0:l-1;c>=0&&c<l;c+=d)if(i(u[c],c,u))return c;return-1}}const XI=rK(1),nK=rK(-1);function sK(d,u,i,a){i=jn(i,a,1);for(var l=i(u),c=0,e=Un(d);c<e;){var y=Math.floor((c+e)/2);i(d[y])<l?c=y+1:e=y}return c}function aK(d,u,i){return function(a,l,c){var e=0,y=Un(a);if(typeof c=="number")d>0?e=c>=0?c:Math.max(c+y,e):y=c>=0?Math.min(c+1,y):c+y+1;else if(i&&c&&y)return c=i(a,l),a[c]===l?c:-1;if(l!==l)return c=u(Mc.call(a,e,y),O6),c>=0?c+e:-1;for(c=d>0?e:y-1;c>=0&&c<y;c+=d)if(a[c]===l)return c;return-1}}const lK=aK(1,XI,sK),dCe=aK(-1,nK);function QI(d,u,i){var a=is(d)?XI:iK,l=a(d,u,i);if(l!==void 0&&l!==-1)return d[l]}function uCe(d,u){return QI(d,kc(u))}function pl(d,u,i){u=Fc(u,i);var a,l;if(is(d))for(a=0,l=d.length;a<l;a++)u(d[a],a,d);else{var c=Xr(d);for(a=0,l=c.length;a<l;a++)u(d[c[a]],c[a],d)}return d}function hd(d,u,i){u=jn(u,i);for(var a=!is(d)&&Xr(d),l=(a||d).length,c=Array(l),e=0;e<l;e++){var y=a?a[e]:e;c[e]=u(d[y],y,d)}return c}function oK(d){var u=function(i,a,l,c){var e=!is(i)&&Xr(i),y=(e||i).length,v=d>0?0:y-1;for(c||(l=i[e?e[v]:v],v+=d);v>=0&&v<y;v+=d){var T=e?e[v]:v;l=a(l,i[T],T,i)}return l};return function(i,a,l,c){var e=arguments.length>=3;return u(i,Fc(a,c,4),l,e)}}const eA=oK(1),dK=oK(-1);function ku(d,u,i){var a=[];return u=jn(u,i),pl(d,function(l,c,e){u(l,c,e)&&a.push(l)}),a}function pCe(d,u,i){return ku(d,SI(jn(u)),i)}function uK(d,u,i){u=jn(u,i);for(var a=!is(d)&&Xr(d),l=(a||d).length,c=0;c<l;c++){var e=a?a[c]:c;if(!u(d[e],e,d))return!1}return!0}function pK(d,u,i){u=jn(u,i);for(var a=!is(d)&&Xr(d),l=(a||d).length,c=0;c<l;c++){var e=a?a[c]:c;if(u(d[e],e,d))return!0}return!1}function cl(d,u,i,a){return is(d)||(d=ju(d)),(typeof i!="number"||a)&&(i=0),lK(d,u,i)>=0}const cCe=xn(function(d,u,i){var a,l;return wn(u)?l=u:(u=Gc(u),a=u.slice(0,-1),u=u[u.length-1]),hd(d,function(c){var e=l;if(!e){if(a&&a.length&&(c=ZI(c,a)),c==null)return;e=c[u]}return e==null?e:e.apply(c,i)})});function tA(d,u){return hd(d,HI(u))}function fCe(d,u){return ku(d,kc(u))}function cK(d,u,i){var a=-1/0,l=-1/0,c,e;if(u==null||typeof u=="number"&&typeof d[0]!="object"&&d!=null){d=is(d)?d:ju(d);for(var y=0,v=d.length;y<v;y++)c=d[y],c!=null&&c>a&&(a=c)}else u=jn(u,i),pl(d,function(T,I,b){e=u(T,I,b),(e>l||e===-1/0&&a===-1/0)&&(a=T,l=e)});return a}function yCe(d,u,i){var a=1/0,l=1/0,c,e;if(u==null||typeof u=="number"&&typeof d[0]!="object"&&d!=null){d=is(d)?d:ju(d);for(var y=0,v=d.length;y<v;y++)c=d[y],c!=null&&c<a&&(a=c)}else u=jn(u,i),pl(d,function(T,I,b){e=u(T,I,b),(e<l||e===1/0&&a===1/0)&&(a=T,l=e)});return a}var hCe=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;function fK(d){return d?fd(d)?Mc.call(d):BI(d)?d.match(hCe):is(d)?hd(d,WI):ju(d):[]}function yK(d,u,i){if(u==null||i)return is(d)||(d=ju(d)),d[JI(d.length-1)];var a=fK(d),l=Un(a);u=Math.max(Math.min(u,l),0);for(var c=l-1,e=0;e<u;e++){var y=JI(e,c),v=a[e];a[e]=a[y],a[y]=v}return a.slice(0,u)}function mCe(d){return yK(d,1/0)}function vCe(d,u,i){var a=0;return u=jn(u,i),tA(hd(d,function(l,c,e){return{value:l,index:a++,criteria:u(l,c,e)}}).sort(function(l,c){var e=l.criteria,y=c.criteria;if(e!==y){if(e>y||e===void 0)return 1;if(e<y||y===void 0)return-1}return l.index-c.index}),"value")}function Nm(d,u){return function(i,a,l){var c=u?[[],[]]:{};return a=jn(a,l),pl(i,function(e,y){var v=a(e,y,i);d(c,e,v)}),c}}const TCe=Nm(function(d,u,i){eo(d,i)?d[i].push(u):d[i]=[u]}),ECe=Nm(function(d,u,i){d[i]=u}),bCe=Nm(function(d,u,i){eo(d,i)?d[i]++:d[i]=1}),ICe=Nm(function(d,u,i){d[i?0:1].push(u)},!0);function ACe(d){return d==null?0:is(d)?d.length:Xr(d).length}function wCe(d,u,i){return u in i}const hK=xn(function(d,u){var i={},a=u[0];if(d==null)return i;wn(a)?(u.length>1&&(a=Fc(a,u[1])),u=jc(d)):(a=wCe,u=yd(u,!1,!1),d=Object(d));for(var l=0,c=u.length;l<c;l++){var e=u[l],y=d[e];a(y,e,d)&&(i[e]=y)}return i}),RCe=xn(function(d,u){var i=u[0],a;return wn(i)?(i=SI(i),u.length>1&&(a=u[1])):(u=hd(yd(u,!1,!1),String),i=function(l,c){return!cl(u,c)}),hK(d,i,a)});function mK(d,u,i){return Mc.call(d,0,Math.max(0,d.length-(u==null||i?1:u)))}function iA(d,u,i){return d==null||d.length<1?u==null||i?void 0:[]:u==null||i?d[0]:mK(d,d.length-u)}function Vm(d,u,i){return Mc.call(d,u==null||i?1:u)}function CCe(d,u,i){return d==null||d.length<1?u==null||i?void 0:[]:u==null||i?d[d.length-1]:Vm(d,Math.max(0,d.length-u))}function gCe(d){return ku(d,Boolean)}function _Ce(d,u){return yd(d,u,!1)}const vK=xn(function(d,u){return u=yd(u,!0,!0),ku(d,function(i){return!cl(u,i)})}),DCe=xn(function(d,u){return vK(d,u)});function rA(d,u,i,a){A6(u)||(a=i,i=u,u=!1),i!=null&&(i=jn(i,a));for(var l=[],c=[],e=0,y=Un(d);e<y;e++){var v=d[e],T=i?i(v,e,d):v;u&&!i?((!e||c!==T)&&l.push(v),c=T):i?cl(c,T)||(c.push(T),l.push(v)):cl(l,v)||l.push(v)}return l}const OCe=xn(function(d){return rA(yd(d,!0,!0))});function PCe(d){for(var u=[],i=arguments.length,a=0,l=Un(d);a<l;a++){var c=d[a];if(!cl(u,c)){var e;for(e=1;e<i&&cl(arguments[e],c);e++);e===i&&u.push(c)}}return u}function nA(d){for(var u=d&&cK(d,Un).length||0,i=Array(u),a=0;a<u;a++)i[a]=tA(d,a);return i}const $Ce=xn(nA);function NCe(d,u){for(var i={},a=0,l=Un(d);a<l;a++)u?i[d[a]]=u[a]:i[d[a][0]]=d[a][1];return i}function VCe(d,u,i){u==null&&(u=d||0,d=0),i||(i=u<d?-1:1);for(var a=Math.max(Math.ceil((u-d)/i),0),l=Array(a),c=0;c<a;c++,d+=i)l[c]=d;return l}function LCe(d,u){if(u==null||u<1)return[];for(var i=[],a=0,l=d.length;a<l;)i.push(Mc.call(d,a,a+=u));return i}function sA(d,u){return d._chain?ji(u).chain():u}function TK(d){return pl(KI(d),function(u){var i=ji[u]=d[u];ji.prototype[u]=function(){var a=[this._wrapped];return a1e.apply(a,arguments),sA(this,i.apply(ji,a))}}),ji}pl(["pop","push","reverse","shift","sort","splice","unshift"],function(d){var u=Dm[d];ji.prototype[d]=function(){var i=this._wrapped;return i!=null&&(u.apply(i,arguments),(d==="shift"||d==="splice")&&i.length===0&&delete i[0]),sA(this,i)}}),pl(["concat","join","slice"],function(d){var u=Dm[d];ji.prototype[d]=function(){var i=this._wrapped;return i!=null&&(i=u.apply(i,arguments)),sA(this,i)}});var EK=TK(Object.freeze(Object.defineProperty({__proto__:null,VERSION:p6,after:lCe,all:uK,allKeys:jc,any:pK,assign:$m,before:tK,bind:Q6,bindAll:eCe,chain:Q1e,chunk:LCe,clone:B1e,collect:hd,compact:gCe,compose:aCe,constant:P6,contains:cl,countBy:bCe,create:L1e,debounce:nCe,default:ji,defaults:q6,defer:iCe,delay:eK,detect:QI,difference:vK,drop:Vm,each:pl,escape:k1e,every:uK,extend:K6,extendOwn:$m,filter:ku,find:QI,findIndex:XI,findKey:iK,findLastIndex:nK,findWhere:uCe,first:iA,flatten:_Ce,foldl:eA,foldr:dK,forEach:pl,functions:KI,get:H6,groupBy:TCe,has:x1e,head:iA,identity:WI,include:cl,includes:cl,indexBy:ECe,indexOf:lK,initial:mK,inject:eA,intersection:PCe,invert:F6,invoke:cCe,isArguments:UI,isArray:fd,isArrayBuffer:C6,isBoolean:A6,isDataView:Om,isDate:y1e,isElement:f1e,isEmpty:Uc,isEqual:C1e,isError:m1e,isFinite:b1e,isFunction:wn,isMap:D1e,isMatch:B6,isNaN:O6,isNull:b6,isNumber:w6,isObject:bi,isRegExp:h1e,isSet:P1e,isString:BI,isSymbol:R6,isTypedArray:V6,isUndefined:I6,isWeakMap:O1e,isWeakSet:$1e,iteratee:zI,keys:Xr,last:CCe,lastIndexOf:dCe,map:hd,mapObject:U1e,matcher:kc,matches:kc,max:cK,memoize:tCe,methods:KI,min:yCe,mixin:TK,negate:SI,noop:J6,now:Kc,object:NCe,omit:RCe,once:oCe,pairs:N1e,partial:Gu,partition:ICe,pick:hK,pluck:tA,property:HI,propertyOf:j1e,random:JI,range:VCe,reduce:eA,reduceRight:dK,reject:pCe,rest:Vm,restArguments:xn,result:Y1e,sample:yK,select:ku,shuffle:mCe,size:ACe,some:pK,sortBy:vCe,sortedIndex:sK,tail:Vm,take:iA,tap:M1e,template:J1e,templateSettings:q1e,throttle:rCe,times:G1e,toArray:fK,toPath:W6,transpose:nA,unescape:K1e,union:OCe,uniq:rA,unique:rA,uniqueId:X1e,unzip:nA,values:ju,where:fCe,without:DCe,wrap:sCe,zip:$Ce},Symbol.toStringTag,{value:"Module"})));EK._=EK;function bK(d){var i;(i=d.dataType)==null||i.validate();const u=[...Od(d)];return Ui(d.errors,u)}const BCe=Object.freeze(Object.defineProperty({__proto__:null,validate:bK},Symbol.toStringTag,{value:"Module"}));function ie(d){if(d){let u=null;return typeof d=="string"?u=d:d.entityId?u=d.entityId:d.type!==p.GenericReference&&(u=d.id),u}return null}function IK(d){return d.listAdded.forEach(u=>{const i=d.project.get(u.id);(i==null?void 0:i.type)===p.DefinitionEntity&&i.parent.type!==p.DataType&&(d.project.emit(Ai.EXPLICIT_DEFINITION_ENTITY_ADDED,i,d),ki(i,ce.PERSISTED_ENTITY)?d.project.emit(Ai.PERSISTED_DEFINITION_ENTITY_ADDED,i,d):ki(i,ce.RELATIONAL_DATABASE)&&d.project.emit(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED,i,d))}),d.listUpdated.forEach(u=>{const i=d.project.get(u.id);(i==null?void 0:i.type)===p.DefinitionEntity&&i.parent.type!==p.DataType&&(d.project.emit(Ai.EXPLICIT_DEFINITION_ENTITY_UPDATED,i,d),ki(i,ce.PERSISTED_ENTITY)?d.project.emit(Ai.PERSISTED_DEFINITION_ENTITY_UPDATED,i,d):ki(i,ce.RELATIONAL_DATABASE)&&d.project.emit(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED,i,d))}),d.listRemoved.forEach(u=>{const i=d.project.get(u.id)||d.project.getDeleted(u.id);(i==null?void 0:i.type)===p.DefinitionEntity&&i.parent.type!==p.DataType&&(d.project.emit(Ai.EXPLICIT_DEFINITION_ENTITY_REMOVED,i,d),ki(i,ce.PERSISTED_ENTITY)?d.project.emit(Ai.PERSISTED_DEFINITION_ENTITY_REMOVED,i,d):ki(i,ce.RELATIONAL_DATABASE)&&d.project.emit(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED,i,d))}),d}async function AK(d){const u=[];return d.listAdded.forEach(i=>{const a=d.project.get(i.id);(a==null?void 0:a.type)===p.DefinitionEntity&&a.parent.type!==p.DataType&&(u.push(d.project.emitAsync(Ai.EXPLICIT_DEFINITION_ENTITY_ADDED,a,d)),ki(a,ce.PERSISTED_ENTITY)?u.push(d.project.emitAsync(Ai.PERSISTED_DEFINITION_ENTITY_ADDED,a,d)):ki(a,ce.RELATIONAL_DATABASE)&&u.push(d.project.emitAsync(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED,a,d)))}),d.listUpdated.forEach(i=>{const a=d.project.get(i.id);(a==null?void 0:a.type)===p.DefinitionEntity&&a.parent.type!==p.DataType&&(u.push(d.project.emitAsync(Ai.EXPLICIT_DEFINITION_ENTITY_UPDATED,a,d)),ki(a,ce.PERSISTED_ENTITY)?u.push(d.project.emitAsync(Ai.PERSISTED_DEFINITION_ENTITY_UPDATED,a,d)):ki(a,ce.RELATIONAL_DATABASE)&&u.push(d.project.emitAsync(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED,a,d)))}),d.listRemoved.forEach(i=>{const a=d.project.get(i.id)||d.project.getDeleted(i.id);(a==null?void 0:a.type)===p.DefinitionEntity&&a.parent.type!==p.DataType&&(u.push(d.project.emitAsync(Ai.EXPLICIT_DEFINITION_ENTITY_REMOVED,a,d)),ki(a,ce.PERSISTED_ENTITY)?u.push(d.project.emitAsync(Ai.PERSISTED_DEFINITION_ENTITY_REMOVED,a,d)):ki(a,ce.RELATIONAL_DATABASE)&&u.push(d.project.emitAsync(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED,a,d)))}),await Promise.all(u),d}var MCe=Object.defineProperty,xCe=(d,u,i)=>u in d?MCe(d,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):d[u]=i,rs=(d,u,i)=>(xCe(d,typeof u!="symbol"?u+"":u,i),i);function to(d){const u=d;return u.timeout=i=>new Promise((a,l)=>{const c=setTimeout(()=>{a(void 0)},i);d.then(e=>{clearTimeout(c),a(e)},e=>{clearTimeout(c),l(e)})}),u}class UCe{constructor(u){rs(this,"eventName"),rs(this,"callbacks",[]),this.eventName=u,this.on=this.on.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}on(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks.includes(u)||this.callbacks.push(u)}off(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(i=>i!==u)}destroy(){this.callbacks=[]}}class Fu{constructor(){rs(this,"subscribedEvents",{}),rs(this,"on"),rs(this,"emit"),rs(this,"emitAsync"),rs(this,"emitAsyncAll"),rs(this,"emitAsyncAllSettled"),rs(this,"emitAsyncSequentially"),rs(this,"emitAsyncSequentiallyAll"),rs(this,"emitAsyncSequentiallyAllSettled"),rs(this,"off"),rs(this,"destroy"),this.getEvent=this.getEvent.bind(this),this._on=this._on.bind(this),this._emit=this._emit.bind(this),this._emitAsync=this._emitAsync.bind(this),this._emitAsyncAll=this._emitAsyncAll.bind(this),this._emitAsyncAllSettled=this._emitAsyncAllSettled.bind(this),this._emitAsyncSequentially=this._emitAsyncSequentially.bind(this),this._emitAsyncSequentiallyAll=this._emitAsyncSequentiallyAll.bind(this),this._emitAsyncSequentiallyAllSettled=this._emitAsyncSequentiallyAllSettled.bind(this),this._off=this._off.bind(this),this._destroy=this._destroy.bind(this),this.on=this._on,this.emit=this._emit,this.emitAsync=this._emitAsync,this.emitAsyncAll=this._emitAsyncAll,this.emitAsyncAllSettled=this._emitAsyncAllSettled,this.emitAsyncSequentially=this._emitAsyncSequentially,this.emitAsyncSequentiallyAll=this._emitAsyncSequentiallyAll,this.emitAsyncSequentiallyAllSettled=this._emitAsyncSequentiallyAllSettled,this.off=this._off,this.destroy=this._destroy}getEvent(u){return this.subscribedEvents[u]||(this.subscribedEvents[u]=new UCe(u)),this.subscribedEvents[u]}_on(u,i){this.getEvent(u).on(i)}_emit(u,...i){const a=this.getEvent(u);a&&a.callbacks.forEach(l=>{l.apply(null,i)})}_emitAsync(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve());const l=Promise.all(a.callbacks.map(c=>{try{const e=c(...i);return e instanceof Promise?e:Promise.resolve(e)}catch(e){return Promise.reject(e)}})).then(()=>{});return to(l)}_emitAsyncAll(u,...i){return this._emitAsync(u,...i)}_emitAsyncAllSettled(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve([]));const l=Promise.allSettled(a.callbacks.map(c=>{try{const e=c(...i);return e instanceof Promise?e:Promise.resolve(e)}catch(e){return Promise.reject(e)}}));return to(l)}_emitAsyncSequentially(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve());const l=(async()=>{for(const c of a.callbacks){const e=c(...i);e instanceof Promise&&await e}})();return to(l)}_emitAsyncSequentiallyAll(u,...i){return this._emitAsyncSequentially(u,...i)}_emitAsyncSequentiallyAllSettled(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve([]));const l=(async()=>{const c=[];for(const e of a.callbacks)try{const y=e(...i),v=y instanceof Promise?await y:y;c.push({status:"fulfilled",value:v})}catch(y){c.push({status:"rejected",reason:y})}return c})();return to(l)}_off(u,i){const a=this.getEvent(u);a&&(i?a.off(i):(a.destroy(),delete this.subscribedEvents[u]))}_destroy(){Object.keys(this.subscribedEvents).forEach(u=>{this._off(u)}),this.subscribedEvents={}}}var aA=(d=>(d.Manual="manual",d.Automatic="automatic",d))(aA||{}),F=(d=>(d.Added="added",d.Updated="updated",d.Removed="removed",d.Affected="affected",d))(F||{}),P=(d=>(d.AddSuccessCall="add-success-call",d.AddErrorCall="add-error-call",d.AddCall="add-call",d.SetParent="set-parent",d.AfterAllChildrenInitialized="after-all-children-initialized",d.UpdateWithShallowTransfer="update-with-shallow-transfer",d.RemoveFromParent="remove-from-parent",d.RemoveEntity="remove-entity",d.RestoreEntity="restore-entity",d.CloneEntity="clone-entity",d.AddInput="add-input",d.RemoveInput="remove-input",d.SetDataType="set-data-type",d.RemoveDataType="remove-data-type",d.SetAdditionalPropertiesDataType="set-additional-properties-data-type",d.RemoveAdditionalPropertiesDataType="remove-additional-properties-data-type",d.SetAllPropertiesImplement="set-all-properties-implement",d.RemoveAllPropertiesImplement="remove-all-properties-implement",d.RemoveValueReader="remove-value-reader",d.AddValueReader="add-value-reader",d.RemoveValueWriter="remove-value-writer",d.SetValueWriter="set-value-writer",d.AddEntryCaller="add-entry-caller",d.AddSuccessCaller="add-success-caller",d.AddErrorCaller="add-error-caller",d.RemoveCall="remove-call",d.RemoveCaller="remove-caller",d.RemoveChildGroup="remove-child-group",d.AddToAndGroup="add-to-and-group",d.AddToOrGroup="add-to-or-group",d.RemoveUnrecognizedInputs="remove-unrecognized-inputs",d.RemoveUnrecognizedOutputs="remove-unrecognized-outputs",d.SyncInputs="sync-inputs",d.SyncOutputs="sync-outputs",d.SetImplements="set-implements",d.SetExtends="set-extends",d.SetExtension="set-extension",d.AddImplementation="add-implementation",d.RemoveImplementation="remove-implementation",d.AddProperty="add-property",d.RemoveProperty="remove-property",d.AddMethod="add-method",d.RemoveMethod="remove-method",d.AddAbstractMethod="add-abstract-method",d.RemoveAbstractMethod="remove-abstract-method",d.SetValueAsTypeSingle="set-value-as-type-single",d.SetValueAsTypeList="set-value-as-type-list",d.SetValueAsType="set-value-as-type",d.RemoveErrorCatching="remove-error-catching",d.RemoveAllErrorCallers="remove-all-error-callers",d.RemoveAllSuccessCallers="remove-all-success-callers",d.RemoveAllCallers="remove-all-callers",d.RemoveAllErrorCalls="remove-all-error-calls",d))(P||{}),Gi=(d=>(d.ActionOwnerEntityNotEditable="action-owner-entity-not-editable",d.ActionCounterpartEntityNotEditable="action-counterpart-entity-not-editable",d.ActionOwnerEntityNonDeletable="action-owner-entity-non-deletable",d.GlobalVariableDeclarationCannnotCatchError="global-variable-declaration-cannot-catch-error",d.GlobalVariableDeclarationCannotReadValue="global-variable-declaration-cannot-read-value",d.GlobalVariableDeclarationCannotBeCalled="global-variable-declaration-cannot-be-called",d.GlobalVariableDeclarationCannotCallFromError="global-variable-declaration-cannot-call-from-error",d))(Gi||{});class wK{constructor({id:u,action:i,errorReason:a,owner:l,counterpart:c,rootAction:e},y){_(this,"id");_(this,"action");_(this,"errorReason");_(this,"owner",null);_(this,"counterpart",null);_(this,"rootAction",!1);_(this,"parent");this.id=u,this.action=i,this.errorReason=a||null,this.owner=l||null,this.counterpart=c||null,this.rootAction=e||!1,this.parent=y}}class k extends Fu{constructor(i,a,l,c,e=!1,y=""){super();_(this,"id",L.UUID.uuid());_(this,"seenEntities",[]);_(this,"added",{});_(this,"updated",{});_(this,"removed",{});_(this,"affected",{});_(this,"self",null);_(this,"author");_(this,"timestamp");_(this,"open",!0);_(this,"dirty",!0);_(this,"startedClose",!1);_(this,"type","manual");_(this,"autoclose",!1);_(this,"autoCloseActionName","");_(this,"project");_(this,"events",new Map);_(this,"ignoreNonEditable",!1);_(this,"ignoreNonDeletable",!1);if(this.project=i,this.author=a||L.sessionAuthor||"",this.timestamp=l,this.self=c,this.autoclose=e,this.autoCloseActionName=y,this.autoclose&&!this.autoCloseActionName)throw new Error("Auto-close change-set must have an auto-close action name.")}get index(){const i=this.project.history.indexOf(this);return i===-1?null:i}get isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.updated).length===0&&Object.keys(this.removed).length===0}get isValid(){var i;return!(this.isEmpty&&this.self&&!this.affected[(i=this.self)==null?void 0:i.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)}event(i){Y.log(`ChangeSet Event: ${i.action} (${i.id})`);const a=new wK(i,this);this.events.set(i.id,a),this.emit("change-set-event",a)}discardOrphans(){this.added[this.project.id]&&(this.updatedIds.forEach(y=>{const v=this.updated[y];this.added[y]=v,delete this.updated[y]}),this.removedIds.forEach(y=>{this.remove(y)}));const i=[...this.addedIds,...this.updatedIds],a=this.project.toFlatIds(),l=Kn(),c=a.filter(y=>!l.includes(y));if(i.filter(y=>!c.includes(y)).forEach(y=>{const v=this.get(y);Y.warn(`Entity ${v==null?void 0:v.type} with id "${y}" present in change-set but not in project. Removing from change-set.`),this.remove(y)}),this.added[this.project.id]){const y=[...this.addedIds,...this.updatedIds],v=this.project.toFlatIds(),T=[...Kn(),...this.project.getAllBuiltInIds()];v.filter(D=>!T.includes(D)).filter(D=>!y.includes(D)).forEach(D=>{const V=this.project.get(D);this.add(V,"added")})}}captureAllChangesInVersionInstances(){[...this.addedIds,...this.updatedIds].forEach(a=>{const l=this.project.get(a);if(!l)throw new Error(`Entity with id "${a}" not found in the project state when capturing version for change-set.`);const c=this.get(a);l.version===c.version&&l.captureVersion()}),this.removedIds.forEach(a=>{const l=this.project.getDeleted(a);if(!l)throw new Error(`Entity with id "${a}" not found in the project state when capturing version for change-set.`);const c=this.get(a);l.version===c.version&&l.captureVersion()})}async attemptAutocloseAsync(i,a){var l;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===i&&(this.self&&a===((l=this.self)==null?void 0:l.id)||!this.self)&&await this.closeAsync(),this}async closeAsync(){return this.startedClose||(this.startedClose=!0,await this.beforeCloseAsync()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.open=!1,this.isEmpty?(Y.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this):(await this.project.closeChangeSet(this),this)}attemptAutoclose(i,a){var l;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===i&&(this.self&&a===((l=this.self)==null?void 0:l.id)||!this.self)&&this.close(),this}recursiveCaptureUpstreamVersions(){[...this.addedIds,...this.updatedIds,...this.removedIds].forEach(a=>{const l=this.get(a),{added:c,updated:e,removed:y,affected:v}=l.recursiveCaptureUpstreamVersions(this.timestamp);for(const T of c)this.add(T,"added");for(const T of e)this.add(T,"updated");for(const T of y)this.add(T,"removed");for(const T of v)this.add(T,"affected")})}sanitize(){this.listAdded.forEach(i=>{i.previousVersion=null})}syncDependents(){return[...this.list,...this.listAffected].forEach(i=>{const a=this.project.get(i.id);!a||a.deleted||dR(a,this.project)||a==null||a.syncDependents(this)}),this}async beforeCloseAsync(){this.syncDependents(),await this.emitAsyncProjectSideEffects(),this.teardown()}beforeClose(){this.syncDependents(),this.emitProjectSideEffects(),this.teardown()}teardown(){this.destroy()}emitProjectSideEffects(){return IK(this)}async emitAsyncProjectSideEffects(){return AK(this)}close(){if(this.startedClose||(this.startedClose=!0,this.beforeClose()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.open=!1,this.isEmpty)return Y.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this;if(this.added[this.project.id]&&this.updatedIds.length)throw new Error("No 'updated' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(this.added[this.project.id]&&this.removedIds.length)throw new Error("No 'removed' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(!this.updated[this.project.id]&&!this.added[this.project.id])throw new Error("Change-set must also have the project entity as 'updated' or 'added'. All changes must propagate upstream until the root project entity.");return this.project.closeChangeSet(this),this}addDependentsToAffected(i){Object.values(i.detachedDependents).forEach(a=>{const{entity:l,field:c}=a;this.has(l.id)||this.add(l,"affected")})}get(i){return this.added[i]?this.added[i]:this.updated[i]?this.updated[i]:this.removed[i]?this.removed[i]:null}remove(i){return this.has(i)&&(delete this.added[i],delete this.updated[i],delete this.removed[i],delete this.affected[i],this.seenEntities=this.seenEntities.filter(a=>a!==i)),this}add(i,a,l={preventRecursion:!1}){var e,y,v;if(!this.open||!this.dirty)return this;if(dR(i,this.project))return this;if(this.seenEntities.indexOf(i.id)===-1&&this.seenEntities.push(i.id),a==="removed"){if(this.added[i.id])return delete this.added[i.id],this.seenEntities=this.seenEntities.filter(I=>I!==i.id),delete this.project.deletedInstances[i.id],this;if(this.updated[i.id]&&delete this.updated[i.id],this.affected[i.id]&&delete this.affected[i.id],!this.hasRemoved(i.id)&&(i.increaseVersion(this.timestamp),!l.preventRecursion)){const{added:I,updated:b,removed:D,affected:V}=i.recursiveCaptureUpstreamVersions(this.timestamp);for(const M of I)this.add(M,"added");for(const M of b)this.add(M,"updated");for(const M of D)this.add(M,"removed");for(const M of V)this.add(M,"affected")}i.captureVersion();const T=(e=i.knownVersions)==null?void 0:e.get(i.version);if(!T)throw Error(`Version ${i.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.removed[i.id]=T,this}if(a==="added"){if(this.removed[i.id])return this;if(this.updated[i.id]&&delete this.updated[i.id],this.affected[i.id]&&delete this.affected[i.id],!this.hasAdded(i.id)&&!l.preventRecursion){const{added:I,updated:b,removed:D,affected:V}=i.recursiveCaptureUpstreamVersions(this.timestamp);for(const M of I)this.add(M,"added");for(const M of b)this.add(M,"updated");for(const M of D)this.add(M,"removed");for(const M of V)this.add(M,"affected")}i.previousVersion=null,i.captureVersion();const T=(y=i.knownVersions)==null?void 0:y.get(i.version);if(!T)throw Error(`Version ${i.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.added[i.id]=T,delete this.affected[i.id],this.addDependentsToAffected(i),this}if(a==="updated"){if(this.removed[i.id])return this;if(this.added[i.id])return i.captureVersion(),this.addDependentsToAffected(i),this;if(this.affected[i.id]&&delete this.affected[i.id],!this.hasUpdated(i.id)&&(i.increaseVersion(this.timestamp),!l.preventRecursion)){const{added:I,updated:b,removed:D,affected:V}=i.recursiveCaptureUpstreamVersions(this.timestamp);for(const M of I)this.add(M,"added");for(const M of b)this.add(M,"updated");for(const M of D)this.add(M,"removed");for(const M of V)this.add(M,"affected")}i.captureVersion();const T=(v=i.knownVersions)==null?void 0:v.get(i.version);if(!T)throw Error(`Version ${i.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.updated[i.id]=T,this.addDependentsToAffected(i),this}if(a==="affected"){if(this.removed[i.id])return this;if(this.added[i.id])return this;if(this.updated[i.id])return this;this.affected[i.id]=i}return this}toJSON(){const i={},a={},l={},c=new Set;for(const e of Object.values(this.added))i[e.id]=e.toShallowJSON();for(const e of Object.values(this.updated))a[e.id]=e.toShallowJSON();for(const e of Object.values(this.removed))l[e.id]=e.toShallowJSON();for(const e of Object.values(this.affected))c.add(e.id);return{added:i,updated:a,removed:l,affected:Array.from(c),self:this.self?this.self.toShallowJSON():null,seenEntities:this.seenEntities}}has(i){return!!this.added[i]||!!this.removed[i]||!!this.updated[i]||!!this.affected[i]}hasAdded(i){return!!this.added[i]}hasUpdated(i){return!!this.updated[i]}hasRemoved(i){return!!this.removed[i]}hasAffected(i){return!!this.affected[i]}}function jCe(d){return new Set([...Object.keys(d.added),...Object.keys(d.updated),...Object.keys(d.removed),...Array.from(d.affected)])}function lA(d,u,i){var y;const a=new Date().toISOString(),l=new k(i,L.sessionAuthor,a,i);if(d===u)throw Y.error("From: ",d),Y.error("To: ",u),new Error("Cannot generate transitional change set between the same two versions or change-sets");let c;if(d==="initial"?c=!0:u==="initial"?c=!1:B(d.timestamp).isBefore(B(u.timestamp))?c=!0:c=!1,Y.log("Transitioning from ",d==="initial"?"initial":d.index),Y.log("Transitioning to ",u==="initial"?"initial":u.index),Y.log("Is forward: ",c),c){const T=u.index,I=d==="initial"?0:d.index;Y.log("ownIndex: ",T),Y.log("startIndex: ",I);const b=T===I?[i.history[T]]:i.history.slice(I+1,T+1);if(b.sort((D,V)=>B(D.timestamp).isAfter(B(V.timestamp))?1:-1),!b.length)throw new Error("No change sets in the history between the history indexes provided");Y.log("REDO change-set: ",b[0].id," ",b[0].timestamp),b.forEach(D=>{oA(D,V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.version),l.timestamp=M.createdAt,l.add(M,F.Added,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.version),l.timestamp=M.createdAt,l.add(M,F.Updated,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.version),l.timestamp=M.createdAt,l.add(M,F.Removed,{preventRecursion:!0})})})}else{const T=d.index,I=u==="initial"?0:u.index,b=T===I?[i.history[T]]:i.history.slice(I+1,T+1);if(b.sort((D,V)=>B(V.timestamp).isAfter(B(D.timestamp))?1:-1),!b.length)throw new Error("No change sets in the history between the history indexes provided");Y.log("UNDO change-set: ",b[0].id," ",b[0].timestamp),b.forEach(D=>{oA(D,V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);V.previousVersion&&M.restoreVersion(V.previousVersion),l.timestamp=M.createdAt,l.add(M,F.Removed,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.previousVersion),l.timestamp=M.createdAt,l.add(M,F.Updated,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.previousVersion),l.timestamp=M.createdAt,l.add(M,F.Added,{preventRecursion:!0})})})}let e;if(u==="initial"){const v=Array.from(((y=i.knownVersions)==null?void 0:y.values())||[]).reduce((T,I)=>!T||B(I.createdAt).isBefore(B(T.createdAt))?I:T,null);if(!v)throw new Error("No oldest version found");e=v.createdAt}else e=u.timestamp;return l.open=!1,{transitionalChangeSet:l,transitionTime:a,timeOfOriginalTargetChanges:e}}function oA(d,u,i,a){if(!(d!=null&&d.self))throw new Error("Change set must have a valid `self` entity state to be traversed");const l=new Oa(d.self);Y.log("changeSet.added: ",Object.keys(d.added).length),Y.log("changeSet.updated: ",Object.keys(d.updated).length),Y.log("changeSet.removed: ",Object.keys(d.removed).length);const c={...d.added,...d.updated,...d.removed};l.order=Object.keys(c),l.flatRecord=c,l.orderEntities(),Y.log("All entities: ",l.order.map((e,y)=>`${y+1}: ${c[e].type} - ${e}`).join(`,
|
|
13
|
+
`+c+"}",v}function Y1e(d,u,i){u=Gc(u);var a=u.length;if(!a)return wn(i)?i.call(d):i;for(var l=0;l<a;l++){var c=d==null?void 0:d[u[l]];c===void 0&&(c=i,l=a),d=wn(c)?c.call(d):c}return d}var S1e=0;function X1e(d){var u=++S1e+"";return d?d+u:u}function Q1e(d){var u=ji(d);return u._chain=!0,u}function X6(d,u,i,a,l){if(!(a instanceof u))return d.apply(i,l);var c=Z6(d.prototype),e=d.apply(c,l);return bi(e)?e:c}var Gu=xn(function(d,u){var i=Gu.placeholder,a=function(){for(var l=0,c=u.length,e=Array(c),y=0;y<c;y++)e[y]=u[y]===i?arguments[l++]:u[y];for(;l<arguments.length;)e.push(arguments[l++]);return X6(d,a,this,this,e)};return a});Gu.placeholder=ji;const Q6=xn(function(d,u,i){if(!wn(d))throw new TypeError("Bind must be called on a function");var a=xn(function(l){return X6(d,a,u,this,i.concat(l))});return a}),is=$6(Un);function yd(d,u,i,a){if(a=a||[],!u&&u!==0)u=1/0;else if(u<=0)return a.concat(d);for(var l=a.length,c=0,e=Un(d);c<e;c++){var y=d[c];if(is(y)&&(fd(y)||UI(y)))if(u>1)yd(y,u-1,i,a),l=a.length;else for(var v=0,T=y.length;v<T;)a[l++]=y[v++];else i||(a[l++]=y)}return a}const eCe=xn(function(d,u){u=yd(u,!1,!1);var i=u.length;if(i<1)throw new Error("bindAll must be passed function names");for(;i--;){var a=u[i];d[a]=Q6(d[a],d)}return d});function tCe(d,u){var i=function(a){var l=i.cache,c=""+(u?u.apply(this,arguments):a);return eo(l,c)||(l[c]=d.apply(this,arguments)),l[c]};return i.cache={},i}const eK=xn(function(d,u,i){return setTimeout(function(){return d.apply(null,i)},u)}),iCe=Gu(eK,ji,1);function rCe(d,u,i){var a,l,c,e,y=0;i||(i={});var v=function(){y=i.leading===!1?0:Kc(),a=null,e=d.apply(l,c),a||(l=c=null)},T=function(){var I=Kc();!y&&i.leading===!1&&(y=I);var b=u-(I-y);return l=this,c=arguments,b<=0||b>u?(a&&(clearTimeout(a),a=null),y=I,e=d.apply(l,c),a||(l=c=null)):!a&&i.trailing!==!1&&(a=setTimeout(v,b)),e};return T.cancel=function(){clearTimeout(a),y=0,a=l=c=null},T}function nCe(d,u,i){var a,l,c,e,y,v=function(){var I=Kc()-l;u>I?a=setTimeout(v,u-I):(a=null,i||(e=d.apply(y,c)),a||(c=y=null))},T=xn(function(I){return y=this,c=I,l=Kc(),a||(a=setTimeout(v,u),i&&(e=d.apply(y,c))),e});return T.cancel=function(){clearTimeout(a),a=c=y=null},T}function sCe(d,u){return Gu(u,d)}function SI(d){return function(){return!d.apply(this,arguments)}}function aCe(){var d=arguments,u=d.length-1;return function(){for(var i=u,a=d[u].apply(this,arguments);i--;)a=d[i].call(this,a);return a}}function lCe(d,u){return function(){if(--d<1)return u.apply(this,arguments)}}function tK(d,u){var i;return function(){return--d>0&&(i=u.apply(this,arguments)),d<=1&&(u=null),i}}const oCe=Gu(tK,2);function iK(d,u,i){u=jn(u,i);for(var a=Xr(d),l,c=0,e=a.length;c<e;c++)if(l=a[c],u(d[l],l,d))return l}function rK(d){return function(u,i,a){i=jn(i,a);for(var l=Un(u),c=d>0?0:l-1;c>=0&&c<l;c+=d)if(i(u[c],c,u))return c;return-1}}const XI=rK(1),nK=rK(-1);function sK(d,u,i,a){i=jn(i,a,1);for(var l=i(u),c=0,e=Un(d);c<e;){var y=Math.floor((c+e)/2);i(d[y])<l?c=y+1:e=y}return c}function aK(d,u,i){return function(a,l,c){var e=0,y=Un(a);if(typeof c=="number")d>0?e=c>=0?c:Math.max(c+y,e):y=c>=0?Math.min(c+1,y):c+y+1;else if(i&&c&&y)return c=i(a,l),a[c]===l?c:-1;if(l!==l)return c=u(Mc.call(a,e,y),O6),c>=0?c+e:-1;for(c=d>0?e:y-1;c>=0&&c<y;c+=d)if(a[c]===l)return c;return-1}}const lK=aK(1,XI,sK),dCe=aK(-1,nK);function QI(d,u,i){var a=is(d)?XI:iK,l=a(d,u,i);if(l!==void 0&&l!==-1)return d[l]}function uCe(d,u){return QI(d,kc(u))}function pl(d,u,i){u=Fc(u,i);var a,l;if(is(d))for(a=0,l=d.length;a<l;a++)u(d[a],a,d);else{var c=Xr(d);for(a=0,l=c.length;a<l;a++)u(d[c[a]],c[a],d)}return d}function hd(d,u,i){u=jn(u,i);for(var a=!is(d)&&Xr(d),l=(a||d).length,c=Array(l),e=0;e<l;e++){var y=a?a[e]:e;c[e]=u(d[y],y,d)}return c}function oK(d){var u=function(i,a,l,c){var e=!is(i)&&Xr(i),y=(e||i).length,v=d>0?0:y-1;for(c||(l=i[e?e[v]:v],v+=d);v>=0&&v<y;v+=d){var T=e?e[v]:v;l=a(l,i[T],T,i)}return l};return function(i,a,l,c){var e=arguments.length>=3;return u(i,Fc(a,c,4),l,e)}}const eA=oK(1),dK=oK(-1);function ku(d,u,i){var a=[];return u=jn(u,i),pl(d,function(l,c,e){u(l,c,e)&&a.push(l)}),a}function pCe(d,u,i){return ku(d,SI(jn(u)),i)}function uK(d,u,i){u=jn(u,i);for(var a=!is(d)&&Xr(d),l=(a||d).length,c=0;c<l;c++){var e=a?a[c]:c;if(!u(d[e],e,d))return!1}return!0}function pK(d,u,i){u=jn(u,i);for(var a=!is(d)&&Xr(d),l=(a||d).length,c=0;c<l;c++){var e=a?a[c]:c;if(u(d[e],e,d))return!0}return!1}function cl(d,u,i,a){return is(d)||(d=ju(d)),(typeof i!="number"||a)&&(i=0),lK(d,u,i)>=0}const cCe=xn(function(d,u,i){var a,l;return wn(u)?l=u:(u=Gc(u),a=u.slice(0,-1),u=u[u.length-1]),hd(d,function(c){var e=l;if(!e){if(a&&a.length&&(c=ZI(c,a)),c==null)return;e=c[u]}return e==null?e:e.apply(c,i)})});function tA(d,u){return hd(d,HI(u))}function fCe(d,u){return ku(d,kc(u))}function cK(d,u,i){var a=-1/0,l=-1/0,c,e;if(u==null||typeof u=="number"&&typeof d[0]!="object"&&d!=null){d=is(d)?d:ju(d);for(var y=0,v=d.length;y<v;y++)c=d[y],c!=null&&c>a&&(a=c)}else u=jn(u,i),pl(d,function(T,I,b){e=u(T,I,b),(e>l||e===-1/0&&a===-1/0)&&(a=T,l=e)});return a}function yCe(d,u,i){var a=1/0,l=1/0,c,e;if(u==null||typeof u=="number"&&typeof d[0]!="object"&&d!=null){d=is(d)?d:ju(d);for(var y=0,v=d.length;y<v;y++)c=d[y],c!=null&&c<a&&(a=c)}else u=jn(u,i),pl(d,function(T,I,b){e=u(T,I,b),(e<l||e===1/0&&a===1/0)&&(a=T,l=e)});return a}var hCe=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;function fK(d){return d?fd(d)?Mc.call(d):BI(d)?d.match(hCe):is(d)?hd(d,WI):ju(d):[]}function yK(d,u,i){if(u==null||i)return is(d)||(d=ju(d)),d[JI(d.length-1)];var a=fK(d),l=Un(a);u=Math.max(Math.min(u,l),0);for(var c=l-1,e=0;e<u;e++){var y=JI(e,c),v=a[e];a[e]=a[y],a[y]=v}return a.slice(0,u)}function mCe(d){return yK(d,1/0)}function vCe(d,u,i){var a=0;return u=jn(u,i),tA(hd(d,function(l,c,e){return{value:l,index:a++,criteria:u(l,c,e)}}).sort(function(l,c){var e=l.criteria,y=c.criteria;if(e!==y){if(e>y||e===void 0)return 1;if(e<y||y===void 0)return-1}return l.index-c.index}),"value")}function Nm(d,u){return function(i,a,l){var c=u?[[],[]]:{};return a=jn(a,l),pl(i,function(e,y){var v=a(e,y,i);d(c,e,v)}),c}}const TCe=Nm(function(d,u,i){eo(d,i)?d[i].push(u):d[i]=[u]}),ECe=Nm(function(d,u,i){d[i]=u}),bCe=Nm(function(d,u,i){eo(d,i)?d[i]++:d[i]=1}),ICe=Nm(function(d,u,i){d[i?0:1].push(u)},!0);function ACe(d){return d==null?0:is(d)?d.length:Xr(d).length}function wCe(d,u,i){return u in i}const hK=xn(function(d,u){var i={},a=u[0];if(d==null)return i;wn(a)?(u.length>1&&(a=Fc(a,u[1])),u=jc(d)):(a=wCe,u=yd(u,!1,!1),d=Object(d));for(var l=0,c=u.length;l<c;l++){var e=u[l],y=d[e];a(y,e,d)&&(i[e]=y)}return i}),RCe=xn(function(d,u){var i=u[0],a;return wn(i)?(i=SI(i),u.length>1&&(a=u[1])):(u=hd(yd(u,!1,!1),String),i=function(l,c){return!cl(u,c)}),hK(d,i,a)});function mK(d,u,i){return Mc.call(d,0,Math.max(0,d.length-(u==null||i?1:u)))}function iA(d,u,i){return d==null||d.length<1?u==null||i?void 0:[]:u==null||i?d[0]:mK(d,d.length-u)}function Vm(d,u,i){return Mc.call(d,u==null||i?1:u)}function CCe(d,u,i){return d==null||d.length<1?u==null||i?void 0:[]:u==null||i?d[d.length-1]:Vm(d,Math.max(0,d.length-u))}function gCe(d){return ku(d,Boolean)}function _Ce(d,u){return yd(d,u,!1)}const vK=xn(function(d,u){return u=yd(u,!0,!0),ku(d,function(i){return!cl(u,i)})}),DCe=xn(function(d,u){return vK(d,u)});function rA(d,u,i,a){A6(u)||(a=i,i=u,u=!1),i!=null&&(i=jn(i,a));for(var l=[],c=[],e=0,y=Un(d);e<y;e++){var v=d[e],T=i?i(v,e,d):v;u&&!i?((!e||c!==T)&&l.push(v),c=T):i?cl(c,T)||(c.push(T),l.push(v)):cl(l,v)||l.push(v)}return l}const OCe=xn(function(d){return rA(yd(d,!0,!0))});function PCe(d){for(var u=[],i=arguments.length,a=0,l=Un(d);a<l;a++){var c=d[a];if(!cl(u,c)){var e;for(e=1;e<i&&cl(arguments[e],c);e++);e===i&&u.push(c)}}return u}function nA(d){for(var u=d&&cK(d,Un).length||0,i=Array(u),a=0;a<u;a++)i[a]=tA(d,a);return i}const $Ce=xn(nA);function NCe(d,u){for(var i={},a=0,l=Un(d);a<l;a++)u?i[d[a]]=u[a]:i[d[a][0]]=d[a][1];return i}function VCe(d,u,i){u==null&&(u=d||0,d=0),i||(i=u<d?-1:1);for(var a=Math.max(Math.ceil((u-d)/i),0),l=Array(a),c=0;c<a;c++,d+=i)l[c]=d;return l}function LCe(d,u){if(u==null||u<1)return[];for(var i=[],a=0,l=d.length;a<l;)i.push(Mc.call(d,a,a+=u));return i}function sA(d,u){return d._chain?ji(u).chain():u}function TK(d){return pl(KI(d),function(u){var i=ji[u]=d[u];ji.prototype[u]=function(){var a=[this._wrapped];return a1e.apply(a,arguments),sA(this,i.apply(ji,a))}}),ji}pl(["pop","push","reverse","shift","sort","splice","unshift"],function(d){var u=Dm[d];ji.prototype[d]=function(){var i=this._wrapped;return i!=null&&(u.apply(i,arguments),(d==="shift"||d==="splice")&&i.length===0&&delete i[0]),sA(this,i)}}),pl(["concat","join","slice"],function(d){var u=Dm[d];ji.prototype[d]=function(){var i=this._wrapped;return i!=null&&(i=u.apply(i,arguments)),sA(this,i)}});var EK=TK(Object.freeze(Object.defineProperty({__proto__:null,VERSION:p6,after:lCe,all:uK,allKeys:jc,any:pK,assign:$m,before:tK,bind:Q6,bindAll:eCe,chain:Q1e,chunk:LCe,clone:B1e,collect:hd,compact:gCe,compose:aCe,constant:P6,contains:cl,countBy:bCe,create:L1e,debounce:nCe,default:ji,defaults:q6,defer:iCe,delay:eK,detect:QI,difference:vK,drop:Vm,each:pl,escape:k1e,every:uK,extend:K6,extendOwn:$m,filter:ku,find:QI,findIndex:XI,findKey:iK,findLastIndex:nK,findWhere:uCe,first:iA,flatten:_Ce,foldl:eA,foldr:dK,forEach:pl,functions:KI,get:H6,groupBy:TCe,has:x1e,head:iA,identity:WI,include:cl,includes:cl,indexBy:ECe,indexOf:lK,initial:mK,inject:eA,intersection:PCe,invert:F6,invoke:cCe,isArguments:UI,isArray:fd,isArrayBuffer:C6,isBoolean:A6,isDataView:Om,isDate:y1e,isElement:f1e,isEmpty:Uc,isEqual:C1e,isError:m1e,isFinite:b1e,isFunction:wn,isMap:D1e,isMatch:B6,isNaN:O6,isNull:b6,isNumber:w6,isObject:bi,isRegExp:h1e,isSet:P1e,isString:BI,isSymbol:R6,isTypedArray:V6,isUndefined:I6,isWeakMap:O1e,isWeakSet:$1e,iteratee:zI,keys:Xr,last:CCe,lastIndexOf:dCe,map:hd,mapObject:U1e,matcher:kc,matches:kc,max:cK,memoize:tCe,methods:KI,min:yCe,mixin:TK,negate:SI,noop:J6,now:Kc,object:NCe,omit:RCe,once:oCe,pairs:N1e,partial:Gu,partition:ICe,pick:hK,pluck:tA,property:HI,propertyOf:j1e,random:JI,range:VCe,reduce:eA,reduceRight:dK,reject:pCe,rest:Vm,restArguments:xn,result:Y1e,sample:yK,select:ku,shuffle:mCe,size:ACe,some:pK,sortBy:vCe,sortedIndex:sK,tail:Vm,take:iA,tap:M1e,template:J1e,templateSettings:q1e,throttle:rCe,times:G1e,toArray:fK,toPath:W6,transpose:nA,unescape:K1e,union:OCe,uniq:rA,unique:rA,uniqueId:X1e,unzip:nA,values:ju,where:fCe,without:DCe,wrap:sCe,zip:$Ce},Symbol.toStringTag,{value:"Module"})));EK._=EK;function bK(d){var i;(i=d.dataType)==null||i.validate();const u=[...Od(d)];return Ui(d.errors,u)}const BCe=Object.freeze(Object.defineProperty({__proto__:null,validate:bK},Symbol.toStringTag,{value:"Module"}));function ie(d){if(d){let u=null;return typeof d=="string"?u=d:d.entityId?u=d.entityId:d.type!==p.GenericReference&&(u=d.id),u}return null}function IK(d){return d.listAdded.forEach(u=>{const i=d.project.get(u.id);(i==null?void 0:i.type)===p.DefinitionEntity&&i.parent.type!==p.DataType&&(d.project.emit(Ai.EXPLICIT_DEFINITION_ENTITY_ADDED,i,d),ki(i,ce.PERSISTED_ENTITY)?d.project.emit(Ai.PERSISTED_DEFINITION_ENTITY_ADDED,i,d):ki(i,ce.RELATIONAL_DATABASE)&&d.project.emit(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED,i,d))}),d.listUpdated.forEach(u=>{const i=d.project.get(u.id);(i==null?void 0:i.type)===p.DefinitionEntity&&i.parent.type!==p.DataType&&(d.project.emit(Ai.EXPLICIT_DEFINITION_ENTITY_UPDATED,i,d),ki(i,ce.PERSISTED_ENTITY)?d.project.emit(Ai.PERSISTED_DEFINITION_ENTITY_UPDATED,i,d):ki(i,ce.RELATIONAL_DATABASE)&&d.project.emit(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED,i,d))}),d.listRemoved.forEach(u=>{const i=d.project.get(u.id)||d.project.getDeleted(u.id);(i==null?void 0:i.type)===p.DefinitionEntity&&i.parent.type!==p.DataType&&(d.project.emit(Ai.EXPLICIT_DEFINITION_ENTITY_REMOVED,i,d),ki(i,ce.PERSISTED_ENTITY)?d.project.emit(Ai.PERSISTED_DEFINITION_ENTITY_REMOVED,i,d):ki(i,ce.RELATIONAL_DATABASE)&&d.project.emit(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED,i,d))}),d}async function AK(d){const u=[];return d.listAdded.forEach(i=>{const a=d.project.get(i.id);(a==null?void 0:a.type)===p.DefinitionEntity&&a.parent.type!==p.DataType&&(u.push(d.project.emitAsync(Ai.EXPLICIT_DEFINITION_ENTITY_ADDED,a,d)),ki(a,ce.PERSISTED_ENTITY)?u.push(d.project.emitAsync(Ai.PERSISTED_DEFINITION_ENTITY_ADDED,a,d)):ki(a,ce.RELATIONAL_DATABASE)&&u.push(d.project.emitAsync(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_ADDED,a,d)))}),d.listUpdated.forEach(i=>{const a=d.project.get(i.id);(a==null?void 0:a.type)===p.DefinitionEntity&&a.parent.type!==p.DataType&&(u.push(d.project.emitAsync(Ai.EXPLICIT_DEFINITION_ENTITY_UPDATED,a,d)),ki(a,ce.PERSISTED_ENTITY)?u.push(d.project.emitAsync(Ai.PERSISTED_DEFINITION_ENTITY_UPDATED,a,d)):ki(a,ce.RELATIONAL_DATABASE)&&u.push(d.project.emitAsync(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_UPDATED,a,d)))}),d.listRemoved.forEach(i=>{const a=d.project.get(i.id)||d.project.getDeleted(i.id);(a==null?void 0:a.type)===p.DefinitionEntity&&a.parent.type!==p.DataType&&(u.push(d.project.emitAsync(Ai.EXPLICIT_DEFINITION_ENTITY_REMOVED,a,d)),ki(a,ce.PERSISTED_ENTITY)?u.push(d.project.emitAsync(Ai.PERSISTED_DEFINITION_ENTITY_REMOVED,a,d)):ki(a,ce.RELATIONAL_DATABASE)&&u.push(d.project.emitAsync(Ai.RELATIONAL_DATABASE_DEFINITION_ENTITY_REMOVED,a,d)))}),await Promise.all(u),d}var MCe=Object.defineProperty,xCe=(d,u,i)=>u in d?MCe(d,u,{enumerable:!0,configurable:!0,writable:!0,value:i}):d[u]=i,rs=(d,u,i)=>(xCe(d,typeof u!="symbol"?u+"":u,i),i);function to(d){const u=d;return u.timeout=i=>new Promise((a,l)=>{const c=setTimeout(()=>{a(void 0)},i);d.then(e=>{clearTimeout(c),a(e)},e=>{clearTimeout(c),l(e)})}),u}class UCe{constructor(u){rs(this,"eventName"),rs(this,"callbacks",[]),this.eventName=u,this.on=this.on.bind(this),this.off=this.off.bind(this),this.destroy=this.destroy.bind(this)}on(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks.includes(u)||this.callbacks.push(u)}off(u){if(typeof u!="function")throw new Error("Event callback must be a function");this.callbacks=this.callbacks.filter(i=>i!==u)}destroy(){this.callbacks=[]}}class Fu{constructor(){rs(this,"subscribedEvents",{}),rs(this,"on"),rs(this,"emit"),rs(this,"emitAsync"),rs(this,"emitAsyncAll"),rs(this,"emitAsyncAllSettled"),rs(this,"emitAsyncSequentially"),rs(this,"emitAsyncSequentiallyAll"),rs(this,"emitAsyncSequentiallyAllSettled"),rs(this,"off"),rs(this,"destroy"),this.getEvent=this.getEvent.bind(this),this._on=this._on.bind(this),this._emit=this._emit.bind(this),this._emitAsync=this._emitAsync.bind(this),this._emitAsyncAll=this._emitAsyncAll.bind(this),this._emitAsyncAllSettled=this._emitAsyncAllSettled.bind(this),this._emitAsyncSequentially=this._emitAsyncSequentially.bind(this),this._emitAsyncSequentiallyAll=this._emitAsyncSequentiallyAll.bind(this),this._emitAsyncSequentiallyAllSettled=this._emitAsyncSequentiallyAllSettled.bind(this),this._off=this._off.bind(this),this._destroy=this._destroy.bind(this),this.on=this._on,this.emit=this._emit,this.emitAsync=this._emitAsync,this.emitAsyncAll=this._emitAsyncAll,this.emitAsyncAllSettled=this._emitAsyncAllSettled,this.emitAsyncSequentially=this._emitAsyncSequentially,this.emitAsyncSequentiallyAll=this._emitAsyncSequentiallyAll,this.emitAsyncSequentiallyAllSettled=this._emitAsyncSequentiallyAllSettled,this.off=this._off,this.destroy=this._destroy}getEvent(u){return this.subscribedEvents[u]||(this.subscribedEvents[u]=new UCe(u)),this.subscribedEvents[u]}_on(u,i){this.getEvent(u).on(i)}_emit(u,...i){const a=this.getEvent(u);a&&a.callbacks.forEach(l=>{l.apply(null,i)})}_emitAsync(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve());const l=Promise.all(a.callbacks.map(c=>{try{const e=c(...i);return e instanceof Promise?e:Promise.resolve(e)}catch(e){return Promise.reject(e)}})).then(()=>{});return to(l)}_emitAsyncAll(u,...i){return this._emitAsync(u,...i)}_emitAsyncAllSettled(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve([]));const l=Promise.allSettled(a.callbacks.map(c=>{try{const e=c(...i);return e instanceof Promise?e:Promise.resolve(e)}catch(e){return Promise.reject(e)}}));return to(l)}_emitAsyncSequentially(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve());const l=(async()=>{for(const c of a.callbacks){const e=c(...i);e instanceof Promise&&await e}})();return to(l)}_emitAsyncSequentiallyAll(u,...i){return this._emitAsyncSequentially(u,...i)}_emitAsyncSequentiallyAllSettled(u,...i){const a=this.getEvent(u);if(!a)return to(Promise.resolve([]));const l=(async()=>{const c=[];for(const e of a.callbacks)try{const y=e(...i),v=y instanceof Promise?await y:y;c.push({status:"fulfilled",value:v})}catch(y){c.push({status:"rejected",reason:y})}return c})();return to(l)}_off(u,i){const a=this.getEvent(u);a&&(i?a.off(i):(a.destroy(),delete this.subscribedEvents[u]))}_destroy(){Object.keys(this.subscribedEvents).forEach(u=>{this._off(u)}),this.subscribedEvents={}}}var aA=(d=>(d.Manual="manual",d.Automatic="automatic",d))(aA||{}),F=(d=>(d.Added="added",d.Updated="updated",d.Removed="removed",d.Affected="affected",d))(F||{}),P=(d=>(d.AddSuccessCall="add-success-call",d.AddErrorCall="add-error-call",d.AddCall="add-call",d.SetParent="set-parent",d.AfterAllChildrenInitialized="after-all-children-initialized",d.UpdateWithShallowTransfer="update-with-shallow-transfer",d.RemoveFromParent="remove-from-parent",d.RemoveEntity="remove-entity",d.RestoreEntity="restore-entity",d.CloneEntity="clone-entity",d.AddInput="add-input",d.RemoveInput="remove-input",d.SetDataType="set-data-type",d.RemoveDataType="remove-data-type",d.SetAdditionalPropertiesDataType="set-additional-properties-data-type",d.RemoveAdditionalPropertiesDataType="remove-additional-properties-data-type",d.SetAllPropertiesImplement="set-all-properties-implement",d.RemoveAllPropertiesImplement="remove-all-properties-implement",d.RemoveValueReader="remove-value-reader",d.AddValueReader="add-value-reader",d.RemoveValueWriter="remove-value-writer",d.SetValueWriter="set-value-writer",d.AddEntryCaller="add-entry-caller",d.AddSuccessCaller="add-success-caller",d.AddErrorCaller="add-error-caller",d.RemoveCall="remove-call",d.RemoveCaller="remove-caller",d.RemoveChildGroup="remove-child-group",d.AddToAndGroup="add-to-and-group",d.AddToOrGroup="add-to-or-group",d.RemoveUnrecognizedInputs="remove-unrecognized-inputs",d.RemoveUnrecognizedOutputs="remove-unrecognized-outputs",d.SyncInputs="sync-inputs",d.SyncOutputs="sync-outputs",d.SetImplements="set-implements",d.SetExtends="set-extends",d.SetExtension="set-extension",d.AddImplementation="add-implementation",d.RemoveImplementation="remove-implementation",d.AddProperty="add-property",d.RemoveProperty="remove-property",d.AddMethod="add-method",d.RemoveMethod="remove-method",d.AddAbstractMethod="add-abstract-method",d.RemoveAbstractMethod="remove-abstract-method",d.SetValueAsTypeSingle="set-value-as-type-single",d.SetValueAsTypeList="set-value-as-type-list",d.SetValueAsType="set-value-as-type",d.RemoveErrorCatching="remove-error-catching",d.RemoveAllErrorCallers="remove-all-error-callers",d.RemoveAllSuccessCallers="remove-all-success-callers",d.RemoveAllCallers="remove-all-callers",d.RemoveAllErrorCalls="remove-all-error-calls",d))(P||{}),Gi=(d=>(d.ActionOwnerEntityNotEditable="action-owner-entity-not-editable",d.ActionCounterpartEntityNotEditable="action-counterpart-entity-not-editable",d.ActionOwnerEntityNonDeletable="action-owner-entity-non-deletable",d.GlobalVariableDeclarationCannnotCatchError="global-variable-declaration-cannot-catch-error",d.GlobalVariableDeclarationCannotReadValue="global-variable-declaration-cannot-read-value",d.GlobalVariableDeclarationCannotBeCalled="global-variable-declaration-cannot-be-called",d.GlobalVariableDeclarationCannotCallFromError="global-variable-declaration-cannot-call-from-error",d))(Gi||{});class wK{constructor({id:u,action:i,errorReason:a,owner:l,counterpart:c,rootAction:e},y){_(this,"id");_(this,"action");_(this,"errorReason");_(this,"owner",null);_(this,"counterpart",null);_(this,"rootAction",!1);_(this,"parent");this.id=u,this.action=i,this.errorReason=a||null,this.owner=l||null,this.counterpart=c||null,this.rootAction=e||!1,this.parent=y}}class k extends Fu{constructor(i,a,l,c,e=!1,y=""){super();_(this,"id",L.UUID.uuid());_(this,"seenEntities",[]);_(this,"added",{});_(this,"updated",{});_(this,"removed",{});_(this,"affected",{});_(this,"self",null);_(this,"author");_(this,"timestamp");_(this,"open",!0);_(this,"dirty",!0);_(this,"startedClose",!1);_(this,"type","manual");_(this,"autoclose",!1);_(this,"autoCloseActionName","");_(this,"project");_(this,"events",new Map);_(this,"ignoreNonEditable",!1);_(this,"ignoreNonDeletable",!1);if(this.project=i,this.author=a||L.sessionAuthor||"",this.timestamp=l,this.self=c,this.autoclose=e,this.autoCloseActionName=y,this.autoclose&&!this.autoCloseActionName)throw new Error("Auto-close change-set must have an auto-close action name.")}get index(){const i=this.project.history.indexOf(this);return i===-1?null:i}get isEmpty(){return Object.keys(this.added).length===0&&Object.keys(this.updated).length===0&&Object.keys(this.removed).length===0}get isValid(){var i;return!(this.isEmpty&&this.self&&!this.affected[(i=this.self)==null?void 0:i.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)}event(i){Y.log(`ChangeSet Event: ${i.action} (${i.id})`);const a=new wK(i,this);this.events.set(i.id,a),this.emit("change-set-event",a)}discardOrphans(){this.added[this.project.id]&&(this.updatedIds.forEach(y=>{const v=this.updated[y];this.added[y]=v,delete this.updated[y]}),this.removedIds.forEach(y=>{this.remove(y)}));const i=[...this.addedIds,...this.updatedIds],a=this.project.toFlatIds(),l=Kn(),c=a.filter(y=>!l.includes(y));if(i.filter(y=>!c.includes(y)).forEach(y=>{const v=this.get(y);Y.warn(`Entity ${v==null?void 0:v.type} with id "${y}" present in change-set but not in project. Removing from change-set.`),this.remove(y)}),this.added[this.project.id]){const y=[...this.addedIds,...this.updatedIds],v=this.project.toFlatIds(),T=[...Kn(),...this.project.getAllBuiltInIds()];v.filter(D=>!T.includes(D)).filter(D=>!y.includes(D)).forEach(D=>{const V=this.project.get(D);this.add(V,"added")})}}captureAllChangesInVersionInstances(){[...this.addedIds,...this.updatedIds].forEach(a=>{const l=this.project.get(a);if(!l)throw new Error(`Entity with id "${a}" not found in the project state when capturing version for change-set.`);const c=this.get(a);l.version===c.version&&l.captureVersion()}),this.removedIds.forEach(a=>{const l=this.project.getDeleted(a);if(!l)throw new Error(`Entity with id "${a}" not found in the project state when capturing version for change-set.`);const c=this.get(a);l.version===c.version&&l.captureVersion()})}async attemptAutocloseAsync(i,a){var l;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===i&&(this.self&&a===((l=this.self)==null?void 0:l.id)||!this.self)&&await this.closeAsync(),this}async closeAsync(i={}){const a=i.awaitBeforeClose??!0,l=i.awaitExtenalClosing??!0;return this.startedClose||(this.startedClose=!0,a?await this.beforeCloseAsync():this.beforeCloseAsync()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.open=!1,this.isEmpty?(Y.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this):(l?await this.project.closeChangeSet(this):this.project.closeChangeSet(this),this)}attemptAutoclose(i,a){var l;return this.autoclose&&this.autoCloseActionName&&this.autoCloseActionName===i&&(this.self&&a===((l=this.self)==null?void 0:l.id)||!this.self)&&this.close(),this}recursiveCaptureUpstreamVersions(){[...this.addedIds,...this.updatedIds,...this.removedIds].forEach(a=>{const l=this.get(a),{added:c,updated:e,removed:y,affected:v}=l.recursiveCaptureUpstreamVersions(this.timestamp);for(const T of c)this.add(T,"added");for(const T of e)this.add(T,"updated");for(const T of y)this.add(T,"removed");for(const T of v)this.add(T,"affected")})}sanitize(){this.listAdded.forEach(i=>{i.previousVersion=null})}syncDependents(){return[...this.list,...this.listAffected].forEach(i=>{const a=this.project.get(i.id);!a||a.deleted||dR(a,this.project)||a==null||a.syncDependents(this)}),this}async beforeCloseAsync(){this.syncDependents(),await this.emitAsyncProjectSideEffects(),this.teardown()}beforeClose(){this.syncDependents(),this.emitProjectSideEffects(),this.teardown()}teardown(){this.destroy()}emitProjectSideEffects(){return IK(this)}async emitAsyncProjectSideEffects(){return AK(this)}close(){if(this.startedClose||(this.startedClose=!0,this.beforeClose()),!this.isValid&&this.self&&!this.added[this.self.id]&&!this.updated[this.self.id]&&this.removed[this.self.id],this.discardOrphans(),this.sanitize(),this.captureAllChangesInVersionInstances(),this.recursiveCaptureUpstreamVersions(),this.captureAllChangesInVersionInstances(),this.open=!1,this.isEmpty)return Y.warn(`Empty change-set (${this.id}) discarded upon closing.`),this.project.discardChangeSet(this),this.project.closePendingChangeSets(),this;if(this.added[this.project.id]&&this.updatedIds.length)throw new Error("No 'updated' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(this.added[this.project.id]&&this.removedIds.length)throw new Error("No 'removed' entities should be present in the change-set when the project entity is in the 'added' list. New projects can only have newly added entities");if(!this.updated[this.project.id]&&!this.added[this.project.id])throw new Error("Change-set must also have the project entity as 'updated' or 'added'. All changes must propagate upstream until the root project entity.");return this.project.closeChangeSet(this),this}addDependentsToAffected(i){Object.values(i.detachedDependents).forEach(a=>{const{entity:l,field:c}=a;this.has(l.id)||this.add(l,"affected")})}get(i){return this.added[i]?this.added[i]:this.updated[i]?this.updated[i]:this.removed[i]?this.removed[i]:null}remove(i){return this.has(i)&&(delete this.added[i],delete this.updated[i],delete this.removed[i],delete this.affected[i],this.seenEntities=this.seenEntities.filter(a=>a!==i)),this}add(i,a,l={preventRecursion:!1}){var e,y,v;if(!this.open||!this.dirty)return this;if(dR(i,this.project))return this;if(this.seenEntities.indexOf(i.id)===-1&&this.seenEntities.push(i.id),a==="removed"){if(this.added[i.id])return delete this.added[i.id],this.seenEntities=this.seenEntities.filter(I=>I!==i.id),delete this.project.deletedInstances[i.id],this;if(this.updated[i.id]&&delete this.updated[i.id],this.affected[i.id]&&delete this.affected[i.id],!this.hasRemoved(i.id)&&(i.increaseVersion(this.timestamp),!l.preventRecursion)){const{added:I,updated:b,removed:D,affected:V}=i.recursiveCaptureUpstreamVersions(this.timestamp);for(const M of I)this.add(M,"added");for(const M of b)this.add(M,"updated");for(const M of D)this.add(M,"removed");for(const M of V)this.add(M,"affected")}i.captureVersion();const T=(e=i.knownVersions)==null?void 0:e.get(i.version);if(!T)throw Error(`Version ${i.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.removed[i.id]=T,this}if(a==="added"){if(this.removed[i.id])return this;if(this.updated[i.id]&&delete this.updated[i.id],this.affected[i.id]&&delete this.affected[i.id],!this.hasAdded(i.id)&&!l.preventRecursion){const{added:I,updated:b,removed:D,affected:V}=i.recursiveCaptureUpstreamVersions(this.timestamp);for(const M of I)this.add(M,"added");for(const M of b)this.add(M,"updated");for(const M of D)this.add(M,"removed");for(const M of V)this.add(M,"affected")}i.previousVersion=null,i.captureVersion();const T=(y=i.knownVersions)==null?void 0:y.get(i.version);if(!T)throw Error(`Version ${i.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.added[i.id]=T,delete this.affected[i.id],this.addDependentsToAffected(i),this}if(a==="updated"){if(this.removed[i.id])return this;if(this.added[i.id])return i.captureVersion(),this.addDependentsToAffected(i),this;if(this.affected[i.id]&&delete this.affected[i.id],!this.hasUpdated(i.id)&&(i.increaseVersion(this.timestamp),!l.preventRecursion)){const{added:I,updated:b,removed:D,affected:V}=i.recursiveCaptureUpstreamVersions(this.timestamp);for(const M of I)this.add(M,"added");for(const M of b)this.add(M,"updated");for(const M of D)this.add(M,"removed");for(const M of V)this.add(M,"affected")}i.captureVersion();const T=(v=i.knownVersions)==null?void 0:v.get(i.version);if(!T)throw Error(`Version ${i.version} should have a cached version instance but it wasn't found when adding entity to change-set`);return this.updated[i.id]=T,this.addDependentsToAffected(i),this}if(a==="affected"){if(this.removed[i.id])return this;if(this.added[i.id])return this;if(this.updated[i.id])return this;this.affected[i.id]=i}return this}toJSON(){const i={},a={},l={},c=new Set;for(const e of Object.values(this.added))i[e.id]=e.toShallowJSON();for(const e of Object.values(this.updated))a[e.id]=e.toShallowJSON();for(const e of Object.values(this.removed))l[e.id]=e.toShallowJSON();for(const e of Object.values(this.affected))c.add(e.id);return{added:i,updated:a,removed:l,affected:Array.from(c),self:this.self?this.self.toShallowJSON():null,seenEntities:this.seenEntities}}has(i){return!!this.added[i]||!!this.removed[i]||!!this.updated[i]||!!this.affected[i]}hasAdded(i){return!!this.added[i]}hasUpdated(i){return!!this.updated[i]}hasRemoved(i){return!!this.removed[i]}hasAffected(i){return!!this.affected[i]}}function jCe(d){return new Set([...Object.keys(d.added),...Object.keys(d.updated),...Object.keys(d.removed),...Array.from(d.affected)])}function lA(d,u,i){var y;const a=new Date().toISOString(),l=new k(i,L.sessionAuthor,a,i);if(d===u)throw Y.error("From: ",d),Y.error("To: ",u),new Error("Cannot generate transitional change set between the same two versions or change-sets");let c;if(d==="initial"?c=!0:u==="initial"?c=!1:B(d.timestamp).isBefore(B(u.timestamp))?c=!0:c=!1,Y.log("Transitioning from ",d==="initial"?"initial":d.index),Y.log("Transitioning to ",u==="initial"?"initial":u.index),Y.log("Is forward: ",c),c){const T=u.index,I=d==="initial"?0:d.index;Y.log("ownIndex: ",T),Y.log("startIndex: ",I);const b=T===I?[i.history[T]]:i.history.slice(I+1,T+1);if(b.sort((D,V)=>B(D.timestamp).isAfter(B(V.timestamp))?1:-1),!b.length)throw new Error("No change sets in the history between the history indexes provided");Y.log("REDO change-set: ",b[0].id," ",b[0].timestamp),b.forEach(D=>{oA(D,V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.version),l.timestamp=M.createdAt,l.add(M,F.Added,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.version),l.timestamp=M.createdAt,l.add(M,F.Updated,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.version),l.timestamp=M.createdAt,l.add(M,F.Removed,{preventRecursion:!0})})})}else{const T=d.index,I=u==="initial"?0:u.index,b=T===I?[i.history[T]]:i.history.slice(I+1,T+1);if(b.sort((D,V)=>B(V.timestamp).isAfter(B(D.timestamp))?1:-1),!b.length)throw new Error("No change sets in the history between the history indexes provided");Y.log("UNDO change-set: ",b[0].id," ",b[0].timestamp),b.forEach(D=>{oA(D,V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);V.previousVersion&&M.restoreVersion(V.previousVersion),l.timestamp=M.createdAt,l.add(M,F.Removed,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.previousVersion),l.timestamp=M.createdAt,l.add(M,F.Updated,{preventRecursion:!0})},V=>{const M=i.instances[V.id]||i.deletedInstances[V.id];let x="";try{x=S(V,i)}catch{}if(!M)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" doesn't have an 'activeVersion' set.`);if(!M.knownVersions)throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value.`);if(!M.knownVersions.get(V.version))throw new Error(`Entity ${V.type} ${x?`"${x}" `:""}with id "${V.id}" has an active version instance missing the 'knownVersions' property value for version "${V.version}".`);M.restoreVersion(V.previousVersion),l.timestamp=M.createdAt,l.add(M,F.Added,{preventRecursion:!0})})})}let e;if(u==="initial"){const v=Array.from(((y=i.knownVersions)==null?void 0:y.values())||[]).reduce((T,I)=>!T||B(I.createdAt).isBefore(B(T.createdAt))?I:T,null);if(!v)throw new Error("No oldest version found");e=v.createdAt}else e=u.timestamp;return l.open=!1,{transitionalChangeSet:l,transitionTime:a,timeOfOriginalTargetChanges:e}}function oA(d,u,i,a){if(!(d!=null&&d.self))throw new Error("Change set must have a valid `self` entity state to be traversed");const l=new Oa(d.self);Y.log("changeSet.added: ",Object.keys(d.added).length),Y.log("changeSet.updated: ",Object.keys(d.updated).length),Y.log("changeSet.removed: ",Object.keys(d.removed).length);const c={...d.added,...d.updated,...d.removed};l.order=Object.keys(c),l.flatRecord=c,l.orderEntities(),Y.log("All entities: ",l.order.map((e,y)=>`${y+1}: ${c[e].type} - ${e}`).join(`,
|
|
14
14
|
`)),Y.log("Traversing new additions"),l.visit(async e=>{if(d.added[e.id])try{Y.log("Adding: ",e.id),u(e)}catch(y){Y.error("Error: ",y),Y.error("Errored entity: ",e)}}),Y.log("Traversing updates"),l.visit(async e=>{if(d.updated[e.id])try{Y.log("Updating: ",e.id),i(e)}catch(y){Y.error("Error: ",y),Y.error("Errored entity: ",e)}}),Y.log("Traversing removals"),l.visit(async(e,y)=>{if(d.removed[e.id])try{Y.log("Removing: ",e.id),a(e)}catch(v){Y.error("Error: ",v),Y.error("Errored entity: ",e)}})}function dA(d,u,i){const a=d+1;return u.splice(a,u.length-a,i),u.length-1}function GCe(d){[...d.listUpdated,...d.listAdded].forEach(u=>{const i=d.project.get(u.id);i.editable=!0})}function kCe(d){[...d.listUpdated,...d.listAdded].forEach(u=>{const i=d.project.get(u.id);i.deletable=!0})}function FCe(d){[...d.listUpdated,...d.listAdded].forEach(u=>{const i=d.project.get(u.id);i.editable=!0,i.deletable=!0})}function KCe(d){[...d.listUpdated,...d.listAdded].forEach(u=>{const i=d.project.get(u.id);i.editable=!1})}function qCe(d){[...d.listUpdated,...d.listAdded].forEach(u=>{const i=d.project.get(u.id);i.deletable=!1})}function ZCe(d){[...d.listUpdated,...d.listAdded].forEach(u=>{const i=d.project.get(u.id);i.editable=!1,i.deletable=!1})}function WCe(d,u){u?d.metaSync({editable:!1,deletable:!1},u):(d.editable=!1,d.deletable=!1),Ee(d,new Set,{ignoreBuiltInBaseEntities:!0}).forEach(a=>{u?a.metaSync({editable:!1,deletable:!1},u):(a.editable=!1,a.deletable=!1)})}function HCe(d,u){u?d.metaSync({editable:!0,deletable:!0},u):(d.editable=!0,d.deletable=!0),Ee(d,new Set,{ignoreBuiltInBaseEntities:!0}).forEach(a=>{u?a.metaSync({editable:!0,deletable:!0},u):(a.editable=!0,a.deletable=!0)})}class uA{constructor(u){_(this,"version");_(this,"previousVersion");_(this,"createdAt");_(this,"deleted",!1);_(this,"author");this.version=u.version,this.previousVersion=u.previousVersion,this.createdAt=B(u.createdAt).toISOString(),this.deleted=u.deleted,this.author=u.author}baseMetaSync(u,i,a){this.deleted=u.deleted!==void 0?u.deleted:this.deleted}}class cr extends uA{constructor(i){super(i);_(this,"deletable",!0);_(this,"editable",!0);this.deletable=i.deletable,this.editable=i.editable}checkCanEditWithCounterpartAndSideEffects(i,a,l,c){var e,y;return!this.checkCanEdit(i,c)||!this.checkCanEdit(a,c)?(this.checkCanEdit(a,c)?(Y.warn(`[${l}] User is not allowed to edit this ${i.type} entity with id: ${i.id}`),c==null||c.event({id:`${l}-${i.id}--${a.id}`,action:l,owner:i,counterpart:a,errorReason:Gi.ActionOwnerEntityNotEditable,rootAction:((y=c==null?void 0:c.self)==null?void 0:y.id)===i.id&&(c==null?void 0:c.autoCloseActionName)===l})):(Y.warn(`[${l}] User is not allowed to edit this ${i.type} entity with id: ${i.id} because its counterpart ${a.type} with id: ${a.id} is not editable`),c==null||c.event({id:`${l}-${i.id}--${a.id}`,action:l,owner:i,counterpart:a,errorReason:Gi.ActionCounterpartEntityNotEditable,rootAction:((e=c==null?void 0:c.self)==null?void 0:e.id)===i.id&&(c==null?void 0:c.autoCloseActionName)===l})),c==null||c.attemptAutoclose(l,i.id),!1):!0}checkCanEditFromScopeOwner(i,a){const l=Cr(i,i.project);return l?this.checkCanEdit(l,a):!0}checkCanEditFromScopeOwnerWithSideEffects(i,a,l){var e;const c=this.checkCanEditFromScopeOwner(i,l);return!c&&!(l!=null&&l.ignoreNonEditable)&&(Y.warn(`[${a}] User is not allowed to edit this ${i.type} entity with id: ${i.id}`),l==null||l.event({id:`${a}-${i.id}`,action:a,owner:i,errorReason:Gi.ActionOwnerEntityNotEditable,rootAction:((e=l==null?void 0:l.self)==null?void 0:e.id)===i.id&&(l==null?void 0:l.autoCloseActionName)===a}),l==null||l.attemptAutoclose(a,i.id)),c}checkCanEdit(i,a){var c,e,y;return(c=i.project)!=null&&c.initialized?i.type===p.BuiltInBaseEntity||i.type===p.PrimitiveEntity?!1:i.initialized?!(Array.from(new Set([...Kn(),...(e=i.project)!=null&&e.initialized?(y=i.project)==null?void 0:y.getAllBuiltInIds():[]])).includes(i.id)||i.parent&&!(this.checkCanEdit(i.parent,a)&&i.editable)&&!(a!=null&&a.ignoreNonEditable)||!i.editable&&!(a!=null&&a.ignoreNonEditable)):!0:!0}checkCanDelete(i,a){var c,e,y;return Array.from(new Set([...Kn(),...(c=i.project)!=null&&c.initialized?(e=i.project)==null?void 0:e.getAllBuiltInIds():[]])).includes(i.id)?!1:i.type===p.Project||(y=i.parent)!=null&&y.deleted?!0:!(!i.deletable&&!(a!=null&&a.ignoreNonDeletable))}baseMetaSync(i,a,l){this.deletable=i.deletable!==void 0?i.deletable:this.deletable,this.editable=i.editable!==void 0?i.editable:this.editable;const c={...i,deleted:this.checkCanDelete(a,l)?i.deleted:!1};super.baseMetaSync(c,a,l)}}var RK=(d=>(d.ArgumentDataTypeEntityField="data-type-entity-field",d.ArgumentDataTypeField="data-type-field",d.ArgumentImplementsField="argument-implements-field",d))(RK||{});const Ht=class Ht extends cr{constructor(i,a){super(i);_(this,"initialData");_(this,"id");_(this,"name");_(this,"codeName",null);_(this,"description",null);_(this,"index");_(this,"required");_(this,"constant",!0);_(this,"type",p.ArgumentDeclaration);_(this,"defaultValue",null);_(this,"dataType",null);_(this,"writesValues",[]);_(this,"implements",[]);_(this,"project");_(this,"errors",[]);_(this,"parent");_(this,"detachedDependents",{});_(this,"knownVersions",null);_(this,"activeVersion",!1);_(this,"initialized",!1);_(this,"startedInitialization",!1);_(this,"suggestion",!1);_(this,"_codeNativeValueValidation",null);this.initialData=i,this.project=a,this.id=i.id,this.index=i.index,this.name=i.name,this.description=i.description,this.codeName=i.codeName,this.required=i.required,this.constant=!0}static new(i=null){return{id:L.UUID.uuid(),version:L.UUID.uuid(),createdAt:(i==null?void 0:i.timestamp)||B().toISOString(),author:(i==null?void 0:i.author)||L.sessionAuthor,previousVersion:null,deleted:!1,deletable:!0,editable:!0,type:p.ArgumentDeclaration,name:"",codeName:null,description:"",index:0,required:!1,constant:!0,implements:[],dataType:null,defaultValue:null,writesValues:[],parent:null}}static fromGenerationTarget(i,a){const l=ie(i.parent),c=a.get(l),e={id:i.id,version:L.UUID.uuid(),createdAt:B().toISOString(),author:L.sessionAuthor,previousVersion:null,deleted:!1,name:i.name,deletable:!0,editable:!0,type:p.ArgumentDeclaration,index:c.inputs.length,defaultValue:null,codeName:i.codeName||null,description:i.description||null,required:i.required,constant:!0,implements:[],dataType:null,writesValues:[],parent:c},y=se(e,a);return y.setParent(c,null),y}static validateGenerationTarget(i,a){let l=JSON.parse(JSON.stringify(i));const c=[],e=Gr(l,{parent:{list:!1,types:[p.FunctionDeclaration,p.Search,p.Condition]}},a);l=e.modifiedData;const y=vR(l,a);if(l.parent){const v=a.get(ie(l.parent));if(v&&Bt.includes(v.type)){const T=v.implements;if(T){const I=T.inputs.find(G=>G.name===l.name),b=T.inputs.filter(G=>!v.inputs.find(Z=>Z.type===p.ArgumentDeclaration&&Z.name===G.name)),D=v.inputs.filter(G=>G.type===p.ArgumentDeclaration),V=D.find(G=>G.name===l.name),M=D.length?`The parent entity already implements the following arguments: ${ht(D.map(G=>`'${G.id}' (${G.name})`),", "," and ")}.`:"The parent entity does not yet have any implemented arguments.",x=b.length?`The parent entity is still missing the following arguments in the implementation: ${ht(b.map(G=>`'${G.id}' (${G.name})`),", "," and ")}.`:"The parent entity has all the arguments it needs implemented.";I?V&&c.push(new pe({id:`${l.id}--${de.NoOverlapWithImplementedSignature}`,code:de.NoOverlapWithImplementedSignature,severity:te.Error,message:`Entity of type '${p.ArgumentDeclaration}' with id '${l.id}' should not exist in a parent entity of type '${v.type}' with id '${v.id}' that implements a ${p.ActionDescriptor} with fixed arguments.
|
|
15
15
|
Adding a new argument would make the implementation invalid. An argument with the same name already exists in the parent entity.
|
|
16
16
|
${M}
|
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.6599",
|
|
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",
|