Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions apps/cms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@payloadcms/admin-bar": "^3.74.0",
"@payloadcms/db-postgres": "^3.74.0",
"@payloadcms/live-preview-react": "^3.74.0",
"@payloadcms/admin-bar": "^3.52.0",
"@payloadcms/db-postgres": "^3.73.0",
"@payloadcms/live-preview-react": "^3.52.0",
"@payloadcms/next": "3.52.0",
"@payloadcms/payload-cloud": "3.60.0",
"@payloadcms/plugin-form-builder": "3.52.0",
Expand Down
8 changes: 4 additions & 4 deletions apps/docs/app/api/ai/docs/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { SupabaseClient } from '@supabase/supabase-js'
import { ApplicationError, clippy, UserError } from 'ai-commands/edge'
import { isFeatureEnabled } from 'common/enabled-features'
import { ApplicationError, UserError, clippy } from 'ai-commands/edge'
import { NextRequest, NextResponse } from 'next/server'
import OpenAI from 'openai'

import { isFeatureEnabled } from 'common/enabled-features'

export const runtime = 'edge'
/* To avoid OpenAI errors, restrict to the Vercel Edge Function regions that
overlap with the OpenAI API regions.
Expand Down Expand Up @@ -56,8 +57,7 @@ export async function POST(req: NextRequest) {
}

const useAltSearchIndex = !isFeatureEnabled('search:fullIndex')
// @ts-ignore: We have 6 version of openai and the types are not compatible with each other, we need to consolidate to one
const response = await clippy(openai as any, supabaseClient, messages, {
const response = await clippy(openai, supabaseClient, messages, {
useAltSearchIndex,
})

Expand Down
25 changes: 10 additions & 15 deletions apps/studio/.github/eslint-rule-baselines.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"rules": {
"react-hooks/exhaustive-deps": 216,
"react-hooks/exhaustive-deps": 213,
"import/no-anonymous-default-export": 57,
"@tanstack/query/exhaustive-deps": 14,
"@typescript-eslint/no-explicit-any": 1261
"@tanstack/query/exhaustive-deps": 13,
"@typescript-eslint/no-explicit-any": 1231
},
"ruleFiles": {
"react-hooks/exhaustive-deps": {
Expand Down Expand Up @@ -38,12 +38,11 @@
"components/interfaces/Billing/Payment/AddNewPaymentMethodModal.tsx": 1,
"components/interfaces/Billing/Payment/PaymentConfirmation.tsx": 1,
"components/interfaces/Billing/Payment/PaymentMethods/NewPaymentMethodElement.tsx": 2,
"components/interfaces/BranchManagement/EditBranchModal.tsx": 2,
"components/interfaces/Connect/DatabaseConnectionString.tsx": 2,
"components/interfaces/Database/Backups/PITR/TimeInput.tsx": 4,
"components/interfaces/Database/EnumeratedTypes/CreateEnumeratedTypeSidePanel.tsx": 1,
"components/interfaces/Database/Extensions/EnableExtensionModal.tsx": 1,
"components/interfaces/Database/Indexes/Indexes.tsx": 2,
"components/interfaces/Database/Replication/ReplicationDiagram/index.tsx": 1,
"components/interfaces/Database/Schemas/SchemaGraph.tsx": 1,
"components/interfaces/DiskManagement/DiskManagementForm.tsx": 1,
"components/interfaces/Functions/EdgeFunctionDetails/EdgeFunctionDetails.tsx": 1,
Expand All @@ -54,6 +53,8 @@
"components/interfaces/Integrations/Queues/SingleQueue/SendMessageModal.tsx": 1,
"components/interfaces/Integrations/Wrappers/WrapperDynamicColumns.tsx": 1,
"components/interfaces/Integrations/templates/StripeSyncEngine/InstallationOverview.tsx": 1,
"components/interfaces/Observability/DatabaseInfrastructureSection.tsx": 1,
"components/interfaces/Observability/useSlowQueriesCount.ts": 1,
"components/interfaces/Organization/BillingSettings/BillingCustomerData/useBillingCustomerDataForm.ts": 1,
"components/interfaces/Organization/BillingSettings/BillingEmail.tsx": 1,
"components/interfaces/Organization/BillingSettings/CreditTopUp.tsx": 1,
Expand Down Expand Up @@ -126,6 +127,7 @@
"components/ui/DatePicker/TimeSplitInput.tsx": 1,
"components/ui/DateRangePicker.tsx": 1,
"components/ui/Error.tsx": 1,
"components/ui/FileExplorerAndEditor/index.tsx": 1,
"components/ui/FilterPopover.tsx": 1,
"components/ui/ScrollGradient.tsx": 1,
"data/__templates/resource-query.ts": 1,
Expand All @@ -140,9 +142,9 @@
"hooks/branches/useEdgeFunctionsDiff.ts": 1,
"hooks/misc/useReportDateRange.ts": 1,
"hooks/misc/useSchemaQueryState.ts": 1,
"hooks/misc/useTrackExperimentExposure.ts": 1,
"hooks/misc/useUpgradePrompt.tsx": 1,
"hooks/ui/useCsvFileDrop.ts": 1,
"hooks/ui/useHotKey.ts": 2,
"pages/forgot-password-mfa.tsx": 1,
"pages/integrations/vercel/[slug]/deploy-button/new-project.tsx": 1,
"pages/integrations/vercel/install.tsx": 1,
Expand Down Expand Up @@ -230,7 +232,6 @@
"data/database/foreign-key-constraints-query.ts": 1,
"data/database/schemas-query.ts": 1,
"data/entity-types/entity-types-infinite-query.ts": 1,
"data/table-editor/table-editor-query.ts": 1,
"data/table-rows/table-rows-query.ts": 1,
"data/tables/tables-query.ts": 2,
"hooks/analytics/useDbQuery.tsx": 1,
Expand All @@ -248,7 +249,6 @@
"components/grid/components/formatter/ReferenceRecordPeek.tsx": 4,
"components/grid/components/grid/AddColumn.tsx": 2,
"components/grid/components/grid/Grid.utils.tsx": 2,
"components/grid/components/grid/GridError.tsx": 4,
"components/grid/components/grid/SelectColumn.tsx": 3,
"components/grid/components/header/Header.utils.ts": 1,
"components/grid/components/header/sort/SortRow.tsx": 1,
Expand Down Expand Up @@ -306,12 +306,8 @@
"components/interfaces/Database/EnumeratedTypes/DeleteEnumeratedTypeModal.tsx": 1,
"components/interfaces/Database/EnumeratedTypes/EditEnumeratedTypeSidePanel.tsx": 2,
"components/interfaces/Database/EnumeratedTypes/EnumeratedTypeValueRow.tsx": 1,
"components/interfaces/Database/Extensions/EnableExtensionModal.tsx": 4,
"components/interfaces/Database/Functions/CreateFunction/FunctionEditor.tsx": 1,
"components/interfaces/Database/Functions/FunctionsList/FunctionList.tsx": 3,
"components/interfaces/Database/Hooks/EditHookPanel.tsx": 9,
"components/interfaces/Database/Hooks/FormContents.tsx": 5,
"components/interfaces/Database/Hooks/HTTPRequestFields.tsx": 6,
"components/interfaces/Database/Hooks/HooksList/HooksList.tsx": 2,
"components/interfaces/Database/Indexes/Indexes.tsx": 1,
"components/interfaces/Database/Migrations/Migrations.tsx": 2,
Expand All @@ -327,7 +323,6 @@
"components/interfaces/Database/Roles/RolesList.tsx": 1,
"components/interfaces/Database/Schemas/SchemaGraph.tsx": 1,
"components/interfaces/Database/Tables/ColumnList.tsx": 2,
"components/interfaces/DiskManagement/DiskManagement.utils.ts": 3,
"components/interfaces/Docs/Description.tsx": 2,
"components/interfaces/Docs/GeneratingTypes.tsx": 1,
"components/interfaces/Docs/Param.tsx": 1,
Expand Down Expand Up @@ -379,7 +374,7 @@
"components/interfaces/Organization/GeneralSettings/DeleteOrganizationButton.tsx": 3,
"components/interfaces/Organization/IntegrationSettings/IntegrationSettings.tsx": 1,
"components/interfaces/Organization/IntegrationSettings/SidePanelVercelProjectLinker.tsx": 1,
"components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx": 1,
"components/interfaces/Organization/InvoicesSettings/InvoicesSettings.tsx": 2,
"components/interfaces/Organization/OAuthApps/PublishAppSidePanel/index.tsx": 9,
"components/interfaces/Organization/ProjectClaim/confirm.tsx": 1,
"components/interfaces/Organization/TeamSettings/MemberRow.tsx": 2,
Expand Down Expand Up @@ -617,7 +612,6 @@
"data/analytics/functions-resource-usage-query.ts": 1,
"data/analytics/infra-monitoring-query.ts": 1,
"data/analytics/project-daily-stats-queries.ts": 1,
"data/api-settings/create-and-expose-api-schema-mutation.ts": 1,
"data/auth/auth-overview-query.ts": 1,
"data/auth/session-access-token-query.ts": 1,
"data/config/project-disk-resize-mutation.ts": 1,
Expand Down Expand Up @@ -692,6 +686,7 @@
"hooks/analytics/useSingleLog.tsx": 1,
"hooks/analytics/useTimeseriesUnixToIso.ts": 1,
"hooks/branches/useBranchMergeDiff.ts": 3,
"hooks/misc/useTrackExperimentExposure.ts": 1,
"hooks/misc/withAuth.tsx": 1,
"hooks/ui/useClickedOutside.ts": 2,
"hooks/ui/useFlag.ts": 1,
Expand Down
11 changes: 11 additions & 0 deletions apps/studio/components/grid/hooks/useFilterLifeCycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ export function useSyncFiltersToUrl() {
const snap = useTableEditorTableStateSnapshot()
const { setParams } = useTableEditorFiltersSort()
const timeoutRef = useRef<NodeJS.Timeout | null>(null)
const previousFiltersRef = useRef<string>('')

useEffect(() => {
// Serialize filters for comparison
const currentFiltersStr = JSON.stringify(snap.filters)

// Only proceed if filters have actually changed
if (currentFiltersStr === previousFiltersRef.current) {
return
}

previousFiltersRef.current = currentFiltersStr

// Clear any existing timeout
if (timeoutRef.current) {
clearTimeout(timeoutRef.current)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { components } from 'api-types'
import { permissions } from '@supabase/shared-types'

export type ScopedAccessTokenPermission =
components['schemas']['CreateScopedAccessTokenBody']['permissions'][number]

export const NON_EXPIRING_TOKEN_VALUE = 'never'
export const CUSTOM_EXPIRY_VALUE = 'custom'

export const EXPIRES_AT_OPTIONS = {
hour: { value: 'hour', label: '1 hour' },
day: { value: 'day', label: '1 day' },
week: { value: 'week', label: '7 days' },
month: { value: 'month', label: '30 days' },
never: { value: NON_EXPIRING_TOKEN_VALUE, label: 'Never' },
custom: { value: CUSTOM_EXPIRY_VALUE, label: 'Custom' },
} as const

const FGA = permissions.FgaPermissions

const getAction = (key: string): string => {
if (key.endsWith('_READ')) return 'read'
if (key.endsWith('_WRITE')) return 'write'
if (key.endsWith('_CREATE')) return 'create'
if (key.endsWith('_DELETE')) return 'delete'
return 'read'
}

const getResource = (key: string): string => {
return key.replace(/_(READ|WRITE|CREATE|DELETE)$/, '').toLowerCase()
}

const buildPermissionList = () => {
const list: Array<{
scope: string
resource: string
action: string
id: string
title: string
}> = []

for (const [scope, scopePerms] of Object.entries(FGA)) {
for (const [key, perm] of Object.entries(scopePerms)) {
list.push({
scope: scope.toLowerCase(),
resource: getResource(key),
action: getAction(key),
id: perm.id,
title: perm.title,
})
}
}

return list
}

export const PERMISSION_LIST = buildPermissionList()

export const ACCESS_TOKEN_RESOURCES = (() => {
const resourceMap = new Map<string, { resource: string; title: string; actions: string[] }>()

for (const p of PERMISSION_LIST) {
const key = `${p.scope}:${p.resource}`
if (!resourceMap.has(key)) {
const cleanTitle = p.title.replace(/^(Read|Manage|Create|Delete)\s+/i, '')
resourceMap.set(key, { resource: key, title: cleanTitle, actions: [] })
}
const entry = resourceMap.get(key)!
if (!entry.actions.includes(p.action)) {
entry.actions.push(p.action)
}
}

return Array.from(resourceMap.values())
})()
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { z } from 'zod'

export const PermissionRowSchema = z.object({
resource: z.string().min(1, 'Please select a resource'),
actions: z.array(z.string()).min(1, 'Please select at least one action'),
})

export const TokenSchema = z
.object({
tokenName: z.string().min(1, 'Please enter a name for the token'),
expiresAt: z.preprocess((val) => (val === 'never' ? undefined : val), z.string().optional()),
customExpiryDate: z.string().optional(),
resourceAccess: z.enum(['all-orgs', 'selected-orgs', 'selected-projects']),
selectedOrganizations: z.array(z.string()).optional(),
selectedProjects: z.array(z.string()).optional(),
permissionRows: z.array(PermissionRowSchema).min(1, 'Please configure at least one permission'),
})
.refine((data) => !(data.expiresAt === 'custom' && !data.customExpiryDate), {
message: 'Please select a custom expiry date',
path: ['expiresAt'],
})

export type TokenFormValues = z.infer<typeof TokenSchema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export const ACCESS_TOKEN_SORT_VALUES = [
'created_at:asc',
'created_at:desc',
'last_used_at:asc',
'last_used_at:desc',
'expires_at:asc',
'expires_at:desc',
] as const

export type AccessTokenSort = (typeof ACCESS_TOKEN_SORT_VALUES)[number]
export type AccessTokenSortColumn = AccessTokenSort extends `${infer Column}:${string}`
? Column
: never
export type AccessTokenSortOrder = AccessTokenSort extends `${string}:${infer Order}`
? Order
: never

export interface BaseToken {
id: string | number
name: string
token_alias: string
created_at: string
last_used_at?: string | null
expires_at?: string | null
}
Loading
Loading