@code0-tech/triangulum 0.16.0 → 0.18.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/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './extraction/getValueFromType';
3
3
  export * from './validation/getFlowValidation';
4
4
  export * from './validation/getValueValidation';
5
5
  export * from './schema/getSignatureSchema';
6
+ export * from './schema/getTypeSchema';
@@ -0,0 +1,13 @@
1
+ import { DataType } from '@code0-tech/sagittarius-graphql-types';
2
+ import { Schema } from '../util/schema.util';
3
+ /**
4
+ * Generates a schema for a given TypeScript type expression string.
5
+ *
6
+ * This function creates a virtual TypeScript environment, wraps the provided type expression
7
+ * into a type alias 'T', and extracts the schema for it.
8
+ *
9
+ * @param typeString - The TypeScript type expression (e.g., "string | number" or "{ a: string }").
10
+ * @param dataTypes - An optional array of additional data type definitions to be included in the environment.
11
+ * @returns The generated Schema for the identified type, or undefined if no valid type was found or an error occurred.
12
+ */
13
+ export declare const getTypeSchema: (typeString: string, dataTypes?: DataType[]) => Schema | undefined;
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`typescript`);c=s(c,1);function l(){return l=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},l.apply(null,arguments)}var u=!1;try{u=typeof localStorage<`u`}catch{}var d=typeof process<`u`,f=u&&typeof localStorage.getItem==`function`&&localStorage.getItem(`DEBUG`)||d&&process.env.DEBUG?console.log:function(e){return``};function p(e,t,n,r,i){r===void 0&&(r={});var a=l({},g(n),r),o=y(e,t,a,n,i),s=o.languageServiceHost,c=o.updateFile,u=o.deleteFile,d=n.createLanguageService(s),f=d.getCompilerOptionsDiagnostics();if(f.length){var p=v(e,r,n);throw Error(n.formatDiagnostics(f,p.compilerHost))}return{name:`vfs`,sys:e,languageService:d,getSourceFile:function(e){return d.getProgram()?.getSourceFile(e)},createFile:function(e,t){c(n.createSourceFile(e,t,a.target,!1))},updateFile:function(e,t,r){var i=d.getProgram().getSourceFile(e);if(!i)throw Error(`Did not find a source file for `+e);var a=i.text,o=r??n.createTextSpan(0,a.length),s=a.slice(0,o.start)+t+a.slice(o.start+o.length);c(n.updateSourceFile(i,s,{span:o,newLength:t.length}))},deleteFile:function(e){var t=d.getProgram().getSourceFile(e);t&&u(t)}}}function m(e){throw Error(`Method '`+e+`' is not implemented.`)}function h(e,t){return function(){for(var n=arguments.length,r=Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=t.apply(void 0,r),o=typeof a==`string`?a.slice(0,80)+`...`:a;return f.apply(void 0,[`> `+e].concat(r)),f(`< `+o),a}}var g=function(e){return l({},e.getDefaultCompilerOptions(),{jsx:e.JsxEmit.React,strict:!0,esModuleInterop:!0,module:e.ModuleKind.ESNext,suppressOutputPathCheck:!0,skipLibCheck:!0,skipDefaultLibCheck:!0},e.versionMajorMinor&&Number(e.versionMajorMinor.split(`.`)[0])>=6?{ignoreDeprecations:`6.0`}:{moduleResolution:e.ModuleResolutionKind.NodeJs})},_=function(e){return e.replace(`/`,`/lib.`).toLowerCase()};function ee(e){return{args:[],createDirectory:function(){return m(`createDirectory`)},directoryExists:h(`directoryExists`,function(t){return Array.from(e.keys()).some(function(e){return e.startsWith(t)})}),exit:function(){return m(`exit`)},fileExists:h(`fileExists`,function(t){return e.has(t)||e.has(_(t))}),getCurrentDirectory:function(){return`/`},getDirectories:function(){return[]},getExecutingFilePath:function(){return m(`getExecutingFilePath`)},readDirectory:h(`readDirectory`,function(t){return t===`/`?Array.from(e.keys()):[]}),readFile:h(`readFile`,function(t){return e.get(t)??e.get(_(t))}),resolvePath:function(e){return e},newLine:`
2
- `,useCaseSensitiveFileNames:!0,write:function(){return m(`write`)},writeFile:function(t,n){e.set(t,n)},deleteFile:function(t){e.delete(t)}}}function v(e,t,n){var r=new Map,i=function(e){return r.set(e.fileName,e),e};return{compilerHost:l({},e,{getCanonicalFileName:function(e){return e},getDefaultLibFileName:function(){return`/`+n.getDefaultLibFileName(t)},getNewLine:function(){return e.newLine},getSourceFile:function(a,o){return r.get(a)||i(n.createSourceFile(a,e.readFile(a),o??t.target??g(n).target,!1))},useCaseSensitiveFileNames:function(){return e.useCaseSensitiveFileNames}}),updateFile:function(t){var n=r.has(t.fileName);return e.writeFile(t.fileName,t.text),r.set(t.fileName,t),n},deleteFile:function(t){var n=r.has(t.fileName);return r.delete(t.fileName),e.deleteFile(t.fileName),n}}}function y(e,t,n,r,i){var a=[].concat(t),o=v(e,n,r),s=o.compilerHost,c=o.updateFile,u=o.deleteFile,d=new Map,f=0;return{languageServiceHost:l({},s,{getProjectVersion:function(){return f.toString()},getCompilationSettings:function(){return n},getCustomTransformers:function(){return i},getScriptFileNames:function(){return a.slice()},getScriptSnapshot:function(t){var n=e.readFile(t);if(n&&typeof n==`string`)return r.ScriptSnapshot.fromString(n)},getScriptVersion:function(e){return d.get(e)||`0`},writeFile:e.writeFile}),updateFile:function(e){f++,d.set(e.fileName,f.toString()),a.includes(e.fileName)||a.push(e.fileName),c(e)},deleteFile:function(e){f++,d.set(e.fileName,f.toString());var t=a.indexOf(e.fileName);t!==-1&&a.splice(t,1),u(e)}}}function b(e){return x.test(e)}var x=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function S(e,t,n,r){let i=C(n);return a(typeof t==`function`?t.call({"":e},``,e):e,``);function a(e,t){if(Array.isArray(r)){let t=r.find(t=>t.test(e));if(t){let n=t.stringify(e);if(typeof n!=`string`||!b(n))throw Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${n})`);return n}}if(typeof e==`boolean`||typeof e==`number`||typeof e==`string`||e===null||e instanceof Date||e instanceof Boolean||e instanceof Number||e instanceof String)return JSON.stringify(e);if(e?.isLosslessNumber||typeof e==`bigint`)return e.toString();if(Array.isArray(e))return o(e,t);if(e&&typeof e==`object`)return s(e,t)}function o(e,n){if(e.length===0)return`[]`;let r=i?n+i:void 0,o=i?`[
2
+ `,useCaseSensitiveFileNames:!0,write:function(){return m(`write`)},writeFile:function(t,n){e.set(t,n)},deleteFile:function(t){e.delete(t)}}}function v(e,t,n){var r=new Map,i=function(e){return r.set(e.fileName,e),e};return{compilerHost:l({},e,{getCanonicalFileName:function(e){return e},getDefaultLibFileName:function(){return`/`+n.getDefaultLibFileName(t)},getNewLine:function(){return e.newLine},getSourceFile:function(a,o){return r.get(a)||i(n.createSourceFile(a,e.readFile(a),o??t.target??g(n).target,!1))},useCaseSensitiveFileNames:function(){return e.useCaseSensitiveFileNames}}),updateFile:function(t){var n=r.has(t.fileName);return e.writeFile(t.fileName,t.text),r.set(t.fileName,t),n},deleteFile:function(t){var n=r.has(t.fileName);return r.delete(t.fileName),e.deleteFile(t.fileName),n}}}function y(e,t,n,r,i){var a=[].concat(t),o=v(e,n,r),s=o.compilerHost,c=o.updateFile,u=o.deleteFile,d=new Map,f=0;return{languageServiceHost:l({},s,{getProjectVersion:function(){return f.toString()},getCompilationSettings:function(){return n},getCustomTransformers:function(){return i},getScriptFileNames:function(){return a.slice()},getScriptSnapshot:function(t){var n=e.readFile(t);if(n&&typeof n==`string`)return r.ScriptSnapshot.fromString(n)},getScriptVersion:function(e){return d.get(e)||`0`},writeFile:e.writeFile}),updateFile:function(e){f++,d.set(e.fileName,f.toString()),a.includes(e.fileName)||a.push(e.fileName),c(e)},deleteFile:function(e){f++,d.set(e.fileName,f.toString());var t=a.indexOf(e.fileName);t!==-1&&a.splice(t,1),u(e)}}}function te(e){return ne.test(e)}var ne=/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function b(e,t,n,r){let i=x(n);return a(typeof t==`function`?t.call({"":e},``,e):e,``);function a(e,t){if(Array.isArray(r)){let t=r.find(t=>t.test(e));if(t){let n=t.stringify(e);if(typeof n!=`string`||!te(n))throw Error(`Invalid JSON number: output of a number stringifier must be a string containing a JSON number (output: ${n})`);return n}}if(typeof e==`boolean`||typeof e==`number`||typeof e==`string`||e===null||e instanceof Date||e instanceof Boolean||e instanceof Number||e instanceof String)return JSON.stringify(e);if(e?.isLosslessNumber||typeof e==`bigint`)return e.toString();if(Array.isArray(e))return o(e,t);if(e&&typeof e==`object`)return s(e,t)}function o(e,n){if(e.length===0)return`[]`;let r=i?n+i:void 0,o=i?`[
3
3
  `:`[`;for(let n=0;n<e.length;n++){let s=typeof t==`function`?t.call(e,String(n),e[n]):e[n];i&&(o+=r),s!==void 0&&typeof s!=`function`?o+=a(s,r):o+=`null`,n<e.length-1&&(o+=i?`,
4
- `:`,`)}return o+=i?`\n${n}]`:`]`,o}function s(e,r){if(typeof e.toJSON==`function`)return S(e.toJSON(),t,n,void 0);let o=Array.isArray(t)?t.map(String):Object.keys(e);if(o.length===0)return`{}`;let s=i?r+i:void 0,l=!0,u=i?`{
4
+ `:`,`)}return o+=i?`\n${n}]`:`]`,o}function s(e,r){if(typeof e.toJSON==`function`)return b(e.toJSON(),t,n,void 0);let o=Array.isArray(t)?t.map(String):Object.keys(e);if(o.length===0)return`{}`;let s=i?r+i:void 0,l=!0,u=i?`{
5
5
  `:`{`;for(let n of o){let r=typeof t==`function`?t.call(e,n,e[n]):e[n];if(c(n,r)){l?l=!1:u+=i?`,
6
- `:`,`;let e=JSON.stringify(n);u+=i?`${s+e}: `:`${e}:`,u+=a(r,s)}}return u+=i?`\n${r}}`:`}`,u}function c(e,t){return t!==void 0&&typeof t!=`function`&&typeof t!=`symbol`}}function C(e){if(typeof e==`number`)return` `.repeat(e);if(typeof e==`string`&&e!==``)return e}var w=`
6
+ `:`,`;let e=JSON.stringify(n);u+=i?`${s+e}: `:`${e}:`,u+=a(r,s)}}return u+=i?`\n${r}}`:`}`,u}function c(e,t){return t!==void 0&&typeof t!=`function`&&typeof t!=`symbol`}}function x(e){if(typeof e==`number`)return` `.repeat(e);if(typeof e==`string`&&e!==``)return e}var S=`
7
7
  interface Array<T> {
8
8
  [n: number]: T;
9
9
  length: number;
@@ -23,33 +23,33 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
23
23
  }
24
24
 
25
25
  import ReturnType = Utils.ReturnType;
26
- `;function T(e,t){let n=new Map;return n.set(e,t),n.set(`lib.codezero.d.ts`,w),p(ee(n),[e,`lib.codezero.d.ts`],c.default,E)}var E={target:c.default.ScriptTarget.Latest,lib:[`lib.codezero.d.ts`],noEmit:!0,strictNullChecks:!0};function D(e,t=`any`,n=!0){let r=Array.from(new Set(e?.flatMap(e=>e.genericKeys||[]))).map(e=>`type ${e} = ${t};`).join(`
26
+ `;function C(e,t){let n=new Map;return n.set(e,t),n.set(`lib.codezero.d.ts`,S),p(ee(n),[e,`lib.codezero.d.ts`],c.default,re)}var re={target:c.default.ScriptTarget.Latest,lib:[`lib.codezero.d.ts`],noEmit:!0,strictNullChecks:!0};function w(e,t=`any`,n=!0){let r=Array.from(new Set(e?.flatMap(e=>e.genericKeys||[]))).map(e=>`type ${e} = ${t};`).join(`
27
27
  `),i=e?.map(e=>`type ${e.identifier}${(e.genericKeys?.length??0)>0?`<${e.genericKeys?.join(`,`)}>`:``} = ${e.type};`).join(`
28
- `);return`${n?r:``}\n${i}`}var O=e=>e?.replace(/[^a-zA-Z0-9]/g,`_`);function k(e,t,n,r=!1){let i=e?.nodes?.nodes||[],a=new Map(t?.map(e=>[e.identifier,e])),o=new Set,s=(t,n=``)=>{let c=i.find(e=>e?.id===t);if(!c||!c.functionDefinition)return``;if(o.add(t),!a.get(c.functionDefinition.identifier))return`${n}// Error: Function ${c.functionDefinition.identifier} not found\n`;let l=(c.parameters?.nodes||[]).map((i,a)=>{let o=i.value;if(!o)return r?`/* @pos ${t} ${a} */ {}`:`/* @pos ${t} ${a} */ undefined`;if(o.__typename===`ReferenceValue`){let n=o,r=typeof n.inputIndex==`number`?`p_${O(n.nodeFunctionId??`undefined`)}_${n.parameterIndex}[${n.inputIndex}]`:n.nodeFunctionId?`node_${O(n.nodeFunctionId)}`:`flow_${O(e?.id??`undefined`)}`;return n.referencePath?.forEach(e=>{r+=`?.${e.path}`}),`/* @pos ${t} ${a} */ ${r}`}if(o.__typename===`LiteralValue`)return`/* @pos ${t} ${a} */ ${S(o?.value)}`;if(o.__typename===`NodeFunctionIdWrapper`){let e=o;return`/* @pos ${t} ${a} */ (...${`p_${O(t)}_${a}`}) => {\n${s(e.id,n+` `)}${n}}`}return r?`/* @pos ${t} ${a} */ {}`:`/* @pos ${t} ${a} */ undefined`}),u=`node_${O(c.id)}`,d=`fn_${c?.functionDefinition?.identifier?.replace(/::/g,`_`)}`;l.includes(`undefined`);let f=`${n}`;return c.functionDefinition.identifier===`std::control::return`?f+=`return /* @pos ${t} null */ ${d}(${l.join(`, `)}) ;\n`:c.functionDefinition.identifier===`std::control::if`?(f+=`const ${u} = /* @pos ${t} null */ ${d}(${l.join(`, `)}) ;\n`,f+=`if(${l[0]}) {
29
- ${s(c.parameters?.nodes?.[1]?.value?.id,n+` `)}
28
+ `);return`${n?r:``}\n${i}`}var T=e=>e?.replace(/[^a-zA-Z0-9]/g,`_`);function E(e,t,n,r=!1){let i=e?.nodes?.nodes||[],a=new Map(t?.map(e=>[e.identifier,e])),o=new Set,s=(t,n=``)=>{let c=i.find(e=>e?.id===t);if(!c||!c.functionDefinition)return``;if(t?.includes(`NodeFunction`)&&o.add(t),!a.get(c.functionDefinition.identifier))return`${n}// Error: Function ${c.functionDefinition.identifier} not found\n`;let l=(c.parameters?.nodes||[]).map((i,a)=>{let o=i.value;if(!o)return r?`/* @pos ${t} ${a} */ {}`:`/* @pos ${t} ${a} */ undefined`;if(o.__typename===`ReferenceValue`){let n=o,r=typeof n.inputIndex==`number`?`p_${T(n.nodeFunctionId??`undefined`)}_${n.parameterIndex}[${n.inputIndex}]`:n.nodeFunctionId?`node_${T(n.nodeFunctionId)}`:`flow_${T(e?.id??`undefined`)}`;return n.referencePath?.forEach(e=>{r+=`?.${e.path}`}),`/* @pos ${t} ${a} */ ${r}`}if(o.__typename===`LiteralValue`)return`/* @pos ${t} ${a} */ ${b(o?.value)}`;if(o.__typename===`SubFlowValue`){let e=o;return`/* @pos ${t} ${a} */ (...${`p_${T(t)}_${a}`}) => {\n${s(e.startingNodeId||e.functionDefinition?.id,n+` `)}${n}}`}return r?`/* @pos ${t} ${a} */ {}`:`/* @pos ${t} ${a} */ undefined`}),u=`node_${T(c.id)}`,d=`fn_${c?.functionDefinition?.identifier?.replace(/::/g,`_`)}`;l.includes(`undefined`);let f=`${n}`;return c.functionDefinition.identifier===`std::control::return`?f+=`return /* @pos ${t} null */ ${d}(${l.join(`, `)}) ;\n`:c.functionDefinition.identifier===`std::control::if`?(f+=`const ${u} = /* @pos ${t} null */ ${d}(${l.join(`, `)}) ;\n`,f+=`if(${l[0]}) {
29
+ ${s(c.parameters?.nodes?.[1]?.value?.startingNodeId||(c.parameters?.nodes?.[1]?.value)?.functionDefinition?.identifier,n+` `)}
30
30
  }`):c.functionDefinition.identifier===`std::control::if_else`?(f+=`const ${u} = /* @pos ${t} null */ ${d}(${l.join(`, `)}) ;\n`,f+=`if(${l[0]}) {
31
- ${s(c.parameters?.nodes?.[1]?.value?.id,n+` `)}
31
+ ${s(c.parameters?.nodes?.[1]?.value?.startingNodeId||(c.parameters?.nodes?.[1]?.value)?.functionDefinition?.identifier,n+` `)}
32
32
  } else {
33
- ${s(c.parameters?.nodes?.[2]?.value?.id,n+` `)}
34
- }`):f+=`const ${u} = /* @pos ${t} null */ ${d}(${l.join(`, `)}) ;\n`,c.nextNodeId&&(f+=s(c.nextNodeId,n)),f},c=D(n),l=`declare function flow${e?.signature??`(): void`}`,u=t?.map(e=>`declare function fn_${e.identifier?.replace(/::/g,`_`)}${e.signature}`).join(`
35
- `),d=new Set(i.map(e=>e?.nextNodeId).filter(e=>!!e)),f=new Set;return i.forEach(e=>e?.parameters?.nodes?.forEach(e=>{e?.value?.__typename===`NodeFunctionIdWrapper`&&e.value.id&&f.add(e.value.id)})),`
33
+ ${s(c.parameters?.nodes?.[2]?.value?.startingNodeId||(c.parameters?.nodes?.[2]?.value)?.functionDefinition?.identifier,n+` `)}
34
+ }`):f+=`const ${u} = /* @pos ${t} null */ ${d}(${l.join(`, `)}) ;\n`,c.nextNodeId&&(f+=s(c.nextNodeId,n)),f},c=w(n),l=`declare function flow${e?.signature??`(): void`}`,u=t?.map(e=>`declare function fn_${e.identifier?.replace(/::/g,`_`)}${e.signature}`).join(`
35
+ `),d=new Set(i.map(e=>e?.nextNodeId).filter(e=>!!e)),f=new Set;return i.forEach(e=>e?.parameters?.nodes?.forEach(e=>{e?.value?.__typename===`SubFlowValue`&&(e.value.startingNodeId||e.value.functionDefinition?.id)&&f.add(e.value.startingNodeId||e.value.functionDefinition?.id)})),`
36
36
  ${c}\n
