-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move from raw SQL access to GraphQL / REST api for now (#40)
* [GraphiQL] Stub in new UI (left old one for now) * [SQL] Stub in "contact us" page for now * [SQL] Updated button icon to be email * [GraphiQL] Update styling & themes * [GraphiQL] Remove title area * [APIs] Add back "Query API" * [Integrations] Add settings button * [Integrations] Plaid settings page * [Integrations] Disable plaid settings for now * [Nav] Ensure nested routes highlight side nav * localStorage.DISABLE_ZOD_FORM_FOR_NOW = true to bypass the zod form * Update view definition to work better with graphql * Hook up graphql editor with the right headers * Experimental rest API explorer via stoplight elements * Moving to the new api-access page * Persist active tab into the query param * Ensure default ledger no longer depends on createDatabaseUser * Renaming old and new api access pages * Add realtime api also * Remove redundant prefix * [API] Tweaks * [Rest] Comment out import since it pollutes global CSS Even without the page loaded into another page * [API] Comment old page for now * [API] Remove Rest explorer for now * [Export] Remove & style sandbox labels * [SQL] Remove old access page for now * [Plaid] Disable preconnect input for now * [Connections] Tweak UI to be easier to read * [API] Show API keys & routes in first tab * [API] Move REST api docs to their own page * [API docs] Punch out to view REST api docs full page * Implement proxy for graphql and rest requests against supabase * [REST] Make docs use dark mode * [REST] Set info section to override Postgres API name * Handle apiKey as well during request proxy * Fix joinPath and add more tests * Use personal access token in the api explorer * Remove token param when proxying * Hooking up the api access page with the correct token * Do not pass the header onwards * Create personal access token if needed * Removing sql endpoint and no more database end user also * Add migration to remove existing database users * Fix migration on vanilla postgres * Declare auth_user as record to make vanilla migration pass * Actually fix migration test * Hide the migrations table from api * Backing up a couple functions we no longer use * Fix ci again, we should use the supabase postgres image --------- Co-authored-by: Rob Phillips <[email protected]>
- Loading branch information
1 parent
1c5750d
commit 2184174
Showing
56 changed files
with
3,908 additions
and
1,199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apps/cli/admin-queries/2023-02-27_1710 json and plv8 test.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
CREATE OR REPLACE FUNCTION public.xjsonb_object_keys(obj jsonb) | ||
RETURNS text[] | ||
LANGUAGE plv8 | ||
IMMUTABLE STRICT | ||
AS $function$ | ||
return Object.keys(obj); | ||
$function$ | ||
|
||
CREATE OR REPLACE FUNCTION public.jsonb_object_keys_to_text_array(_js jsonb) | ||
RETURNS text[] | ||
LANGUAGE sql | ||
IMMUTABLE PARALLEL SAFE STRICT | ||
AS $function$SELECT ARRAY(SELECT jsonb_object_keys(_js))$function$ | ||
|
||
CREATE OR REPLACE FUNCTION public.plv8_test(keys text[], vals text[]) | ||
RETURNS json | ||
LANGUAGE plv8 | ||
IMMUTABLE STRICT | ||
AS $function$ | ||
var o = {}; | ||
for(var i=0; i<keys.length; i++){ | ||
o[keys[i]] = vals[i]; | ||
} | ||
return o; | ||
$function$ | ||
|
||
|
||
CREATE OR REPLACE FUNCTION public.jsonb_array_to_text_array(_js jsonb) | ||
RETURNS text[] | ||
LANGUAGE sql | ||
IMMUTABLE PARALLEL SAFE STRICT | ||
AS $function$SELECT ARRAY(SELECT jsonb_array_elements_text(_js))$function$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- Create user | ||
CREATE USER "usr_deca735c-a043-4394-b12d-33e4b3717a83" PASSWORD "key_test"; | ||
GRANT "usr_deca735c-a043-4394-b12d-33e4b3717a83" TO "postgres"; | ||
GRANT USAGE ON SCHEMA public TO "usr_deca735c-a043-4394-b12d-33e4b3717a83"; | ||
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO "usr_deca735c-a043-4394-b12d-33e4b3717a83"; | ||
REVOKE ALL PRIVILEGES ON public.migrations FROM "usr_deca735c-a043-4394-b12d-33e4b3717a83"; | ||
REVOKE ALL PRIVILEGES ON public.integration FROM "usr_deca735c-a043-4394-b12d-33e4b3717a83"; | ||
UPDATE auth.users SET raw_user_meta_data = raw_user_meta_data || 'key_test' WHERE id = 'deca735c-a043-4394-b12d-33e4b3717a83'; | ||
|
||
-- Drop user | ||
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM "usr_deca735c-a043-4394-b12d-33e4b3717a83"; | ||
REVOKE USAGE ON SCHEMA public FROM "usr_deca735c-a043-4394-b12d-33e4b3717a83"; | ||
DROP USER "usr_deca735c-a043-4394-b12d-33e4b3717a83"; | ||
UPDATE auth.users SET raw_user_meta_data = raw_user_meta_data - 'apiKey' WHERE id = ${userId}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
drop schema graphile_worker CASCADE; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
REVOKE ALL ON pg_catalog.pg_user FROM public; | ||
-- This will prevent user from being able to query for the existance of other users. | ||
-- TODO: What other permissions does the `public` role have that they shouldn't have in this context? | ||
|
||
|
||
-- TODO: We ran this query on dev postgres accidentally, how do we revert it back? | ||
|
||
|
||
SELECT grantee, privilege_type | ||
FROM information_schema.role_table_grants | ||
WHERE table_name='pg_user'; | ||
|
||
SELECT | ||
* | ||
FROM | ||
information_schema.table_privileges | ||
WHERE | ||
grantee = 'PUBLIC' and "table_name" = 'pg_user'; | ||
|
||
select * from pg_shadow; | ||
|
||
grant select on pg_catalog.pg_user to public; | ||
|
||
|
||
SELECT * | ||
FROM pg_default_acl; | ||
|
||
select * from pg_authid; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {createGraphiQLFetcher} from '@graphiql/toolkit' | ||
import {graphqlEndpoint, xPatHeaderKey} from '@usevenice/app-config/constants' | ||
import {useConstant} from '@usevenice/ui' | ||
import {GraphiQL} from 'graphiql' | ||
import 'graphiql/graphiql.css' | ||
import React from 'react' | ||
|
||
export function GraphQLExplorer({pat}: {pat: string}) { | ||
const fetcher = useConstant(() => | ||
createGraphiQLFetcher({url: graphqlEndpoint.pathname}), | ||
) | ||
const headersString = React.useMemo( | ||
() => JSON.stringify({[xPatHeaderKey]: pat}, null, 4), | ||
[pat], | ||
) | ||
|
||
return ( | ||
<div className="grow"> | ||
<GraphiQL | ||
fetcher={fetcher} | ||
defaultHeaders={headersString} | ||
defaultQuery={`{ | ||
transactionCollection { | ||
edges { | ||
node{ | ||
id | ||
description | ||
amountUnit | ||
amountQuantity | ||
account { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
} | ||
}`}> | ||
<GraphiQL.Logo> | ||
<div /> | ||
</GraphiQL.Logo> | ||
</GraphiQL> | ||
</div> | ||
) | ||
} |
83 changes: 0 additions & 83 deletions
83
apps/web/components/api-access/VeniceDatabaseExplorer/QueryOutput/ActionsBar.tsx
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
apps/web/components/api-access/VeniceDatabaseExplorer/QueryOutput/ApiEndpointCard.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
apps/web/components/api-access/VeniceDatabaseExplorer/QueryOutput/OutputFormat.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
2184174
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
venice – ./
usevenice.vercel.app
venice-venice.vercel.app
app.venice.is
venice-git-main-venice.vercel.app