@code0-tech/triangulum 0.1.0 → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright 2023-2026 Code0 UG (haftungsbeschränkt) i.G.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ AI Usage Restriction: Notwithstanding the permissions granted above, this Software and its source code may not be used, in whole or in part, for the purpose of training, fine-tuning, or developing artificial intelligence (AI) models or machine learning algorithms without prior written consent from the Copyright Holder.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -2,4 +2,4 @@ import { LiteralValue } from '@code0-tech/sagittarius-graphql-types';
2
2
  /**
3
3
  * Uses the TypeScript compiler to generate a precise type string from any runtime value.
4
4
  */
5
- export declare const getTypeFromValue: (value: LiteralValue) => string;
5
+ export declare const getTypeFromValue: (value: LiteralValue | null) => string;
@@ -1,4 +1,4 @@
1
- import { ExtendedDataType } from '../utils';
1
+ import { DataType } from '@code0-tech/sagittarius-graphql-types';
2
2
  export declare enum DataTypeVariant {
3
3
  PRIMITIVE = 0,
4
4
  TYPE = 1,
@@ -8,4 +8,4 @@ export declare enum DataTypeVariant {
8
8
  /**
9
9
  * Determines the variant of a given TypeScript type string using the TS compiler.
10
10
  */
11
- export declare const getTypeVariant: (type: string, dataTypes: ExtendedDataType[]) => DataTypeVariant;
11
+ export declare const getTypeVariant: (type: string, dataTypes: DataType[]) => DataTypeVariant;
@@ -1,5 +1,4 @@
1
- import { NodeFunction } from '@code0-tech/sagittarius-graphql-types';
2
- import { ExtendedDataType, ExtendedFunction } from '../utils';
1
+ import { DataType, FunctionDefinition, NodeFunction } from '@code0-tech/sagittarius-graphql-types';
3
2
  export interface NodeTypes {
4
3
  parameters: string[];
5
4
  returnType: string;
@@ -7,4 +6,4 @@ export interface NodeTypes {
7
6
  /**
8
7
  * Resolves the types of the parameters and the return type of a NodeFunction.
9
8
  */
10
- export declare const getTypesFromNode: (node: NodeFunction, functions: ExtendedFunction[], dataTypes: ExtendedDataType[]) => NodeTypes;
9
+ export declare const getTypesFromNode: (node: NodeFunction, functions: FunctionDefinition[], dataTypes: DataType[]) => NodeTypes;
@@ -0,0 +1,5 @@
1
+ import { DataType, LiteralValue } from '@code0-tech/sagittarius-graphql-types';
2
+ /**
3
+ * Generates a sample LiteralValue from a TypeScript type string.
4
+ */
5
+ export declare const getValueFromType: (type: string, dataTypes: DataType[]) => LiteralValue;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,10 @@
1
- export * from './src/index'
2
- export {}
1
+ export * from './extraction/getTypeFromValue';
2
+ export * from './extraction/getTypeVariant';
3
+ export * from './extraction/getValueFromType';
4
+ export * from './extraction/getTypesFromNode';
5
+ export * from './suggestion/getNodeSuggestions';
6
+ export * from './suggestion/getReferenceSuggestions';
7
+ export * from './suggestion/getValueSuggestions';
8
+ export * from './validation/getFlowValidation';
9
+ export * from './validation/getNodeValidation';
10
+ export * from './validation/getValueValidation';
@@ -1,7 +1,6 @@
1
- import { NodeFunction } from '@code0-tech/sagittarius-graphql-types';
2
- import { ExtendedFunction } from '../utils';
1
+ import { DataType, FunctionDefinition, NodeFunction } from '@code0-tech/sagittarius-graphql-types';
3
2
  /**
4
3
  * Suggests NodeFunctions based on a given type and a list of available FunctionDefinitions.
5
4
  * Returns functions whose return type is compatible with the target type.
6
5
  */
7
- export declare function getNodeSuggestions(type: string, functions: ExtendedFunction[]): NodeFunction[];
6
+ export declare function getNodeSuggestions(type: string, functions: FunctionDefinition[], dataTypes: DataType[]): NodeFunction[];
@@ -0,0 +1,6 @@
1
+ import { DataType, Flow, FunctionDefinition, NodeFunction, ReferenceValue } from '@code0-tech/sagittarius-graphql-types';
2
+ /**
3
+ * Calculates all available reference suggestions for a specific target node in a flow
4
+ * and filters them by a required type.
5
+ */
6
+ export declare const getReferenceSuggestions: (flow: Flow, nodeId: NodeFunction["id"], type: string, functions: FunctionDefinition[], dataTypes: DataType[]) => ReferenceValue[];
@@ -1,4 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("typescript"),W=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("typescript");function A(){return A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A.apply(null,arguments)}var W=!1;try{W=typeof localStorage<"u"}catch{}var X=typeof process<"u",ee=W&&typeof localStorage.getItem=="function"&&localStorage.getItem("DEBUG")||X&&process.env.DEBUG,J=ee?console.log:function(e){return""};function te(e,t,n,r,o){r===void 0&&(r={});var c=A({},G(n),r),s=re(e,t,c,n,o),a=s.languageServiceHost,u=s.updateFile,m=s.deleteFile,f=n.createLanguageService(a),p=f.getCompilerOptionsDiagnostics();if(p.length){var i=Y(e,r,n);throw new Error(n.formatDiagnostics(p,i.compilerHost))}return{name:"vfs",sys:e,languageService:f,getSourceFile:function(v){var d;return(d=f.getProgram())==null?void 0:d.getSourceFile(v)},createFile:function(v,d){u(n.createSourceFile(v,d,c.target,!1))},updateFile:function(v,d,h){var g=f.getProgram().getSourceFile(v);if(!g)throw new Error("Did not find a source file for "+v);var S=g.text,y=h??n.createTextSpan(0,S.length),$=S.slice(0,y.start)+d+S.slice(y.start+y.length),T=n.updateSourceFile(g,$,{span:y,newLength:d.length});u(T)},deleteFile:function(v){var d=f.getProgram().getSourceFile(v);d&&m(d)}}}function R(e){throw new Error("Method '"+e+"' is not implemented.")}function w(e,t){return function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];var c=t.apply(void 0,r),s=typeof c=="string"?c.slice(0,80)+"...":c;return J.apply(void 0,["> "+e].concat(r)),J("< "+s),c}}var G=function(t){return A({},t.getDefaultCompilerOptions(),{jsx:t.JsxEmit.React,strict:!0,esModuleInterop:!0,module:t.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0},t.versionMajorMinor&&Number(t.versionMajorMinor.split(".")[0])>=6?{ignoreDeprecations:"6.0"}:{moduleResolution:t.ModuleResolutionKind.NodeJs})},K=function(t){return t.replace("/","/lib.").toLowerCase()};function ne(e){return{args:[],createDirectory:function(){return R("createDirectory")},directoryExists:w("directoryExists",function(t){return Array.from(e.keys()).some(function(n){return n.startsWith(t)})}),exit:function(){return R("exit")},fileExists:w("fileExists",function(t){return e.has(t)||e.has(K(t))}),getCurrentDirectory:function(){return"/"},getDirectories:function(){return[]},getExecutingFilePath:function(){return R("getExecutingFilePath")},readDirectory:w("readDirectory",function(t){return t==="/"?Array.from(e.keys()):[]}),readFile:w("readFile",function(t){var n;return(n=e.get(t))!=null?n:e.get(K(t))}),resolvePath:function(n){return n},newLine:`
2
+ `,useCaseSensitiveFileNames:!0,write:function(){return R("write")},writeFile:function(n,r){e.set(n,r)},deleteFile:function(n){e.delete(n)}}}function Y(e,t,n){var r=new Map,o=function(a){return r.set(a.fileName,a),a},c={compilerHost:A({},e,{getCanonicalFileName:function(a){return a},getDefaultLibFileName:function(){return"/"+n.getDefaultLibFileName(t)},getNewLine:function(){return e.newLine},getSourceFile:function(a,u){var m;return r.get(a)||o(n.createSourceFile(a,e.readFile(a),(m=u??t.target)!=null?m:G(n).target,!1))},useCaseSensitiveFileNames:function(){return e.useCaseSensitiveFileNames}}),updateFile:function(a){var u=r.has(a.fileName);return e.writeFile(a.fileName,a.text),r.set(a.fileName,a),u},deleteFile:function(a){var u=r.has(a.fileName);return r.delete(a.fileName),e.deleteFile(a.fileName),u}};return c}function re(e,t,n,r,o){var c=[].concat(t),s=Y(e,n,r),a=s.compilerHost,u=s.updateFile,m=s.deleteFile,f=new Map,p=0,i=A({},a,{getProjectVersion:function(){return p.toString()},getCompilationSettings:function(){return n},getCustomTransformers:function(){return o},getScriptFileNames:function(){return c.slice()},getScriptSnapshot:function(d){var h=e.readFile(d);if(h&&typeof h=="string")return r.ScriptSnapshot.fromString(h)},getScriptVersion:function(d){return f.get(d)||"0"},writeFile:e.writeFile}),l={languageServiceHost:i,updateFile:function(d){p++,f.set(d.fileName,p.toString()),c.includes(d.fileName)||c.push(d.fileName),u(d)},deleteFile:function(d){p++,f.set(d.fileName,p.toString());var h=c.indexOf(d.fileName);h!==-1&&c.splice(h,1),m(d)}};return l}const ie=`
2
3
  interface Array<T> {
3
4
  [n: number]: T;
4
5
  length: number;
@@ -13,56 +14,55 @@
13
14
  interface IArguments { }
14
15
  interface RegExp { }
15
16
  type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
16
- `;function I(n,s,r){return{getSourceFile:e=>{if(e===n)return r;if(e.includes("lib.")||e.endsWith(".d.ts"))return t.createSourceFile(e,W,t.ScriptTarget.Latest)},writeFile:()=>{},getDefaultLibFileName:()=>"lib.d.ts",useCaseSensitiveFileNames:()=>!0,getCanonicalFileName:e=>e,getCurrentDirectory:()=>"/",getNewLine:()=>`
17
- `,fileExists:e=>e===n||e.includes("lib.")||e.endsWith(".d.ts"),readFile:e=>e===n?s:e.includes("lib.")||e.endsWith(".d.ts")?W:void 0,directoryExists:()=>!0,getDirectories:()=>[]}}const V={target:t.ScriptTarget.Latest,lib:["lib.esnext.d.ts"],noEmit:!0,strictNullChecks:!0};function A(n){const s=Array.from(new Set(n.flatMap(e=>e.genericKeys||[]))).map(e=>`type ${e} = any;`).join(`
18
- `),r=n.map(e=>`type ${e.identifier}${e.genericKeys?`<${e.genericKeys.join(",")}>`:""} = ${e.type};`).join(`
19
- `);return`${s}
20
- ${r}`}function z(n,s){let r=n;for(const e of s){if(r==null)return"unknown";typeof e.path=="string"&&(r=r[e.path])}return typeof r}function B(n,s){const r=n.nodes;if(r)return Array.isArray(r)?r.find(e=>e.id===s):r.nodes?.find(e=>e.id===s)}function K(n,s,r){const e=n?.value;if(!e)return"undefined";if(e.__typename==="ReferenceValue"){const o=e,c=B(s,o.nodeFunctionId);if(!c)return"undefined";let u=r(s,c).inferredType;if(o.referencePath&&o.referencePath.length>0){let d;const m=c.parameters?.nodes;if(m&&m.length>0){const p=m[0];p?.value?.__typename==="LiteralValue"&&(d=p.value.value)}u=z(d,o.referencePath)}return`({} as ${u})`}if(e.__typename==="NodeFunctionIdWrapper"){const o=e.id,c=B(s,o);if(!c)return"(() => undefined)";const u=p=>{if(p.functionDefinition?.identifier==="std::control::return")return p;const y=p.nextNodeId?B(s,p.nextNodeId):void 0;return y?u(y):void 0},d=u(c);return d?`(() => ({} as ${r(s,d).inferredType}))`:"(() => undefined)"}return e.__typename==="LiteralValue"?JSON.stringify(e.value):"undefined"}const U=(n,s)=>{const r=n.nodes?.nodes;if(r)return r.find(e=>e?.parameters?.nodes?.some(o=>o?.value?.__typename==="NodeFunctionIdWrapper"&&o.value.id===s))},J=(n,s,r,e=new Set)=>{const o=s.id;if(!o||e.has(o))return!1;e.add(o);const c=d=>{const m=n.nodes?.nodes?.find(p=>p?.nextNodeId===d);return m?m.id===r?!0:c(m.id):!1};if(c(o))return!0;const u=U(n,o);return u?u.id===r?!0:J(n,u,r,e):!1},G=(n,s,r)=>{if(!r.nodeFunctionId)return{isValid:!0};if(r.parameterIndex!==void 0&&r.inputIndex!==void 0){if(s.id===r.nodeFunctionId)return{isValid:!0};let e=U(n,s.id);for(;e;){if(e.id===r.nodeFunctionId)return{isValid:!0};e=U(n,e.id)}return{isValid:!1,error:`Invalid input reference: Node ${s.id} is not in the scope of Node ${r.nodeFunctionId}.`}}return J(n,s,r.nodeFunctionId)?{isValid:!0}:{isValid:!1,error:`Node ${r.nodeFunctionId} has not been executed yet or is not visible in this scope.`}},M=n=>n.replace(/[^a-zA-Z0-9]/g,"_"),H=(n,s,r)=>{const e=new Set,o=n.nodes?.nodes||[],c=new Map(s.map(f=>[f.identifier,f])),u=(f,N="")=>{if(e.has(f))return"";const l=o.find(E=>E?.id===f);if(!l||!l.functionDefinition)return"";e.add(f);const _=c.get(l.functionDefinition?.identifier);if(!_)return`${N}// Error: Function ${l.functionDefinition.identifier} not found
21
- `;const S=(l.parameters?.nodes||[]).map((E,R)=>{const C=E.value;if(!C)return"undefined";if(C.__typename==="ReferenceValue"){const L=C;if(!L.nodeFunctionId)return"undefined";let b=L.parameterIndex!==void 0?`p_${M(L.nodeFunctionId)}_${L.parameterIndex}`:`node_${M(L.nodeFunctionId)}`;return L.referencePath?.forEach(j=>{b+=`?.${j.path}`}),b}if(C.__typename==="LiteralValue")return JSON.stringify(C.value);if(C.__typename==="NodeFunctionIdWrapper"){const L=C,b=`p_${M(l.id)}_${R}`,j=u(L.id,N+" ");return`(${b}) => {
22
- ${j}${N}}`}return"undefined"}).join(", "),$=`node_${M(l.id)}`,P=`fn_${_.identifier?.replace(/::/g,"_")}`,x=S.includes("undefined")||(_.genericKeys?.length??0)>0;let D=`${N}const ${$} = ${P}(${S})${x?" as any":""} ;
23
- `;return l.nextNodeId&&(D+=u(l.nextNodeId,N)),D},d=A(r),m=s.map(f=>`declare function fn_${f.identifier?.replace(/::/g,"_")}${f.signature}`).join(`
24
- `),p=o.map(f=>f?.id?u(f.id):"").filter(f=>f!=="").join(`
25
- `),y=`${d}
26
- ${m}
27
-
28
- // --- Flow ---
29
- ${p}`,a="flow_virtual.ts",i=t.createSourceFile(a,y,t.ScriptTarget.Latest),g=I(a,y,i),h=t.createProgram([a],V,g).getSemanticDiagnostics(i).map(f=>{const N=t.flattenDiagnosticMessageText(f.messageText,`
30
- `);return N.includes("Argument of type 'undefined'")||N.includes("not assignable to type 'undefined'")?null:{message:N,code:f.code,severity:"error"}}).filter(f=>f!==null);return{isValid:h.length===0,inferredType:"void",errors:h}},q=[{identifier:"LIST",type:"T[]",genericKeys:["T"]},{identifier:"NUMBER",type:"number"},{identifier:"HTTP_METHOD",type:'"GET" | "POST" | "PUT" | "DELETE"'},{identifier:"STRING",type:"string"},{identifier:"CONSUMER",type:"(item:R) => void",genericKeys:["R"]},{identifier:"PREDICATE",type:"(item:R) => T",genericKeys:["R","T"]},{identifier:"NUMBER_ARRAY",type:"LIST<NUMBER>",linkedDataTypeIdentifiers:["LIST","NUMBER"]}];function Q(n,s){if(!n||!s||s.length===0)return[];const r="suggestions.ts",e=A(q);function o(a){const i=a.match(/<([^>]+)>/);return i?i[1].split(",").map(g=>g.trim()).filter(Boolean).length:0}const c=`
31
- ${e}
32
- type TargetType = ${n};
33
- ${s.map((a,i)=>`
34
- declare function Fu${i}${a.signature};
35
- type F${i} = ReturnType<typeof Fu${i}${o(a.signature)>0?`<${Array(o(a.signature)).fill("any").join(", ")}>`:""}>;
17
+ `;function D(e,t){const n=new Map;n.set(e,t),n.set("lib.codezero.d.ts",ie);const r=ne(n);return te(r,[e,"lib.codezero.d.ts"],F,oe)}const oe={target:F.ScriptTarget.Latest,lib:["lib.codezero.d.ts"],noEmit:!0,strictNullChecks:!0};function E(e){const t=Array.from(new Set(e.flatMap(r=>r.genericKeys||[]))).map(r=>`type ${r} = any;`).join(`
18
+ `),n=e.map(r=>`type ${r.identifier}${r.genericKeys?`<${r.genericKeys.join(",")}>`:""} = ${r.type};`).join(`
19
+ `);return`${t}
20
+ ${n}`}function ae(e,t){let n=e;for(const r of t){if(n==null)return"unknown";typeof r.path=="string"&&(n=n[r.path])}return typeof n}function H(e,t){const n=e.nodes;if(n)return Array.isArray(n)?n.find(r=>r.id===t):n.nodes?.find(r=>r.id===t)}function q(e,t,n){const r=e?.value;if(!r)return"undefined";if(r.__typename==="ReferenceValue"){const o=r,c=H(t,o.nodeFunctionId);if(!c)return"undefined";let s=n(t,c).returnType;if(o.referencePath&&o.referencePath.length>0){let a;const u=c.parameters?.nodes;if(u&&u.length>0){const m=u[0];m?.value?.__typename==="LiteralValue"&&(a=m.value.value)}s=ae(a,o.referencePath)}return`({} as ${s})`}if(r.__typename==="NodeFunctionIdWrapper"){const o=r.id,c=H(t,o);if(!c)return"(() => undefined)";const s=m=>{if(m.functionDefinition?.identifier==="std::control::return")return m;const f=m.nextNodeId?H(t,m.nextNodeId):void 0;return f?s(f):void 0},a=s(c);return a?`(() => ({} as ${n(t,a).returnType}))`:"(() => undefined)"}return r.__typename==="LiteralValue"?JSON.stringify(r.value):"undefined"}const U=(e,t)=>{const n=e.nodes?.nodes;if(n)return n.find(r=>r?.parameters?.nodes?.some(o=>o?.value?.__typename==="NodeFunctionIdWrapper"&&o.value.id===t))},Q=(e,t,n,r=new Set)=>{const o=t.id;if(!o||r.has(o))return!1;r.add(o);const c=a=>{const u=e.nodes?.nodes?.find(m=>m?.nextNodeId===a);return u?u.id===n?!0:c(u.id):!1};if(c(o))return!0;const s=U(e,o);return s?s.id===n?!0:Q(e,s,n,r):!1},se=(e,t,n)=>{if(!n.nodeFunctionId)return{isValid:!0};if(n.parameterIndex!==void 0&&n.inputIndex!==void 0){if(t.id===n.nodeFunctionId)return{isValid:!0};let r=U(e,t.id);for(;r;){if(r.id===n.nodeFunctionId)return{isValid:!0};r=U(e,r.id)}return{isValid:!1,error:`Invalid input reference: Node ${t.id} is not in the scope of Node ${n.nodeFunctionId}.`}}return Q(e,t,n.nodeFunctionId)?{isValid:!0}:{isValid:!1,error:`Node ${n.nodeFunctionId} has not been executed yet or is not visible in this scope.`}},ce=e=>{const n=`const tempValue = ${JSON.stringify(e?.value)??"any"};`,r="index.ts",o=D(r,n),c=o.getSourceFile(r),a=o.languageService.getProgram().getTypeChecker();let u="any";const m=f=>{if(F.isVariableDeclaration(f)&&f.name.getText()==="tempValue"){const p=a.getTypeAtLocation(f);u=a.typeToString(p,f,F.TypeFormatFlags.NoTruncation|F.TypeFormatFlags.UseFullyQualifiedType)}F.forEachChild(f,m)};return m(c),u};var Z=(e=>(e[e.PRIMITIVE=0]="PRIMITIVE",e[e.TYPE=1]="TYPE",e[e.ARRAY=2]="ARRAY",e[e.OBJECT=3]="OBJECT",e))(Z||{});const ue=(e,t)=>{const r=`
21
+ ${E(t)}
22
+ type TargetType = ${e};
23
+ const val: TargetType = {} as any;
24
+ `,o="index.ts",c=D(o,r),s=c.getSourceFile(o),u=c.languageService.getProgram().getTypeChecker();let m=1;const f=p=>{if(F.isVariableDeclaration(p)&&p.name.getText()==="val"){const i=u.getTypeAtLocation(p);u.isArrayType(i)?m=2:i.isStringLiteral()||i.isNumberLiteral()||(i.getFlags()&(F.TypeFlags.String|F.TypeFlags.Number|F.TypeFlags.Boolean|F.TypeFlags.EnumLiteral|F.TypeFlags.BigInt|F.TypeFlags.ESSymbol))!==0?m=0:(i.isClassOrInterface()||(i.getFlags()&F.TypeFlags.Object)!==0)&&i.getProperties().length>0?m=3:m=1}F.forEachChild(p,f)};return f(s),m},le=(e,t)=>{const n=`
25
+ ${E(t)}
26
+ type Target = ${e};
27
+ `,r="index.ts",o=D(r,n),c=o.getSourceFile(r),a=o.languageService.getProgram().getTypeChecker(),u=c.statements.find(i=>F.isTypeAliasDeclaration(i)&&i.name.text==="Target");if(!u)return{__typename:"LiteralValue",value:null};const m=a.getTypeAtLocation(u.type),f=(i,l,v=new Set)=>{if(v.has(i))return null;v.add(i);const d=i.getFlags();if(i.isUnion()){if(l.type,F.isTypeAliasDeclaration(l)&&l.type&&F.isUnionTypeNode(l.type)){const S=a.getTypeFromTypeNode(l.type.types[0]);return f(S,l,v)}const h=i.types.filter(S=>{const y=S.getFlags();return!(y&F.TypeFlags.Undefined)&&!(y&F.TypeFlags.Null)}),g=h.length>0?h[0]:i.types[0];return f(g,l,v)}if(d&F.TypeFlags.StringLiteral)return i.value;if(d&F.TypeFlags.String)return"sample";if(d&F.TypeFlags.NumberLiteral)return i.value;if(d&F.TypeFlags.Number)return 1;if(d&F.TypeFlags.BooleanLiteral)return i.intrinsicName==="true";if(d&F.TypeFlags.Boolean)return!1;if(a.isArrayType(i)){const g=i.typeArguments?.[0]||a.getAnyType();return[f(g,l,v)]}if(i.isClassOrInterface()||d&F.TypeFlags.Object||i.getProperties().length>0){const h={};return i.getProperties().forEach(S=>{const y=a.getTypeOfSymbolAtLocation(S,l);y&&(h[S.getName()]=f(y,l,v))}),h}return null};return{value:f(m,u)}},j=(e,t,n,r)=>{const c=new Map(n.map(T=>[T.identifier,T])).get(t.functionDefinition?.identifier);if(!c)return{isValid:!1,returnType:"any",diagnostics:[{message:`Function ${t.id} not found`,nodeId:t.id,code:404,severity:"error"}]};const s=t.parameters?.nodes||[],a=[];for(const T of s){const N=T.value;if(N?.__typename==="ReferenceValue"){const x=se(e,t,N);x.isValid||a.push({message:x.error||"Scope error",code:403,nodeId:t.id,parameterIndex:s.indexOf(T),severity:"error"})}}if(a.length>0)return{isValid:!1,returnType:"any",diagnostics:a};const u=s.map(T=>q(T,e,(N,x)=>j(N,x,n,r))),m=u.map(T=>T==="undefined"?"({} as any)":T).join(", ");let f=c.signature;const p=`
28
+ ${E(r)}
29
+ declare function testFunc${f};
30
+ const result = testFunc(${m});
31
+ `,i="index.ts",l=D(i,p),v=l.getSourceFile(i),d=l.languageService.getProgram(),h=d.getTypeChecker(),g=d.getSemanticDiagnostics(v);let S="any";const y=T=>{if(F.isVariableDeclaration(T)&&T.name.getText()==="result"){const N=h.getTypeAtLocation(T);S=h.typeToString(N,T,F.TypeFormatFlags.NoTruncation|F.TypeFormatFlags.UseFullyQualifiedType)}F.forEachChild(T,y)};y(v);const $=g.map(T=>{const N=F.flattenDiagnosticMessageText(T.messageText,`
32
+ `),x=/\b([TRKV])\b/.test(N),C=N.includes("not assignable to parameter of type")&&(N.includes("'{}'")||N.includes("undefined"))||N.includes("not assignable to type 'undefined'")||N.includes("not assignable to type 'void'")||N.includes("may be a mistake because neither type sufficiently overlaps");return{message:N,code:T.code,nodeId:t.id,parameterIndex:(()=>{if(T.start!==void 0){const P=s.findIndex((M,I)=>{const b=p.indexOf(u[I]);return T.start>=b&&T.start<b+u[I].length});if(P!==-1)return P}})(),severity:x||C?"warning":"error"}});return{isValid:!$.some(T=>T.severity==="error"),returnType:S,diagnostics:$}},ge=(e,t,n)=>{const o=new Map(t.map(y=>[y.identifier,y])).get(e.functionDefinition?.identifier);if(!o)return{parameters:[],returnType:"any"};const c={id:"gid://sagittarius/Flow/0",nodes:{__typename:"NodeFunctionConnection",nodes:[e]}},u=(e.parameters?.nodes||[]).map(y=>q(y,c,($,T)=>j($,T,t,n))).map(y=>y==="undefined"?"({} as any)":y).join(", "),m=o.signature,f=`
33
+ ${E(n)}
34
+ declare function testFunc${m};
35
+ const result = testFunc(${u});
36
+ `,p="index.ts",i=D(p,f),l=i.getSourceFile(p),d=i.languageService.getProgram().getTypeChecker();let h="any",g=[];const S=y=>{if(F.isVariableDeclaration(y)&&y.name.getText()==="result"){const $=d.getTypeAtLocation(y);if(h=d.typeToString($,y,F.TypeFormatFlags.NoTruncation),F.isCallExpression(y.initializer)){const T=y.initializer,N=d.getResolvedSignature(T);N&&(g=N.getParameters().map(x=>{const C=d.getTypeOfSymbolAtLocation(x,T);return d.typeToString(C,T,F.TypeFormatFlags.NoTruncation)}))}}F.forEachChild(y,S)};return S(l),{parameters:g,returnType:h}};function de(e,t,n){if(!e||!t||t.length===0)return[];function r(i){const l=i.match(/<([^>]+)>/);return l?l[1].split(",").map(v=>v.trim()).filter(Boolean).length:0}const c=`
37
+ ${E(n)}
38
+ type TargetType = ${e};
39
+ ${t.map((i,l)=>`
40
+ declare function Fu${l}${i.signature};
41
+ type F${l} = ReturnType<typeof Fu${l}${r(i.signature)>0?`<${Array(r(i.signature)).fill("any").join(", ")}>`:""}>;
36
42
  `).join(`
37
43
  `)}
38
- ${s.map((a,i)=>`const check${i}: TargetType = {} as F${i};`).join(`
44
+ ${t.map((i,l)=>`const check${l}: TargetType = {} as F${l};`).join(`
39
45
  `)}
40
- `;console.log(c);const u=t.createSourceFile(r,c,t.ScriptTarget.Latest),d=I(r,c,u),p=t.createProgram([r],{...V},d).getSemanticDiagnostics(),y=new Set;return p.forEach(a=>{a.file===u&&a.start!==void 0&&y.add(u.getLineAndCharacterOfPosition(a.start).line)}),s.map((a,i)=>{const g=`const check${i}: TargetType = {} as F${i};`,T=c.split(`
41
- `).findIndex(h=>h.includes(g));return T!==-1&&y.has(T)?null:{__typename:"NodeFunction",id:"gid://sagittarius/NodeFunction/1",functionDefinition:{__typename:"FunctionDefinition",id:a.identifier,identifier:a.identifier},parameters:{__typename:"NodeParameterConnection",nodes:(a.parameterDefinitions?.nodes||[]).map(h=>({__typename:"NodeParameter",parameterDefinition:{__typename:"ParameterDefinition",id:h?.identifier,identifier:h?.identifier},value:null}))}}}).filter(a=>a!==null)}const O=(n,s,r,e)=>{const c=new Map(r.map(F=>[F.identifier,F])).get(s.functionDefinition?.identifier);if(!c)return{isValid:!1,inferredType:"any",errors:[{message:`Function ${s.id} not found`,code:404,severity:"error"}]};const u=s.parameters?.nodes||[],d=[];for(const F of u){const S=F.value;if(S?.__typename==="ReferenceValue"){const $=G(n,s,S);$.isValid||d.push({message:$.error||"Scope error",code:403,severity:"error"})}}if(d.length>0)return{isValid:!1,inferredType:"any",errors:d};const p=u.map(F=>K(F,n,(S,$)=>O(S,$,r,e))).map(F=>F==="undefined"?"({} as any)":F).join(", ");let y=c.signature;const a=`
42
- ${A(e)}
43
- declare function testFunc${y};
44
- const result = testFunc(${p});
45
- `,i="node_virtual.ts",g=t.createSourceFile(i,a,t.ScriptTarget.Latest),v=I(i,a,g),T=t.createProgram([i],V,v),h=T.getTypeChecker(),f=T.getSemanticDiagnostics(g);let N="any";const l=F=>{if(t.isVariableDeclaration(F)&&F.name.getText()==="result"){const S=h.getTypeAtLocation(F);N=h.typeToString(S,F,t.TypeFormatFlags.NoTruncation|t.TypeFormatFlags.UseFullyQualifiedType)}t.forEachChild(F,l)};l(g);const _=f.map(F=>{const S=t.flattenDiagnosticMessageText(F.messageText,`
46
- `),$=/\b([TRKV])\b/.test(S),P=S.includes("not assignable to parameter of type")&&(S.includes("'{}'")||S.includes("undefined"))||S.includes("not assignable to type 'undefined'")||S.includes("not assignable to type 'void'")||S.includes("may be a mistake because neither type sufficiently overlaps");return{message:S,code:F.code,severity:$||P?"warning":"error"}});return{isValid:!_.some(F=>F.severity==="error"),inferredType:N,errors:_}},Z=(n,s,r,e,o)=>{const c=[],u=n.nodes?.nodes||[],d=u.find(i=>i?.id===s);if(!d)return[];const m=A(o),p=(i,g)=>{if(!r||r==="any"||i==="any")return!0;const v=`suggestion_check_${Math.random().toString(36).substring(7)}.ts`,T=`
47
- ${m}
46
+ `,s="index.ts",a=D(s,c),u=a.getSourceFile(s),f=a.languageService.getProgram().getSemanticDiagnostics(),p=new Set;return f.forEach(i=>{i.file===u&&i.start!==void 0&&p.add(u.getLineAndCharacterOfPosition(i.start).line)}),t.map((i,l)=>{const v=`const check${l}: TargetType = {} as F${l};`,h=c.split(`
47
+ `).findIndex(g=>g.includes(v));return h!==-1&&p.has(h)?null:{__typename:"NodeFunction",id:"gid://sagittarius/NodeFunction/1",functionDefinition:{__typename:"FunctionDefinition",id:i.identifier,identifier:i.identifier},parameters:{__typename:"NodeParameterConnection",nodes:(i.parameterDefinitions?.nodes||[]).map(g=>({__typename:"NodeParameter",parameterDefinition:{__typename:"ParameterDefinition",id:g?.identifier,identifier:g?.identifier},value:null}))}}}).filter(i=>i!==null)}const fe=(e,t,n,r,o)=>{const c=[],s=e.nodes?.nodes||[],a=s.find(i=>i?.id===t);if(!a)return[];const u=E(o),m=(i,l)=>{if(!n||n==="any"||i==="any")return!0;const v="index.ts",d=`
48
+ ${u}
48
49
  const val: ${i} = {} as any;
49
- const test: ${r} = val${g?`.${g}`:""};
50
- `,h=t.createSourceFile(v,T,t.ScriptTarget.Latest),f=I(v,T,h);return!t.createProgram([v],V,f).getSemanticDiagnostics(h).some(_=>_.category===t.DiagnosticCategory.Error)},y=(i,g)=>{const v=[],T=`probing_${Math.random().toString(36).substring(7)}.ts`,h=`
51
- ${m}
50
+ const test: ${n} = val${l?`.${l}`:""};
51
+ `,h=D(v,d),g=h.getSourceFile(v);return!h.languageService.getProgram().getSemanticDiagnostics(g).some($=>$.category===F.DiagnosticCategory.Error)},f=(i,l)=>{const v=[],d="index.ts",h=`
52
+ ${u}
52
53
  const val: ${i} = {} as any;
53
- `,f=t.createSourceFile(T,h,t.ScriptTarget.Latest),N=I(T,h,f),l=t.createProgram([T],V,N),_=l.getTypeChecker();p(i)&&v.push({...g,referencePath:[]});const F=($,P=[])=>{if(P.length>3)return;const x=$.getProperties();for(const D of x){const E=D.getName();let R;if(_.getPropertyOfType){const b=_.getPropertyOfType($,E);b&&(R=_.getTypeOfSymbolAtLocation(b,f))}else{const b=$.getProperty(E);b&&(R=_.getTypeOfSymbolAtLocation(b,f))}if(!R)continue;const C=[...P,E],L=C.join(".");p(i,L)&&v.push({...g,referencePath:C.map(b=>({__typename:"ReferencePath",path:b}))}),F(R,C)}};if(l.getSemanticDiagnostics(f).length===0){let $;const P=x=>{t.isVariableDeclaration(x)&&x.name.getText()==="val"&&($=_.getTypeAtLocation(x)),t.forEachChild(x,P)};P(f),$&&F($)}return v};if(n.inputType){const i=n.inputType.identifier||"any";c.push(...y(i,{__typename:"ReferenceValue",nodeFunctionId:null,parameterIndex:0,referencePath:[]}))}u.forEach(i=>{if(!(!i||i.id===s)&&X(n,i,d)){const g=O(n,i,e,o);c.push(...y(g.inferredType,{__typename:"ReferenceValue",nodeFunctionId:i.id,referencePath:[]}))}});let a=k(n,s);for(;a;){if(e.find(g=>g.identifier===a.functionDefinition?.identifier)){const g=a.parameters?.nodes?.findIndex(v=>{const T=v?.value;if(T?.__typename==="NodeFunctionIdWrapper"){const h=T;return h.id===s||w(n,h.id||void 0,s)}return!1});g!==void 0&&g!==-1&&c.push(...y("any",{__typename:"ReferenceValue",nodeFunctionId:a.id,parameterIndex:g,inputIndex:0,referencePath:[]}))}a=k(n,a.id)}return c};function X(n,s,r){const e=n.nodes?.nodes||[];let o=s.nextNodeId;const c=new Set;for(;o;){if(o===r.id)return!0;if(c.has(o))break;c.add(o),o=e.find(m=>m?.id===o)?.nextNodeId}let u=k(n,r.id);for(;u;){if(u.id===s.id)return!0;u=k(n,u.id)}return!1}function k(n,s){return n.nodes?.nodes?.find(e=>e?.parameters?.nodes?.some(o=>o?.value?.__typename==="NodeFunctionIdWrapper"&&o.value.id===s))||void 0}function w(n,s,r){if(!s)return!1;if(s===r)return!0;const o=(n.nodes?.nodes||[]).find(u=>u?.id===s);return o?o.nextNodeId&&w(n,o.nextNodeId||void 0,r)?!0:!!o.parameters?.nodes?.some(u=>{const d=u?.value;return d?.__typename==="NodeFunctionIdWrapper"?w(n,d.id||void 0,r):!1}):!1}const ee=n=>{const r=`const tempValue = ${JSON.stringify(n.value)};`,e="temp_value.ts",o=t.createSourceFile(e,r,t.ScriptTarget.Latest),c=I(e,r,o),d=t.createProgram([e],{target:t.ScriptTarget.Latest,noEmit:!0},c).getTypeChecker();let m="any";const p=y=>{if(t.isVariableDeclaration(y)&&y.name.getText()==="tempValue"){const a=d.getTypeAtLocation(y);m=d.typeToString(a,y,t.TypeFormatFlags.NoTruncation|t.TypeFormatFlags.UseFullyQualifiedType)}t.forEachChild(y,p)};return p(o),m};var Y=(n=>(n[n.PRIMITIVE=0]="PRIMITIVE",n[n.TYPE=1]="TYPE",n[n.ARRAY=2]="ARRAY",n[n.OBJECT=3]="OBJECT",n))(Y||{});const te=(n,s)=>{const r=A(s),e=`type_probe_${Math.random().toString(36).substring(7)}.ts`,o=`
54
- ${r}
55
- type TargetType = ${n};
56
- const val: TargetType = {} as any;
57
- `,c=t.createSourceFile(e,o,t.ScriptTarget.Latest),u=I(e,o,c),m=t.createProgram([e],V,u).getTypeChecker();let p=1;const y=a=>{if(t.isVariableDeclaration(a)&&a.name.getText()==="val"){const i=m.getTypeAtLocation(a);m.isArrayType(i)?p=2:i.isStringLiteral()||i.isNumberLiteral()||(i.getFlags()&(t.TypeFlags.String|t.TypeFlags.Number|t.TypeFlags.Boolean|t.TypeFlags.EnumLiteral|t.TypeFlags.BigInt|t.TypeFlags.ESSymbol))!==0?p=0:(i.isClassOrInterface()||(i.getFlags()&t.TypeFlags.Object)!==0)&&i.getProperties().length>0?p=3:p=1}t.forEachChild(a,y)};return y(c),p},ne=(n,s)=>{const r=`
58
- ${A(s)}
59
- type Target = ${n};
60
- `,e="temp_type_to_value.ts",o=t.createSourceFile(e,r,t.ScriptTarget.Latest,!0),c=I(e,r,o),d=t.createProgram([e],V,c).getTypeChecker(),m=o.statements.find(i=>t.isTypeAliasDeclaration(i)&&i.name.text==="Target");if(!m)return{__typename:"LiteralValue",value:null};const p=d.getTypeAtLocation(m.type),y=(i,g,v=new Set)=>{if(v.has(i))return null;v.add(i);const T=i.getFlags();if(i.isUnion()){if(g.type,t.isTypeAliasDeclaration(g)&&g.type&&t.isUnionTypeNode(g.type)){const N=d.getTypeFromTypeNode(g.type.types[0]);return y(N,g,v)}const h=i.types.filter(N=>{const l=N.getFlags();return!(l&t.TypeFlags.Undefined)&&!(l&t.TypeFlags.Null)}),f=h.length>0?h[0]:i.types[0];return y(f,g,v)}if(T&t.TypeFlags.StringLiteral)return i.value;if(T&t.TypeFlags.String)return"sample";if(T&t.TypeFlags.NumberLiteral)return i.value;if(T&t.TypeFlags.Number)return 1;if(T&t.TypeFlags.BooleanLiteral)return i.intrinsicName==="true";if(T&t.TypeFlags.Boolean)return!1;if(d.isArrayType(i)){const f=i.typeArguments?.[0]||d.getAnyType();return[y(f,g,v)]}if(i.isClassOrInterface()||T&t.TypeFlags.Object||i.getProperties().length>0){const h={};return i.getProperties().forEach(N=>{const l=d.getTypeOfSymbolAtLocation(N,g);l&&(h[N.getName()]=y(l,g,v))}),h}return null};return{value:y(p,m)}},re=n=>{if(!n)return[];const s=`type T = ${n}; const val: T = {} as any;`,r="suggestions_virtual.ts",e=t.createSourceFile(r,s,t.ScriptTarget.Latest),o=I(r,s,e),u=t.createProgram([r],{...V,noLib:!0},o).getTypeChecker(),d=e.statements.find(t.isTypeAliasDeclaration);if(!d)return[];const m=u.getTypeAtLocation(d),p=a=>a.isUnion()?a.types.flatMap(p):a.isStringLiteral()?[a.value]:a.isNumberLiteral()?[a.value.toString()]:a.intrinsicName==="true"?["true"]:a.intrinsicName==="false"?["false"]:[];return Array.from(new Set(p(m))).map(a=>({__typename:"LiteralValue",value:a}))},ie=(n,s,r)=>{const e=JSON.stringify(s.value),o=`
61
- ${A(r)}
62
- const testValue: ${n} = ${e};
63
- `,c="value_check.ts",u=t.createSourceFile(c,o,t.ScriptTarget.Latest),d=I(c,o,u),p=t.createProgram([c],V,d).getSemanticDiagnostics(u);return p.length>0?{isValid:!1,error:t.flattenDiagnosticMessageText(p[0].messageText,`
64
- `)}:{isValid:!0}},se=(n,s,r)=>{const o=new Map(s.map(l=>[l.identifier,l])).get(n.functionDefinition?.identifier);if(!o)return{parameters:[],returnType:"any"};const c={id:"gid://sagittarius/Flow/0",nodes:{__typename:"NodeFunctionConnection",nodes:[n]}},m=(n.parameters?.nodes||[]).map(l=>K(l,c,(_,F)=>O(_,F,s,r))).map(l=>l==="undefined"?"({} as any)":l).join(", "),p=o.signature,y=`
65
- ${A(r)}
66
- declare function testFunc${p};
67
- const result = testFunc(${m});
68
- `,a="node_types_virtual.ts",i=t.createSourceFile(a,y,t.ScriptTarget.Latest),g=I(a,y,i),T=t.createProgram([a],V,g).getTypeChecker();let h="any",f=[];const N=l=>{if(t.isVariableDeclaration(l)&&l.name.getText()==="result"){const _=T.getTypeAtLocation(l);if(h=T.typeToString(_,l,t.TypeFormatFlags.NoTruncation),t.isCallExpression(l.initializer)){const F=l.initializer,S=T.getResolvedSignature(F);S&&(f=S.getParameters().map($=>{const P=T.getTypeOfSymbolAtLocation($,F);return T.typeToString(P,F,t.TypeFormatFlags.NoTruncation)}))}}t.forEachChild(l,N)};return N(i),{parameters:f,returnType:h}};exports.DataTypeVariant=Y;exports.getFlowValidation=H;exports.getNodeSuggestions=Q;exports.getNodeValidation=O;exports.getReferenceSuggestions=Z;exports.getTypeFromValue=ee;exports.getTypeVariant=te;exports.getTypesFromNode=se;exports.getValueFromType=ne;exports.getValueSuggestions=re;exports.getValueValidation=ie;
54
+ `,g=D(d,h),S=g.getSourceFile(d),y=g.languageService.getProgram(),$=y.getTypeChecker();m(i)&&v.push({...l,referencePath:[]});const T=(x,C=[])=>{if(C.length>3)return;const P=x.getProperties();for(const M of P){const I=M.getName();let b;if($.getPropertyOfType){const _=$.getPropertyOfType(x,I);_&&(b=$.getTypeOfSymbolAtLocation(_,S))}else{const _=x.getProperty(I);_&&(b=$.getTypeOfSymbolAtLocation(_,S))}if(!b)continue;const V=[...C,I],L=V.join(".");m(i,L)&&v.push({...l,referencePath:V.map(_=>({__typename:"ReferencePath",path:_}))}),T(b,V)}};if(y.getSemanticDiagnostics(S).length===0){let x;const C=P=>{F.isVariableDeclaration(P)&&P.name.getText()==="val"&&(x=$.getTypeAtLocation(P)),F.forEachChild(P,C)};C(S),x&&T(x)}return v};if(e.inputType){const i=e.inputType||"any";c.push(...f(i,{}))}s.forEach(i=>{if(!(!i||i.id===t)&&pe(e,i,a)){const l=j(e,i,r,o);c.push(...f(l.returnType,{__typename:"ReferenceValue",nodeFunctionId:i.id,referencePath:[]}))}});let p=O(e,t);for(;p;){if(r.find(l=>l.identifier===p.functionDefinition?.identifier)){const l=p.parameters?.nodes?.findIndex(v=>{const d=v?.value;if(d?.__typename==="NodeFunctionIdWrapper"){const h=d;return h.id===t||z(e,h.id||void 0,t)}return!1});l!==void 0&&l!==-1&&c.push(...f("any",{__typename:"ReferenceValue",nodeFunctionId:p.id,parameterIndex:l,inputIndex:0,referencePath:[]}))}p=O(e,p.id)}return c};function pe(e,t,n){const r=e.nodes?.nodes||[];let o=t.nextNodeId;const c=new Set;for(;o;){if(o===n.id)return!0;if(c.has(o))break;c.add(o),o=r.find(u=>u?.id===o)?.nextNodeId}let s=O(e,n.id);for(;s;){if(s.id===t.id)return!0;s=O(e,s.id)}return!1}function O(e,t){return e.nodes?.nodes?.find(r=>r?.parameters?.nodes?.some(o=>o?.value?.__typename==="NodeFunctionIdWrapper"&&o.value.id===t))||void 0}function z(e,t,n){if(!t)return!1;if(t===n)return!0;const o=(e.nodes?.nodes||[]).find(s=>s?.id===t);return o?o.nextNodeId&&z(e,o.nextNodeId||void 0,n)?!0:!!o.parameters?.nodes?.some(s=>{const a=s?.value;return a?.__typename==="NodeFunctionIdWrapper"?z(e,a.id||void 0,n):!1}):!1}const me=e=>{if(!e)return[];const t=`type T = ${e}; const val: T = {} as any;`,n="index.ts",r=D(n,t),o=r.getSourceFile(n),s=r.languageService.getProgram().getTypeChecker(),a=o.statements.find(F.isTypeAliasDeclaration);if(!a)return[];const u=s.getTypeAtLocation(a),m=p=>p.isUnion()?p.types.flatMap(m):p.isStringLiteral()?[p.value]:p.isNumberLiteral()?[p.value.toString()]:p.intrinsicName==="true"?["true"]:p.intrinsicName==="false"?["false"]:[];return Array.from(new Set(m(u))).map(p=>({__typename:"LiteralValue",value:p}))},k=e=>e.replace(/[^a-zA-Z0-9]/g,"_"),ye=(e,t,n)=>{const r=new Set,o=e.nodes?.nodes||[],c=new Map(t.map(g=>[g.identifier,g])),s=(g,S="")=>{if(r.has(g))return"";const y=o.find(I=>I?.id===g);if(!y||!y.functionDefinition)return"";r.add(g);const $=c.get(y.functionDefinition?.identifier);if(!$)return`${S}// Error: Function ${y.functionDefinition.identifier} not found
55
+ `;const N=(y.parameters?.nodes||[]).map((I,b)=>{const V=I.value;if(!V)return"undefined";if(V.__typename==="ReferenceValue"){const L=V;if(!L.nodeFunctionId)return"undefined";let _=L.parameterIndex!==void 0?`/* @pos ${g} ${b} */ p_${k(L.nodeFunctionId)}_${L.parameterIndex}`:`/* @pos ${g} ${b} */ node_${k(L.nodeFunctionId)}`;return L.referencePath?.forEach(B=>{_+=`?.${B.path}`}),_}if(V.__typename==="LiteralValue")return`/* @pos ${g} ${b} */ ${JSON.stringify(V.value)}`;if(V.__typename==="NodeFunctionIdWrapper"){const L=V,_=`p_${k(y.id)}_${b}`,B=s(L.id,S+" ");return`/* @pos ${g} ${b} */ (${_}) => {
56
+ ${B}${S}}`}return"undefined"}).join(", "),x=`node_${k(y.id)}`,C=`fn_${$.identifier?.replace(/::/g,"_")}`,P=N.includes("undefined");let M=`${S}const ${x} = ${C}(${N})${P?" as any":""} ;
57
+ `;return y.nextNodeId&&(M+=s(y.nextNodeId,S)),M},a=E(n),u=t.map(g=>`declare function fn_${g.identifier?.replace(/::/g,"_")}${g.signature}`).join(`
58
+ `),m=o.map(g=>g?.id?s(g.id):"").filter(g=>g!=="").join(`
59
+ `),f=`${a}
60
+ ${u}
61
+
62
+ // --- Flow ---
63
+ ${m}`,p="index.ts",i=D(p,f),l=i.getSourceFile(p),h=i.languageService.getProgram().getSemanticDiagnostics(l).map(g=>{const S=F.flattenDiagnosticMessageText(g.messageText,`
64
+ `);if(S.includes("Argument of type 'undefined'")||S.includes("not assignable to type 'undefined'"))return null;let $,T;if(g.start!==void 0){const C=l.getFullText().substring(0,g.start).match(/\/\* @pos ([^ ]+) (\d+) \*\/\s*$/);C&&($=C[1],T=parseInt(C[2],10))}return{message:S,code:g.code,severity:"error",nodeId:$,parameterIndex:T}}).filter(g=>g!==null);return{isValid:!h.some(g=>g?.severity==="error"),returnType:"void",diagnostics:h}},Fe=(e,t,n)=>{const r=JSON.stringify(t.value),o=`
65
+ ${E(n)}
66
+ const testValue: ${e} = ${r};
67
+ `,c="index.ts",u=D(c,o).languageService.getSemanticDiagnostics(c).map(m=>{const f=F.flattenDiagnosticMessageText(m.messageText,`
68
+ `),p=/\b([TRKV])\b/.test(f),i=f.includes("not assignable to parameter of type")&&(f.includes("'{}'")||f.includes("undefined"))||f.includes("not assignable to type 'undefined'")||f.includes("not assignable to type 'void'")||f.includes("may be a mistake because neither type sufficiently overlaps");return{message:f,code:m.code,severity:p||i?"warning":"error"}});return{isValid:!u.some(m=>m.severity==="error"),returnType:"void",diagnostics:u}};exports.DataTypeVariant=Z;exports.getFlowValidation=ye;exports.getNodeSuggestions=de;exports.getNodeValidation=j;exports.getReferenceSuggestions=fe;exports.getTypeFromValue=ce;exports.getTypeVariant=ue;exports.getTypesFromNode=ge;exports.getValueFromType=le;exports.getValueSuggestions=me;exports.getValueValidation=Fe;