37
37
  ${l}\n
38
38
  ${u}\n
39
39
  (() =>
40
- ${e?`const flow_${O(e.id??``)} = /* @pos null null */ flow(${e.settings?.nodes?.map((e,t)=>`/* @pos null ${t} */ ${S(e?.value)}`).join(`, `)??``});`:``}
40
+ ${e?`const flow_${T(e.id??``)} = /* @pos null null */ flow(${e.settings?.nodes?.map((e,t)=>`/* @pos null ${t} */ ${b(e?.value)}`).join(`, `)??``});`:``}
41
41
  ${i.filter(e=>e?.id&&!d.has(e.id)&&!f.has(e.id)).map(e=>s(e.id)).join(`
42
42
  `)}
43
43
  )();
44
- `}var te=(e,t)=>{let n=S(e?.value);if(!n)return`any`;let r=`
45
- ${D(t,`unknown`)}
44
+ `}var ie=(e,t)=>{let n=b(e?.value);if(!n)return`any`;let r=`
45
+ ${w(t,`unknown`)}
46
46
  const tempValue = ${n??`any`};
47
- `,i=`index.ts`,a=T(i,r),o=a.getSourceFile(i),s=a.languageService.getProgram().getTypeChecker(),l=`any`,u=e=>{if(c.default.isVariableDeclaration(e)&&e.name.getText()===`tempValue`){let t=s.getTypeAtLocation(e),n=s.getSymbolsInScope(e,c.default.SymbolFlags.TypeAlias),r=t=>{if(t.isUnion()){let e=t.types.map(r);return Array.from(new Set(e)).sort().join(` | `)}if(s.isArrayType(t)){let e=t.typeArguments||[],n=e.length>0?r(e[0]):`any`;return e[0]?.isUnion()?`(${n})[]`:`${n}[]`}if(t.getFlags()&c.default.TypeFlags.Object||t.isClassOrInterface()){let n=s.getPropertiesOfType(t);if(n.length>0)return`{ ${n.map(t=>{let n=s.getTypeOfSymbolAtLocation(t,e);return`${t.getName()}: ${r(n)}`}).join(`, `)} }`}let i=n.filter(e=>s.isTypeAssignableTo(t,s.getDeclaredTypeOfSymbol(e)));return i.length>0?i.sort((e,t)=>{let n=s.getDeclaredTypeOfSymbol(e),r=s.getDeclaredTypeOfSymbol(t),i=s.isTypeAssignableTo(n,r),a=s.isTypeAssignableTo(r,n);return i&&!a?-1:a&&!i?1:e.getName().length-t.getName().length||e.getName().localeCompare(t.getName())})[0].getName():s.typeToString(t,e)};l=r(t)}c.default.forEachChild(e,u)};return u(o),l},ne=(e,t)=>{let n=`
48
- ${D(t)}
47
+ `,i=`index.ts`,a=C(i,r),o=a.getSourceFile(i),s=a.languageService.getProgram().getTypeChecker(),l=`any`,u=e=>{if(c.default.isVariableDeclaration(e)&&e.name.getText()===`tempValue`){let t=s.getTypeAtLocation(e),n=s.getSymbolsInScope(e,c.default.SymbolFlags.TypeAlias),r=t=>{if(t.isUnion()){let e=t.types.map(r);return Array.from(new Set(e)).sort().join(` | `)}if(s.isArrayType(t)){let e=t.typeArguments||[],n=e.length>0?r(e[0]):`any`;return e[0]?.isUnion()?`(${n})[]`:`${n}[]`}if(t.getFlags()&c.default.TypeFlags.Object||t.isClassOrInterface()){let n=s.getPropertiesOfType(t);if(n.length>0)return`{ ${n.map(t=>{let n=s.getTypeOfSymbolAtLocation(t,e);return`${t.getName()}: ${r(n)}`}).join(`, `)} }`}let i=n.filter(e=>s.isTypeAssignableTo(t,s.getDeclaredTypeOfSymbol(e)));return i.length>0?i.sort((e,t)=>{let n=s.getDeclaredTypeOfSymbol(e),r=s.getDeclaredTypeOfSymbol(t),i=s.isTypeAssignableTo(n,r),a=s.isTypeAssignableTo(r,n);return i&&!a?-1:a&&!i?1:e.getName().length-t.getName().length||e.getName().localeCompare(t.getName())})[0].getName():s.typeToString(t,e)};l=r(t)}c.default.forEachChild(e,u)};return u(o),l},ae=(e,t)=>{let n=`
48
+ ${w(t)}
49
49
  type Target = ${e};
