Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@ariakit/react": "^0.4.17",
"@babel/plugin-proposal-decorators": "^7.28.0",
"@babel/plugin-transform-class-properties": "^7.27.1",
"@code0-tech/sagittarius-graphql-types": "^0.0.0-a395eea54741fc1bb9649341ff6f082cc1c3e67e",
"@code0-tech/sagittarius-graphql-types": "^0.0.0-a2b1f5e9adf8f52b5a0f235ca9906ac5a699b4fc",
"@dagrejs/dagre": "^2.0.0",
"@mdx-js/react": "^3.1.1",
"@radix-ui/react-checkbox": "^1.3.3",
Expand Down Expand Up @@ -94,7 +94,7 @@
"types": "dist/index.d.ts",
"peerDependencies": {
"@ariakit/react": "^0.4.5",
"@code0-tech/sagittarius-graphql-types": "^0.0.0-a395eea54741fc1bb9649341ff6f082cc1c3e67e",
"@code0-tech/sagittarius-graphql-types": "^0.0.0-a2b1f5e9adf8f52b5a0f235ca9906ac5a699b4fc",
"@radix-ui/react-checkbox": "^1.3.2",
"@radix-ui/react-dialog": "^1.1.14",
"@radix-ui/react-dropdown-menu": "^2.1.15",
Expand Down
22 changes: 13 additions & 9 deletions src/components/breadcrumb/Breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ export const Breadcrumb: React.FC<BreadcrumbProps> = props => {

const {splitter = <IconChevronRight size={16}/>, children, ...rest} = props

return <div {...mergeCode0Props(`breadcrumb`, rest)}>
{
React.Children.map(children, (child, index) => {
return <>
const count = React.Children.count(children)

return (
<div {...mergeCode0Props(`breadcrumb`, rest)}>
{React.Children.map(children, (child, index) => (
<React.Fragment key={index}>
{child}
{index <= (React.Children.count(child)) ? <span className={"breadcrumb__splitter"}>{splitter}</span> : null}
</>
})
}
</div>
{index < count - 1 ? (
<span className="breadcrumb__splitter">{splitter}</span>
) : null}
</React.Fragment>
))}
</div>
)
}
17 changes: 13 additions & 4 deletions src/components/d-flow-data-type/DFlowDataType.view.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type {
DataType,
import {
DataType, DataTypeIdentifier, DataTypeIdentifierConnection,
DataTypeRuleConnection,
DataTypeVariant, Maybe, Runtime, Scalars, Translation,
} from "@code0-tech/sagittarius-graphql-types";
import {attachDataTypeIdentifiers, resolveDataTypeIdentifiers} from "../d-flow/DFlow.util";


export class DataTypeView {
Expand All @@ -11,6 +12,8 @@ export class DataTypeView {
private readonly _aliases?: Maybe<Array<Translation>>;
/** Time when this DataType was created */
private readonly _createdAt?: Maybe<Scalars['Time']['output']>;
/** The data type identifiers that are referenced in this data type and its rules */
private readonly _dataTypeIdentifiers?: Maybe<DataTypeIdentifierConnection>;
/** Display message of the function */
private readonly _displayMessages?: Maybe<Array<Translation>>;
/** Generic keys of the datatype */
Expand All @@ -33,13 +36,14 @@ export class DataTypeView {
constructor(dataType: DataType) {
this._aliases = dataType.aliases;
this._createdAt = dataType.createdAt;
this._dataTypeIdentifiers = dataType.dataTypeIdentifiers;
this._displayMessages = dataType.displayMessages;
this._genericKeys = dataType.genericKeys;
this._id = dataType.id;
this._identifier = dataType.identifier;
this._name = dataType.name;
this._runtime = dataType.runtime;
this._rules = dataType.rules;
this._rules = attachDataTypeIdentifiers(resolveDataTypeIdentifiers((this._dataTypeIdentifiers?.nodes ?? []) as DataTypeIdentifier[]), dataType.rules);
this._updatedAt = dataType.updatedAt;
this._variant = dataType.variant;
}
Expand All @@ -52,6 +56,10 @@ export class DataTypeView {
return this._createdAt;
}

get dataTypeIdentifiers(): Maybe<DataTypeIdentifierConnection> | undefined {
return this._dataTypeIdentifiers;
}

get displayMessages(): Maybe<Array<Translation>> | undefined {
return this._displayMessages;
}
Expand Down Expand Up @@ -98,7 +106,8 @@ export class DataTypeView {
runtime: this._runtime,
variant: this._variant,
genericKeys: this._genericKeys,
rules: this._rules
rules: this._rules,
dataTypeIdentifiers: this._dataTypeIdentifiers
}
}
}
24 changes: 18 additions & 6 deletions src/components/d-flow-function/DFlowFunction.view.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import {
DataTypeIdentifier,
DataTypeIdentifier, DataTypeIdentifierConnection,
FunctionDefinition,
Maybe, ParameterDefinition,
RuntimeFunctionDefinition,
Scalars, Translation,
} from "@code0-tech/sagittarius-graphql-types";
import {attachDataTypeIdentifiers, resolveDataTypeIdentifiers} from "../d-flow/DFlow.util";

export class FunctionDefinitionView {

/** Name of the function */
private readonly _aliases?: Maybe<Array<Translation>>;
/** Time when this FunctionDefinition was created */
private readonly _createdAt?: Maybe<Scalars['Time']['output']>;
/** All data type identifiers used within this Node Function */
private readonly _dataTypeIdentifiers?: Maybe<DataTypeIdentifierConnection>;
/** Deprecation message of the function */
private readonly _deprecationMessages?: Maybe<Array<Translation>>;
/** Description of the function */
Expand Down Expand Up @@ -40,8 +43,12 @@ export class FunctionDefinitionView {
private readonly _updatedAt?: Maybe<Scalars['Time']['output']>;

constructor(object: FunctionDefinition) {

const dataTypeIdentifiers = resolveDataTypeIdentifiers((object.dataTypeIdentifiers?.nodes ?? []) as DataTypeIdentifier[])

this._aliases = object.aliases;
this._createdAt = object.createdAt;
this._dataTypeIdentifiers = object.dataTypeIdentifiers;
this._deprecationMessages = object.deprecationMessages;
this._descriptions = object.descriptions;
this._displayMessages = object.displayMessages;
Expand All @@ -50,8 +57,8 @@ export class FunctionDefinitionView {
this._id = object.id;
this._identifier = object.identifier;
this._names = object.names;
this._parameterDefinitions = object.parameterDefinitions?.nodes?.map(definition => new ParameterDefinitionView(definition!!)) ?? undefined;
this._returnType = object.returnType;
this._parameterDefinitions = object.parameterDefinitions?.nodes?.map(definition => new ParameterDefinitionView(definition!!, dataTypeIdentifiers)) ?? undefined;
this._returnType = attachDataTypeIdentifiers(dataTypeIdentifiers, object.returnType);
this._runtimeFunctionDefinition = object.runtimeFunctionDefinition;
this._throwsError = object.throwsError;
this._updatedAt = object.updatedAt;
Expand All @@ -66,6 +73,10 @@ export class FunctionDefinitionView {
return this._createdAt;
}

get dataTypeIdentifiers(): Maybe<DataTypeIdentifierConnection> | undefined {
return this._dataTypeIdentifiers;
}

get deprecationMessages(): Maybe<Array<Translation>> | undefined {
return this._deprecationMessages;
}
Expand Down Expand Up @@ -136,7 +147,8 @@ export class FunctionDefinitionView {
returnType: this._returnType,
runtimeFunctionDefinition: this._runtimeFunctionDefinition,
throwsError: this._throwsError,
updatedAt: this._updatedAt
updatedAt: this._updatedAt,
dataTypeIdentifiers: this._dataTypeIdentifiers
}
}
}
Expand All @@ -160,9 +172,9 @@ export class ParameterDefinitionView {
/** Time when this ParameterDefinition was last updated */
private readonly _updatedAt?: Maybe<Scalars['Time']['output']>;

constructor(object: ParameterDefinition) {
constructor(object: ParameterDefinition, dataTypeIdentifiers: DataTypeIdentifier[]) {
this._createdAt = object.createdAt;
this._dataTypeIdentifier = object.dataTypeIdentifier;
this._dataTypeIdentifier = attachDataTypeIdentifiers(dataTypeIdentifiers, object.dataTypeIdentifier);
this._descriptions = object.descriptions;
this._documentations = object.documentations;
this._id = object.id;
Expand Down
32 changes: 18 additions & 14 deletions src/components/d-flow-input/DFlowInputDataType.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import React from "react";
import {ValidationProps} from "../form";
import {
InputLabel,
InputMessage,
InputSuggestion,
InputSuggestionMenuContent,
InputSuggestionMenuContentItems,
TextInput,
ValidationProps
} from "../form";
import type {
DataType,
DataTypeIdentifier,
Expand All @@ -9,29 +17,19 @@ import type {
DataTypeRulesNumberRangeConfig,
DataTypeRulesParentTypeConfig,
DataTypeRulesVariant,
Flow,
GenericMapper,
GenericType
} from "@code0-tech/sagittarius-graphql-types";
import {InputMessage} from "../form";
import "./DFlowInputDataType.style.scss";
import {TextInput} from "../form";
import {Button} from "../button/Button";
import {IconSettings, IconTrash} from "@tabler/icons-react";
import {Text} from "../text/Text";
import {Flex} from "../flex/Flex";
import {Badge} from "../badge/Badge";
import {InputLabel} from "../form";
import {useDataTypeSuggestions} from "../d-flow-suggestion/DFlowDataTypeSuggestions.hook";
import {DFlowSuggestionMenuFooter} from "../d-flow-suggestion/DFlowSuggestionMenuFooter";
import {toInputSuggestions} from "../d-flow-suggestion/DFlowSuggestionMenu.util";
import {DFlowSuggestionType} from "../d-flow-suggestion";
import {Menu, MenuPortal, MenuTrigger} from "../menu/Menu";
import {
InputSuggestion,
InputSuggestionMenuContent,
InputSuggestionMenuContentItems
} from "../form";

const NON_TYPE_RULE_VARIANTS = new Set<DataTypeRulesVariant>([
"ITEM_OF_COLLECTION" as DataTypeRulesVariant.ItemOfCollection,
Expand Down Expand Up @@ -237,10 +235,16 @@ export const DFlowInputDataType: React.FC<DFlowInputDataTypeProps> = (props) =>
<InputSuggestionMenuContent>
<InputSuggestionMenuContentItems onSuggestionSelect={(suggestion) => {
updateValue(nextValue => {
if (!nextValue) return

if ("rules" in nextValue) {
nextValue?.rules?.nodes?.push(suggestion.value)
} else if ("dataType" in (nextValue as DataTypeIdentifier)?.genericType!!) {
(nextValue as DataTypeIdentifier)?.genericType?.dataType?.rules?.nodes?.push(suggestion.value)
nextValue.rules?.nodes?.push(suggestion.value)
return
}

// GenericType branch
if ("dataType" in nextValue) {
nextValue.dataType?.rules?.nodes?.push(suggestion.value)
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const useRefObjects = (flowId: Flow['id']): Array<ExtendedReferenceValue> => {
const nodeContext = nodeContexts?.find(context => context.nodeFunctionId === node?.id)

if (resolvedReturnType && nodeContext) {
return referenceExtraction(nodeContext, resolvedReturnType)
return referenceExtraction(nodeContext, resolvedReturnType, dataTypeService)
}

return {} as ReferenceValue
Expand Down Expand Up @@ -196,7 +196,7 @@ const useRefObjects = (flowId: Flow['id']): Array<ExtendedReferenceValue> => {
parameterIndex: index,
inputTypeIndex: inputIndex,
inputTypeIdentifier: inputType.inputIdentifier!
}, resolved)
}, resolved, dataTypeService)
})
})
})
Expand All @@ -210,13 +210,14 @@ const useRefObjects = (flowId: Flow['id']): Array<ExtendedReferenceValue> => {
].flat()
}

const referenceExtraction = (nodeContext: ExtendedReferenceValue, dataTypeIdentifier: DataTypeIdentifier): ReferenceValue[] => {
const referenceExtraction = (nodeContext: ExtendedReferenceValue, dataTypeIdentifier: DataTypeIdentifier, dataTypeService?: DFlowDataTypeReactiveService): ReferenceValue[] => {

const dataType: Maybe<DataType> | undefined = dataTypeIdentifier.dataType ?? dataTypeIdentifier.genericType?.dataType
const dataType: Maybe<DataType> | undefined = dataTypeService ? dataTypeService.getDataType(dataTypeIdentifier) : dataTypeIdentifier.dataType ?? dataTypeIdentifier.genericType?.dataType
if (!dataType) return []

const references = dataType.rules?.nodes?.map(rule => {
if (rule?.variant === "CONTAINS_KEY") {
if (!dataTypeIdentifier) return
return referenceExtraction({
...nodeContext,
referencePath: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const useValueSuggestions = (dataTypeIdentifier?: DataTypeIdentifier): DF
displayText: [i.toString() ?? ""],
value: {
__typename: "LiteralValue",
value: i
value: String(i)
Comment thread
nicosammito marked this conversation as resolved.
},
})
}
Expand Down
8 changes: 6 additions & 2 deletions src/components/d-flow-type/DFlowType.view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
Maybe,
Scalars, Translation,
} from "@code0-tech/sagittarius-graphql-types";
import {DataTypeView} from "../d-flow-data-type";


export class FlowTypeView {
Expand Down Expand Up @@ -44,10 +45,13 @@ export class FlowTypeView {
this._flowTypeSettings = flowType.flowTypeSettings;
this._id = flowType.id;
this._identifier = flowType.identifier;
this._inputType = flowType.inputType;
this._inputType = flowType.inputType ? new DataTypeView(flowType.inputType).json : undefined;
this._names = flowType.names;
this._returnType = flowType.returnType;
this._returnType = flowType.returnType ? new DataTypeView(flowType.returnType).json : undefined;
this._updatedAt = flowType.updatedAt;

console.log(JSON.stringify(this.inputType))
console.log(this.inputType)
}

get aliases(): Maybe<Array<Translation>> | undefined {
Expand Down
Loading