Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL to REST translator #25978

Merged
merged 74 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
01d9b15
feat: sql-to-rest poc
gregnr May 1, 2024
930c87d
feat: sql-to-supabase-js poc
gregnr May 1, 2024
2b17f5a
chore: upgrade to libpg-query@15
gregnr May 2, 2024
4e59f69
feat: sql-to-rest docs tool
gregnr May 2, 2024
e974bed
docs(sql-to-rest): add introduction
gregnr May 2, 2024
6f20462
docs: wording improvements
gregnr May 2, 2024
285255c
fix: theme
gregnr May 2, 2024
0a69bc2
chore: tailwind placeholder
gregnr May 2, 2024
555be6e
feat(sql-to-rest): limit, offset, and range
gregnr May 2, 2024
260077f
feat(sql-to-rest): sort by
gregnr May 2, 2024
4e13795
fix(sql-to-rest): ui theme
gregnr May 2, 2024
e74db9c
feat(sql-to-rest): casts
gregnr May 2, 2024
199b83a
feat(sql-to-rest): dynamic faqs in ui
gregnr May 2, 2024
6bc233e
feat(sql-to-rest): improve ui responsiveness
gregnr May 2, 2024
1a9d391
feat(sql-to-rest): more advanced faqs in ui
gregnr May 2, 2024
7fba930
feat(sql-to-rest): http and curl syntax highlighting
gregnr May 3, 2024
7ef2dcf
feat(sql-to-rest): baseUrl in http/curl rendering
gregnr May 3, 2024
d084f2d
docs(sql-to-rest): clarification on curl flags
gregnr May 3, 2024
6f84b87
feat(sql-to-rest): more faqs
gregnr May 3, 2024
0f5ab8d
refactor(sql-to-rest): split faqs into own file
gregnr May 3, 2024
3c0c7f5
refactor(sql-to-rest): move formatters to sql-to-rest package
gregnr May 3, 2024
1a93258
docs(sql-to-rest): move page to new tools section
gregnr May 3, 2024
270a31b
feat(sql-to-rest): joins and resource embeddings
gregnr May 6, 2024
37e56f7
chore(sql-to-rest): rename 'convert' to 'translate'
gregnr May 6, 2024
025a356
feat(sql-to-rest): add faqs
gregnr May 6, 2024
c439efd
feat(sql-to-rest): ui improvements
gregnr May 6, 2024
ff13c85
feat(sql-to-rest): faq title adjustment
gregnr May 6, 2024
9221188
feat(sql-to-rest): link to client lib docs
gregnr May 6, 2024
238fdc6
feat(sql-to-rest): assumptions
gregnr May 6, 2024
afebb83
feat(sql-to-rest): friendly 'not supported yet' errors
gregnr May 6, 2024
5618958
feat(sql-to-rest): json columns
gregnr May 7, 2024
3e27a26
feat(sql-to-rest): remove curl -G flag if unused
gregnr May 7, 2024
2c85cd2
feat(sql-to-rest): better error handling
gregnr May 7, 2024
2cf8c67
chore: revert accidental rls ai work
gregnr May 7, 2024
5b1b8ac
fix: build errors
gregnr May 7, 2024
d62037b
fix(sql-to-rest): theme
gregnr May 7, 2024
7967e4f
feat(sql-to-rest): change base url
gregnr May 7, 2024
a5fb595
feat(sql-to-rest): basic aggregate poc
gregnr May 8, 2024
8ca3cc1
feat(sql-to-rest): group by
gregnr May 8, 2024
9196f6d
feat(sql-to-rest): more group by checks
gregnr May 9, 2024
d754bf4
feat(sql-to-rest): count(*) special case
gregnr May 9, 2024
c810e59
fix(sql-to-rest): tests
gregnr May 9, 2024
9c38a32
feat(sql-to-rest): faq on 'and' operator
gregnr May 9, 2024
aaf0398
fix(sql-to-rest): error messages
gregnr May 9, 2024
a14ab01
fix(sql-to-rest): multiple filters on same column
gregnr May 9, 2024
7f11b37
refactor(sql-to-rest): error hints
gregnr May 9, 2024
560006a
feat(sql-to-rest): match and imatch
gregnr May 9, 2024
ee005f4
feat(sql-to-rest): in operator
gregnr May 9, 2024
2981cb4
feat(sql-to-rest): parsing error hints
gregnr May 9, 2024
804f85d
feat(sql-to-rest): default language to curl
gregnr May 9, 2024
a2afc84
feat(sql-to-rest): format on cmd+s
gregnr May 9, 2024
ff4664f
feat(sql-to-rest): format initial value
gregnr May 9, 2024
c963fb3
fix(sql-to-rest): turn off tab query group
gregnr May 10, 2024
0a10ca2
feat(sql-to-rest): improve wording in error messages
gregnr May 10, 2024
6a4fcd4
feat(sql-to-rest): animated code blocks
gregnr May 10, 2024
c9d4d6f
feat(sql-to-rest): more error hints
gregnr May 10, 2024
15c42eb
fix(sql-to-rest): strip primary relation prefix from columns
gregnr May 15, 2024
bebc610
feat(sql-to-rest): json column in order by clause
gregnr May 16, 2024
96afc5c
feat(sql-to-rest): validate all referenced relations exist in from cl…
gregnr May 16, 2024
6042383
refactor(sql-to-rest): split core sql-to-rest lib into separate repo
gregnr May 17, 2024
fd08762
Merge branch 'master' into feat/sql-to-rest
gregnr May 17, 2024
decd651
feat(sql-to-rest): upgrade to v0.1.1
gregnr May 17, 2024
568c7ff
feat(sql-to-rest): upgrade to v0.1.2
gregnr May 18, 2024
c2112d4
feat(sql-to-rest): upgrade to v0.1.4
gregnr May 21, 2024
f541573
chore: upgrade libpg-query
gregnr May 21, 2024
b957716
feat: update 'create a pr' link
gregnr May 21, 2024
b8d7560
Merge branch 'chore/upgrade-libpg-query' into feat/sql-to-rest
gregnr May 21, 2024
6e529f9
fix: app builds
gregnr May 21, 2024
040eac3
fix: prettier
gregnr May 21, 2024
15cf6db
fix: typecheck
gregnr May 21, 2024
d7d95e3
fix: studio tests
gregnr May 21, 2024
066a3f6
Merge branch 'master' into feat/sql-to-rest
gregnr May 21, 2024
ac294eb
chore: remove console.log
gregnr May 22, 2024
89dde7f
docs(sql-to-rest): remove broken link to client libraries
gregnr May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/database-new/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"@ui/*": ["./../../packages/ui/src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"./../../packages/ui/src/**/*.d.ts"
],
"exclude": ["node_modules"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,11 @@ export const api: NavMenuConstant = {
url: '/guides/api/rest/generating-types',
items: [],
},
{
name: 'Tools',
url: '/guides/api',
items: [{ name: 'SQL to REST API Translator', url: '/guides/api/sql-to-rest' }],
},
{
name: 'Guides',
url: '/guides/api',
Expand Down
6 changes: 4 additions & 2 deletions apps/docs/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import { NavData } from './NavData'
import { SharedData } from './SharedData'

// Partials
import HuggingFaceDeployment from './MDX/ai/quickstart_hf_deployment.mdx'
import AuthRateLimits from './MDX/auth_rate_limits.mdx'
import DatabaseSetup from './MDX/database_setup.mdx'
import GetSessionWarning from './MDX/get_session_warning.mdx'
import HuggingFaceDeployment from './MDX/ai/quickstart_hf_deployment.mdx'
import KotlinProjectSetup from './MDX/kotlin_project_setup.mdx'
import MigrationWarnings from './MDX/migration_warnings.mdx'
import OAuthPkceFlow from './MDX/oauth_pkce_flow.mdx'
Expand All @@ -47,6 +47,7 @@ import SocialProviderSettingsSupabase from './MDX/social_provider_settings_supab
import SocialProviderSetup from './MDX/social_provider_setup.mdx'

// Icons
import { IconArrowDown, IconCheck } from 'ui'
import {
IconMenuApi,
IconMenuAuth,
Expand All @@ -69,9 +70,9 @@ import {
IconMenuStorage,
IconMenuSwift,
} from './Navigation/NavigationMenu/HomeMenuIcons'
import { IconArrowDown, IconCheck } from 'ui'

// Heavy/rare (lazy-loaded)
import SqlToRest from '@ui-patterns/SqlToRest'
import { AppleSecretGenerator } from './AppleSecretGenerator'
import { AuthSmsProviderConfig } from './AuthSmsProviderConfig'
import { Extensions } from './Extensions'
Expand Down Expand Up @@ -160,6 +161,7 @@ const components = {
SharedData,
SocialProviderSettingsSupabase,
SocialProviderSetup,
SqlToRest,
StepHikeCompact,
TabPanel,
Tabs,
Expand Down
32 changes: 32 additions & 0 deletions apps/docs/content/guides/api/sql-to-rest.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
id: 'sql-to-rest'
title: 'SQL to REST API Translator'
subtitle: 'Translate SQL queries to HTTP requests and Supabase client code'
description: 'Translate SQL queries to HTTP requests and Supabase client code'
---

Sometimes it's challenging to translate SQL queries to the equivalent [PostgREST](https://postgrest.org/) request or Supabase client code. Use this tool to help with this translation.

<Admonition type="info">

PostgREST supports a subset of SQL, so not all SQL queries will translate.

</Admonition>

<SqlToRest
defaultValue={stripIndent`
select
title,
description
from
books
where
description ilike '%cheese%'
order by
title desc
limit
5
offset
10
`}
/>
3 changes: 2 additions & 1 deletion apps/docs/pages/guides/api/[[...slug]].tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { stripIndent } from 'common-tags'
import { type GetStaticPaths, type GetStaticProps, type InferGetStaticPropsType } from 'next'
import { MDXRemote } from 'next-mdx-remote'

Expand All @@ -23,7 +24,7 @@ export default function ApiGuide({

return (
<Layout meta={meta} hideToc={hideToc} editLink={editLink} menuId={MenuId.Api}>
<MDXRemote {...mdxSource} components={components} />
<MDXRemote {...mdxSource} components={components} scope={{ stripIndent }} />
</Layout>
)
}
3 changes: 2 additions & 1 deletion apps/docs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"**/*.ts",
"**/*.tsx",
"pages/guides/append-test.js",
"jest.config.mjs"
"jest.config.mjs",
"./../../packages/ui/src/**/*.d.ts"
],
"exclude": ["node_modules"]
}
2 changes: 1 addition & 1 deletion apps/storybook/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"@ui/*": ["./../../packages/ui/src/*"] // handle ui package paths
}
},
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "./../../packages/ui/src/**/*.d.ts"],
"exclude": ["node_modules"]
}
7 changes: 6 additions & 1 deletion apps/studio/jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ const config = {
testEnvironment: 'jsdom',
testTimeout: 10000,
testRegex: '(.*\\.test.(js|jsx|ts|tsx)$)',
setupFiles: ['jest-canvas-mock', './tests/setup/radix', './tests/setup/polyfills'],
setupFiles: [
'jest-canvas-mock',
'./tests/setup/radix',
'./tests/setup/polyfills',
'./tests/setup/fetch-mock',
],
}

