@elyx-code/project-logic-tree 0.0.7032 → 0.0.7033

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.cjs CHANGED
@@ -609,7 +609,7 @@ The only use for declaring global callable entities is for a 'variable-declarati
609
609
  Or for a logic that the user is going to manually test themselves by clicking on the user-interface.`,entity:s}));else{const i=Zv(s);if(!i.reachable&&i.entryPoint){let r=`This '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" is not reachable from the project's closest entry point '${i.entryPoint.type}' "${ye(i.entryPoint,s.project)}".`;r+=`
610
610
  This is because there are termination statements in the call chain before reaching this '${s.type}'.
611
611
  If a caller entity calls a termination statement, it will always prevent all other calls from executing.`;let a=`
612
- This '${s.type}' is blocked `;i.blocks.forEach((c,e)=>{const f=c.blockedByCaller,h=c.blockedByCalling;e===0?a+="by ":e===i.blocks.length-1&&(a+="and by "),a+=`its ancestor "${ye(f,s.project)}" with id "${f.id}" that calls a '${h.type}' entity with id "${h.id}"`,e<i.blocks.length-1?a+=", ":a+="."}),u.push(new Gi({id:`${s.id}--${_e.UnreachableEntity}`,code:_e.UnreachableEntity,severity:ve.Warning,message:`${r}${a}`,entity:s}))}}return Ti(s.errors,u)}function gUe(s){const u=[],i=pi(s,s.project);if(i){if(i.type===d.Project)return u}else return u;if(s.type===d.Condition&&s.parent.type===d.Condition||s.type===d.InternalCall&&!s.calledBy.length||s.type===d.VariableInstance&&!s.calledBy.length&&!s.successCalls.length&&!s.errorCalls.length&&s.usedInternalCalls.length)return u;const r=i.getDataType(null),a=Ea(r,{removeDuplicates:!0}),c=a.find(f=>{var h;return((h=f==null?void 0:f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id}),e=a.every(f=>{var h;return f.isResolved&&((h=f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id});return!r||!c?u:((s.type===d.Condition||s.catchesError)&&!s.errorCalls.length&&e&&u.push(new Gi({id:`${s.id}--${Ae.ParentScopeRequiresReturnCurrentCatchesErrorWithNoCalls}`,code:Ae.ParentScopeRequiresReturnCurrentCatchesErrorWithNoCalls,severity:ve.Error,message:`This '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" catches its errors, which terminates the branch, but its parent ${i.type} "${ye(i,s.project)}" with id "${i.id}" requires a returned value.`,entity:s})),Ti(s.errors,u))}function ts(s){const u=[...gUe(s)],i=pi(s,s.project);if(i){if(i.type===d.Project)return u}else return u;if(s.type===d.Condition&&s.parent.type===d.Condition||s.type===d.InternalCall&&!s.calledBy.length||s.type===d.VariableInstance&&!s.calledBy.length&&!s.successCalls.length&&!s.errorCalls.length&&s.usedInternalCalls.length)return u;const r=i.getDataType(null),a=Ea(r,{removeDuplicates:!0}),c=a.find(f=>{var h;return((h=f==null?void 0:f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id}),e=a.every(f=>{var h;return f.isResolved&&((h=f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id});return!r||!c?u:(!s.successCalls.length&&e&&u.push(new Gi({id:`${s.id}--${Ae.ParentScopeRequiresReturnCurrentHasNoSuccessCalls}`,code:Ae.ParentScopeRequiresReturnCurrentHasNoSuccessCalls,severity:ve.Error,message:`This '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" has no success calls, which terminates the branch, but its parent ${i.type} "${ye(i,s.project)}" with id "${i.id}" requires a returned value.`,entity:s})),Ti(s.errors,u))}function ea(s){const u=[];if(s.type===d.InputMap&&hi.includes(s.parent.type)&&s.parent.internalCalls.some(r=>!!r.calledBy.length))return u;const i=s.project.requestActiveDynamicValue(s,!0);if((i==null?void 0:i.type)===Fe.Missing){const r=zt({id:`${s.id}--${Ae.MissingRequiredValue}`,message:`The '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" is missing its required value before it can be executed or published.`,severity:ve.Error,code:Ae.MissingRequiredValue,entity:s});u.push(r.error)}return u}function Gs(s){var i,r;const u=[];if(s.codeNativeValueValidation){const a=s.project.requestActiveDynamicValue(s,!0);if(a&&((i=a.value)!=null&&i.value)){const c=s.codeNativeValueValidation(s,(r=a.value)==null?void 0:r.value);u.push(...c.errors)}}return u}function pE(s){var u;return!!((u=ea(s))!=null&&u.find(i=>i.code===Ae.MissingRequiredValue))}function Hb(s){const u=[];if(!s.internalCalls.length)return u;const i=s.internalCalls.some(r=>r.calledBy.length||r.successCalls.length||r.errorCalls.length||r.getUsedInputs().length||r.getUsedOutputs().length);if(s.readsValue&&i){const r=zt({id:`${s.id}--${Ae.VariableReadsValueAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" reads a value. A variable with internal calls can't read a value.`,severity:ve.Error,code:Ae.VariableReadsValueAndInternalCall,entity:s});u.push(r.error)}if(s.writesValues.length&&i){const r=zt({id:`${s.id}--${Ae.VariableWritesValuesAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" writes values. A variable with internal calls can't write a value.`,severity:ve.Error,code:Ae.VariableWritesValuesAndInternalCall,entity:s});u.push(r.error)}if(s.getUsedInputs().length&&i){const r=zt({id:`${s.id}--${Ae.VariableHasInputsAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" has inputs. A variable with internal calls can't have inputs.`,severity:ve.Error,code:Ae.VariableHasInputsAndInternalCall,entity:s});u.push(r.error)}if(s.getUsedOutputs().length&&i){const r=zt({id:`${s.id}--${Ae.VariableHasOutputsAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" has outputs. A variable with internal calls can't have outputs.`,severity:ve.Error,code:Ae.VariableHasOutputsAndInternalCall,entity:s});u.push(r.error)}if(s.calledBy.length&&i){const r=zt({id:`${s.id}--${Ae.VariableIsCalledAndHasInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" is called by other entities. A variable with internal calls can't be called by other entities.`,severity:ve.Error,code:Ae.VariableIsCalledAndHasInternalCall,entity:s});u.push(r.error)}if([...s.successCalls,...s.errorCalls].length&&i){const r=zt({id:`${s.id}--${Ae.VariableCallsOthersAndHasInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" calls other entities. A variable with internal calls can't call other entities.`,severity:ve.Error,code:Ae.VariableCallsOthersAndHasInternalCall,entity:s});u.push(r.error)}return u}function EVi(s){const u=s.variableDeclarations,i=s.events.flatMap(e=>[e,...Pt(e)]),r=s.functions.flatMap(e=>s.instancesList.find(f=>f.type===d.FunctionCall&&f.declaration.id===e.id)?[e,...Pt(e)]:[]),a=s.entities.flatMap(e=>[e,...s.entities.reduce((f,h)=>[...f,...h.methods.flatMap(m=>[m,...Pt(m)])],[])]);return Eb([...u,...i,...r,...a].flatMap(e=>e.getErrors()))}function IUe(s){var e,f;if(s.type!==d.InternalCall){if(!mi.includes(s.parent.type))return!1;const h=s.parent;let m=[...h.returnStatements].filter(D=>{const R=D.getDataType(null),C=Ea(R,{removeDuplicates:!0,removeNulls:!0});return C.length&&!C.some(x=>!x.entity&&!x.isGroup&&!x.foreignKeyRef)||C.some(x=>{var G;return!!x.entity&&![U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes((G=x.entity)==null?void 0:G.id)})});if(s.type===d.Loop){const D=Pt(s.body);m=m.filter(R=>!D.some(C=>C.id===R.id))}if(!!m.length)return!0;const b=((e=h.implements)==null?void 0:e.getDataType(null))||null,A=Ea(b,{removeDuplicates:!0,removeNulls:!0});return!(!A.length||A.some(D=>!D.entity&&!D.isGroup&&!D.foreignKeyRef)||A.some(D=>{var R;return!!D.entity&&[U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes((R=D.entity)==null?void 0:R.id)}))}if(!mi.includes(s.parent.parent.type))return!1;const u=s.parent.parent;if(!![...u.returnStatements].filter(h=>{const m=h.getDataType(null),v=Ea(m,{removeDuplicates:!0,removeNulls:!0});return v.length&&!v.some(b=>!b.entity&&!b.isGroup&&!b.foreignKeyRef)||v.some(b=>{var A;return!!b.entity&&![U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes((A=b.entity)==null?void 0:A.id)})}).length)return!0;const a=((f=u.implements)==null?void 0:f.getDataType(null))||null,c=Ea(a,{removeDuplicates:!0,removeNulls:!0});return!(!c.length||c.some(h=>!h.entity&&!h.isGroup&&!h.foreignKeyRef)||c.some(h=>{var m;return!!h.entity&&[U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes((m=h.entity)==null?void 0:m.id)}))}function Wb(s){const u=[],i=s.getDataType(null)||null,r=Ea(i,{removeDuplicates:!0}),a=r.find(m=>{var v;return((v=m==null?void 0:m.entity)==null?void 0:v.id)!==U["primitive-entity"].void.id}),c=r.every(m=>{var v;return m.isResolved&&((v=m.entity)==null?void 0:v.id)!==U["primitive-entity"].void.id});if(!i||!a)return u;const e=s.returnStatements.length;if(Pt(s,{excludeLoopBodies:!0}).filter(m=>St.includes(m.type)?!1:m.type===d.InternalCall&&!m.calledBy.length?u:m.type===d.Condition?m.parent.type===d.Condition?!1:!m.successCalls.length||!m.errorCalls.length:!!((!m.successCalls.length||!m.errorCalls.length&&m.catchesError)&&m.calledBy.length)).length&&(c||e)){const m=zt({id:`${s.id}--${Ae.LackingReturnStatementOnSomeBranches}`,message:`The '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" is missing the required return statement by its implementation on some branches.`,severity:ve.Error,code:Ae.LackingReturnStatementOnSomeBranches,entity:s});u.push(m.error)}return u}function is(s){const u=[];if(!Ar.includes(s.type)||St.includes(s.type)||mi.includes(s.type)||!IUe(s))return u;if(!s.successCalls.length&&!s.errorCalls.length&&s.calledBy.length){const i=zt({id:`${s.id}--${Ae.LastCalledEntityMustBeReturnEntity}`,message:`The '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" cannot be the last entity of the branch. A return statement must be the last entity on all branches of its parent entry-point.`,severity:ve.Error,code:Ae.LastCalledEntityMustBeReturnEntity,entity:s});u.push(i.error)}return u}const RUe=["class","function","if","else","for","while","do","switch","case","default","break","continue","return","try","catch","finally","throw","import","export","as","from","in","instanceof","typeof","yield","await","async","this","new","delete","void","with","const","let","var","public","private","protected","static","get","set","constructor","extends","implements","interface","namespace","package","abstract","readonly","module"];function zb(s,u=[xr],i=[],r){const a=[],c=r??s.name;if(!c){const m=zt({id:`${s.id}--${_e.EmptyName}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" does not have a name. Entities of type ${s.type} must have valid names.`,severity:ve.Error,code:_e.EmptyName,entity:s});return a.push(m.error),a}const e=c.trim(),f=!i.some(m=>m.name===c||m.name===e);if(!f){const m=zt({id:`${s.id}--${_e.NameNotUniqueInScope}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" does not have a unique name. Entities of type ${s.type} must have valid names among all other entities of its type.`,severity:ve.Error,code:_e.NameNotUniqueInScope,entity:s});a.push(m.error)}if(u.forEach(m=>{const v=m(c);if(!!i.some(D=>m(D.name||"")===v)&&f){const D=zt({id:`${s.id}--${_e.NameAsResolvedCodeNameNotUniqueInScope}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" does not have a unique name once it is resolved as it will appear in code: "${v}". Entities of type ${s.type} must have valid names including their code name form.`,severity:ve.Error,code:_e.NameAsResolvedCodeNameNotUniqueInScope,entity:s});a.push(D.error)}if(RUe.find(D=>D===v)){const D=zt({id:`${s.id}--${_e.NameIsForbiddenKeyword}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" has a name that is a forbidden keyword: "${v}". Entities of type ${s.type} must not use reserved keywords as names.`,severity:ve.Error,code:_e.NameIsForbiddenKeyword,entity:s});a.push(D.error)}}),!/^[a-zA-Z_]/.test(c)){const m=zt({id:`${s.id}--${_e.NameMustStartWithLetterOrUnderscore}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" has a name that does not start with a letter or underscore.`,severity:ve.Error,code:_e.NameMustStartWithLetterOrUnderscore,entity:s});a.push(m.error)}return a}async function wUe(s,u={}){var e,f;const i=te.YieldTracker.from(u),r=[];let a=[];if(s.entity&&a.push("entity"),s.andChildrenGroup&&a.push("andChildrenGroup"),s.orChildrenGroup&&a.push("orChildrenGroup"),s.foreignKeyRef&&a.push("foreignKeyRef"),s.foreignKeyAllowed&&a.push("foreignKeyAllowed"),a.length>1){const h=zt({id:s.id+"--"+Ae.InvalidPropertiesCombination,message:`Data type with id "${s.id}" has invalid properties combination. Only one of the following properties can be present at the time: 'entity', 'andChildrenGroup', 'orChildrenGroup', 'foreignKeyRef' or 'foreignKeyAllowed'.
612
+ This '${s.type}' is blocked `;i.blocks.forEach((c,e)=>{const f=c.blockedByCaller,h=c.blockedByCalling;e===0?a+="by ":e===i.blocks.length-1&&(a+="and by "),a+=`its ancestor "${ye(f,s.project)}" with id "${f.id}" that calls a '${h.type}' entity with id "${h.id}"`,e<i.blocks.length-1?a+=", ":a+="."}),u.push(new Gi({id:`${s.id}--${_e.UnreachableEntity}`,code:_e.UnreachableEntity,severity:ve.Warning,message:`${r}${a}`,entity:s}))}}return Ti(s.errors,u)}function gUe(s){const u=[],i=pi(s,s.project);if(i){if(i.type===d.Project)return u}else return u;if(s.type===d.Condition&&s.parent.type===d.Condition||s.type===d.InternalCall&&!s.calledBy.length||s.type===d.VariableInstance&&!s.calledBy.length&&!s.successCalls.length&&!s.errorCalls.length&&s.usedInternalCalls.length)return u;const r=i.getDataType(null),a=Ea(r,{removeDuplicates:!0}),c=a.find(f=>{var h;return((h=f==null?void 0:f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id}),e=a.every(f=>{var h;return f.isResolved&&((h=f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id});return!r||!c?u:((s.type===d.Condition||s.catchesError)&&!s.errorCalls.length&&e&&u.push(new Gi({id:`${s.id}--${Ae.ParentScopeRequiresReturnCurrentCatchesErrorWithNoCalls}`,code:Ae.ParentScopeRequiresReturnCurrentCatchesErrorWithNoCalls,severity:ve.Error,message:`This '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" catches its errors, which terminates the branch, but its parent ${i.type} "${ye(i,s.project)}" with id "${i.id}" requires a returned value.`,entity:s})),Ti(s.errors,u))}function ts(s){const u=[...gUe(s)],i=pi(s,s.project);if(i){if(i.type===d.Project)return u}else return u;if(s.type===d.Condition&&s.parent.type===d.Condition||s.type===d.InternalCall&&!s.calledBy.length||s.type===d.VariableInstance&&!s.calledBy.length&&!s.successCalls.length&&!s.errorCalls.length&&s.usedInternalCalls.length)return u;const r=i.getDataType(null),a=Ea(r,{removeDuplicates:!0}),c=a.find(f=>{var h;return((h=f==null?void 0:f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id}),e=a.every(f=>{var h;return f.isResolved&&((h=f.entity)==null?void 0:h.id)!==U["primitive-entity"].void.id});return!r||!c?u:(!s.successCalls.length&&e&&u.push(new Gi({id:`${s.id}--${Ae.ParentScopeRequiresReturnCurrentHasNoSuccessCalls}`,code:Ae.ParentScopeRequiresReturnCurrentHasNoSuccessCalls,severity:ve.Error,message:`This '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" has no success calls, which terminates the branch, but its parent ${i.type} "${ye(i,s.project)}" with id "${i.id}" requires a returned value.`,entity:s})),Ti(s.errors,u))}function ea(s){const u=[];if(s.type===d.InputMap&&hi.includes(s.parent.type)&&s.parent.internalCalls.some(r=>!!r.calledBy.length))return u;const i=s.project.requestActiveDynamicValue(s,!0);if((i==null?void 0:i.type)===Fe.Missing){const r=zt({id:`${s.id}--${Ae.MissingRequiredValue}`,message:`The '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" is missing its required value before it can be executed or published.`,severity:ve.Error,code:Ae.MissingRequiredValue,entity:s});u.push(r.error)}return u}function Gs(s){var i,r;const u=[];if(s.codeNativeValueValidation){const a=s.project.requestActiveDynamicValue(s,!0);if(a&&((i=a.value)!=null&&i.value)){const c=s.codeNativeValueValidation(s,(r=a.value)==null?void 0:r.value);u.push(...c.errors)}}return u}function pE(s){var u;return!!((u=ea(s))!=null&&u.find(i=>i.code===Ae.MissingRequiredValue))}function Hb(s){const u=[];if(!s.internalCalls.length)return u;const i=s.internalCalls.some(r=>r.calledBy.length||r.successCalls.length||r.errorCalls.length||r.getUsedInputs().length||r.getUsedOutputs().length);if(s.readsValue&&i){const r=zt({id:`${s.id}--${Ae.VariableReadsValueAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" reads a value. A variable with internal calls can't read a value.`,severity:ve.Error,code:Ae.VariableReadsValueAndInternalCall,entity:s});u.push(r.error)}if(s.writesValues.length&&i){const r=zt({id:`${s.id}--${Ae.VariableWritesValuesAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" writes values. A variable with internal calls can't write a value.`,severity:ve.Error,code:Ae.VariableWritesValuesAndInternalCall,entity:s});u.push(r.error)}if(s.getUsedInputs().length&&i){const r=zt({id:`${s.id}--${Ae.VariableHasInputsAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" has inputs. A variable with internal calls can't have inputs.`,severity:ve.Error,code:Ae.VariableHasInputsAndInternalCall,entity:s});u.push(r.error)}if(s.getUsedOutputs().length&&i){const r=zt({id:`${s.id}--${Ae.VariableHasOutputsAndInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" has outputs. A variable with internal calls can't have outputs.`,severity:ve.Error,code:Ae.VariableHasOutputsAndInternalCall,entity:s});u.push(r.error)}if(s.calledBy.length&&i){const r=zt({id:`${s.id}--${Ae.VariableIsCalledAndHasInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" is called by other entities. A variable with internal calls can't be called by other entities.`,severity:ve.Error,code:Ae.VariableIsCalledAndHasInternalCall,entity:s});u.push(r.error)}if([...s.successCalls,...s.errorCalls].length&&i){const r=zt({id:`${s.id}--${Ae.VariableCallsOthersAndHasInternalCall}`,message:`Variable "${ye(s,s.project)}" with id "${s.id}" calls other entities. A variable with internal calls can't call other entities.`,severity:ve.Error,code:Ae.VariableCallsOthersAndHasInternalCall,entity:s});u.push(r.error)}return u}function EVi(s){const u=s.variableDeclarations,i=s.events.flatMap(e=>[e,...Pt(e)]),r=s.functions.flatMap(e=>s.instancesList.find(f=>f.type===d.FunctionCall&&f.declaration.id===e.id)?[e,...Pt(e)]:[]),a=s.entities.flatMap(e=>[e,...s.entities.reduce((f,h)=>[...f,...h.methods.flatMap(m=>[m,...Pt(m)])],[])]);return Eb([...u,...i,...r,...a].flatMap(e=>e.getErrors()))}function IUe(s){var e,f;if(s.type!==d.InternalCall){if(!mi.includes(s.parent.type))return!1;const h=s.parent;let m=[...h.returnStatements].filter(D=>{const R=D.getDataType(null),C=Ea(R,{removeDuplicates:!0,removeNulls:!0});return C.length&&!C.some(G=>!G.entity&&!G.isGroup&&!G.foreignKeyRef)&&!C.some(G=>{var $;return!!G.entity&&[U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes(($=G.entity)==null?void 0:$.id)})});if(s.type===d.Loop){const D=Pt(s.body);m=m.filter(R=>!D.some(C=>C.id===R.id))}if(!!m.length)return!0;const b=((e=h.implements)==null?void 0:e.getDataType(null))||null,A=Ea(b,{removeDuplicates:!0,removeNulls:!0});return!(!A.length||A.some(D=>!D.entity&&!D.isGroup&&!D.foreignKeyRef)||A.some(D=>{var R;return!!D.entity&&[U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes((R=D.entity)==null?void 0:R.id)}))}if(!mi.includes(s.parent.parent.type))return!1;const u=s.parent.parent;if(!![...u.returnStatements].filter(h=>{const m=h.getDataType(null),v=Ea(m,{removeDuplicates:!0,removeNulls:!0});return v.length&&!v.some(A=>!A.entity&&!A.isGroup&&!A.foreignKeyRef)&&!v.some(A=>{var D;return!!A.entity&&[U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes((D=A.entity)==null?void 0:D.id)})}).length)return!0;const a=((f=u.implements)==null?void 0:f.getDataType(null))||null,c=Ea(a,{removeDuplicates:!0,removeNulls:!0});return!(!c.length||c.some(h=>!h.entity&&!h.isGroup&&!h.foreignKeyRef)||c.some(h=>{var m;return!!h.entity&&[U["primitive-entity"].void.id,U["primitive-entity"].untyped.id].includes((m=h.entity)==null?void 0:m.id)}))}function Wb(s){const u=[],i=s.getDataType(null)||null,r=Ea(i,{removeDuplicates:!0}),a=r.find(m=>{var v;return((v=m==null?void 0:m.entity)==null?void 0:v.id)!==U["primitive-entity"].void.id}),c=r.every(m=>{var v;return m.isResolved&&((v=m.entity)==null?void 0:v.id)!==U["primitive-entity"].void.id});if(!i||!a)return u;const e=s.returnStatements.length;if(Pt(s,{excludeLoopBodies:!0}).filter(m=>St.includes(m.type)?!1:m.type===d.InternalCall&&!m.calledBy.length?u:m.type===d.Condition?m.parent.type===d.Condition?!1:!m.successCalls.length||!m.errorCalls.length:!!((!m.successCalls.length||!m.errorCalls.length&&m.catchesError)&&m.calledBy.length)).length&&(c||e)){const m=zt({id:`${s.id}--${Ae.LackingReturnStatementOnSomeBranches}`,message:`The '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" is missing the required return statement by its implementation on some branches.`,severity:ve.Error,code:Ae.LackingReturnStatementOnSomeBranches,entity:s});u.push(m.error)}return u}function is(s){const u=[];if(!Ar.includes(s.type)||St.includes(s.type)||mi.includes(s.type)||!IUe(s))return u;if(!s.successCalls.length&&!s.errorCalls.length&&s.calledBy.length){const i=zt({id:`${s.id}--${Ae.LastCalledEntityMustBeReturnEntity}`,message:`The '${s.type}' entity "${ye(s,s.project)}" with id "${s.id}" cannot be the last entity of the branch. A return statement must be the last entity on all branches of its parent entry-point.`,severity:ve.Error,code:Ae.LastCalledEntityMustBeReturnEntity,entity:s});u.push(i.error)}return u}const RUe=["class","function","if","else","for","while","do","switch","case","default","break","continue","return","try","catch","finally","throw","import","export","as","from","in","instanceof","typeof","yield","await","async","this","new","delete","void","with","const","let","var","public","private","protected","static","get","set","constructor","extends","implements","interface","namespace","package","abstract","readonly","module"];function zb(s,u=[xr],i=[],r){const a=[],c=r??s.name;if(!c){const m=zt({id:`${s.id}--${_e.EmptyName}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" does not have a name. Entities of type ${s.type} must have valid names.`,severity:ve.Error,code:_e.EmptyName,entity:s});return a.push(m.error),a}const e=c.trim(),f=!i.some(m=>m.name===c||m.name===e);if(!f){const m=zt({id:`${s.id}--${_e.NameNotUniqueInScope}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" does not have a unique name. Entities of type ${s.type} must have valid names among all other entities of its type.`,severity:ve.Error,code:_e.NameNotUniqueInScope,entity:s});a.push(m.error)}if(u.forEach(m=>{const v=m(c);if(!!i.some(D=>m(D.name||"")===v)&&f){const D=zt({id:`${s.id}--${_e.NameAsResolvedCodeNameNotUniqueInScope}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" does not have a unique name once it is resolved as it will appear in code: "${v}". Entities of type ${s.type} must have valid names including their code name form.`,severity:ve.Error,code:_e.NameAsResolvedCodeNameNotUniqueInScope,entity:s});a.push(D.error)}if(RUe.find(D=>D===v)){const D=zt({id:`${s.id}--${_e.NameIsForbiddenKeyword}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" has a name that is a forbidden keyword: "${v}". Entities of type ${s.type} must not use reserved keywords as names.`,severity:ve.Error,code:_e.NameIsForbiddenKeyword,entity:s});a.push(D.error)}}),!/^[a-zA-Z_]/.test(c)){const m=zt({id:`${s.id}--${_e.NameMustStartWithLetterOrUnderscore}`,message:`${Js[s.type].singular} "${ye(s,s.project)}" with id "${s.id}" has a name that does not start with a letter or underscore.`,severity:ve.Error,code:_e.NameMustStartWithLetterOrUnderscore,entity:s});a.push(m.error)}return a}async function wUe(s,u={}){var e,f;const i=te.YieldTracker.from(u),r=[];let a=[];if(s.entity&&a.push("entity"),s.andChildrenGroup&&a.push("andChildrenGroup"),s.orChildrenGroup&&a.push("orChildrenGroup"),s.foreignKeyRef&&a.push("foreignKeyRef"),s.foreignKeyAllowed&&a.push("foreignKeyAllowed"),a.length>1){const h=zt({id:s.id+"--"+Ae.InvalidPropertiesCombination,message:`Data type with id "${s.id}" has invalid properties combination. Only one of the following properties can be present at the time: 'entity', 'andChildrenGroup', 'orChildrenGroup', 'foreignKeyRef' or 'foreignKeyAllowed'.
613
613
 
614
614
  Currently present fields: "${qt(a,'", "','" and "')}".`,severity:ve.Error,code:Ae.InvalidPropertiesCombination,entity:s});r.push(h.error)}if(((e=s.entity)==null?void 0:e.type)===d.PrimitiveEntity&&s.entity.id===U["primitive-entity"].enum.id&&!((f=s.options)!=null&&f.length)){const h=zt({id:s.id+"--"+Ae.MissingEnumOptions,message:`Data type with id "${s.id}" is an enum but has no options.`,severity:ve.Error,code:Ae.MissingEnumOptions,entity:s});r.push(h.error)}const c=Ti(s.errors,r);await i.tick();for(const h of s.andChildrenGroup||[])await h.validateAsync({tracker:i});for(const h of s.orChildrenGroup||[])await h.validateAsync({tracker:i});return c}function DUe(s){var r,a;const u=[];let i=[];if(s.entity&&i.push("entity"),s.andChildrenGroup&&i.push("andChildrenGroup"),s.orChildrenGroup&&i.push("orChildrenGroup"),s.foreignKeyRef&&i.push("foreignKeyRef"),s.foreignKeyAllowed&&i.push("foreignKeyAllowed"),i.length>1){const c=zt({id:s.id+"--"+Ae.InvalidPropertiesCombination,message:`Data type with id "${s.id}" has invalid properties combination. Only one of the following properties can be present at the time: 'entity', 'andChildrenGroup', 'orChildrenGroup', 'foreignKeyRef' or 'foreignKeyAllowed'.
615
615
 
package/dist/index.js CHANGED
@@ -188089,14 +188089,14 @@ function Iwi(s) {
188089
188089
  // This check is similar, but not exactly equal to the dt.isResolved
188090
188090
  // Because the `.isResolved` is `true` when `.foreignKeyAllowed` is `true`,
188091
188091
  // which we don't care about here
188092
- (N) => !N.entity && !N.isGroup && !N.foreignKeyRef
188093
- ) || D.some(
188094
- (N) => {
188095
- var M;
188096
- return !!N.entity && ![
188092
+ (M) => !M.entity && !M.isGroup && !M.foreignKeyRef
188093
+ ) && !D.some(
188094
+ (M) => {
188095
+ var $;
188096
+ return !!M.entity && [
188097
188097
  j["primitive-entity"].void.id,
188098
188098
  j["primitive-entity"].untyped.id
188099
- ].includes((M = N.entity) == null ? void 0 : M.id);
188099
+ ].includes(($ = M.entity) == null ? void 0 : $.id);
188100
188100
  }
188101
188101
  );
188102
188102
  });
@@ -188140,17 +188140,14 @@ function Iwi(s) {
188140
188140
  removeNulls: !0
188141
188141
  });
188142
188142
  return v.length && !v.some(
188143
- // This check is similar, but not exactly equal to the dt.isResolved
188144
- // Because the `.isResolved` is `true` when `.foreignKeyAllowed` is `true`,
188145
- // which we don't care about here
188146
- (E) => !E.entity && !E.isGroup && !E.foreignKeyRef
188147
- ) || v.some(
188148
- (E) => {
188149
- var A;
188150
- return !!E.entity && ![
188143
+ (A) => !A.entity && !A.isGroup && !A.foreignKeyRef
188144
+ ) && !v.some(
188145
+ (A) => {
188146
+ var C;
188147
+ return !!A.entity && [
188151
188148
  j["primitive-entity"].void.id,
188152
188149
  j["primitive-entity"].untyped.id
188153
- ].includes((A = E.entity) == null ? void 0 : A.id);
188150
+ ].includes((C = A.entity) == null ? void 0 : C.id);
188154
188151
  }
188155
188152
  );
188156
188153
  }).length)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyx-code/project-logic-tree",
3
- "version": "0.0.7032",
3
+ "version": "0.0.7033",
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",