50
- `,r=`index.ts`,i=T(r,n),a=i.getSourceFile(r),o=i.languageService.getProgram().getTypeChecker(),s=a.statements.find(e=>c.default.isTypeAliasDeclaration(e)&&e.name.text===`Target`);if(!s)return{__typename:`LiteralValue`,value:null};let l=o.getTypeAtLocation(s.type),u=(e,t,n=new Set)=>{let r=new Set(n);if(r.has(e))return null;let i=e.getFlags();if(e.isUnion()){if(t.type,c.default.isTypeAliasDeclaration(t)&&t.type&&c.default.isUnionTypeNode(t.type))return u(o.getTypeFromTypeNode(t.type.types[0]),t,r);let n=e.types.filter(e=>{let t=e.getFlags();return!(t&c.default.TypeFlags.Undefined)&&!(t&c.default.TypeFlags.Null)});return u(n.length>0?n[0]:e.types[0],t,r)}if(i&c.default.TypeFlags.StringLiteral)return e.value;if(i&c.default.TypeFlags.String)return``;if(i&c.default.TypeFlags.NumberLiteral)return e.value;if(i&c.default.TypeFlags.Number)return 0;if(i&c.default.TypeFlags.BooleanLiteral)return e.intrinsicName===`true`;if(i&c.default.TypeFlags.Boolean)return!1;if(o.isArrayType(e)){r.add(e);let n=u(e.typeArguments?.[0]||o.getAnyType(),t,r);return n===null?[]:[n]}if(e.isClassOrInterface()||i&c.default.TypeFlags.Object||e.getProperties().length>0){r.add(e);let n={};return e.getProperties().forEach(e=>{let i=o.getTypeOfSymbolAtLocation(e,t),a=e.valueDeclaration;i&&(n[e.getName()]=u(i,a||t,r))}),n}return null};return{__typename:`LiteralValue`,value:u(l,s)}},A=(e,t,n)=>{if(!e?.startingNodeId)return{isValid:!1,returnType:`void`,diagnostics:[{nodeId:null,parameterIndex:null,code:0,message:`You need to provide a starting node to be able to execute this flow.`,severity:`error`}]};if(!e.nodes?.nodes?.find(t=>t?.id==e.startingNodeId))return{isValid:!1,returnType:`void`,diagnostics:[{nodeId:null,parameterIndex:null,code:0,message:`The starting node is not linked within the flow. Please make sure the starting node is connected to the rest of the flow.`,severity:`error`}]};let r=k(e,t,n),i=`index.ts`,a=T(i,r),o=a.getSourceFile(i),s=a.languageService.getProgram().getSemanticDiagnostics(o).map(e=>{let t=(0,c.flattenDiagnosticMessageText)(e.messageText,`
51
- `),n,r=null;if(e.start!==void 0){let t=o.getFullText(),i=Math.max(0,e.start-300),a=Math.min(t.length,e.start),s=t.substring(i,a),c=/\/\* @pos ([^ ]+) (\d+|null) \*\//g,l,u=null,d=-1;for(;(l=c.exec(s))!==null;){let t=i+l.index+l[0].length;t<=e.start&&t>d&&(d=t,u=l)}u&&(n=u[1]===`null`?null:u[1],r=parseInt(u[2],10))}return{message:t,code:e.code,severity:`error`,nodeId:n,parameterIndex:typeof r==`number`&&Number.isSafeInteger(r)?r:null}}).filter(e=>e!==null);return{isValid:!s.some(e=>e?.severity===`error`),returnType:`void`,diagnostics:s}},j=(e,t,n)=>{let r=S(t?.value),i=`
52
- ${D(n)}
50
+ `,r=`index.ts`,i=C(r,n),a=i.getSourceFile(r),o=i.languageService.getProgram().getTypeChecker(),s=a.statements.find(e=>c.default.isTypeAliasDeclaration(e)&&e.name.text===`Target`);if(!s)return{__typename:`LiteralValue`,value:null};let l=o.getTypeAtLocation(s.type),u=(e,t,n=new Set)=>{let r=new Set(n);if(r.has(e))return null;let i=e.getFlags();if(e.isUnion()){if(t.type,c.default.isTypeAliasDeclaration(t)&&t.type&&c.default.isUnionTypeNode(t.type))return u(o.getTypeFromTypeNode(t.type.types[0]),t,r);let n=e.types.filter(e=>{let t=e.getFlags();return!(t&c.default.TypeFlags.Undefined)&&!(t&c.default.TypeFlags.Null)});return u(n.length>0?n[0]:e.types[0],t,r)}if(i&c.default.TypeFlags.StringLiteral)return e.value;if(i&c.default.TypeFlags.String)return``;if(i&c.default.TypeFlags.NumberLiteral)return e.value;if(i&c.default.TypeFlags.Number)return 0;if(i&c.default.TypeFlags.BooleanLiteral)return e.intrinsicName===`true`;if(i&c.default.TypeFlags.Boolean)return!1;if(o.isArrayType(e)){r.add(e);let n=u(e.typeArguments?.[0]||o.getAnyType(),t,r);return n===null?[]:[n]}if(e.isClassOrInterface()||i&c.default.TypeFlags.Object||e.getProperties().length>0){r.add(e);let n={};return e.getProperties().forEach(e=>{let i=o.getTypeOfSymbolAtLocation(e,t),a=e.valueDeclaration;i&&(n[e.getName()]=u(i,a||t,r))}),n}return null};return{__typename:`LiteralValue`,value:u(l,s)}},D=(e,t,n)=>{if(!e?.startingNodeId)return{isValid:!1,returnType:`void`,diagnostics:[{nodeId:null,parameterIndex:null,code:0,message:`You need to provide a starting node to be able to execute this flow.`,severity:`error`}]};if(!e.nodes?.nodes?.find(t=>t?.id==e.startingNodeId))return{isValid:!1,returnType:`void`,diagnostics:[{nodeId:null,parameterIndex:null,code:0,message:`The starting node is not linked within the flow. Please make sure the starting node is connected to the rest of the flow.`,severity:`error`}]};let r=E(e,t,n),i=`index.ts`,a=C(i,r),o=a.getSourceFile(i),s=a.languageService.getProgram().getSemanticDiagnostics(o).map(e=>{let t=(0,c.flattenDiagnosticMessageText)(e.messageText,`
51
+ `),n,r=null;if(e.start!==void 0){let t=o.getFullText(),i=Math.max(0,e.start-300),a=Math.min(t.length,e.start),s=t.substring(i,a),c=/\/\* @pos ([^ ]+) (\d+|null) \*\//g,l,u=null,d=-1;for(;(l=c.exec(s))!==null;){let t=i+l.index+l[0].length;t<=e.start&&t>d&&(d=t,u=l)}u&&(n=u[1]===`null`?null:u[1],r=parseInt(u[2],10))}return{message:t,code:e.code,severity:`error`,nodeId:n,parameterIndex:typeof r==`number`&&Number.isSafeInteger(r)?r:null}}).filter(e=>e!==null);return{isValid:!s.some(e=>e?.severity===`error`),returnType:`void`,diagnostics:s}},O=(e,t,n)=>{let r=b(t?.value),i=`
52
+ ${w(n)}
53
53
  const testValue: ${e} = ${r};
