From c8aae043b641fa535fcfb42735671c235fa3e178 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Tue, 19 Sep 2023 16:46:48 +0800 Subject: [PATCH 1/2] Revert API docs snippets changes --- studio/components/interfaces/Docs/Snippets.ts | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/studio/components/interfaces/Docs/Snippets.ts b/studio/components/interfaces/Docs/Snippets.ts index e8d6e8d676b..44aa501ec92 100644 --- a/studio/components/interfaces/Docs/Snippets.ts +++ b/studio/components/interfaces/Docs/Snippets.ts @@ -56,27 +56,28 @@ Future main() async { }`, }, }), - authKey: (title: string, varName: string, apiKey: string) => ({ + authKey: (title: string, varName: string, apikey: string) => ({ title: `${title}`, bash: { language: 'bash', - code: `${apiKey}`, + code: `${apikey}`, }, js: { language: 'js', - code: `const ${varName} = '${apiKey}'`, + code: `const ${varName} = '${apikey}'`, }, }), authKeyExample: ( defaultApiKey: string, endpoint: string, - { keyName, showBearer = true }: { keyName?: string; showBearer?: boolean } + { keyName, showBearer = true }: { keyName: string; showBearer: boolean } ) => ({ title: 'Example usage', bash: { language: 'bash', code: ` -curl '${endpoint}/rest/v1/' ${ +curl '${endpoint}/rest/v1/' \\ +-H "apikey: ${defaultApiKey}" ${ showBearer ? `\\ -H "Authorization: Bearer ${defaultApiKey}"` @@ -125,7 +126,8 @@ const supabase = createClient(SUPABASE_URL, process.env.${keyName || 'SUPABASE_K language: 'bash', code: ` curl -X POST '${endpoint}/rest/v1/rpc/${rpcName}' \\${bashParams} --H "Content-Type: application/json" ${ +-H "Content-Type: application/json" \\ +-H "apikey: ${apiKey}" ${ showBearer ? `\\ -H "Authorization: Bearer ${apiKey}"` @@ -251,6 +253,7 @@ const ${listenerName} = supabase.channel('custom-filter-channel') language: 'bash', code: ` curl '${endpoint}/rest/v1/${resourceId}?select=*' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" `, }, @@ -281,6 +284,7 @@ let { data: ${resourceId}, error } = await supabase language: 'bash', code: ` curl '${endpoint}/rest/v1/${resourceId}?select=${columnName}' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" `, }, @@ -299,6 +303,7 @@ let { data: ${resourceId}, error } = await supabase language: 'bash', code: ` curl '${endpoint}/rest/v1/${resourceId}?select=some_column,other_table(foreign_key)' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" `, }, @@ -322,6 +327,7 @@ let { data: ${resourceId}, error } = await supabase language: 'bash', code: ` curl '${endpoint}/rest/v1/${resourceId}?select=*' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" \\ -H "Range: 0-9" `, @@ -342,6 +348,7 @@ let { data: ${resourceId}, error } = await supabase language: 'bash', code: ` curl '${endpoint}/rest/v1/${resourceId}?id=eq.1&select=*' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" \\ -H "Range: 0-9" `, @@ -378,6 +385,7 @@ let { data: ${resourceId}, error } = await supabase language: 'bash', code: ` curl -X POST '${endpoint}/rest/v1/${resourceId}' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" \\ -H "Content-Type: application/json" \\ -H "Prefer: return=minimal" \\ @@ -402,6 +410,7 @@ const { data, error } = await supabase language: 'bash', code: ` curl -X POST '${endpoint}/rest/v1/${resourceId}' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '[{ "some_column": "someValue" }, { "other_column": "otherValue" }]' @@ -426,6 +435,7 @@ const { data, error } = await supabase language: 'bash', code: ` curl -X POST '${endpoint}/rest/v1/${resourceId}' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" \\ -H "Content-Type: application/json" \\ -H "Prefer: resolution=merge-duplicates" \\ @@ -448,6 +458,7 @@ const { data, error } = await supabase language: 'bash', code: ` curl -X PATCH '${endpoint}/rest/v1/${resourceId}?some_column=eq.someValue' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" \\ -H "Content-Type: application/json" \\ -H "Prefer: return=minimal" \\ @@ -471,6 +482,7 @@ const { data, error } = await supabase language: 'bash', code: ` curl -X DELETE '${endpoint}/rest/v1/${resourceId}?some_column=eq.someValue' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" `, }, @@ -490,6 +502,7 @@ const { error } = await supabase language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/signup' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ "email": "someone@email.com", @@ -513,6 +526,7 @@ let { data, error } = await supabase.auth.signUp({ language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/token?grant_type=password' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ "email": "someone@email.com", @@ -536,6 +550,7 @@ let { data, error } = await supabase.auth.signInWithPassword({ language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/magiclink' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ "email": "someone@email.com" @@ -557,6 +572,7 @@ let { data, error } = await supabase.auth.signInWithOtp({ language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/signup' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ "phone": "+13334445555", @@ -580,6 +596,7 @@ let { data, error } = await supabase.auth.signUp({ language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/otp' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ "phone": "+13334445555" @@ -601,6 +618,7 @@ let { data, error } = await supabase.auth.signInWithOtp({ language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/verify' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ "type": "sms", @@ -626,6 +644,7 @@ let { data, error } = await supabase.auth.verifyOtp({ language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/invite' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ @@ -661,6 +680,7 @@ let { data, error } = await supabase.auth.signInWithOAuth({ language: 'bash', code: ` curl -X GET '${endpoint}/auth/v1/user' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer USER_TOKEN" `, }, @@ -677,6 +697,7 @@ const { data: { user } } = await supabase.auth.getUser() language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/recover' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -d '{ "email": "someone@email.com" @@ -696,6 +717,7 @@ let { data, error } = await supabase.auth.resetPasswordForEmail(email) language: 'bash', code: ` curl -X PUT '${endpoint}/auth/v1/user' \\ +-H "apikey: ${apiKey}" \\ -H "Authorization: Bearer " \\ -H "Content-Type: application/json" \\ -d '{ @@ -724,6 +746,7 @@ const { data, error } = await supabase.auth.updateUser({ language: 'bash', code: ` curl -X POST '${endpoint}/auth/v1/logout' \\ +-H "apikey: ${apiKey}" \\ -H "Content-Type: application/json" \\ -H "Authorization: Bearer USER_TOKEN" `, From 251869b3ec901816c8b7a49881395d61ed228b85 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Tue, 19 Sep 2023 16:50:06 +0800 Subject: [PATCH 2/2] Fix --- studio/components/interfaces/Docs/Snippets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/studio/components/interfaces/Docs/Snippets.ts b/studio/components/interfaces/Docs/Snippets.ts index 44aa501ec92..f6f60556c19 100644 --- a/studio/components/interfaces/Docs/Snippets.ts +++ b/studio/components/interfaces/Docs/Snippets.ts @@ -70,7 +70,7 @@ Future main() async { authKeyExample: ( defaultApiKey: string, endpoint: string, - { keyName, showBearer = true }: { keyName: string; showBearer: boolean } + { keyName, showBearer = true }: { keyName?: string; showBearer?: boolean } ) => ({ title: 'Example usage', bash: {