@trustgraph/react-state 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +139 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +138 -138
- package/dist/index.esm.js.map +1 -1
- package/dist/model/settings-types.d.ts +2 -2
- package/dist/model/settings-types.d.ts.map +1 -1
- package/dist/state/entity-query.d.ts +4 -11
- package/dist/state/entity-query.d.ts.map +1 -1
- package/dist/state/flow-blueprints.d.ts +63 -0
- package/dist/state/flow-blueprints.d.ts.map +1 -0
- package/dist/state/flow-parameters.d.ts +3 -3
- package/dist/state/flow-parameters.d.ts.map +1 -1
- package/dist/state/flows.d.ts +5 -5
- package/dist/state/flows.d.ts.map +1 -1
- package/dist/state/graph-embeddings.d.ts +7 -7
- package/dist/state/graph-embeddings.d.ts.map +1 -1
- package/dist/state/library.d.ts +11 -11
- package/dist/state/library.d.ts.map +1 -1
- package/dist/state/nlp-query.d.ts +9 -9
- package/dist/state/nlp-query.d.ts.map +1 -1
- package/dist/state/processing.d.ts +3 -3
- package/dist/state/processing.d.ts.map +1 -1
- package/dist/state/token-costs.d.ts +3 -11
- package/dist/state/token-costs.d.ts.map +1 -1
- package/dist/state/triples.d.ts +9 -9
- package/dist/state/triples.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -313,8 +313,8 @@ const DEFAULT_SETTINGS = {
|
|
|
313
313
|
mcpTools: false, // Off by default
|
|
314
314
|
schemas: false, // Off by default
|
|
315
315
|
tokenCost: false, // Off by default
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
flowBlueprints: false, // Off by default
|
|
317
|
+
flowBlueprintEditor: false, // Off by default - experimental feature
|
|
318
318
|
structuredQuery: false, // Off by default
|
|
319
319
|
llmModels: false, // Off by default
|
|
320
320
|
},
|
|
@@ -547,19 +547,19 @@ const useFlows = () => {
|
|
|
547
547
|
},
|
|
548
548
|
});
|
|
549
549
|
/**
|
|
550
|
-
* Query for fetching all flow
|
|
550
|
+
* Query for fetching all flow blueprints
|
|
551
551
|
* Uses React Query for caching and background refetching
|
|
552
552
|
*/
|
|
553
|
-
const
|
|
554
|
-
queryKey: ["flow-
|
|
553
|
+
const flowBlueprintsQuery = reactQuery.useQuery({
|
|
554
|
+
queryKey: ["flow-blueprints"],
|
|
555
555
|
enabled: isSocketReady,
|
|
556
556
|
queryFn: () => {
|
|
557
557
|
return socket
|
|
558
558
|
.flows()
|
|
559
|
-
.
|
|
559
|
+
.getFlowBlueprints()
|
|
560
560
|
.then((cls) => Promise.all(cls.map((id) => socket
|
|
561
561
|
.flows()
|
|
562
|
-
.
|
|
562
|
+
.getFlowBlueprint(id)
|
|
563
563
|
.then((cls) => [id, cls]))));
|
|
564
564
|
},
|
|
565
565
|
});
|
|
@@ -567,10 +567,10 @@ const useFlows = () => {
|
|
|
567
567
|
* Mutation for starting a new flow for processing workflows
|
|
568
568
|
*/
|
|
569
569
|
const startFlowMutation = reactQuery.useMutation({
|
|
570
|
-
mutationFn: ({ id,
|
|
570
|
+
mutationFn: ({ id, blueprintName, description, parameters, onSuccess, }) => {
|
|
571
571
|
return socket
|
|
572
572
|
.flows()
|
|
573
|
-
.startFlow(id,
|
|
573
|
+
.startFlow(id, blueprintName, description, parameters)
|
|
574
574
|
.then(() => {
|
|
575
575
|
// Execute success callback if provided
|
|
576
576
|
if (onSuccess)
|
|
@@ -615,7 +615,7 @@ const useFlows = () => {
|
|
|
615
615
|
});
|
|
616
616
|
// Show loading indicators for long-running operations
|
|
617
617
|
useActivity(flowsQuery.isLoading, "Loading flows");
|
|
618
|
-
useActivity(
|
|
618
|
+
useActivity(flowBlueprintsQuery.isLoading, "Loading flow blueprints");
|
|
619
619
|
useActivity(startFlowMutation.isPending, "Starting flow");
|
|
620
620
|
useActivity(stopFlowMutation.isPending, "Stopping flows");
|
|
621
621
|
// Return flows state and operations for use in components
|
|
@@ -625,11 +625,11 @@ const useFlows = () => {
|
|
|
625
625
|
isLoading: flowsQuery.isLoading,
|
|
626
626
|
isError: flowsQuery.isError,
|
|
627
627
|
error: flowsQuery.error,
|
|
628
|
-
// Flow data and query state
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
628
|
+
// Flow blueprint data and query state
|
|
629
|
+
flowBlueprints: flowBlueprintsQuery.data,
|
|
630
|
+
isFlowBlueprintsLoading: flowBlueprintsQuery.isLoading,
|
|
631
|
+
isFlowBlueprintsError: flowBlueprintsQuery.isError,
|
|
632
|
+
flowBlueprintsError: flowBlueprintsQuery.error,
|
|
633
633
|
// Flow start operations
|
|
634
634
|
startFlow: startFlowMutation.mutate,
|
|
635
635
|
isStarting: startFlowMutation.isPending,
|
|
@@ -3425,7 +3425,7 @@ const useTokenCosts = () => {
|
|
|
3425
3425
|
* Uses React Query for caching and background refetching
|
|
3426
3426
|
*/
|
|
3427
3427
|
const query = reactQuery.useQuery({
|
|
3428
|
-
queryKey: ["token-
|
|
3428
|
+
queryKey: ["token-cost"],
|
|
3429
3429
|
enabled: isSocketReady,
|
|
3430
3430
|
queryFn: () => {
|
|
3431
3431
|
return socket
|
|
@@ -3441,17 +3441,17 @@ const useTokenCosts = () => {
|
|
|
3441
3441
|
},
|
|
3442
3442
|
});
|
|
3443
3443
|
/**
|
|
3444
|
-
* Mutation for deleting a specific model's token
|
|
3444
|
+
* Mutation for deleting a specific model's token cost
|
|
3445
3445
|
* Removes the token cost configuration for a given model
|
|
3446
3446
|
*/
|
|
3447
|
-
const
|
|
3447
|
+
const deleteTokenCostMutation = reactQuery.useMutation({
|
|
3448
3448
|
mutationFn: ({ model, onSuccess }) => {
|
|
3449
3449
|
// Delete the token cost configuration for the specified model
|
|
3450
3450
|
return socket
|
|
3451
3451
|
.config()
|
|
3452
3452
|
.deleteConfig([
|
|
3453
3453
|
{
|
|
3454
|
-
type: "token-
|
|
3454
|
+
type: "token-cost",
|
|
3455
3455
|
key: model,
|
|
3456
3456
|
},
|
|
3457
3457
|
])
|
|
@@ -3472,20 +3472,20 @@ const useTokenCosts = () => {
|
|
|
3472
3472
|
},
|
|
3473
3473
|
onSuccess: () => {
|
|
3474
3474
|
// Invalidate cache to trigger refetch
|
|
3475
|
-
queryClient.invalidateQueries({ queryKey: ["token-
|
|
3475
|
+
queryClient.invalidateQueries({ queryKey: ["token-cost"] });
|
|
3476
3476
|
// Show success notification
|
|
3477
3477
|
notify.success("Successful deletion");
|
|
3478
3478
|
},
|
|
3479
3479
|
});
|
|
3480
3480
|
/**
|
|
3481
|
-
* Mutation for updating token
|
|
3481
|
+
* Mutation for updating token cost for a specific model
|
|
3482
3482
|
* Converts per-million token prices to per-token prices and saves
|
|
3483
3483
|
* configuration
|
|
3484
3484
|
*/
|
|
3485
3485
|
const updateTokenCostMutation = reactQuery.useMutation({
|
|
3486
3486
|
mutationFn: ({ model, input_price, output_price, onSuccess }) => {
|
|
3487
3487
|
// Convert per-million token prices to per-token prices
|
|
3488
|
-
const
|
|
3488
|
+
const tokenCosts = {
|
|
3489
3489
|
input_price: input_price / 1000000,
|
|
3490
3490
|
output_price: output_price / 1000000,
|
|
3491
3491
|
};
|
|
@@ -3494,9 +3494,9 @@ const useTokenCosts = () => {
|
|
|
3494
3494
|
.config()
|
|
3495
3495
|
.putConfig([
|
|
3496
3496
|
{
|
|
3497
|
-
type: "token-
|
|
3497
|
+
type: "token-cost",
|
|
3498
3498
|
key: model,
|
|
3499
|
-
value: JSON.stringify(
|
|
3499
|
+
value: JSON.stringify(tokenCosts),
|
|
3500
3500
|
},
|
|
3501
3501
|
])
|
|
3502
3502
|
.then((x) => {
|
|
@@ -3516,14 +3516,14 @@ const useTokenCosts = () => {
|
|
|
3516
3516
|
},
|
|
3517
3517
|
onSuccess: () => {
|
|
3518
3518
|
// Invalidate cache to refresh the token costs list
|
|
3519
|
-
queryClient.invalidateQueries({ queryKey: ["token-
|
|
3519
|
+
queryClient.invalidateQueries({ queryKey: ["token-cost"] });
|
|
3520
3520
|
notify.success("Token costs updated");
|
|
3521
3521
|
},
|
|
3522
3522
|
});
|
|
3523
3523
|
// Show loading indicators for long-running operations
|
|
3524
3524
|
useActivity(query.isLoading, "Loading token costs");
|
|
3525
|
-
useActivity(
|
|
3526
|
-
useActivity(updateTokenCostMutation.isPending, "Updating token
|
|
3525
|
+
useActivity(deleteTokenCostMutation.isPending, "Deleting token cost");
|
|
3526
|
+
useActivity(updateTokenCostMutation.isPending, "Updating token cost");
|
|
3527
3527
|
// Return token cost state and operations for use in components
|
|
3528
3528
|
return {
|
|
3529
3529
|
// Token cost query state
|
|
@@ -3532,9 +3532,9 @@ const useTokenCosts = () => {
|
|
|
3532
3532
|
isError: query.isError,
|
|
3533
3533
|
error: query.error,
|
|
3534
3534
|
// Token cost deletion operations
|
|
3535
|
-
|
|
3536
|
-
isDeleting:
|
|
3537
|
-
deleteError:
|
|
3535
|
+
deleteTokenCost: deleteTokenCostMutation.mutate,
|
|
3536
|
+
isDeleting: deleteTokenCostMutation.isPending,
|
|
3537
|
+
deleteError: deleteTokenCostMutation.error,
|
|
3538
3538
|
// Token cost update operations
|
|
3539
3539
|
updateTokenCost: updateTokenCostMutation.mutate,
|
|
3540
3540
|
isSubmitting: updateTokenCostMutation.isPending,
|
|
@@ -3559,7 +3559,7 @@ const useLLMModels = () => {
|
|
|
3559
3559
|
queryFn: async () => {
|
|
3560
3560
|
const response = await socket
|
|
3561
3561
|
.config()
|
|
3562
|
-
.getConfig([{ type: "parameter-
|
|
3562
|
+
.getConfig([{ type: "parameter-type", key: "llm-model" }]);
|
|
3563
3563
|
if (!response.values || response.values.length === 0) {
|
|
3564
3564
|
return [];
|
|
3565
3565
|
}
|
|
@@ -3595,7 +3595,7 @@ const useLLMModels = () => {
|
|
|
3595
3595
|
};
|
|
3596
3596
|
await socket.config().putConfig([
|
|
3597
3597
|
{
|
|
3598
|
-
type: "parameter-
|
|
3598
|
+
type: "parameter-type",
|
|
3599
3599
|
key: name,
|
|
3600
3600
|
value: JSON.stringify(updatedDef),
|
|
3601
3601
|
},
|
|
@@ -3624,11 +3624,11 @@ const useLLMModels = () => {
|
|
|
3624
3624
|
|
|
3625
3625
|
// @ts-nocheck
|
|
3626
3626
|
/**
|
|
3627
|
-
* Custom hook for managing flow
|
|
3628
|
-
* Provides functionality for fetching, creating, updating, and deleting flow
|
|
3629
|
-
* @returns {Object} Flow
|
|
3627
|
+
* Custom hook for managing flow blueprint operations
|
|
3628
|
+
* Provides functionality for fetching, creating, updating, and deleting flow blueprintes
|
|
3629
|
+
* @returns {Object} Flow blueprint state and operations
|
|
3630
3630
|
*/
|
|
3631
|
-
const
|
|
3631
|
+
const useFlowBlueprints = () => {
|
|
3632
3632
|
// WebSocket connection for communicating with the config service
|
|
3633
3633
|
const socket = reactProvider.useSocket();
|
|
3634
3634
|
const connectionState = reactProvider.useConnectionState();
|
|
@@ -3640,11 +3640,11 @@ const useFlowClasses = () => {
|
|
|
3640
3640
|
const isSocketReady = connectionState?.status === "authenticated" ||
|
|
3641
3641
|
connectionState?.status === "unauthenticated";
|
|
3642
3642
|
/**
|
|
3643
|
-
* Query for fetching all flow
|
|
3643
|
+
* Query for fetching all flow blueprintes
|
|
3644
3644
|
* Uses React Query for caching and background refetching
|
|
3645
3645
|
*/
|
|
3646
3646
|
const query = reactQuery.useQuery({
|
|
3647
|
-
queryKey: ["flow-
|
|
3647
|
+
queryKey: ["flow-blueprints"],
|
|
3648
3648
|
enabled: isSocketReady,
|
|
3649
3649
|
staleTime: 0, // Force fresh data
|
|
3650
3650
|
gcTime: 0, // Don't cache (React Query v5 uses gcTime instead of cacheTime)
|
|
@@ -3653,54 +3653,54 @@ const useFlowClasses = () => {
|
|
|
3653
3653
|
try {
|
|
3654
3654
|
const response = await socket.config().getConfigAll();
|
|
3655
3655
|
// Handle both array and object responses
|
|
3656
|
-
const config = response.config["flow-
|
|
3656
|
+
const config = response.config["flow-blueprints"];
|
|
3657
3657
|
if (Array.isArray(config)) {
|
|
3658
3658
|
// If it's already an array, check if it's an array of [key, value] pairs
|
|
3659
3659
|
if (config.length > 0 &&
|
|
3660
3660
|
Array.isArray(config[0]) &&
|
|
3661
3661
|
config[0].length === 2) {
|
|
3662
|
-
// It's an array of [id,
|
|
3663
|
-
const converted = config.map(([id,
|
|
3664
|
-
let
|
|
3665
|
-
// If the
|
|
3666
|
-
if (typeof
|
|
3662
|
+
// It's an array of [id, flowBlueprint] pairs - convert to objects
|
|
3663
|
+
const converted = config.map(([id, flowBlueprintData]) => {
|
|
3664
|
+
let flowBlueprint = flowBlueprintData;
|
|
3665
|
+
// If the flowBlueprint is a JSON string, parse it
|
|
3666
|
+
if (typeof flowBlueprintData === "string") {
|
|
3667
3667
|
try {
|
|
3668
|
-
|
|
3668
|
+
flowBlueprint = JSON.parse(flowBlueprintData);
|
|
3669
3669
|
}
|
|
3670
3670
|
catch (error) {
|
|
3671
|
-
console.error(`Failed to parse flow
|
|
3672
|
-
|
|
3671
|
+
console.error(`Failed to parse flow blueprint JSON for ${id}:`, error);
|
|
3672
|
+
flowBlueprint = flowBlueprintData;
|
|
3673
3673
|
}
|
|
3674
3674
|
}
|
|
3675
3675
|
return {
|
|
3676
3676
|
id,
|
|
3677
|
-
...
|
|
3677
|
+
...flowBlueprint,
|
|
3678
3678
|
};
|
|
3679
3679
|
});
|
|
3680
3680
|
return converted;
|
|
3681
3681
|
}
|
|
3682
3682
|
else {
|
|
3683
|
-
// It's already an array of flow
|
|
3683
|
+
// It's already an array of flow blueprint objects
|
|
3684
3684
|
return config;
|
|
3685
3685
|
}
|
|
3686
3686
|
}
|
|
3687
3687
|
else if (config && typeof config === "object") {
|
|
3688
|
-
// Convert object to array of flow
|
|
3689
|
-
const converted = Object.entries(config).map(([id,
|
|
3690
|
-
let
|
|
3691
|
-
// If the
|
|
3692
|
-
if (typeof
|
|
3688
|
+
// Convert object to array of flow blueprintes
|
|
3689
|
+
const converted = Object.entries(config).map(([id, flowBlueprintData]) => {
|
|
3690
|
+
let flowBlueprint = flowBlueprintData;
|
|
3691
|
+
// If the flowBlueprint is a JSON string, parse it
|
|
3692
|
+
if (typeof flowBlueprintData === "string") {
|
|
3693
3693
|
try {
|
|
3694
|
-
|
|
3694
|
+
flowBlueprint = JSON.parse(flowBlueprintData);
|
|
3695
3695
|
}
|
|
3696
3696
|
catch (error) {
|
|
3697
|
-
console.error(`Failed to parse flow
|
|
3698
|
-
|
|
3697
|
+
console.error(`Failed to parse flow blueprint JSON for ${id}:`, error);
|
|
3698
|
+
flowBlueprint = flowBlueprintData;
|
|
3699
3699
|
}
|
|
3700
3700
|
}
|
|
3701
3701
|
return {
|
|
3702
3702
|
id,
|
|
3703
|
-
...
|
|
3703
|
+
...flowBlueprint,
|
|
3704
3704
|
};
|
|
3705
3705
|
});
|
|
3706
3706
|
return converted;
|
|
@@ -3708,171 +3708,171 @@ const useFlowClasses = () => {
|
|
|
3708
3708
|
return [];
|
|
3709
3709
|
}
|
|
3710
3710
|
catch (error) {
|
|
3711
|
-
console.error("Failed to fetch flow
|
|
3712
|
-
throw new Error("Failed to fetch flow
|
|
3711
|
+
console.error("Failed to fetch flow blueprintes:", error);
|
|
3712
|
+
throw new Error("Failed to fetch flow blueprintes");
|
|
3713
3713
|
}
|
|
3714
3714
|
},
|
|
3715
3715
|
});
|
|
3716
3716
|
// Track loading state
|
|
3717
|
-
useActivity(query.isLoading, "Loading flow
|
|
3717
|
+
useActivity(query.isLoading, "Loading flow blueprintes");
|
|
3718
3718
|
/**
|
|
3719
|
-
* Mutation for creating a new flow
|
|
3719
|
+
* Mutation for creating a new flow blueprint
|
|
3720
3720
|
*/
|
|
3721
3721
|
const createMutation = reactQuery.useMutation({
|
|
3722
|
-
mutationFn: async ({ id,
|
|
3722
|
+
mutationFn: async ({ id, flowBlueprint, }) => {
|
|
3723
3723
|
try {
|
|
3724
3724
|
await socket.config().putConfig([
|
|
3725
3725
|
{
|
|
3726
|
-
type: "flow-
|
|
3726
|
+
type: "flow-blueprints",
|
|
3727
3727
|
key: id,
|
|
3728
|
-
value: JSON.stringify(
|
|
3728
|
+
value: JSON.stringify(flowBlueprint),
|
|
3729
3729
|
},
|
|
3730
3730
|
]);
|
|
3731
3731
|
return {
|
|
3732
3732
|
id,
|
|
3733
|
-
...
|
|
3733
|
+
...flowBlueprint,
|
|
3734
3734
|
};
|
|
3735
3735
|
}
|
|
3736
3736
|
catch (error) {
|
|
3737
|
-
console.error(`Failed to create flow
|
|
3738
|
-
throw new Error(`Failed to create flow
|
|
3737
|
+
console.error(`Failed to create flow blueprint ${id}:`, error);
|
|
3738
|
+
throw new Error(`Failed to create flow blueprint: ${id}`);
|
|
3739
3739
|
}
|
|
3740
3740
|
},
|
|
3741
|
-
onSuccess: (
|
|
3742
|
-
// Invalidate and refetch flow
|
|
3743
|
-
queryClient.invalidateQueries({ queryKey: ["flow-
|
|
3744
|
-
notify.success(`Flow
|
|
3741
|
+
onSuccess: (flowBlueprint) => {
|
|
3742
|
+
// Invalidate and refetch flow blueprintes
|
|
3743
|
+
queryClient.invalidateQueries({ queryKey: ["flow-blueprints"] });
|
|
3744
|
+
notify.success(`Flow blueprint "${flowBlueprint.id}" created successfully`);
|
|
3745
3745
|
},
|
|
3746
3746
|
onError: (error) => {
|
|
3747
|
-
notify.error(`Failed to create flow
|
|
3747
|
+
notify.error(`Failed to create flow blueprint: ${error.message}`);
|
|
3748
3748
|
},
|
|
3749
3749
|
});
|
|
3750
3750
|
/**
|
|
3751
|
-
* Mutation for updating an existing flow
|
|
3751
|
+
* Mutation for updating an existing flow blueprint
|
|
3752
3752
|
*/
|
|
3753
3753
|
const updateMutation = reactQuery.useMutation({
|
|
3754
|
-
mutationFn: async ({ id,
|
|
3754
|
+
mutationFn: async ({ id, flowBlueprint, }) => {
|
|
3755
3755
|
try {
|
|
3756
|
-
// Get current flow
|
|
3756
|
+
// Get current flow blueprint to merge changes
|
|
3757
3757
|
const currentResponse = await socket.config().getConfig([
|
|
3758
3758
|
{
|
|
3759
|
-
type: "flow-
|
|
3759
|
+
type: "flow-blueprints",
|
|
3760
3760
|
key: id,
|
|
3761
3761
|
},
|
|
3762
3762
|
]);
|
|
3763
|
-
const
|
|
3764
|
-
...currentResponse.config["flow-
|
|
3765
|
-
...
|
|
3763
|
+
const updatedFlowBlueprint = {
|
|
3764
|
+
...currentResponse.config["flow-blueprints"][id],
|
|
3765
|
+
...flowBlueprint,
|
|
3766
3766
|
};
|
|
3767
3767
|
await socket.config().putConfig([
|
|
3768
3768
|
{
|
|
3769
|
-
type: "flow-
|
|
3769
|
+
type: "flow-blueprints",
|
|
3770
3770
|
key: id,
|
|
3771
|
-
value: JSON.stringify(
|
|
3771
|
+
value: JSON.stringify(updatedFlowBlueprint),
|
|
3772
3772
|
},
|
|
3773
3773
|
]);
|
|
3774
3774
|
return {
|
|
3775
3775
|
id,
|
|
3776
|
-
...
|
|
3776
|
+
...updatedFlowBlueprint,
|
|
3777
3777
|
};
|
|
3778
3778
|
}
|
|
3779
3779
|
catch (error) {
|
|
3780
|
-
console.error(`Failed to update flow
|
|
3781
|
-
throw new Error(`Failed to update flow
|
|
3780
|
+
console.error(`Failed to update flow blueprint ${id}:`, error);
|
|
3781
|
+
throw new Error(`Failed to update flow blueprint: ${id}`);
|
|
3782
3782
|
}
|
|
3783
3783
|
},
|
|
3784
|
-
onSuccess: (
|
|
3784
|
+
onSuccess: (flowBlueprint) => {
|
|
3785
3785
|
// Update cache
|
|
3786
|
-
queryClient.invalidateQueries({ queryKey: ["flow-
|
|
3787
|
-
notify.success(`Flow
|
|
3786
|
+
queryClient.invalidateQueries({ queryKey: ["flow-blueprints"] });
|
|
3787
|
+
notify.success(`Flow blueprint "${flowBlueprint.id}" updated successfully`);
|
|
3788
3788
|
},
|
|
3789
3789
|
onError: (error) => {
|
|
3790
|
-
notify.error(`Failed to update flow
|
|
3790
|
+
notify.error(`Failed to update flow blueprint: ${error.message}`);
|
|
3791
3791
|
},
|
|
3792
3792
|
});
|
|
3793
3793
|
/**
|
|
3794
|
-
* Mutation for deleting a flow
|
|
3794
|
+
* Mutation for deleting a flow blueprint
|
|
3795
3795
|
*/
|
|
3796
3796
|
const deleteMutation = reactQuery.useMutation({
|
|
3797
3797
|
mutationFn: async (id) => {
|
|
3798
3798
|
try {
|
|
3799
|
-
await socket.flows().
|
|
3799
|
+
await socket.flows().deleteFlowBlueprint(id);
|
|
3800
3800
|
}
|
|
3801
3801
|
catch (error) {
|
|
3802
|
-
console.error(`Failed to delete flow
|
|
3802
|
+
console.error(`Failed to delete flow blueprint ${id}:`, error);
|
|
3803
3803
|
// Re-throw the original error to preserve the API error message
|
|
3804
3804
|
throw error;
|
|
3805
3805
|
}
|
|
3806
3806
|
},
|
|
3807
3807
|
onSuccess: (_, id) => {
|
|
3808
3808
|
// Remove from cache
|
|
3809
|
-
queryClient.invalidateQueries({ queryKey: ["flow-
|
|
3810
|
-
notify.success(`Flow
|
|
3809
|
+
queryClient.invalidateQueries({ queryKey: ["flow-blueprints"] });
|
|
3810
|
+
notify.success(`Flow blueprint "${id}" deleted successfully`);
|
|
3811
3811
|
},
|
|
3812
3812
|
onError: (error) => {
|
|
3813
3813
|
// Show the actual API error message without additional prefixes
|
|
3814
|
-
notify.error(error.message || "Unknown error occurred while deleting flow
|
|
3814
|
+
notify.error(error.message || "Unknown error occurred while deleting flow blueprint");
|
|
3815
3815
|
},
|
|
3816
3816
|
});
|
|
3817
3817
|
/**
|
|
3818
|
-
* Mutation for duplicating a flow
|
|
3818
|
+
* Mutation for duplicating a flow blueprint
|
|
3819
3819
|
*/
|
|
3820
3820
|
const duplicateMutation = reactQuery.useMutation({
|
|
3821
3821
|
mutationFn: async ({ sourceId, targetId, }) => {
|
|
3822
3822
|
try {
|
|
3823
|
-
// Get source flow
|
|
3823
|
+
// Get source flow blueprint
|
|
3824
3824
|
const sourceResponse = await socket.config().getConfig([
|
|
3825
3825
|
{
|
|
3826
|
-
type: "flow-
|
|
3826
|
+
type: "flow-blueprints",
|
|
3827
3827
|
key: sourceId,
|
|
3828
3828
|
},
|
|
3829
3829
|
]);
|
|
3830
|
-
const
|
|
3830
|
+
const sourceFlowBlueprint = sourceResponse.config["flow-blueprints"][sourceId];
|
|
3831
3831
|
// Create duplicate with updated description
|
|
3832
|
-
const
|
|
3833
|
-
...
|
|
3834
|
-
description: `${
|
|
3835
|
-
tags: [...(
|
|
3832
|
+
const duplicatedFlowBlueprint = {
|
|
3833
|
+
...sourceFlowBlueprint,
|
|
3834
|
+
description: `${sourceFlowBlueprint.description || sourceId} (Copy)`,
|
|
3835
|
+
tags: [...(sourceFlowBlueprint.tags || []), "copy"],
|
|
3836
3836
|
};
|
|
3837
|
-
// Save as new flow
|
|
3837
|
+
// Save as new flow blueprint
|
|
3838
3838
|
await socket.config().putConfig([
|
|
3839
3839
|
{
|
|
3840
|
-
type: "flow-
|
|
3840
|
+
type: "flow-blueprints",
|
|
3841
3841
|
key: targetId,
|
|
3842
|
-
value: JSON.stringify(
|
|
3842
|
+
value: JSON.stringify(duplicatedFlowBlueprint),
|
|
3843
3843
|
},
|
|
3844
3844
|
]);
|
|
3845
3845
|
return {
|
|
3846
3846
|
id: targetId,
|
|
3847
|
-
...
|
|
3847
|
+
...duplicatedFlowBlueprint,
|
|
3848
3848
|
};
|
|
3849
3849
|
}
|
|
3850
3850
|
catch (error) {
|
|
3851
|
-
console.error(`Failed to duplicate flow
|
|
3852
|
-
throw new Error(`Failed to duplicate flow
|
|
3851
|
+
console.error(`Failed to duplicate flow blueprint ${sourceId}:`, error);
|
|
3852
|
+
throw new Error(`Failed to duplicate flow blueprint: ${sourceId}`);
|
|
3853
3853
|
}
|
|
3854
3854
|
},
|
|
3855
|
-
onSuccess: (
|
|
3856
|
-
queryClient.invalidateQueries({ queryKey: ["flow-
|
|
3857
|
-
notify.success(`Flow
|
|
3855
|
+
onSuccess: (flowBlueprint) => {
|
|
3856
|
+
queryClient.invalidateQueries({ queryKey: ["flow-blueprints"] });
|
|
3857
|
+
notify.success(`Flow blueprint duplicated as "${flowBlueprint.id}"`);
|
|
3858
3858
|
},
|
|
3859
3859
|
onError: (error) => {
|
|
3860
|
-
notify.error(`Failed to duplicate flow
|
|
3860
|
+
notify.error(`Failed to duplicate flow blueprint: ${error.message}`);
|
|
3861
3861
|
},
|
|
3862
3862
|
});
|
|
3863
3863
|
// Track mutation loading states
|
|
3864
|
-
useActivity(createMutation.isPending, "Creating flow
|
|
3865
|
-
useActivity(updateMutation.isPending, "Updating flow
|
|
3866
|
-
useActivity(deleteMutation.isPending, "Deleting flow
|
|
3867
|
-
useActivity(duplicateMutation.isPending, "Duplicating flow
|
|
3864
|
+
useActivity(createMutation.isPending, "Creating flow blueprint");
|
|
3865
|
+
useActivity(updateMutation.isPending, "Updating flow blueprint");
|
|
3866
|
+
useActivity(deleteMutation.isPending, "Deleting flow blueprint");
|
|
3867
|
+
useActivity(duplicateMutation.isPending, "Duplicating flow blueprint");
|
|
3868
3868
|
return {
|
|
3869
3869
|
// Query state
|
|
3870
|
-
|
|
3870
|
+
flowBlueprints: query.data || [],
|
|
3871
3871
|
isLoading: query.isLoading,
|
|
3872
3872
|
error: query.error,
|
|
3873
3873
|
refetch: query.refetch,
|
|
3874
3874
|
// Utilities
|
|
3875
|
-
|
|
3875
|
+
getFlowBlueprint: (id) => {
|
|
3876
3876
|
const found = query.data?.find((fc) => {
|
|
3877
3877
|
return fc.id === id;
|
|
3878
3878
|
});
|
|
@@ -3882,10 +3882,10 @@ const useFlowClasses = () => {
|
|
|
3882
3882
|
return query.data?.some((fc) => fc.id === id) ?? false;
|
|
3883
3883
|
},
|
|
3884
3884
|
// Mutations
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3885
|
+
createFlowBlueprint: createMutation.mutateAsync,
|
|
3886
|
+
updateFlowBlueprint: updateMutation.mutateAsync,
|
|
3887
|
+
deleteFlowBlueprint: deleteMutation.mutateAsync,
|
|
3888
|
+
duplicateFlowBlueprint: duplicateMutation.mutateAsync,
|
|
3889
3889
|
// Mutation states
|
|
3890
3890
|
isCreating: createMutation.isPending,
|
|
3891
3891
|
isUpdating: updateMutation.isPending,
|
|
@@ -3894,9 +3894,9 @@ const useFlowClasses = () => {
|
|
|
3894
3894
|
};
|
|
3895
3895
|
};
|
|
3896
3896
|
/**
|
|
3897
|
-
* Generate a unique flow
|
|
3897
|
+
* Generate a unique flow blueprint ID
|
|
3898
3898
|
*/
|
|
3899
|
-
const
|
|
3899
|
+
const generateFlowBlueprintId = (baseName = "flow-class") => {
|
|
3900
3900
|
const timestamp = Date.now();
|
|
3901
3901
|
const random = Math.random().toString(36).substring(2, 8);
|
|
3902
3902
|
return `${baseName}-${timestamp}-${random}`;
|
|
@@ -3904,29 +3904,29 @@ const generateFlowClassId = (baseName = "flow-class") => {
|
|
|
3904
3904
|
|
|
3905
3905
|
// @ts-nocheck
|
|
3906
3906
|
/**
|
|
3907
|
-
* Custom hook for fetching parameter definitions for a flow
|
|
3908
|
-
* @param
|
|
3907
|
+
* Custom hook for fetching parameter definitions for a flow blueprint
|
|
3908
|
+
* @param flowBlueprintName - The name of the flow blueprint to fetch parameters for
|
|
3909
3909
|
* @returns Parameter definitions, mapping, and loading states
|
|
3910
3910
|
*/
|
|
3911
|
-
const useFlowParameters = (
|
|
3911
|
+
const useFlowParameters = (flowBlueprintName) => {
|
|
3912
3912
|
const socket = reactProvider.useSocket();
|
|
3913
3913
|
const connectionState = reactProvider.useConnectionState();
|
|
3914
3914
|
const isSocketReady = connectionState?.status === "authenticated" ||
|
|
3915
3915
|
connectionState?.status === "unauthenticated";
|
|
3916
3916
|
/**
|
|
3917
|
-
* Query for fetching parameter definitions for a flow
|
|
3917
|
+
* Query for fetching parameter definitions for a flow blueprint
|
|
3918
3918
|
*/
|
|
3919
3919
|
const parametersQuery = reactQuery.useQuery({
|
|
3920
|
-
queryKey: ["flow-parameters",
|
|
3921
|
-
enabled: isSocketReady && !!
|
|
3920
|
+
queryKey: ["flow-parameters", flowBlueprintName],
|
|
3921
|
+
enabled: isSocketReady && !!flowBlueprintName,
|
|
3922
3922
|
queryFn: async () => {
|
|
3923
|
-
if (!
|
|
3923
|
+
if (!flowBlueprintName)
|
|
3924
3924
|
return null;
|
|
3925
3925
|
try {
|
|
3926
|
-
// Get flow
|
|
3927
|
-
const
|
|
3926
|
+
// Get flow blueprint definition first
|
|
3927
|
+
const flowBlueprint = await socket.flows().getFlowBlueprint(flowBlueprintName);
|
|
3928
3928
|
// Extract parameter metadata with new structure
|
|
3929
|
-
const parameterMetadata =
|
|
3929
|
+
const parameterMetadata = flowBlueprint.parameters || {};
|
|
3930
3930
|
if (Object.keys(parameterMetadata).length === 0) {
|
|
3931
3931
|
return {
|
|
3932
3932
|
parameterDefinitions: {},
|
|
@@ -3942,14 +3942,14 @@ const useFlowParameters = (flowClassName) => {
|
|
|
3942
3942
|
// Fetch parameter definitions from config
|
|
3943
3943
|
const definitionNames = Object.values(parameterMapping);
|
|
3944
3944
|
const configKeys = definitionNames.map((name) => ({
|
|
3945
|
-
type: "parameter-
|
|
3945
|
+
type: "parameter-type",
|
|
3946
3946
|
key: name,
|
|
3947
3947
|
}));
|
|
3948
3948
|
const configResponse = await socket.config().getConfig(configKeys);
|
|
3949
3949
|
const parameterDefinitions = {};
|
|
3950
3950
|
// Parse config response to get parameter definitions
|
|
3951
3951
|
configResponse.values?.forEach((item) => {
|
|
3952
|
-
if (item.type === "parameter-
|
|
3952
|
+
if (item.type === "parameter-type") {
|
|
3953
3953
|
try {
|
|
3954
3954
|
parameterDefinitions[item.key] = JSON.parse(item.value);
|
|
3955
3955
|
}
|
|
@@ -4542,7 +4542,7 @@ exports.RDFS_LABEL = RDFS_LABEL;
|
|
|
4542
4542
|
exports.SETTINGS_STORAGE_KEY = SETTINGS_STORAGE_KEY;
|
|
4543
4543
|
exports.createDocId = createDocId;
|
|
4544
4544
|
exports.fileToBase64 = fileToBase64;
|
|
4545
|
-
exports.
|
|
4545
|
+
exports.generateFlowBlueprintId = generateFlowBlueprintId;
|
|
4546
4546
|
exports.getTriples = getTriples;
|
|
4547
4547
|
exports.prepareMetadata = prepareMetadata;
|
|
4548
4548
|
exports.textToBase64 = textToBase64;
|
|
@@ -4554,7 +4554,7 @@ exports.useCollections = useCollections;
|
|
|
4554
4554
|
exports.useConversation = useConversation;
|
|
4555
4555
|
exports.useEmbeddings = useEmbeddings;
|
|
4556
4556
|
exports.useEntityDetail = useEntityDetail;
|
|
4557
|
-
exports.
|
|
4557
|
+
exports.useFlowBlueprints = useFlowBlueprints;
|
|
4558
4558
|
exports.useFlowParameters = useFlowParameters;
|
|
4559
4559
|
exports.useFlows = useFlows;
|
|
4560
4560
|
exports.useGraphEmbeddings = useGraphEmbeddings;
|