export default createJestConfig(config)
10 changes: 9 additions & 1 deletion apps/studio/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,15 @@ const nextConfig = {
'vercel.com',
],
},
transpilePackages: ['ui', 'ui-patterns', 'common', 'shared-data', 'api-types', 'icons'],
transpilePackages: [
'ui',
'ui-patterns',
'common',
'shared-data',
'api-types',
'icons',
'libpg-query',
],
webpack(config) {
config.module?.rules
.find((rule) => rule.oneOf)
Expand Down
1 change: 1 addition & 0 deletions apps/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
"jest-environment-jsdom": "^29.7.0",
"jest-fetch-mock": "^3.0.3",
"postcss": "^8.4.31",
"prettier": "^4.0.0-alpha.8",
"storybook-dark-mode": "^3.0.1",
Expand Down
22 changes: 22 additions & 0 deletions apps/studio/tests/setup/fetch-mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { enableFetchMocks } from 'jest-fetch-mock'
import { readFile } from 'fs/promises'
import { fileURLToPath } from 'url'

enableFetchMocks()

fetch.mockResponse(async (request) => {
// Support loading .wasm files in Jest jsdom environment
if (request.url.endsWith('.wasm')) {
const filePath = fileURLToPath(request.url)
const file = await readFile(filePath)
return {
status: 200,
body: file,
}
} else {
return {
status: 404,
body: 'Not Found',
}
}
})
10 changes: 9 additions & 1 deletion apps/studio/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
}
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", ".next/types/**/*.ts"],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx",
".next/types/**/*.ts",
"./../../packages/ui/src/**/*.d.ts"
],
"exclude": ["node_modules"]
}
8 changes: 7 additions & 1 deletion apps/www/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@
]
},
"exclude": ["node_modules", "supabase"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"./../../packages/ui/src/**/*.d.ts"
]
}