Skip to content

Commit 4c360bc

Browse files
committed
fix circular dependency of updateStorageUsage and checkStorage in utils
1 parent de33b8a commit 4c360bc

File tree

5 files changed

+39
-25
lines changed

5 files changed

+39
-25
lines changed

packages/server/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flowise-bullmq",
3-
"version": "3.0.25",
3+
"version": "3.0.38",
44
"description": "Flowiseai Server",
55
"main": "dist/index",
66
"types": "dist/index.d.ts",
@@ -28,6 +28,9 @@
2828
"start:default": "cd bin && ./run start",
2929
"start-worker:windows": "cd bin && run worker",
3030
"start-worker:default": "cd bin && ./run worker",
31+
"user": "run-script-os",
32+
"user:windows": "cd bin && run user",
33+
"user:default": "cd bin && ./run user",
3134
"dev": "nodemon",
3235
"oclif-dev": "run-script-os",
3336
"oclif-dev:windows": "cd bin && dev start",

packages/server/src/services/openai-realtime/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
getStartingNodes,
1111
resolveVariables
1212
} from '../../utils'
13+
import { checkStorage, updateStorageUsage } from '../../utils/quotaUsage'
1314
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
1415
import { ChatFlow } from '../../database/entities/ChatFlow'
1516
import { IDepthQueue, IReactFlowNode } from '../../Interface'
@@ -110,7 +111,9 @@ const buildAndInitTool = async (chatflowid: string, _chatId?: string, _apiMessag
110111
variableOverrides,
111112
orgId,
112113
workspaceId,
113-
subscriptionId
114+
subscriptionId,
115+
updateStorageUsage,
116+
checkStorage
114117
})
115118

116119
const nodeToExecute =

packages/server/src/utils/buildChatflow.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,9 @@ export const executeFlow = async ({
515515
baseURL,
516516
orgId,
517517
workspaceId,
518-
subscriptionId
518+
subscriptionId,
519+
updateStorageUsage,
520+
checkStorage
519521
})
520522

521523
const setVariableNodesOutput = getSetVariableNodesOutput(reactFlowNodes)

packages/server/src/utils/index.ts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ import {
6464
SecretsManagerClient,
6565
SecretsManagerClientConfig
6666
} from '@aws-sdk/client-secrets-manager'
67-
import { checkStorage, updateStorageUsage } from './quotaUsage'
68-
import { UsageCacheManager } from '../UsageCacheManager'
6967

7068
export const QUESTION_VAR_PREFIX = 'question'
7169
export const FILE_ATTACHMENT_PREFIX = 'file_attachment'
@@ -206,22 +204,6 @@ export const constructGraphs = (
206204
return { graph, nodeDependencies }
207205
}
208206

209-
/**
210-
* Get starting node and check if flow is valid
211-
* @param {INodeDependencies} nodeDependencies
212-
*/
213-
export const getStartingNode = (nodeDependencies: INodeDependencies) => {
214-
// Find starting node
215-
const startingNodeIds = [] as string[]
216-
Object.keys(nodeDependencies).forEach((nodeId) => {
217-
if (nodeDependencies[nodeId] === 0) {
218-
startingNodeIds.push(nodeId)
219-
}
220-
})
221-
222-
return { startingNodeIds }
223-
}
224-
225207
/**
226208
* Get starting nodes and check if flow is valid
227209
* @param {INodeDependencies} graph
@@ -258,6 +240,22 @@ export const getStartingNodes = (graph: INodeDirectedGraph, endNodeId: string) =
258240
return { startingNodeIds, depthQueue: depthQueueReversed }
259241
}
260242

243+
/**
244+
* Get starting node and check if flow is valid
245+
* @param {INodeDependencies} nodeDependencies
246+
*/
247+
export const getStartingNode = (nodeDependencies: INodeDependencies) => {
248+
// Find starting node
249+
const startingNodeIds = [] as string[]
250+
Object.keys(nodeDependencies).forEach((nodeId) => {
251+
if (nodeDependencies[nodeId] === 0) {
252+
startingNodeIds.push(nodeId)
253+
}
254+
})
255+
256+
return { startingNodeIds }
257+
}
258+
261259
/**
262260
* Get all connected nodes from startnode
263261
* @param {INodeDependencies} graph
@@ -503,8 +501,10 @@ type BuildFlowParams = {
503501
orgId?: string
504502
workspaceId?: string
505503
subscriptionId?: string
506-
usageCacheManager?: UsageCacheManager
504+
usageCacheManager?: any
507505
uploadedFilesContent?: string
506+
updateStorageUsage?: (orgId: string, workspaceId: string, totalSize: number, usageCacheManager?: any) => void
507+
checkStorage?: (orgId: string, subscriptionId: string, usageCacheManager: any) => Promise<any>
508508
}
509509

510510
/**
@@ -539,7 +539,9 @@ export const buildFlow = async ({
539539
orgId,
540540
workspaceId,
541541
subscriptionId,
542-
usageCacheManager
542+
usageCacheManager,
543+
updateStorageUsage,
544+
checkStorage
543545
}: BuildFlowParams) => {
544546
const flowNodes = cloneDeep(reactFlowNodes)
545547

@@ -1283,6 +1285,7 @@ export const findAvailableConfigs = (reactFlowNodes: IReactFlowNode[], component
12831285
for (const flowNode of reactFlowNodes) {
12841286
for (const inputParam of flowNode.data.inputParams) {
12851287
let obj: IOverrideConfig | undefined
1288+
12861289
if (inputParam.type === 'file') {
12871290
obj = {
12881291
node: flowNode.data.label,
@@ -1521,6 +1524,7 @@ export const decryptCredentialData = async (
15211524

15221525
if (USE_AWS_SECRETS_MANAGER && secretsManagerClient) {
15231526
try {
1527+
logger.info(`[server]: Reading AWS Secret: ${encryptedData}`)
15241528
if (encryptedData.startsWith('FlowiseCredential_')) {
15251529
const command = new GetSecretValueCommand({ SecretId: encryptedData })
15261530
const response = await secretsManagerClient.send(command)
@@ -1824,7 +1828,7 @@ export const getUploadPath = (): string => {
18241828
: path.join(getUserHome(), '.flowise', 'uploads')
18251829
}
18261830

1827-
export function generateId() {
1831+
export const generateId = () => {
18281832
return uuidv4()
18291833
}
18301834

packages/server/src/utils/upsertVector.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ export const executeUpsert = async ({
193193
variableOverrides,
194194
orgId,
195195
workspaceId,
196-
subscriptionId
196+
subscriptionId,
197+
updateStorageUsage,
198+
checkStorage
197199
})
198200

199201
// Save to DB

0 commit comments

Comments
 (0)