Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
6386e6b
updates
lakeesiv Jan 13, 2026
5dddb03
required
lakeesiv Jan 13, 2026
e80660f
trashy table viewer
lakeesiv Jan 13, 2026
4316f45
updates
lakeesiv Jan 13, 2026
7e4fc32
updates
lakeesiv Jan 13, 2026
0872314
filtering ui
lakeesiv Jan 14, 2026
9a3d563
updates
lakeesiv Jan 14, 2026
48ecb19
updates
lakeesiv Jan 14, 2026
ed807be
updates
lakeesiv Jan 14, 2026
8a8589e
one input mode
lakeesiv Jan 14, 2026
a919816
format
lakeesiv Jan 14, 2026
6605c88
fix lints
lakeesiv Jan 14, 2026
c1eef30
improved errors
lakeesiv Jan 14, 2026
a537ca7
updates
lakeesiv Jan 14, 2026
fc6dbcf
updates
lakeesiv Jan 14, 2026
48250f5
chages
lakeesiv Jan 14, 2026
c155d8a
doc strings
lakeesiv Jan 14, 2026
4d176c0
breaking down file
lakeesiv Jan 14, 2026
e287388
update comments with ai
lakeesiv Jan 14, 2026
dfa018f
updates
lakeesiv Jan 14, 2026
22f89cf
comments
lakeesiv Jan 14, 2026
8f9cf93
changes
lakeesiv Jan 14, 2026
4422a69
revert
lakeesiv Jan 15, 2026
15bef48
updates
lakeesiv Jan 15, 2026
cfbc8d7
dedupe
lakeesiv Jan 15, 2026
b3ca0c9
updates
lakeesiv Jan 15, 2026
df3e869
updates
lakeesiv Jan 15, 2026
96a3fe5
updates
lakeesiv Jan 15, 2026
cbb93c6
refactoring
lakeesiv Jan 15, 2026
c9373c7
renames & refactors
lakeesiv Jan 15, 2026
b08ce03
refactoring
lakeesiv Jan 15, 2026
ffad20e
updates
lakeesiv Jan 15, 2026
793c888
undo
lakeesiv Jan 15, 2026
c3afbae
update db
lakeesiv Jan 15, 2026
5a69d16
wand
lakeesiv Jan 15, 2026
fdc3af9
updates
lakeesiv Jan 15, 2026
80270ce
fix comments
lakeesiv Jan 15, 2026
57fbd2a
fixes
lakeesiv Jan 15, 2026
7f894ec
simplify comments
lakeesiv Jan 15, 2026
ed543a7
u[dates
lakeesiv Jan 15, 2026
e503408
renames
lakeesiv Jan 15, 2026
0a6312d
better comments
lakeesiv Jan 16, 2026
4665595
validation
lakeesiv Jan 16, 2026
d00997c
updates
lakeesiv Jan 16, 2026
cfffd05
updates
lakeesiv Jan 16, 2026
1a13762
updates
lakeesiv Jan 16, 2026
4490996
fix sorting
lakeesiv Jan 16, 2026
fef2d2c
fix appearnce
lakeesiv Jan 16, 2026
c94bb5a
updating prompt to make it user sort
lakeesiv Jan 16, 2026
e695007
rm
lakeesiv Jan 16, 2026
a940dd6
updates
lakeesiv Jan 16, 2026
271375d
rename
lakeesiv Jan 16, 2026
26d9662
comments
lakeesiv Jan 16, 2026
5173320
clean comments
lakeesiv Jan 16, 2026
ea72ab5
simplicifcaiton
lakeesiv Jan 16, 2026
42aa794
updates
lakeesiv Jan 16, 2026
897891e
updates
lakeesiv Jan 16, 2026
7093209
refactor
lakeesiv Jan 16, 2026
2e624c2
reduced type confusion
lakeesiv Jan 16, 2026
f90c9c7
undo
lakeesiv Jan 16, 2026
abb671e
rename
lakeesiv Jan 16, 2026
448b8f0
undo changes
lakeesiv Jan 16, 2026
e4dd14d
undo
lakeesiv Jan 16, 2026
cca1772
simplify
lakeesiv Jan 16, 2026
86c5e1b
updates
lakeesiv Jan 16, 2026
94c6795
updates
lakeesiv Jan 16, 2026
3d81c1c
revert
lakeesiv Jan 16, 2026
51d1b95
updates
lakeesiv Jan 16, 2026
c662a31
db updates
lakeesiv Jan 16, 2026
e7f4516
type fix
lakeesiv Jan 16, 2026
4357230
fix
lakeesiv Jan 17, 2026
0e1133f
fix error handling
lakeesiv Jan 17, 2026
8955915
updates
lakeesiv Jan 17, 2026
ea77790
docs
lakeesiv Jan 17, 2026
292cd39
docs
lakeesiv Jan 17, 2026
118e4f6
updates
lakeesiv Jan 17, 2026
7ca628d
rename
lakeesiv Jan 17, 2026
37b50cb
dedupe
lakeesiv Jan 17, 2026
4b6de03
revert
lakeesiv Jan 17, 2026
e79e9e7
Merge origin/main into lakees/db
lakeesiv Jan 17, 2026
8574d66
uncook
lakeesiv Jan 17, 2026
d0c3c6a
updates
lakeesiv Jan 17, 2026
6e8dc77
fix
lakeesiv Jan 17, 2026
87f8fcd
fix
lakeesiv Jan 17, 2026
f05f5bb
fix
lakeesiv Jan 17, 2026
a8e413a
fix
lakeesiv Jan 17, 2026
107679b
prepare merge
icecrasher321 Jan 22, 2026
8d43947
Merge staging into lakees/db
icecrasher321 Jan 22, 2026
1f682eb
readd migrations
icecrasher321 Jan 22, 2026
2d49de7
add back missed code
icecrasher321 Jan 22, 2026
2818b74
migrate enrichment logic to general abstraction
icecrasher321 Jan 22, 2026
1938818
address bugbot concerns
icecrasher321 Jan 22, 2026
be757a4
adhere to size limits for tables
icecrasher321 Jan 22, 2026
d9dbe93
remove conflicting migration
icecrasher321 Feb 11, 2026
f0a8d82
Merge remote-tracking branch 'origin/staging' into lakees/db
icecrasher321 Feb 11, 2026
0ffcce8
add back migrations
icecrasher321 Feb 11, 2026
ca70280
fix tables auth
icecrasher321 Feb 11, 2026
8bf3370
fix permissive auth
icecrasher321 Feb 11, 2026
c4986a9
fix lint
icecrasher321 Feb 11, 2026
c18fbcf
Merge branch 'staging' into lakees/db
waleedlatif1 Feb 19, 2026
b476b8d
reran migrations
waleedlatif1 Feb 19, 2026
592dd46
migrate to use tanstack query for all server state
waleedlatif1 Feb 19, 2026
f1938f0
update table-selector
waleedlatif1 Feb 19, 2026
7b0e030
update names
waleedlatif1 Feb 19, 2026
407f9c7
added tables to permission groups, updated subblock types
waleedlatif1 Feb 19, 2026
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
Prev Previous commit
Next Next commit
updates
  • Loading branch information
lakeesiv committed Jan 17, 2026
commit df3e869f22d703d3a4f77e7cdb0131d1e1fb76fd
2 changes: 1 addition & 1 deletion apps/sim/app/api/table/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { z } from 'zod'
import { checkHybridAuth } from '@/lib/auth/hybrid'
import { generateRequestId } from '@/lib/core/utils/request'
import { TABLE_LIMITS, validateTableName, validateTableSchema } from '@/lib/table'
import type { TableSchema } from '@/lib/table/validation/validation'
import type { TableSchema } from '@/lib/table/validation/schema'
import type { TableColumnData, TableSchemaData } from './utils'

const logger = createLogger('TableAPI')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { useCallback, useMemo, useState } from 'react'
import { ArrowDownAZ, ArrowUpAZ, Plus, X } from 'lucide-react'
import { Button, Combobox, Input } from '@/components/emcn'
import type { FilterCondition } from '@/lib/table/filters/filter-constants'
import { useFilterBuilder } from '@/lib/table/filters/use-filter-builder'
import type { FilterCondition } from '@/lib/table/filters/constants'
import { useFilterBuilder } from '@/lib/table/filters/use-builder'

/**
* Represents a sort configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import { useEffect, useMemo, useRef, useState } from 'react'
import { Plus, X } from 'lucide-react'
import { Button, Combobox, type ComboboxOption, Input } from '@/components/emcn'
import { cn } from '@/lib/core/utils/cn'
import {
conditionsToJsonString,
jsonStringToConditions,
} from '@/lib/table/filters/filter-builder-utils'
import type { FilterCondition } from '@/lib/table/filters/filter-constants'
import { useFilterBuilder } from '@/lib/table/filters/use-filter-builder'
import { conditionsToJsonString, jsonStringToConditions } from '@/lib/table/filters/builder-utils'
import type { FilterCondition } from '@/lib/table/filters/constants'
import { useFilterBuilder } from '@/lib/table/filters/use-builder'
import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/formatted-text'
import { SubBlockInputController } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/sub-block-input-controller'
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Plus, X } from 'lucide-react'
import { nanoid } from 'nanoid'
import { Button, Combobox, type ComboboxOption } from '@/components/emcn'
import {
generateId,
jsonStringToSortConditions,
SORT_DIRECTIONS,
type SortCondition,
sortConditionsToJsonString,
} from '@/lib/table/filters/filter-builder-utils'
} from '@/lib/table/filters/builder-utils'
import { SORT_DIRECTIONS, type SortCondition } from '@/lib/table/filters/constants'
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'

interface SortFormatProps {
Expand All @@ -30,7 +29,7 @@ interface SortFormatProps {
* Creates a new sort condition with default values
*/
const createDefaultCondition = (columns: ComboboxOption[]): SortCondition => ({
id: generateId(),
id: nanoid(),
column: columns[0]?.value || '',
direction: 'asc',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AlertTriangle, Wand2 } from 'lucide-react'
import { Label, Tooltip } from '@/components/emcn/components'
import { Button } from '@/components/ui/button'
import { cn } from '@/lib/core/utils/cn'
import type { FilterCondition, SortCondition } from '@/lib/table/filters/filter-builder-utils'
import type { FilterCondition, SortCondition } from '@/lib/table/filters/constants'
import type { FieldDiffStatus } from '@/lib/workflows/diff/types'
import {
CheckboxList,
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/table.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TableIcon } from '@/components/icons'
import { conditionsToFilter, sortConditionsToSort } from '@/lib/table/filters/filter-builder-utils'
import { conditionsToFilter, sortConditionsToSort } from '@/lib/table/filters/builder-utils'
import type { BlockConfig } from '@/blocks/types'
import type { TableQueryResponse } from '@/tools/table/types'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
/**
* Shared utilities for filter builder UI components.
*
* @module lib/table/filters/filter-builder-utils
* @module lib/table/filters/builder-utils
*/

// Re-export shared constants and types for backward compatibility
export {
COMPARISON_OPERATORS,
type FilterCondition,
generateConditionId as generateId,
LOGICAL_OPERATORS,
SORT_DIRECTIONS,
type SortCondition,
} from './filter-constants'

// Import for internal use
import { type FilterCondition, generateConditionId, type SortCondition } from './filter-constants'

// Use internal alias for generateConditionId
const generateId = generateConditionId
import { nanoid } from 'nanoid'
import type { FilterCondition, SortCondition } from './constants'

type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }

Expand Down Expand Up @@ -141,7 +128,7 @@ function parseFilterGroup(group: Record<string, JsonValue>): FilterCondition[] {
for (const [op, opValue] of Object.entries(value)) {
if (op.startsWith('$')) {
conditions.push({
id: generateId(),
id: nanoid(),
logicalOperator: 'and',
column,
operator: op.substring(1),
Expand All @@ -151,7 +138,7 @@ function parseFilterGroup(group: Record<string, JsonValue>): FilterCondition[] {
}
} else {
conditions.push({
id: generateId(),
id: nanoid(),
logicalOperator: 'and',
column,
operator: 'eq',
Expand Down Expand Up @@ -234,7 +221,7 @@ export function sortToConditions(sort: Record<string, string> | null): SortCondi
if (!sort) return []

return Object.entries(sort).map(([column, direction]) => ({
id: generateId(),
id: nanoid(),
column,
direction: direction === 'desc' ? 'desc' : 'asc',
}))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Shared constants and types for table filtering and sorting.
*
* @module lib/table/filters/filter-constants
* @module lib/table/filters/constants
*
*/

Expand Down Expand Up @@ -68,13 +68,3 @@ export interface SortCondition {
/** Sort direction */
direction: 'asc' | 'desc'
}

/**
* Generates a unique ID for filter or sort conditions.
* Used as React keys for list items in builder UI.
*
* @returns Random alphanumeric string
*/
export function generateConditionId(): string {
return Math.random().toString(36).substring(2, 9)
}
6 changes: 3 additions & 3 deletions apps/sim/lib/table/filters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* @module lib/table/filters
*/

export * from './filter-builder-utils'
export * from './filter-constants'
export * from './use-filter-builder'
export * from './builder-utils'
export * from './constants'
export * from './use-builder'
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,37 @@
*
* Provides reusable filter condition management logic shared between
* the table data viewer's FilterBuilder and workflow block's FilterFormat.
*
* @module lib/table/filters/use-filter-builder
*/

import { useCallback, useMemo } from 'react'
import { nanoid } from 'nanoid'
import {
COMPARISON_OPERATORS,
type FilterCondition,
generateConditionId,
LOGICAL_OPERATORS,
SORT_DIRECTIONS,
type SortCondition,
} from './filter-constants'
} from './constants'

/**
* Column option for dropdowns.
*/
export interface ColumnOption {
value: string
label: string
}

/**
* Props for the useFilterBuilder hook.
*/
export interface UseFilterBuilderProps {
/** Available columns for filtering */
columns: ColumnOption[]
/** Current filter conditions */
conditions: FilterCondition[]
/** Setter function for updating conditions */
setConditions: (conditions: FilterCondition[]) => void
/** Whether the builder is read-only */
isReadOnly?: boolean
}

/**
* Return type for the useFilterBuilder hook.
*/
export interface UseFilterBuilderReturn {
/** Memoized comparison operator options */
comparisonOptions: ColumnOption[]
/** Memoized logical operator options */
logicalOptions: ColumnOption[]
/** Memoized sort direction options */
sortDirectionOptions: ColumnOption[]
/** Adds a new filter condition */
addCondition: () => void
/** Removes a filter condition by ID */
removeCondition: (id: string) => void
/** Updates a specific field of a condition */
updateCondition: (id: string, field: keyof FilterCondition, value: string) => void
/** Creates a default condition (for external use) */
createDefaultCondition: () => FilterCondition
}

Expand Down Expand Up @@ -97,7 +75,6 @@ export function useFilterBuilder({
setConditions,
isReadOnly = false,
}: UseFilterBuilderProps): UseFilterBuilderReturn {
// Memoized options for dropdowns
const comparisonOptions = useMemo(
() => COMPARISON_OPERATORS.map((op) => ({ value: op.value, label: op.label })),
[]
Expand All @@ -113,30 +90,21 @@ export function useFilterBuilder({
[]
)

/**
* Creates a new filter condition with default values.
*/
const createDefaultCondition = useCallback((): FilterCondition => {
return {
id: generateConditionId(),
id: nanoid(),
logicalOperator: 'and',
column: columns[0]?.value || '',
operator: 'eq',
value: '',
}
}, [columns])

/**
* Adds a new filter condition.
*/
const addCondition = useCallback(() => {
if (isReadOnly) return
setConditions([...conditions, createDefaultCondition()])
}, [isReadOnly, conditions, setConditions, createDefaultCondition])

/**
* Removes a filter condition by ID.
*/
const removeCondition = useCallback(
(id: string) => {
if (isReadOnly) return
Expand All @@ -145,9 +113,6 @@ export function useFilterBuilder({
[isReadOnly, conditions, setConditions]
)

/**
* Updates a specific field of a condition.
*/
const updateCondition = useCallback(
(id: string, field: keyof FilterCondition, value: string) => {
if (isReadOnly) return
Expand All @@ -167,31 +132,17 @@ export function useFilterBuilder({
}
}

/**
* Props for sort configuration management.
*/
export interface UseSortBuilderProps {
/** Available columns for sorting */
columns: ColumnOption[]
/** Current sort condition */
sortCondition: SortCondition | null
/** Setter function for updating sort */
setSortCondition: (sort: SortCondition | null) => void
}

/**
* Return type for the useSortBuilder hook.
*/
export interface UseSortBuilderReturn {
/** Memoized sort direction options */
sortDirectionOptions: ColumnOption[]
/** Adds a sort configuration */
addSort: () => void
/** Removes the sort configuration */
removeSort: () => void
/** Updates the sort column */
updateSortColumn: (column: string) => void
/** Updates the sort direction */
updateSortDirection: (direction: 'asc' | 'desc') => void
}

Expand Down Expand Up @@ -221,7 +172,7 @@ export function useSortBuilder({

const addSort = useCallback(() => {
setSortCondition({
id: generateConditionId(),
id: nanoid(),
column: columns[0]?.value || '',
direction: 'asc',
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
* These helpers consolidate common validation patterns (size, schema, uniqueness)
* into reusable functions that return formatted error responses.
*
* @module lib/table/validation/validation-helpers
* @module lib/table/validation/helpers
*/

import { db } from '@sim/db'
import { userTableRows } from '@sim/db/schema'
import { eq } from 'drizzle-orm'
import { NextResponse } from 'next/server'
import type { TableSchema } from './validation'
import type { TableSchema } from './schema'
import {
getUniqueColumns,
validateRowAgainstSchema,
validateRowSize,
validateUniqueConstraints,
} from './validation'
} from './schema'

/**
* Row data type for validation functions.
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/lib/table/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* @module lib/table/validation
*/

export * from './validation'
export * from './validation-helpers'
export * from './helpers'
export * from './schema'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Validation utilities for table schemas and row data.
*
* @module lib/table/validation/validation
* @module lib/table/validation/schema
*/

import type { ColumnType } from '../constants'
Expand Down