mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 16:19:10 +03:00
* feat: add https auth hook support * fix: commit changes * fix: add enterprise hook config * fix: add descriptionText * Revert the changes to the ui components. * Refactor the whole hooks page into a table with adding/editing hook in a side panel. * Dele te unused file. * Rename all web strings to HTTPS. * Put all fields in the hook card in a copyable and revealable input. * Start nudges * Nudges * Add validation for both types of hooks. * Reorganize the layouts for the both types of hooks. * Move the button for enabling a hook in the side panel. * Move the button for deleting a hook in the side panel. * Minor redesign of the hook card. * Add a link to upgrade to enterprise. * Fix type errors. * Simplify function selector. * Add checked prop to the toggle. * Wait when deleting a hook. * Use the new RadioGroup. * Add a flag for https hooks. * Minor CSS fixes. * Change the page to use scaffold containers. * Minor fixes. * Convert the description to markdown. Fix. the generate secret onClick handler. --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> Co-authored-by: Terry Sutton <saltcod@gmail.com>
30 lines
800 B
TypeScript
30 lines
800 B
TypeScript
import { Hook } from './hooks.constants'
|
|
|
|
export const extractMethod = (
|
|
uri: string,
|
|
secret?: string
|
|
):
|
|
| { type: 'postgres'; schema: string; functionName: string }
|
|
| { type: 'https'; url: string; secret: string } => {
|
|
if (uri.startsWith('https')) {
|
|
return { type: 'https', url: uri, secret: secret || '' }
|
|
} else {
|
|
const [_proto, _x, _db, schema, functionName] = (uri || '').split('/')
|
|
|
|
return {
|
|
type: 'postgres',
|
|
schema: schema || '',
|
|
functionName: functionName || '',
|
|
}
|
|
}
|
|
}
|
|
|
|
export const isValidHook = (h: Hook) => {
|
|
return (
|
|
(h.method.type === 'postgres' &&
|
|
h.method.schema.length > 0 &&
|
|
h.method.functionName.length > 0) ||
|
|
(h.method.type === 'https' && h.method.url.startsWith('https') && h.method.secret.length > 0)
|
|
)
|
|
}
|