54
- `,a=`index.ts`,o=T(a,i).languageService.getSemanticDiagnostics(a).map(e=>{let t=c.default.flattenDiagnosticMessageText(e.messageText,`
55
- `),n=t.includes(`not assignable to parameter of type`)&&(t.includes(`'{}'`)||t.includes(`undefined`))||t.includes(`not assignable to type 'undefined'`)||t.includes(`not assignable to type 'void'`)||t.includes(`may be a mistake because neither type sufficiently overlaps`);return{message:t,code:e.code,severity:n?`warning`:`error`}});return{isValid:!o.some(e=>e.severity===`error`),returnType:`void`,diagnostics:o}},M=e=>e.isUnion()?e.types.flatMap(M):e.isStringLiteral()?[{value:e.value,__typename:`LiteralValue`}]:e.isNumberLiteral()?[{value:e.value.toString()}]:e.intrinsicName===`true`?[{value:!0,__typename:`LiteralValue`}]:e.intrinsicName===`false`?[{value:!1,__typename:`LiteralValue`}]:[],N=(e,t,n,r)=>r.flatMap(r=>{let i=r.getName();if(!P(i))return[];let a=r.getDeclarations()?.[0];if(!a||a.getEnd()>=t.getEnd())return[];let o=e.getTypeOfSymbolAtLocation(r,t);return i.startsWith(`node_`)?F(i,o,e,n):i.startsWith(`p_`)?I(i,o,e,n):i.startsWith(`flow_`)?L(o,e,n):[]}),P=e=>e.startsWith(`node_`)||e.startsWith(`p_`)||e.startsWith(`flow_`),F=(e,t,n,r)=>{if((t.flags&c.default.TypeFlags.Void)!==0)return[];let i=R(e.replace(`node_`,``));return B(t,n,r).flatMap(({path:e})=>{let t={__typename:`ReferenceValue`,nodeFunctionId:i};return e.length>0&&(t.referencePath=e),t})},I=(e,t,n,r)=>{let{nodeFunctionId:i,paramIndexFromName:a}=z(e);if(!n.isTupleType(t))return[];let o=t;return n.getTypeArguments(o).flatMap((e,t)=>B(e,n,r).flatMap(({path:e})=>{let n={__typename:`ReferenceValue`,nodeFunctionId:i,parameterIndex:isNaN(a)?0:a,inputIndex:t,inputTypeIdentifier:o.target.labeledElementDeclarations?.[t].name.getText()};return e.length>0&&(n.referencePath=e),n}))},L=(e,t,n)=>B(e,t,n).flatMap(({path:e})=>{let t={__typename:`ReferenceValue`,nodeFunctionId:null};return e.length>0&&(t.referencePath=e),t}),R=e=>e.replace(/___/g,`://`).replace(/__/g,`/`).replace(/_/g,`/`),z=e=>{let t=e.replace(`p_`,``),n=t.lastIndexOf(`_`),r=t.substring(0,n),i=parseInt(t.substring(n+1),10);return{nodeFunctionId:R(r),paramIndexFromName:i}},B=(e,t,n,r=[])=>{let i=[];if(t.isTypeAssignableTo(e,n)&&i.push({path:r,type:e}),V(e)){let a=e.getProperties();a&&a.length>0&&a.forEach(e=>{let a=t.getTypeOfSymbolAtLocation(e,e.valueDeclaration),o=e.getName(),s=[...r,{path:o}];i.push(...B(a,t,n,s))})}return i},V=e=>{let t=c.default.TypeFlags.String|c.default.TypeFlags.Number|c.default.TypeFlags.Boolean|c.default.TypeFlags.Undefined|c.default.TypeFlags.Null|c.default.TypeFlags.BigInt|c.default.TypeFlags.ESSymbol;return(e.flags&t)===0},H=(e,t,n,r)=>Q(r)?[]:t.flatMap(t=>{let i=U(e,t,n,r);return i?[i]:[]}),U=(e,t,n,r)=>{let i=e.getSignatureFromDeclaration(t),a=W(e,e.getReturnTypeOfSignature(i));if(!e.isTypeAssignableTo(a,r))return null;let o=G(t.name?.getText());return re(n.find(e=>e.identifier===o))},W=(e,t)=>t.isTypeParameter()?e.getBaseConstraintOfType(t)||e.getAnyType():t,G=e=>e?e.replace(`fn_`,``).replace(`_`,`::`).replace(`_`,`::`):``,re=e=>{let t=(e?.parameterDefinitions?.nodes?.length??0)>0,n={__typename:`NodeFunction`,id:`gid://sagittarius/NodeFunction/1`,functionDefinition:{__typename:`FunctionDefinition`,id:e?.id,identifier:e?.identifier,names:e?.names,descriptions:e?.descriptions,displayIcon:e?.displayIcon}};return t&&(n.parameters=K(e?.parameterDefinitions?.nodes||[])),n},K=e=>({__typename:`NodeParameterConnection`,nodes:e.map(e=>q(e))}),q=e=>({__typename:`NodeParameter`,parameterDefinition:{__typename:`ParameterDefinition`,id:e?.id,identifier:e?.identifier},value:e?.defaultValue?{__typename:`LiteralValue`,value:e.defaultValue.value}:null}),J=(e,t,n,r,i,a=!0)=>{let o=M(n),s=N(e,t,n,e.getSymbolsInScope(t,c.default.SymbolFlags.Variable)),l=H(e,r,i,n),u=a?{suggestions:[...o,...s,...l]}:{};if(Y(n))return{input:`boolean`,...u};if(X(n))return{input:`number`,...u};if(Z(n))return{input:`text`,...u};if(ae(n))return{input:`select`,...u};if(Q(n))return{input:`sub-flow`,...u};if(oe(e,n))return{input:`list`,items:e.getTypeArguments(n).flatMap(n=>(n.isUnion()?n.types:[n]).map(n=>J(e,t,n,r,i,a))),...u};if((n.flags&c.default.TypeFlags.Object)!==0){let o={},s=[];for(let l of e.getPropertiesOfType(n)){let n=l.valueDeclaration??l.declarations?.[0];if(!n)continue;let u=e.getTypeOfSymbolAtLocation(l,n),d=(l.flags&c.default.SymbolFlags.Optional)!==0||u.isUnion()&&u.types.some(e=>(e.flags&c.default.TypeFlags.Undefined)!==0),f=(u.isUnion()?u.types.filter(e=>(e.flags&c.default.TypeFlags.Undefined)===0):[u]).map(n=>J(e,t,n,r,i,a));o[l.name]=f.length===1?f[0]:f,d||s.push(l.name)}return{input:`data`,properties:o,required:s,...u}}return{input:`generic`}};function Y(e){return(e.flags&c.default.TypeFlags.Boolean)!==0||(e.flags&c.default.TypeFlags.BooleanLiteral)!==0}function X(e){return(e.flags&c.default.TypeFlags.Number)!==0||(e.flags&c.default.TypeFlags.NumberLiteral)!==0}function Z(e){return(e.flags&c.default.TypeFlags.String)!==0||(e.flags&c.default.TypeFlags.StringLiteral)!==0}function ie(e){return Z(e)||X(e)||Y(e)}function ae(e){return e.isUnion()?e.types.every(ie):!1}function oe(e,t){return e.isArrayType(t)||e.isTupleType(t)}function Q(e){return e.getCallSignatures().length>0}var $=(e,t,n,r)=>{let i=k(e,n,t),a=`index.ts`,o=T(a,i),s=o.getSourceFile(a),c=o.languageService.getProgram().getTypeChecker(),l=e.nodes?.nodes?.find(e=>e?.id===r),u=r?`fn_${l?.functionDefinition?.identifier?.replace(/::/g,`_`)}`:`flow`,d=r?`node_${O(r)}`:`flow_${O(e.id)}`,f=se(s),p=ce(s).get(d),m=f.get(u);return fe(r,c,p,le(c,p),ue(c,m,p),de(m),r?f:new Map,r?n:[])},se=e=>new Map(e.statements.filter(c.default.isFunctionDeclaration).map(e=>[e.name.getText(),e])),ce=e=>{let t=[];return e.statements.forEach(e=>{e.forEachChild(function e(n){c.default.isVariableDeclaration(n)&&(n.parent.flags&c.default.NodeFlags.Const)!==0&&t.push([n.name.getText(),n]),n.forEachChild(e)})}),new Map(t)},le=(e,t)=>{if(!(!t?.initializer||!c.default.isCallExpression(t.initializer)))return e.getResolvedSignature(t.initializer)?.parameters.map(n=>e.getTypeOfSymbolAtLocation(n,t.initializer))},ue=(e,t,n)=>{if(!(!t||!n?.initializer))return t.parameters.map(t=>{let r=e.getSymbolAtLocation(t.name);return e.getTypeOfSymbolAtLocation(r,n.initializer)})},de=e=>{let t=e.typeParameters?.map(e=>e.name.getText())||[],n={};return e.parameters.forEach((e,r)=>{let i=e.type?.getText()||``;t.forEach(e=>{i.includes(e)&&(n[e]||(n[e]=[]),n[e].push(r))})}),Object.values(n).filter(e=>e.length>1).map(([e,...t])=>t.map(t=>({parameterIndex:t,dependsOnIndex:e}))).flat()},fe=(e,t,n,r,i,a,o,s)=>r?r.map((r,c)=>({nodeId:e,schema:J(t,n,r,Array.from(o.values()),s),functionSchema:J(t,n,i?.[c],Array.from(o.values()),s,!1),blockedBy:a.filter(e=>e.parameterIndex===c).map(e=>e.dependsOnIndex)})):[];exports.getFlowValidation=A,exports.getSignatureSchema=$,exports.getTypeFromValue=te,exports.getValueFromType=ne,exports.getValueValidation=j;
54
+ `,a=`index.ts`,o=C(a,i).languageService.getSemanticDiagnostics(a).map(e=>{let t=c.default.flattenDiagnosticMessageText(e.messageText,`
55
+ `),n=t.includes(`not assignable to parameter of type`)&&(t.includes(`'{}'`)||t.includes(`undefined`))||t.includes(`not assignable to type 'undefined'`)||t.includes(`not assignable to type 'void'`)||t.includes(`may be a mistake because neither type sufficiently overlaps`);return{message:t,code:e.code,severity:n?`warning`:`error`}});return{isValid:!o.some(e=>e.severity===`error`),returnType:`void`,diagnostics:o}},k=e=>e.isUnion()?e.types.flatMap(k):e.isStringLiteral()?[{value:e.value,__typename:`LiteralValue`}]:e.isNumberLiteral()?[{value:e.value.toString()}]:e.intrinsicName===`true`?[{value:!0,__typename:`LiteralValue`}]:e.intrinsicName===`false`?[{value:!1,__typename:`LiteralValue`}]:[],A=(e,t,n,r)=>r.flatMap(r=>{let i=r.getName();if(!j(i))return[];let a=r.getDeclarations()?.[0];if(!a||a.getEnd()>=t.getEnd())return[];let o=e.getTypeOfSymbolAtLocation(r,t);return i.startsWith(`node_`)?M(i,o,e,n):i.startsWith(`p_`)?N(i,o,e,n):i.startsWith(`flow_`)?P(o,e,n):[]}),j=e=>e.startsWith(`node_`)||e.startsWith(`p_`)||e.startsWith(`flow_`),M=(e,t,n,r)=>{if((t.flags&c.default.TypeFlags.Void)!==0)return[];let i=F(e.replace(`node_`,``));return L(t,n,r).flatMap(({path:e})=>{let t={__typename:`ReferenceValue`,nodeFunctionId:i};return e.length>0&&(t.referencePath=e),t})},N=(e,t,n,r)=>{let{nodeFunctionId:i,paramIndexFromName:a}=I(e);if(!n.isTupleType(t))return[];let o=t;return n.getTypeArguments(o).flatMap((e,t)=>L(e,n,r).flatMap(({path:e})=>{let n={__typename:`ReferenceValue`,nodeFunctionId:i,parameterIndex:isNaN(a)?0:a,inputIndex:t,inputTypeIdentifier:o.target.labeledElementDeclarations?.[t].name.getText()};return e.length>0&&(n.referencePath=e),n}))},P=(e,t,n)=>L(e,t,n).flatMap(({path:e})=>{let t={__typename:`ReferenceValue`,nodeFunctionId:null};return e.length>0&&(t.referencePath=e),t}),F=e=>e.replace(/___/g,`://`).replace(/__/g,`/`).replace(/_/g,`/`),I=e=>{let t=e.replace(`p_`,``),n=t.lastIndexOf(`_`),r=t.substring(0,n),i=parseInt(t.substring(n+1),10);return{nodeFunctionId:F(r),paramIndexFromName:i}},L=(e,t,n,r=[])=>{let i=[];if(t.isTypeAssignableTo(e,n)&&i.push({path:r,type:e}),R(e)){let a=e.getProperties();a&&a.length>0&&a.forEach(e=>{let a=t.getTypeOfSymbolAtLocation(e,e.valueDeclaration),o=e.getName(),s=[...r,{path:o}];i.push(...L(a,t,n,s))})}return i},R=e=>{let t=c.default.TypeFlags.String|c.default.TypeFlags.Number|c.default.TypeFlags.Boolean|c.default.TypeFlags.Undefined|c.default.TypeFlags.Null|c.default.TypeFlags.BigInt|c.default.TypeFlags.ESSymbol;return(e.flags&t)===0},z=(e,t,n,r)=>Q(r)?[]:t.flatMap(t=>{let i=B(e,t,n,r);return i?[i]:[]}),B=(e,t,n,r)=>{if(t.parameters.length>0)return null;let i=e.getSignatureFromDeclaration(t),a=V(e,e.getReturnTypeOfSignature(i));if(!e.isTypeAssignableTo(a,r))return null;let o=H(t.name?.getText());return oe(n.find(e=>e.identifier===o))},V=(e,t)=>t.isTypeParameter()?e.getBaseConstraintOfType(t)||e.getAnyType():t,H=e=>e?e.replace(`fn_`,``).replace(`_`,`::`).replace(`_`,`::`):``,oe=e=>{let t=(e?.parameterDefinitions?.nodes?.length??0)>0,n={__typename:`NodeFunction`,id:`gid://sagittarius/NodeFunction/1`,functionDefinition:{__typename:`FunctionDefinition`,id:e?.id,identifier:e?.identifier,names:e?.names,descriptions:e?.descriptions,displayIcon:e?.displayIcon}};return t&&(n.parameters=U(e?.parameterDefinitions?.nodes||[])),n},U=e=>({__typename:`NodeParameterConnection`,nodes:e.map(e=>W(e))}),W=e=>({__typename:`NodeParameter`,parameterDefinition:{__typename:`ParameterDefinition`,id:e?.id,identifier:e?.identifier},value:e?.defaultValue?{__typename:`LiteralValue`,value:e.defaultValue.value}:null}),G=(e,t,n,r)=>Q(r)?t.flatMap(t=>{let i=K(e,t,n,r);return i?[i]:[]}):[],K=(e,t,n,r)=>{let i=e.getTypeAtLocation(t);if(!e.isTypeAssignableTo(i,r))return null;let a=q(t.name?.getText()),o=n.find(e=>e.identifier===a);return o?se(o):null},q=e=>e?e.replace(`fn_`,``).replace(`_`,`::`).replace(`_`,`::`):``,se=e=>({__typename:`SubFlowValue`,functionDefinition:e,signature:e.signature,settings:e.parameterDefinitions?.nodes?.map(e=>({__typename:`SubFlowValueSetting`,identifier:e?.identifier,defaultValue:e?.defaultValue??null,hidden:e?.hidden??!1,optional:e?.optional??!1}))}),J=(e,t,n,r,i,a=!0)=>{let o=a?{suggestions:[...k(n),...t?A(e,t,n,e.getSymbolsInScope(t,c.default.SymbolFlags.Variable)):[],...z(e,r,i,n),...G(e,r,i,n)]}:{};if(Y(n))return{input:`boolean`,...o};if(X(n))return{input:`number`,...o};if(Z(n))return{input:`text`,...o};if(le(n))return{input:`select`,...o};if(Q(n))return{input:`sub-flow`,...o};if(ue(e,n))return{input:`list`,items:e.getTypeArguments(n).flatMap(n=>(n.isUnion()?n.types:[n]).map(n=>J(e,t,n,r,i,a))),...o};if((n.flags&c.default.TypeFlags.Object)!==0){let s={},l=[];for(let o of e.getPropertiesOfType(n)){let n=o.valueDeclaration??o.declarations?.[0];if(!n)continue;let u=e.getTypeOfSymbolAtLocation(o,n),d=(o.flags&c.default.SymbolFlags.Optional)!==0||u.isUnion()&&u.types.some(e=>(e.flags&c.default.TypeFlags.Undefined)!==0),f=(u.isUnion()?u.types.filter(e=>(e.flags&c.default.TypeFlags.Undefined)===0):[u]).map(n=>J(e,t,n,r,i,a));s[o.name]=f.length===1?f[0]:f,d||l.push(o.name)}return{input:`data`,properties:s,required:l,...o}}return{input:`generic`}};function Y(e){return(e.flags&c.default.TypeFlags.Boolean)!==0||(e.flags&c.default.TypeFlags.BooleanLiteral)!==0}function X(e){return(e.flags&c.default.TypeFlags.Number)!==0||(e.flags&c.default.TypeFlags.NumberLiteral)!==0}function Z(e){return(e.flags&c.default.TypeFlags.String)!==0||(e.flags&c.default.TypeFlags.StringLiteral)!==0}function ce(e){return Z(e)||X(e)||Y(e)}function le(e){return e.isUnion()?e.types.every(ce):!1}function ue(e,t){return e.isArrayType(t)||e.isTupleType(t)}function Q(e){return e.getCallSignatures().length>0}var de=(e,t,n,r)=>{let i=E(e,n,t),a=`index.ts`,o=C(a,i),s=o.getSourceFile(a),c=o.languageService.getProgram().getTypeChecker(),l=e.nodes?.nodes?.find(e=>e?.id===r),u=r?`fn_${l?.functionDefinition?.identifier?.replace(/::/g,`_`)}`:`flow`,d=r?`node_${T(r)}`:`flow_${T(e.id)}`,f=fe(s),p=pe(s).get(d),m=f.get(u);return $(r,c,p,me(c,p),he(c,m,p),ge(m),r?f:new Map,r?n:[])},fe=e=>new Map(e.statements.filter(c.default.isFunctionDeclaration).map(e=>[e.name.getText(),e])),pe=e=>{let t=[];return e.statements.forEach(e=>{e.forEachChild(function e(n){c.default.isVariableDeclaration(n)&&(n.parent.flags&c.default.NodeFlags.Const)!==0&&t.push([n.name.getText(),n]),n.forEachChild(e)})}),new Map(t)},me=(e,t)=>{if(!(!t?.initializer||!c.default.isCallExpression(t.initializer)))return e.getResolvedSignature(t.initializer)?.parameters.map(n=>e.getTypeOfSymbolAtLocation(n,t.initializer))},he=(e,t,n)=>{if(!(!t||!n?.initializer))return t.parameters.map(t=>{let r=e.getSymbolAtLocation(t.name);return e.getTypeOfSymbolAtLocation(r,n.initializer)})},ge=e=>{let t=e.typeParameters?.map(e=>e.name.getText())||[],n={};return e.parameters.forEach((e,r)=>{let i=e.type?.getText()||``;t.forEach(e=>{i.includes(e)&&(n[e]||(n[e]=[]),n[e].push(r))})}),Object.values(n).filter(e=>e.length>1).map(([e,...t])=>t.map(t=>({parameterIndex:t,dependsOnIndex:e}))).flat()},$=(e,t,n,r,i,a,o,s)=>r?r.map((r,c)=>({nodeId:e,schema:J(t,n,r,Array.from(o.values()),s),functionSchema:J(t,n,i?.[c],Array.from(o.values()),s,!1),blockedBy:a.filter(e=>e.parameterIndex===c).map(e=>e.dependsOnIndex)})):[],_e=(e,t=[])=>{let n=`index.ts`,r=C(n,`${w(t)}\ntype MyType = ${e}`).languageService.getProgram(),i=r?.getSourceFile(n),a=r?.getTypeChecker();if(!i||!a)return;let o=i.statements.filter(e=>c.default.isTypeAliasDeclaration(e)||c.default.isInterfaceDeclaration(e)||c.default.isClassDeclaration(e)).pop();if(!o)return;let s=a.getTypeAtLocation(o);if(s)return J(a,void 0,s,[],[],!1)};exports.getFlowValidation=D,exports.getSignatureSchema=de,exports.getTypeFromValue=ie,exports.getTypeSchema=_e,exports.getValueFromType=ae,exports.getValueValidation=O;
@@ -244,74 +244,74 @@ function _(e) {
244
244
  }
