mirror of
https://github.com/supabase/supabase.git
synced 2026-07-03 10:14:22 +08:00
* Add hooks for async protected schemas. * Migrate the ProtectedSchemaWarning to support the new implementation. * sq * Migrate all uses of protected schemas to the new approach. * Delete extra file. * Refactor the import foreign schema dialog to forbid protected and exposed schemas. * Add the type to the protected schema. * Revert ImportForeignSchemaDialog, it'll be addressed in another PR. * Update apps/studio/hooks/useProtectedSchemas.ts Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Fix a bad commit. * Minor fixes. * Fix the FDW delete mutation to handle names with numbers. * Simplify the logic to skip a fetch. * Minor fixes. * Make the useIcebergFdwSchemasQuery work for all iceberg FDWs. * Fix the tab schemas to always show in the Table Editor. * Apply suggestion from @joshenlim Co-authored-by: Joshen Lim <joshenlimek@gmail.com> * Fix a minor typo. * Refactor ProtectedSchemaWarning to use Admonition, and standardise input field for target schema iceberg --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { type FDW } from 'data/fdw/fdws-query'
|
|
import { getDecryptedValues } from 'data/vault/vault-secret-decrypted-value-query'
|
|
import { INTEGRATIONS } from '../Integrations/Landing/Integrations.constants'
|
|
import { WrapperMeta } from '../Integrations/Wrappers/Wrappers.types'
|
|
import { convertKVStringArrayToJson } from '../Integrations/Wrappers/Wrappers.utils'
|
|
|
|
export const getDecryptedParameters = async ({
|
|
ref,
|
|
connectionString,
|
|
wrapper,
|
|
}: {
|
|
ref?: string
|
|
connectionString?: string
|
|
wrapper: FDW
|
|
}) => {
|
|
const integration = INTEGRATIONS.find((i) => i.id === 'iceberg_wrapper' && i.type === 'wrapper')
|
|
const wrapperMeta = (integration?.type === 'wrapper' && integration.meta) as WrapperMeta
|
|
const wrapperServerOptions = wrapperMeta.server.options
|
|
|
|
const serverOptions = convertKVStringArrayToJson(wrapper?.server_options ?? [])
|
|
|
|
const paramsToBeDecrypted = Object.fromEntries(
|
|
new Map(
|
|
Object.entries(serverOptions).filter(([key, value]) => {
|
|
return wrapperServerOptions.find((option) => option.name === key)?.encrypted
|
|
})
|
|
)
|
|
)
|
|
|
|
const decryptedValues = await getDecryptedValues({
|
|
projectRef: ref,
|
|
connectionString: connectionString,
|
|
ids: Object.values(paramsToBeDecrypted),
|
|
})
|
|
|
|
const paramsWithDecryptedValues = Object.fromEntries(
|
|
new Map(
|
|
Object.entries(paramsToBeDecrypted).map(([name, id]) => {
|
|
const decryptedValue = decryptedValues[id]
|
|
return [name, decryptedValue]
|
|
})
|
|
)
|
|
)
|
|
|
|
return {
|
|
...serverOptions,
|
|
...paramsWithDecryptedValues,
|
|
}
|
|
}
|