Skip to content

Commit b46f760

Browse files
committed
added new rate limit category, ack PR comments
1 parent a2c794a commit b46f760

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

apps/sim/app/api/v1/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface RateLimitResult {
1919

2020
export async function checkRateLimit(
2121
request: NextRequest,
22-
endpoint: 'logs' | 'logs-detail' = 'logs'
22+
endpoint: 'logs' | 'logs-detail' | 'workflows' | 'workflow-detail' = 'logs'
2323
): Promise<RateLimitResult> {
2424
try {
2525
const auth = await authenticateV1Request(request)

apps/sim/app/api/v1/workflows/[id]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
1515
const requestId = crypto.randomUUID().slice(0, 8)
1616

1717
try {
18-
const rateLimit = await checkRateLimit(request, 'logs-detail')
18+
const rateLimit = await checkRateLimit(request, 'workflow-detail')
1919
if (!rateLimit.allowed) {
2020
return createRateLimitResponse(rateLimit)
2121
}

apps/sim/app/api/v1/workflows/route.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function GET(request: NextRequest) {
4242
const requestId = crypto.randomUUID().slice(0, 8)
4343

4444
try {
45-
const rateLimit = await checkRateLimit(request, 'logs')
45+
const rateLimit = await checkRateLimit(request, 'workflows')
4646
if (!rateLimit.allowed) {
4747
return createRateLimitResponse(rateLimit)
4848
}
@@ -87,20 +87,21 @@ export async function GET(request: NextRequest) {
8787
if (params.cursor) {
8888
const cursorData = decodeCursor(params.cursor)
8989
if (cursorData) {
90-
conditions.push(
91-
or(
92-
gt(workflow.sortOrder, cursorData.sortOrder),
93-
and(
94-
eq(workflow.sortOrder, cursorData.sortOrder),
95-
gt(workflow.createdAt, new Date(cursorData.createdAt))
96-
),
97-
and(
98-
eq(workflow.sortOrder, cursorData.sortOrder),
99-
eq(workflow.createdAt, new Date(cursorData.createdAt)),
100-
gt(workflow.id, cursorData.id)
101-
)
102-
)!
90+
const cursorCondition = or(
91+
gt(workflow.sortOrder, cursorData.sortOrder),
92+
and(
93+
eq(workflow.sortOrder, cursorData.sortOrder),
94+
gt(workflow.createdAt, new Date(cursorData.createdAt))
95+
),
96+
and(
97+
eq(workflow.sortOrder, cursorData.sortOrder),
98+
eq(workflow.createdAt, new Date(cursorData.createdAt)),
99+
gt(workflow.id, cursorData.id)
100+
)
103101
)
102+
if (cursorCondition) {
103+
conditions.push(cursorCondition)
104+
}
104105
}
105106
}
106107

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/general/components/api-info-modal.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,19 @@ export function ApiInfoModal({ open, onOpenChange, workflowId }: ApiInfoModalPro
137137
const handleSave = useCallback(async () => {
138138
if (!workflowId) return
139139

140+
const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
141+
if (activeWorkflowId !== workflowId) {
142+
return
143+
}
144+
140145
setIsSaving(true)
141146
try {
142147
if (description.trim() !== (workflowMetadata?.description || '')) {
143148
updateWorkflow(workflowId, { description: description.trim() || 'New workflow' })
144149
}
145150

146151
if (starterBlockId) {
147-
const currentValue = subBlockValues[starterBlockId]?.inputFormat || inputFormat
148-
const updatedValue = (currentValue as NormalizedField[]).map((field) => ({
152+
const updatedValue = inputFormat.map((field) => ({
149153
...field,
150154
description: paramDescriptions[field.name]?.trim() || undefined,
151155
}))
@@ -162,7 +166,6 @@ export function ApiInfoModal({ open, onOpenChange, workflowId }: ApiInfoModalPro
162166
workflowMetadata,
163167
updateWorkflow,
164168
starterBlockId,
165-
subBlockValues,
166169
inputFormat,
167170
paramDescriptions,
168171
setValue,

0 commit comments

Comments
 (0)