245
245
  //#endregion
246
246
  //#region src/utils.ts
247
- var v = "\n interface Array<T> { \n [n: number]: T; \n length: number; \n }\n interface String { readonly length: number; }\n interface Number { }\n interface Boolean { }\n interface Object { }\n interface Function { }\n interface CallableFunction extends Function {}\n interface NewableFunction extends Function {}\n interface IArguments { }\n interface RegExp { }\n \n declare namespace Utils {\n type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;\n }\n\n import ReturnType = Utils.ReturnType;\n";
248
- function y(t, n) {
247
+ var ee = "\n interface Array<T> { \n [n: number]: T; \n length: number; \n }\n interface String { readonly length: number; }\n interface Number { }\n interface Boolean { }\n interface Object { }\n interface Function { }\n interface CallableFunction extends Function {}\n interface NewableFunction extends Function {}\n interface IArguments { }\n interface RegExp { }\n \n declare namespace Utils {\n type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;\n }\n\n import ReturnType = Utils.ReturnType;\n";
248
+ function v(t, n) {
249
249
  let r = /* @__PURE__ */ new Map();
250
- return r.set(t, n), r.set("lib.codezero.d.ts", v), o(d(r), [t, "lib.codezero.d.ts"], e, b);
250
+ return r.set(t, n), r.set("lib.codezero.d.ts", ee), o(d(r), [t, "lib.codezero.d.ts"], e, y);
251
251
  }
252
- var b = {
252
+ var y = {
253
253
  target: e.ScriptTarget.Latest,
254
254
  lib: ["lib.codezero.d.ts"],
255
255
  noEmit: !0,
256
256
  strictNullChecks: !0
257
257
  };
258
- function x(e, t = "any", n = !0) {
258
+ function b(e, t = "any", n = !0) {
259
259
  let r = Array.from(new Set(e?.flatMap((e) => e.genericKeys || []))).map((e) => `type ${e} = ${t};`).join("\n"), i = e?.map((e) => `type ${e.identifier}${(e.genericKeys?.length ?? 0) > 0 ? `<${e.genericKeys?.join(",")}>` : ""} = ${e.type};`).join("\n");
260
260
  return `${n ? r : ""}\n${i}`;
261
261
  }
262
- var S = (e) => e?.replace(/[^a-zA-Z0-9]/g, "_");
263
- function C(e, t, n, r = !1) {
262
+ var x = (e) => e?.replace(/[^a-zA-Z0-9]/g, "_");
263
+ function S(e, t, n, r = !1) {
264
264
  let i = e?.nodes?.nodes || [], a = new Map(t?.map((e) => [e.identifier, e])), o = /* @__PURE__ */ new Set(), s = (t, n = "") => {
265
265
  let c = i.find((e) => e?.id === t);
266
266
  if (!c || !c.functionDefinition) return "";
267
- if (o.add(t), !a.get(c.functionDefinition.identifier)) return `${n}// Error: Function ${c.functionDefinition.identifier} not found\n`;
267
+ if (t?.includes("NodeFunction") && o.add(t), !a.get(c.functionDefinition.identifier)) return `${n}// Error: Function ${c.functionDefinition.identifier} not found\n`;
268
268
  let l = (c.parameters?.nodes || []).map((i, a) => {
269
269
  let o = i.value;
270
270
  if (!o) return r ? `/* @pos ${t} ${a} */ {}` : `/* @pos ${t} ${a} */ undefined`;
271
271
  if (o.__typename === "ReferenceValue") {
272
- let n = o, r = typeof n.inputIndex == "number" ? `p_${S(n.nodeFunctionId ?? "undefined")}_${n.parameterIndex}[${n.inputIndex}]` : n.nodeFunctionId ? `node_${S(n.nodeFunctionId)}` : `flow_${S(e?.id ?? "undefined")}`;
272
+ let n = o, r = typeof n.inputIndex == "number" ? `p_${x(n.nodeFunctionId ?? "undefined")}_${n.parameterIndex}[${n.inputIndex}]` : n.nodeFunctionId ? `node_${x(n.nodeFunctionId)}` : `flow_${x(e?.id ?? "undefined")}`;
273
273
  return n.referencePath?.forEach((e) => {
274
274
  r += `?.${e.path}`;
275
275
  }), `/* @pos ${t} ${a} */ ${r}`;
276
276
  }
277
277
  if (o.__typename === "LiteralValue") return `/* @pos ${t} ${a} */ ${g(o?.value)}`;
278
- if (o.__typename === "NodeFunctionIdWrapper") {
278
+ if (o.__typename === "SubFlowValue") {
279
279
  let e = o;
280
- return `/* @pos ${t} ${a} */ (...${`p_${S(t)}_${a}`}) => {\n${s(e.id, n + " ")}${n}}`;
280
+ return `/* @pos ${t} ${a} */ (...${`p_${x(t)}_${a}`}) => {\n${s(e.startingNodeId || e.functionDefinition?.id, n + " ")}${n}}`;
281
281
  }
282
282
  return r ? `/* @pos ${t} ${a} */ {}` : `/* @pos ${t} ${a} */ undefined`;
283
- }), u = `node_${S(c.id)}`, d = `fn_${c?.functionDefinition?.identifier?.replace(/::/g, "_")}`;
283
+ }), u = `node_${x(c.id)}`, d = `fn_${c?.functionDefinition?.identifier?.replace(/::/g, "_")}`;
284
284
  l.includes("undefined");
285
285
  let f = `${n}`;
286
286
  return c.functionDefinition.identifier === "std::control::return" ? f += `return /* @pos ${t} null */ ${d}(${l.join(", ")}) ;\n` : c.functionDefinition.identifier === "std::control::if" ? (f += `const ${u} = /* @pos ${t} null */ ${d}(${l.join(", ")}) ;\n`, f += `if(${l[0]}) {
287
- ${s(c.parameters?.nodes?.[1]?.value?.id, n + " ")}
287
+ ${s(c.parameters?.nodes?.[1]?.value?.startingNodeId || (c.parameters?.nodes?.[1]?.value)?.functionDefinition?.identifier, n + " ")}
288
288
  }`) : c.functionDefinition.identifier === "std::control::if_else" ? (f += `const ${u} = /* @pos ${t} null */ ${d}(${l.join(", ")}) ;\n`, f += `if(${l[0]}) {
289
- ${s(c.parameters?.nodes?.[1]?.value?.id, n + " ")}
289
+ ${s(c.parameters?.nodes?.[1]?.value?.startingNodeId || (c.parameters?.nodes?.[1]?.value)?.functionDefinition?.identifier, n + " ")}
290
290
  } else {
291
- ${s(c.parameters?.nodes?.[2]?.value?.id, n + " ")}
291
+ ${s(c.parameters?.nodes?.[2]?.value?.startingNodeId || (c.parameters?.nodes?.[2]?.value)?.functionDefinition?.identifier, n + " ")}
292
292
  }`) : f += `const ${u} = /* @pos ${t} null */ ${d}(${l.join(", ")}) ;\n`, c.nextNodeId && (f += s(c.nextNodeId, n)), f;
293
- }, c = x(n), l = `declare function flow${e?.signature ?? "(): void"}`, u = t?.map((e) => `declare function fn_${e.identifier?.replace(/::/g, "_")}${e.signature}`).join("\n"), d = new Set(i.map((e) => e?.nextNodeId).filter((e) => !!e)), f = /* @__PURE__ */ new Set();
293
+ }, c = b(n), l = `declare function flow${e?.signature ?? "(): void"}`, u = t?.map((e) => `declare function fn_${e.identifier?.replace(/::/g, "_")}${e.signature}`).join("\n"), d = new Set(i.map((e) => e?.nextNodeId).filter((e) => !!e)), f = /* @__PURE__ */ new Set();
294
294
  return i.forEach((e) => e?.parameters?.nodes?.forEach((e) => {
295
- e?.value?.__typename === "NodeFunctionIdWrapper" && e.value.id && f.add(e.value.id);
295
+ e?.value?.__typename === "SubFlowValue" && (e.value.startingNodeId || e.value.functionDefinition?.id) && f.add(e.value.startingNodeId || e.value.functionDefinition?.id);
296
296
  })), `
297
297
  ${c}\n
298
298
  ${l}\n
299
299
  ${u}\n
300
300
  (() =>
301
- ${e ? `const flow_${S(e.id ?? "")} = /* @pos null null */ flow(${e.settings?.nodes?.map((e, t) => `/* @pos null ${t} */ ${g(e?.value)}`).join(", ") ?? ""});` : ""}
301
+ ${e ? `const flow_${x(e.id ?? "")} = /* @pos null null */ flow(${e.settings?.nodes?.map((e, t) => `/* @pos null ${t} */ ${g(e?.value)}`).join(", ") ?? ""});` : ""}
302
302
  ${i.filter((e) => e?.id && !d.has(e.id) && !f.has(e.id)).map((e) => s(e.id)).join("\n")}
303
303
  )();
304
304
  `;
305
305
  }
306
306
  //#endregion
307
307
  //#region src/extraction/getTypeFromValue.ts
308
- var w = (t, n) => {
308
+ var C = (t, n) => {
309
309
  let r = g(t?.value);
310
310
  if (!r) return "any";
311
311
  let i = `
312
- ${x(n, "unknown")}
312
+ ${b(n, "unknown")}
313
313
  const tempValue = ${r ?? "any"};
314
- `, a = "index.ts", o = y(a, i), s = o.getSourceFile(a), c = o.languageService.getProgram().getTypeChecker(), l = "any", u = (t) => {
314
+ `, a = "index.ts", o = v(a, i), s = o.getSourceFile(a), c = o.languageService.getProgram().getTypeChecker(), l = "any", u = (t) => {
315
315
  if (e.isVariableDeclaration(t) && t.name.getText() === "tempValue") {
316
316
  let n = c.getTypeAtLocation(t), r = c.getSymbolsInScope(t, e.SymbolFlags.TypeAlias), i = (n) => {
317
317
  if (n.isUnion()) {
@@ -340,11 +340,11 @@ var w = (t, n) => {
340
340
  e.forEachChild(t, u);
341
341
  };
342
342
  return u(s), l;
343
- }, T = (t, n) => {
343
+ }, w = (t, n) => {
344
344
  let r = `
345
- ${x(n)}
345
+ ${b(n)}
346
346
  type Target = ${t};
347
- `, i = "index.ts", a = y(i, r), o = a.getSourceFile(i), s = a.languageService.getProgram().getTypeChecker(), c = o.statements.find((t) => e.isTypeAliasDeclaration(t) && t.name.text === "Target");
347
+ `, i = "index.ts", a = v(i, r), o = a.getSourceFile(i), s = a.languageService.getProgram().getTypeChecker(), c = o.statements.find((t) => e.isTypeAliasDeclaration(t) && t.name.text === "Target");
348
348
  if (!c) return {
349
349
  __typename: "LiteralValue",
350
350
  value: null
@@ -386,7 +386,7 @@ var w = (t, n) => {
386
386
  __typename: "LiteralValue",
387
387
  value: u(l, c)
388
388
  };
389
- }, E = (e, n, r) => {
389
+ }, T = (e, n, r) => {
390
390
  if (!e?.startingNodeId) return {
391
391
  isValid: !1,
392
392
  returnType: "void",
@@ -409,7 +409,7 @@ var w = (t, n) => {
409
409
  severity: "error"
410
410
  }]
411
411
  };
412
- let i = C(e, n, r), a = "index.ts", o = y(a, i), s = o.getSourceFile(a), c = o.languageService.getProgram().getSemanticDiagnostics(s).map((e) => {
412
+ let i = S(e, n, r), a = "index.ts", o = v(a, i), s = o.getSourceFile(a), c = o.languageService.getProgram().getSemanticDiagnostics(s).map((e) => {
413
413
  let n = t(e.messageText, "\n"), r, i = null;
414
414
  if (e.start !== void 0) {
415
415
  let t = s.getFullText(), n = Math.max(0, e.start - 300), a = Math.min(t.length, e.start), o = t.substring(n, a), c = /\/\* @pos ([^ ]+) (\d+|null) \*\//g, l, u = null, d = -1;
@@ -432,11 +432,11 @@ var w = (t, n) => {
432
432
  returnType: "void",
433
433
  diagnostics: c
434
434
  };
435
- }, D = (t, n, r) => {
435
+ }, E = (t, n, r) => {
436
436
  let i = g(n?.value), a = `
437
- ${x(r)}
437
+ ${b(r)}
438
438
  const testValue: ${t} = ${i};
439
- `, o = "index.ts", s = y(o, a).languageService.getSemanticDiagnostics(o).map((t) => {
439
+ `, o = "index.ts", s = v(o, a).languageService.getSemanticDiagnostics(o).map((t) => {
440
440
  let n = e.flattenDiagnosticMessageText(t.messageText, "\n"), r = 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");
441
441
  return {
442
442
  message: n,
@@ -449,7 +449,7 @@ var w = (t, n) => {
449
449
  returnType: "void",
450
450
  diagnostics: s
451
451
  };
452
- }, O = (e) => e.isUnion() ? e.types.flatMap(O) : e.isStringLiteral() ? [{
452
+ }, D = (e) => e.isUnion() ? e.types.flatMap(D) : e.isStringLiteral() ? [{
453
453
  value: e.value,
454
454
  __typename: "LiteralValue"
455
455
  }] : e.isNumberLiteral() ? [{ value: e.value.toString() }] : e.intrinsicName === "true" ? [{
@@ -458,28 +458,28 @@ var w = (t, n) => {
458
458
  }] : e.intrinsicName === "false" ? [{
459
459
  value: !1,
460
460
  __typename: "LiteralValue"
461
- }] : [], k = (e, t, n, r) => r.flatMap((r) => {
461
+ }] : [], te = (e, t, n, r) => r.flatMap((r) => {
462
462
  let i = r.getName();
463
- if (!A(i)) return [];
463
+ if (!O(i)) return [];
464
464
  let a = r.getDeclarations()?.[0];
465
465
  if (!a || a.getEnd() >= t.getEnd()) return [];
466
466
  let o = e.getTypeOfSymbolAtLocation(r, t);
467
- return i.startsWith("node_") ? j(i, o, e, n) : i.startsWith("p_") ? M(i, o, e, n) : i.startsWith("flow_") ? N(o, e, n) : [];
468
- }), A = (e) => e.startsWith("node_") || e.startsWith("p_") || e.startsWith("flow_"), j = (t, n, r, i) => {
467
+ return i.startsWith("node_") ? k(i, o, e, n) : i.startsWith("p_") ? A(i, o, e, n) : i.startsWith("flow_") ? j(o, e, n) : [];
468
+ }), O = (e) => e.startsWith("node_") || e.startsWith("p_") || e.startsWith("flow_"), k = (t, n, r, i) => {
469
469
  if ((n.flags & e.TypeFlags.Void) !== 0) return [];
470
- let a = P(t.replace("node_", ""));
471
- return I(n, r, i).flatMap(({ path: e }) => {
470
+ let a = M(t.replace("node_", ""));
471
+ return P(n, r, i).flatMap(({ path: e }) => {
472
472
  let t = {
473
473
  __typename: "ReferenceValue",
474
474
  nodeFunctionId: a
475
475
  };
476
476
  return e.length > 0 && (t.referencePath = e), t;
477
477
  });
478
- }, M = (e, t, n, r) => {
479
- let { nodeFunctionId: i, paramIndexFromName: a } = F(e);
478
+ }, A = (e, t, n, r) => {
479
+ let { nodeFunctionId: i, paramIndexFromName: a } = N(e);
480
480
  if (!n.isTupleType(t)) return [];
481
481
  let o = t;
482
- return n.getTypeArguments(o).flatMap((e, t) => I(e, n, r).flatMap(({ path: e }) => {
482
+ return n.getTypeArguments(o).flatMap((e, t) => P(e, n, r).flatMap(({ path: e }) => {
483
483
  let n = {
484
484
  __typename: "ReferenceValue",
485
485
  nodeFunctionId: i,
@@ -489,43 +489,44 @@ var w = (t, n) => {
489
489
  };
490
490
  return e.length > 0 && (n.referencePath = e), n;
491
491
  }));
492
- }, N = (e, t, n) => I(e, t, n).flatMap(({ path: e }) => {
492
+ }, j = (e, t, n) => P(e, t, n).flatMap(({ path: e }) => {
493
493
  let t = {
494
494
  __typename: "ReferenceValue",
495
495
  nodeFunctionId: null
496
496
  };
497
497
  return e.length > 0 && (t.referencePath = e), t;
498
- }), P = (e) => e.replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/"), F = (e) => {
498
+ }), M = (e) => e.replace(/___/g, "://").replace(/__/g, "/").replace(/_/g, "/"), N = (e) => {
499
499
  let t = e.replace("p_", ""), n = t.lastIndexOf("_"), r = t.substring(0, n), i = parseInt(t.substring(n + 1), 10);
500
500
  return {
501
- nodeFunctionId: P(r),
501
+ nodeFunctionId: M(r),
502
502
  paramIndexFromName: i
503
503
  };
504
- }, I = (e, t, n, r = []) => {
504
+ }, P = (e, t, n, r = []) => {
505
505
  let i = [];
506
506
  if (t.isTypeAssignableTo(e, n) && i.push({
507
507
  path: r,
508
508
  type: e
509
- }), L(e)) {
509
+ }), F(e)) {
510
510
  let a = e.getProperties();
511
511
  a && a.length > 0 && a.forEach((e) => {
512
512
  let a = t.getTypeOfSymbolAtLocation(e, e.valueDeclaration), o = e.getName(), s = [...r, { path: o }];
513
- i.push(...I(a, t, n, s));
513
+ i.push(...P(a, t, n, s));
514
514
  });
515
515
  }
516
516
  return i;
517
- }, L = (t) => {
517
+ }, F = (t) => {
518
518
  let n = e.TypeFlags.String | e.TypeFlags.Number | e.TypeFlags.Boolean | e.TypeFlags.Undefined | e.TypeFlags.Null | e.TypeFlags.BigInt | e.TypeFlags.ESSymbol;
519
519
  return (t.flags & n) === 0;
520
- }, R = (e, t, n, r) => Q(r) ? [] : t.flatMap((t) => {
521
- let i = z(e, t, n, r);
520
+ }, I = (e, t, n, r) => Q(r) ? [] : t.flatMap((t) => {
521
+ let i = L(e, t, n, r);
522
522
  return i ? [i] : [];
523
- }), z = (e, t, n, r) => {
524
- let i = e.getSignatureFromDeclaration(t), a = B(e, e.getReturnTypeOfSignature(i));
523
+ }), L = (e, t, n, r) => {
524
+ if (t.parameters.length > 0) return null;
525
+ let i = e.getSignatureFromDeclaration(t), a = R(e, e.getReturnTypeOfSignature(i));
525
526
  if (!e.isTypeAssignableTo(a, r)) return null;
526
- let o = V(t.name?.getText());
527
- return H(n.find((e) => e.identifier === o));
528
- }, B = (e, t) => t.isTypeParameter() ? e.getBaseConstraintOfType(t) || e.getAnyType() : t, V = (e) => e ? e.replace("fn_", "").replace("_", "::").replace("_", "::") : "", H = (e) => {
527
+ let o = z(t.name?.getText());
528
+ return B(n.find((e) => e.identifier === o));
529
+ }, R = (e, t) => t.isTypeParameter() ? e.getBaseConstraintOfType(t) || e.getAnyType() : t, z = (e) => e ? e.replace("fn_", "").replace("_", "::").replace("_", "::") : "", B = (e) => {
529
530
  let t = (e?.parameterDefinitions?.nodes?.length ?? 0) > 0, n = {
530
531
  __typename: "NodeFunction",
531
532
  id: "gid://sagittarius/NodeFunction/1",
@@ -538,11 +539,11 @@ var w = (t, n) => {
538
539
  displayIcon: e?.displayIcon
539
540
  }
540
541
  };
541
- return t && (n.parameters = U(e?.parameterDefinitions?.nodes || [])), n;
542
- }, U = (e) => ({
542
+ return t && (n.parameters = V(e?.parameterDefinitions?.nodes || [])), n;
543
+ }, V = (e) => ({
543
544
  __typename: "NodeParameterConnection",
544
- nodes: e.map((e) => W(e))
545
- }), W = (e) => ({
545
+ nodes: e.map((e) => H(e))
546
+ }), H = (e) => ({
546
547
  __typename: "NodeParameter",
547
548
  parameterDefinition: {
548
549
  __typename: "ParameterDefinition",
@@ -553,70 +554,90 @@ var w = (t, n) => {
553
554
  __typename: "LiteralValue",
554
555
  value: e.defaultValue.value
555
556
  } : null
556
- }), G = (t, n, r, i, a, o = !0) => {
557
- let s = O(r), c = k(t, n, r, t.getSymbolsInScope(n, e.SymbolFlags.Variable)), l = R(t, i, a, r), u = o ? { suggestions: [
558
- ...s,
559
- ...c,
560
- ...l
557
+ }), U = (e, t, n, r) => Q(r) ? t.flatMap((t) => {
558
+ let i = ne(e, t, n, r);
559
+ return i ? [i] : [];
560
+ }) : [], ne = (e, t, n, r) => {
561
+ let i = e.getTypeAtLocation(t);
562
+ if (!e.isTypeAssignableTo(i, r)) return null;
563
+ let a = W(t.name?.getText()), o = n.find((e) => e.identifier === a);
564
+ return o ? G(o) : null;
565
+ }, W = (e) => e ? e.replace("fn_", "").replace("_", "::").replace("_", "::") : "", G = (e) => ({
566
+ __typename: "SubFlowValue",
567
+ functionDefinition: e,
568
+ signature: e.signature,
569
+ settings: e.parameterDefinitions?.nodes?.map((e) => ({
570
+ __typename: "SubFlowValueSetting",
571
+ identifier: e?.identifier,
572
+ defaultValue: e?.defaultValue ?? null,
573
+ hidden: e?.hidden ?? !1,
574
+ optional: e?.optional ?? !1
575
+ }))
576
+ }), K = (t, n, r, i, a, o = !0) => {
577
+ let s = o ? { suggestions: [
578
+ ...D(r),
579
+ ...n ? te(t, n, r, t.getSymbolsInScope(n, e.SymbolFlags.Variable)) : [],
580
+ ...I(t, i, a, r),
581
+ ...U(t, i, a, r)
561
582
  ] } : {};
562
- if (K(r)) return {
583
+ if (q(r)) return {
563
584
  input: "boolean",
564
- ...u
585
+ ...s
565
586
  };
566
- if (q(r)) return {
587
+ if (J(r)) return {
567
588
  input: "number",
568
- ...u
589
+ ...s
569
590
  };
570
- if (J(r)) return {
591
+ if (Y(r)) return {
571
592
  input: "text",
572
- ...u
593
+ ...s
573
594
  };
574
- if (X(r)) return {
595
+ if (Z(r)) return {
575
596
  input: "select",
576
- ...u
597
+ ...s
577
598
  };
578
599
  if (Q(r)) return {
579
600
  input: "sub-flow",
580
- ...u
601
+ ...s
581
602
  };
582
- if (Z(t, r)) return {
603
+ if (re(t, r)) return {
583
604
  input: "list",
584
- items: t.getTypeArguments(r).flatMap((e) => (e.isUnion() ? e.types : [e]).map((e) => G(t, n, e, i, a, o))),
585
- ...u
605
+ items: t.getTypeArguments(r).flatMap((e) => (e.isUnion() ? e.types : [e]).map((e) => K(t, n, e, i, a, o))),
606
+ ...s
586
607
  };
587
608
  if ((r.flags & e.TypeFlags.Object) !== 0) {
588
- let s = {}, c = [];
589
- for (let l of t.getPropertiesOfType(r)) {
590
- let r = l.valueDeclaration ?? l.declarations?.[0];
609
+ let c = {}, l = [];
610
+ for (let s of t.getPropertiesOfType(r)) {
611
+ let r = s.valueDeclaration ?? s.declarations?.[0];
591
612
  if (!r) continue;
592
- let u = t.getTypeOfSymbolAtLocation(l, r), d = (l.flags & e.SymbolFlags.Optional) !== 0 || u.isUnion() && u.types.some((t) => (t.flags & e.TypeFlags.Undefined) !== 0), f = (u.isUnion() ? u.types.filter((t) => (t.flags & e.TypeFlags.Undefined) === 0) : [u]).map((e) => G(t, n, e, i, a, o));
593
- s[l.name] = f.length === 1 ? f[0] : f, d || c.push(l.name);
613
+ let u = t.getTypeOfSymbolAtLocation(s, r), d = (s.flags & e.SymbolFlags.Optional) !== 0 || u.isUnion() && u.types.some((t) => (t.flags & e.TypeFlags.Undefined) !== 0), f = (u.isUnion() ? u.types.filter((t) => (t.flags & e.TypeFlags.Undefined) === 0) : [u]).map((e) => K(t, n, e, i, a, o));
614
+ c[s.name] = f.length === 1 ? f[0] : f, d || l.push(s.name);
594
615
  }
595
616
  return {
596
617
  input: "data",
597
- properties: s,
598
- required: c,
599
- ...u
618
+ properties: c,
619
+ required: l,
620
+ ...s
600
621
  };
601
622
  }
602
623
  return { input: "generic" };
603
624
  };
604
- function K(t) {
625
+ function q(t) {
605
626
  return (t.flags & e.TypeFlags.Boolean) !== 0 || (t.flags & e.TypeFlags.BooleanLiteral) !== 0;
606
627
  }
607
- function q(t) {
628
+ function J(t) {
608
629
  return (t.flags & e.TypeFlags.Number) !== 0 || (t.flags & e.TypeFlags.NumberLiteral) !== 0;
609
630
  }
610
- function J(t) {
631
+ function Y(t) {
611
632
  return (t.flags & e.TypeFlags.String) !== 0 || (t.flags & e.TypeFlags.StringLiteral) !== 0;
612
633
  }
613
- function Y(e) {
614
- return J(e) || q(e) || K(e);
615
- }
616
634
  function X(e) {
617
- return e.isUnion() ? e.types.every(Y) : !1;
635
+ return Y(e) || J(e) || q(e);
636
+ }
637
+ function Z(e) {
638
+ return e.isUnion() ? e.types.every(X) : !1;
618
639
  }
619
- function Z(e, t) {
640
+ function re(e, t) {
620
641
  return e.isArrayType(t) || e.isTupleType(t);
621
642
  }
622
643
  function Q(e) {
@@ -624,24 +645,24 @@ function Q(e) {
624
645
  }
625
646
  //#endregion
626
647
  //#region src/schema/getSignatureSchema.ts
627
- var $ = (e, t, n, r) => {
628
- let i = C(e, n, t), a = "index.ts", o = y(a, i), s = o.getSourceFile(a), c = o.languageService.getProgram().getTypeChecker(), l = e.nodes?.nodes?.find((e) => e?.id === r), u = r ? `fn_${l?.functionDefinition?.identifier?.replace(/::/g, "_")}` : "flow", d = r ? `node_${S(r)}` : `flow_${S(e.id)}`, f = ee(s), p = te(s).get(d), m = f.get(u);
629
- return ae(r, c, p, ne(c, p), re(c, m, p), ie(m), r ? f : /* @__PURE__ */ new Map(), r ? n : []);
630
- }, ee = (t) => new Map(t.statements.filter(e.isFunctionDeclaration).map((e) => [e.name.getText(), e])), te = (t) => {
648
+ var ie = (e, t, n, r) => {
649
+ let i = S(e, n, t), a = "index.ts", o = v(a, i), s = o.getSourceFile(a), c = o.languageService.getProgram().getTypeChecker(), l = e.nodes?.nodes?.find((e) => e?.id === r), u = r ? `fn_${l?.functionDefinition?.identifier?.replace(/::/g, "_")}` : "flow", d = r ? `node_${x(r)}` : `flow_${x(e.id)}`, f = ae(s), p = oe(s).get(d), m = f.get(u);
650
+ return $(r, c, p, se(c, p), ce(c, m, p), le(m), r ? f : /* @__PURE__ */ new Map(), r ? n : []);
651
+ }, ae = (t) => new Map(t.statements.filter(e.isFunctionDeclaration).map((e) => [e.name.getText(), e])), oe = (t) => {
631
652
  let n = [];
632
653
  return t.statements.forEach((t) => {
633
654
  t.forEachChild(function t(r) {
634
655
  e.isVariableDeclaration(r) && (r.parent.flags & e.NodeFlags.Const) !== 0 && n.push([r.name.getText(), r]), r.forEachChild(t);
635
656
  });
636
657
  }), new Map(n);
637
- }, ne = (t, n) => {
658
+ }, se = (t, n) => {
638
659
  if (!(!n?.initializer || !e.isCallExpression(n.initializer))) return t.getResolvedSignature(n.initializer)?.parameters.map((e) => t.getTypeOfSymbolAtLocation(e, n.initializer));
639
- }, re = (e, t, n) => {
660
+ }, ce = (e, t, n) => {
640
661
  if (!(!t || !n?.initializer)) return t.parameters.map((t) => {
641
662
  let r = e.getSymbolAtLocation(t.name);
642
663
  return e.getTypeOfSymbolAtLocation(r, n.initializer);
643
664
  });
644
- }, ie = (e) => {
665
+ }, le = (e) => {
645
666
  let t = e.typeParameters?.map((e) => e.name.getText()) || [], n = {};
646
667
  return e.parameters.forEach((e, r) => {
647
668
  let i = e.type?.getText() || "";
@@ -652,11 +673,18 @@ var $ = (e, t, n, r) => {
652
673
  parameterIndex: t,
653
674
  dependsOnIndex: e
654
675
  }))).flat();
655
- }, ae = (e, t, n, r, i, a, o, s) => r ? r.map((r, c) => ({
676
+ }, $ = (e, t, n, r, i, a, o, s) => r ? r.map((r, c) => ({
656
677
  nodeId: e,
657
- schema: G(t, n, r, Array.from(o.values()), s),
658
- functionSchema: G(t, n, i?.[c], Array.from(o.values()), s, !1),
678
+ schema: K(t, n, r, Array.from(o.values()), s),
679
+ functionSchema: K(t, n, i?.[c], Array.from(o.values()), s, !1),
659
680
  blockedBy: a.filter((e) => e.parameterIndex === c).map((e) => e.dependsOnIndex)
660
- })) : [];
681
+ })) : [], ue = (t, n = []) => {
682
+ let r = "index.ts", i = v(r, `${b(n)}\ntype MyType = ${t}`).languageService.getProgram(), a = i?.getSourceFile(r), o = i?.getTypeChecker();
683
+ if (!a || !o) return;
684
+ let s = a.statements.filter((t) => e.isTypeAliasDeclaration(t) || e.isInterfaceDeclaration(t) || e.isClassDeclaration(t)).pop();
685
+ if (!s) return;
686
+ let c = o.getTypeAtLocation(s);
687
+ if (c) return K(o, void 0, c, [], [], !1);
688
+ };
661
689
  //#endregion
662
- export { E as getFlowValidation, $ as getSignatureSchema, w as getTypeFromValue, T as getValueFromType, D as getValueValidation };
690
+ export { T as getFlowValidation, ie as getSignatureSchema, C as getTypeFromValue, ue as getTypeSchema, w as getValueFromType, E as getValueValidation };
@@ -1,5 +1,5 @@
1
1
  import { default as ts, FunctionDeclaration } from 'typescript';
2
- import { FunctionDefinition, LiteralValue, NodeFunction, ReferenceValue } from '@code0-tech/sagittarius-graphql-types';
2
+ import { FunctionDefinition, LiteralValue, NodeFunction, ReferenceValue, SubFlowValue } from '@code0-tech/sagittarius-graphql-types';
3
3
  /**
4
4
  * Base interface for all input types.
5
5
  * Provides common properties for suggestions and input metadata.
@@ -8,7 +8,7 @@ export interface Input {
8
8
  /** The type of input (string representation) */
9
9
  input?: string;
10
10
  /** Array of suggested values (functions, references, or literals) */
11
- suggestions?: (NodeFunction | ReferenceValue | LiteralValue)[];
11
+ suggestions?: (NodeFunction | ReferenceValue | LiteralValue | SubFlowValue)[];
12
12
  }
13
13
  /**
14
14
  * Represents a generic input type with no specific structure.
@@ -91,7 +91,7 @@ export type Schema = PrimitiveInput | DataInput | ListInput | TypeInput | SubFlo
91
91
  * @param suggestions
92
92
  * @returns A Schema object describing how to handle the parameter type
93
93
  */
94
- export declare const getSchema: (checker: ts.TypeChecker, node: ts.VariableDeclaration, parameterType: ts.Type, functionDeclarations: FunctionDeclaration[], functions: FunctionDefinition[], suggestions?: boolean) => Schema;
94
+ export declare const getSchema: (checker: ts.TypeChecker, node: ts.VariableDeclaration | undefined, parameterType: ts.Type, functionDeclarations: FunctionDeclaration[], functions: FunctionDefinition[], suggestions?: boolean) => Schema;
95
95
  /**
96
96
  * Checks if a type is a callable type (has call signatures).
97
97
  *
@@ -0,0 +1,19 @@
1
+ import { default as ts } from 'typescript';
2
+ import { FunctionDefinition, SubFlowValue } from '@code0-tech/sagittarius-graphql-types';
3
+ /**
4
+ * Extracts and creates a list of SubFlowValue objects from function declarations
5
+ * that are compatible with the given parameter type.
6
+ *
7
+ * This function filters function declarations based on type compatibility and
8
+ * converts matching functions into SubFlowValue objects that can be used as
9
+ * sub-flows in a larger workflow.
10
+ *
11
+ * @param {ts.TypeChecker} checker - The TypeScript type checker for type analysis
12
+ * @param {ts.FunctionDeclaration[]} functionDeclarations - Array of function declarations to analyze
13
+ * @param {FunctionDefinition[]} functions - Array of function definitions for reference lookup
14
+ * @param {ts.Type} paramType - The target parameter type that functions must be compatible with
15
+ *
16
+ * @returns {SubFlowValue[]} An array of SubFlowValue objects for compatible functions,
17
+ * or an empty array if the paramType is not a sub-flow type
18
+ */
19
+ export declare const getSubFlows: (checker: ts.TypeChecker, functionDeclarations: ts.FunctionDeclaration[], functions: FunctionDefinition[], paramType: ts.Type) => SubFlowValue[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/triangulum",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/code0-tech/triangulum#readme",
6
6
  "bugs": {
@@ -23,7 +23,7 @@
23
23
  "build": "vite build"
24
24
  },
25
25
  "devDependencies": {
26
- "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9",
26
+ "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44",
27
27
  "@types/node": "^25.6.0",
28
28
  "@typescript/vfs": "^1.6.4",
29
29
  "typescript": "^6.0.3",
@@ -33,7 +33,7 @@
33
33
  "lossless-json": "^4.3.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2531971636-6b64e2c0adb50c5e7b78390e5fcd72c807e694b9",
36
+ "@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2554302654-2b34b39821c688ebf0e1067f2aee8b42274e2a44",
37
37
  "@typescript/vfs": "^1.6.4",
38
38
  "typescript": "^5.9.3 || ^6.0.2",
39
39
  "lossless-json": "^4.3.0"