@code0-tech/triangulum 0.1.0 → 0.3.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 +9 -0
- package/dist/{src/extraction → extraction}/getTypeFromValue.d.ts +1 -1
- package/dist/extraction/getTypeVariant.d.ts +12 -0
- package/dist/extraction/getTypesFromNode.d.ts +9 -0
- package/dist/extraction/getValueFromType.d.ts +5 -0
- package/dist/index.d.ts +10 -2
- package/dist/suggestion/getNodeSuggestions.d.ts +6 -0
- package/dist/suggestion/getReferenceSuggestions.d.ts +6 -0
- package/dist/suggestion/getValueSuggestions.d.ts +5 -0
- package/dist/triangulum.cjs.js +53 -50
- package/dist/triangulum.es.js +675 -464
- package/dist/{src/utils.d.ts → utils.d.ts} +10 -15
- package/dist/validation/getFlowValidation.d.ts +6 -0
- package/dist/validation/getNodeValidation.d.ts +6 -0
- package/dist/validation/getValueValidation.d.ts +3 -0
- package/package.json +10 -6
- package/dist/src/extraction/getTypeVariant.d.ts +0 -11
- package/dist/src/extraction/getTypesFromNode.d.ts +0 -10
- package/dist/src/extraction/getValueFromType.d.ts +0 -6
- package/dist/src/index.d.ts +0 -10
- package/dist/src/suggestion/getNodeSuggestions.d.ts +0 -7
- package/dist/src/suggestion/getReferenceSuggestions.d.ts +0 -7
- package/dist/src/suggestion/getValueSuggestions.d.ts +0 -5
- package/dist/src/validation/getFlowValidation.d.ts +0 -6
- package/dist/src/validation/getNodeValidation.d.ts +0 -6
- package/dist/src/validation/getValueValidation.d.ts +0 -10
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { DataType, Flow,
|
|
1
|
+
import { DataType, Flow, NodeFunction, NodeParameter, ReferencePath, ReferenceValue } from '@code0-tech/sagittarius-graphql-types';
|
|
2
2
|
import { default as ts } from 'typescript';
|
|
3
|
+
import { VirtualTypeScriptEnvironment } from '@typescript/vfs';
|
|
3
4
|
/**
|
|
4
5
|
* Result of a node or flow validation.
|
|
5
6
|
*/
|
|
6
7
|
export interface ValidationResult {
|
|
7
8
|
isValid: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
returnType: string;
|
|
10
|
+
diagnostics: Array<{
|
|
10
11
|
message: string;
|
|
11
12
|
code: number;
|
|
12
13
|
severity: "error" | "warning";
|
|
14
|
+
nodeId?: NodeFunction["id"];
|
|
15
|
+
parameterIndex?: number;
|
|
13
16
|
}>;
|
|
14
17
|
}
|
|
15
|
-
export interface ExtendedDataType extends DataType {
|
|
16
|
-
type: string;
|
|
17
|
-
linkedDataTypeIdentifiers?: string[];
|
|
18
|
-
}
|
|
19
|
-
export interface ExtendedFunction extends Omit<FunctionDefinition, 'returnType'> {
|
|
20
|
-
signature: string;
|
|
21
|
-
linkedDataTypeIdentifiers?: string[];
|
|
22
|
-
}
|
|
23
18
|
/**
|
|
24
19
|
* Minimal TypeScript library definitions for the virtual compiler environment.
|
|
25
20
|
*/
|
|
@@ -27,7 +22,7 @@ export declare const MINIMAL_LIB = "\n interface Array<T> { \n [n: num
|
|
|
27
22
|
/**
|
|
28
23
|
* Common configuration for the TypeScript compiler host across different validation/inference tasks.
|
|
29
24
|
*/
|
|
30
|
-
export declare function createCompilerHost(fileName: string, sourceCode: string
|
|
25
|
+
export declare function createCompilerHost(fileName: string, sourceCode: string): VirtualTypeScriptEnvironment;
|
|
31
26
|
/**
|
|
32
27
|
* Common TypeScript compiler options used for validation and type inference.
|
|
33
28
|
*/
|
|
@@ -35,7 +30,7 @@ export declare const DEFAULT_COMPILER_OPTIONS: ts.CompilerOptions;
|
|
|
35
30
|
/**
|
|
36
31
|
* Extracts and returns common type and generic declarations from DATA_TYPES.
|
|
37
32
|
*/
|
|
38
|
-
export declare function getSharedTypeDeclarations(dataTypes
|
|
33
|
+
export declare function getSharedTypeDeclarations(dataTypes?: DataType[]): string;
|
|
39
34
|
/**
|
|
40
35
|
* Determines the type along a reference path for objects.
|
|
41
36
|
* @param value The base value to traverse.
|
|
@@ -46,11 +41,11 @@ export declare function getTypeFromReferencePath(value: any, referencePath: Refe
|
|
|
46
41
|
/**
|
|
47
42
|
* Extracts and returns the TypeScript code representation for a NodeParameter.
|
|
48
43
|
*/
|
|
49
|
-
export declare function getParameterCode(param
|
|
44
|
+
export declare function getParameterCode(param?: NodeParameter, flow?: Flow, getNodeValidation?: (flow?: Flow, node?: NodeFunction) => ValidationResult): string;
|
|
50
45
|
/**
|
|
51
46
|
* Validates if a reference is accessible from the current node's scope.
|
|
52
47
|
*/
|
|
53
|
-
export declare const validateReference: (flow
|
|
48
|
+
export declare const validateReference: (flow?: Flow, currentNode?: NodeFunction, ref?: ReferenceValue) => {
|
|
54
49
|
isValid: boolean;
|
|
55
50
|
error?: string;
|
|
56
51
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DataType, Flow, FunctionDefinition } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
+
import { ValidationResult } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Validates a flow by generating virtual TypeScript code and running it through the TS compiler.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getFlowValidation: (flow?: Flow, functions?: FunctionDefinition[], dataTypes?: DataType[]) => ValidationResult;
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code0-tech/triangulum",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "https://github.com/code0-tech/triangulum#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -29,14 +29,18 @@
|
|
|
29
29
|
"test": "vitest run",
|
|
30
30
|
"build": "vite build"
|
|
31
31
|
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"typescript": "^5.9.3"
|
|
34
|
-
},
|
|
35
32
|
"devDependencies": {
|
|
36
|
-
"@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-
|
|
33
|
+
"@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2385560645-52d09772ef7058a833cf32edc393ce95668b8404",
|
|
37
34
|
"@types/node": "^25.3.2",
|
|
35
|
+
"typescript": "^5.9.3",
|
|
38
36
|
"vite": "^7.3.1",
|
|
39
37
|
"vite-plugin-dts": "^4.5.4",
|
|
40
|
-
"vitest": "^4.0.18"
|
|
38
|
+
"vitest": "^4.0.18",
|
|
39
|
+
"@typescript/vfs": "^1.6.4"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@code0-tech/sagittarius-graphql-types": "0.0.0-experimental-2385560645-52d09772ef7058a833cf32edc393ce95668b8404",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"@typescript/vfs": "^1.6.4"
|
|
41
45
|
}
|
|
42
46
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ExtendedDataType } from '../utils';
|
|
2
|
-
export declare enum DataTypeVariant {
|
|
3
|
-
PRIMITIVE = 0,
|
|
4
|
-
TYPE = 1,
|
|
5
|
-
ARRAY = 2,
|
|
6
|
-
OBJECT = 3
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Determines the variant of a given TypeScript type string using the TS compiler.
|
|
10
|
-
*/
|
|
11
|
-
export declare const getTypeVariant: (type: string, dataTypes: ExtendedDataType[]) => DataTypeVariant;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NodeFunction } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { ExtendedDataType, ExtendedFunction } from '../utils';
|
|
3
|
-
export interface NodeTypes {
|
|
4
|
-
parameters: string[];
|
|
5
|
-
returnType: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Resolves the types of the parameters and the return type of a NodeFunction.
|
|
9
|
-
*/
|
|
10
|
-
export declare const getTypesFromNode: (node: NodeFunction, functions: ExtendedFunction[], dataTypes: ExtendedDataType[]) => NodeTypes;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LiteralValue } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { ExtendedDataType } from '../utils';
|
|
3
|
-
/**
|
|
4
|
-
* Generates a sample LiteralValue from a TypeScript type string.
|
|
5
|
-
*/
|
|
6
|
-
export declare const getValueFromType: (type: string, dataTypes: ExtendedDataType[]) => LiteralValue;
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './validation/getFlowValidation';
|
|
2
|
-
export * from './suggestion/getNodeSuggestions';
|
|
3
|
-
export * from './validation/getNodeValidation';
|
|
4
|
-
export * from './suggestion/getReferenceSuggestions';
|
|
5
|
-
export * from './extraction/getTypeFromValue';
|
|
6
|
-
export * from './extraction/getTypeVariant';
|
|
7
|
-
export * from './extraction/getValueFromType';
|
|
8
|
-
export * from './suggestion/getValueSuggestions';
|
|
9
|
-
export * from './validation/getValueValidation';
|
|
10
|
-
export * from './extraction/getTypesFromNode';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NodeFunction } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { ExtendedFunction } from '../utils';
|
|
3
|
-
/**
|
|
4
|
-
* Suggests NodeFunctions based on a given type and a list of available FunctionDefinitions.
|
|
5
|
-
* Returns functions whose return type is compatible with the target type.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getNodeSuggestions(type: string, functions: ExtendedFunction[]): NodeFunction[];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Flow, NodeFunction, ReferenceValue } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { ExtendedDataType, ExtendedFunction } from '../utils';
|
|
3
|
-
/**
|
|
4
|
-
* Calculates all available reference suggestions for a specific target node in a flow
|
|
5
|
-
* and filters them by a required type.
|
|
6
|
-
*/
|
|
7
|
-
export declare const getReferenceSuggestions: (flow: Flow, nodeId: NodeFunction["id"], type: string, functions: ExtendedFunction[], dataTypes: ExtendedDataType[]) => ReferenceValue[];
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Flow } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { ExtendedDataType, ExtendedFunction, ValidationResult } from '../utils';
|
|
3
|
-
/**
|
|
4
|
-
* Validates a flow by generating virtual TypeScript code and running it through the TS compiler.
|
|
5
|
-
*/
|
|
6
|
-
export declare const getFlowValidation: (flow: Flow, functions: ExtendedFunction[], dataTypes: ExtendedDataType[]) => ValidationResult;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { Flow, NodeFunction } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { ExtendedDataType, ExtendedFunction, 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: ExtendedFunction[], dataTypes: ExtendedDataType[]) => ValidationResult;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LiteralValue } from '@code0-tech/sagittarius-graphql-types';
|
|
2
|
-
import { ExtendedDataType } from '../utils';
|
|
3
|
-
/**
|
|
4
|
-
* Validates whether a literal value conforms to a specific TypeScript type string.
|
|
5
|
-
*/
|
|
6
|
-
export interface ValueValidationResult {
|
|
7
|
-
isValid: boolean;
|
|
8
|
-
error?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const getValueValidation: (type: string, value: LiteralValue, dataTypes: ExtendedDataType[]) => ValueValidationResult;
|