MCPcopy Index your code
hub / github.com/simstudioai/sim / getFolderLockStatus

Function getFolderLockStatus

packages/platform-authz/src/workflow.ts:91–140  ·  view source on GitHub ↗
(folderId: string | null)

Source from the content-addressed store, hash-verified

89}
90
91export async function getFolderLockStatus(folderId: string | null): Promise<LockStatus> {
92 if (!folderId) {
93 return {
94 locked: false,
95 directLocked: false,
96 inheritedLocked: false,
97 lockedBy: null,
98 lockedFolderId: null,
99 }
100 }
101
102 let currentFolderId: string | null = folderId
103 let isDirect = true
104 const visited = new Set<string>()
105
106 while (currentFolderId && !visited.has(currentFolderId)) {
107 visited.add(currentFolderId)
108 const [folder] = await db
109 .select({
110 id: workflowFolder.id,
111 parentId: workflowFolder.parentId,
112 locked: workflowFolder.locked,
113 })
114 .from(workflowFolder)
115 .where(and(eq(workflowFolder.id, currentFolderId), isNull(workflowFolder.archivedAt)))
116 .limit(1)
117
118 if (!folder) break
119 if (folder.locked) {
120 return {
121 locked: true,
122 directLocked: isDirect,
123 inheritedLocked: !isDirect,
124 lockedBy: 'folder',
125 lockedFolderId: folder.id,
126 }
127 }
128
129 currentFolderId = folder.parentId
130 isDirect = false
131 }
132
133 return {
134 locked: false,
135 directLocked: false,
136 inheritedLocked: false,
137 lockedBy: null,
138 lockedFolderId: null,
139 }
140}
141
142export async function getWorkflowLockStatus(workflowId: string): Promise<LockStatus> {
143 const [wf] = await db

Callers 2

getWorkflowLockStatusFunction · 0.85
assertFolderMutableFunction · 0.85

Calls 2

eqFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected