@code0-tech/triangulum 0.2.0 → 0.4.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/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { DataType, Flow, NodeFunction, NodeParameter, ReferencePath, ReferenceValue } from '@code0-tech/sagittarius-graphql-types';
1
+ import { DataType, Flow, FunctionDefinition, NodeFunction, ReferencePath } from '@code0-tech/sagittarius-graphql-types';
2
2
  import { default as ts } from 'typescript';
3
3
  import { VirtualTypeScriptEnvironment } from '@typescript/vfs';
4
4
  /**
@@ -18,7 +18,7 @@ export interface ValidationResult {
18
18
  /**
19
19
  * Minimal TypeScript library definitions for the virtual compiler environment.
20
20
  */
21
- export declare const MINIMAL_LIB = "\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 type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;\n";
21
+ export declare const MINIMAL_LIB = "\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 type Record<K extends keyof any, T> = { [P in K]: T; };\n type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;\n";
22
22
  /**
23
23
  * Common configuration for the TypeScript compiler host across different validation/inference tasks.
24
24
  */
@@ -30,7 +30,7 @@ export declare const DEFAULT_COMPILER_OPTIONS: ts.CompilerOptions;
30
30
  /**
31
31
  * Extracts and returns common type and generic declarations from DATA_TYPES.
32
32
  */
33
- export declare function getSharedTypeDeclarations(dataTypes: DataType[]): string;
33
+ export declare function getSharedTypeDeclarations(dataTypes?: DataType[]): string;
34
34
  /**
35
35
  * Determines the type along a reference path for objects.
36
36
  * @param value The base value to traverse.
@@ -39,13 +39,18 @@ export declare function getSharedTypeDeclarations(dataTypes: DataType[]): string
39
39
  */
40
40
  export declare function getTypeFromReferencePath(value: any, referencePath: ReferencePath[]): string;
41
41
  /**
42
- * Extracts and returns the TypeScript code representation for a NodeParameter.
42
+ * Sanitizes an ID for use as a TypeScript variable name.
43
43
  */
44
- export declare function getParameterCode(param: NodeParameter, flow: Flow, getNodeValidation: (flow: Flow, node: NodeFunction) => ValidationResult): string;
44
+ export declare const sanitizeId: (id: string) => string;
45
45
  /**
46
- * Validates if a reference is accessible from the current node's scope.
46
+ * Generates TypeScript source code for a flow, suitable for validation and type inference.
47
47
  */
48
- export declare const validateReference: (flow: Flow, currentNode: NodeFunction, ref: ReferenceValue) => {
49
- isValid: boolean;
50
- error?: string;
51
- };
48
+ export declare function generateFlowSourceCode(flow?: Flow, functions?: FunctionDefinition[], dataTypes?: DataType[], isForInference?: boolean): string;
49
+ export interface InferredTypes {
50
+ nodes: Map<string, string>;
51
+ parameters: Map<string, string[]>;
52
+ }
53
+ /**
54
+ * Infers types for all nodes and parameters in a flow using the TypeScript compiler.
55
+ */
56
+ export declare function getInferredTypesFromFlow(flow?: Flow, functions?: FunctionDefinition[], dataTypes?: DataType[]): InferredTypes;
@@ -3,4 +3,4 @@ import { ValidationResult } from '../utils';
3
3
  /**
4
4
  * Validates a flow by generating virtual TypeScript code and running it through the TS compiler.
5
5
  */
6
- export declare const getFlowValidation: (flow: Flow, functions: FunctionDefinition[], dataTypes: DataType[]) => ValidationResult;
6
+ export declare const getFlowValidation: (flow?: Flow, functions?: FunctionDefinition[], dataTypes?: DataType[]) => ValidationResult;
@@ -1,3 +1,3 @@
1
1
  import { DataType, LiteralValue } from '@code0-tech/sagittarius-graphql-types';
2
2
  import { ValidationResult } from '../utils';
3
- export declare const getValueValidation: (type: string, value: LiteralValue, dataTypes: DataType[]) => ValidationResult;
3
+ export declare const getValueValidation: (type?: string, value?: LiteralValue, dataTypes?: DataType[]) => ValidationResult;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code0-tech/triangulum",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/code0-tech/triangulum#readme",
6
6
  "bugs": {
@@ -1,6 +0,0 @@
1
- import { DataType, Flow, FunctionDefinition, NodeFunction } from '@code0-tech/sagittarius-graphql-types';
2
- import { ValidationResult } from '../utils';
3
- /**
4
- * Validates a single node's parameters and scope, then infers its return type.
5
- */
6
- export declare const getNodeValidation: (flow: Flow, node: NodeFunction, functions: FunctionDefinition[], dataTypes: DataType[]) => ValidationResult;