From b93dc055b788f8a2b1d35518af0fc50e9128bd79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=9C=EB=AF=BC?= Date: Thu, 29 Feb 2024 15:00:51 +0900 Subject: [PATCH 1/3] chore: add @supabase/supabase-js --- package.json | 1 + pnpm-lock.yaml | 87 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6094735..002c48a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "private": true, "dependencies": { + "@supabase/supabase-js": "^2.39.7", "react": "18.2.0", "react-dom": "18.2.0", "react-router-dom": "6.11.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3c95ab2..fe74388 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@supabase/supabase-js': + specifier: ^2.39.7 + version: 2.39.7 react: specifier: 18.2.0 version: 18.2.0 @@ -2559,6 +2562,63 @@ packages: engines: {node: '>=10'} dev: true + /@supabase/functions-js@2.1.5: + resolution: {integrity: sha512-BNzC5XhCzzCaggJ8s53DP+WeHHGT/NfTsx2wUSSGKR2/ikLFQTBCDzMvGz/PxYMqRko/LwncQtKXGOYp1PkPaw==} + dependencies: + '@supabase/node-fetch': 2.6.15 + dev: false + + /@supabase/gotrue-js@2.62.2: + resolution: {integrity: sha512-AP6e6W9rQXFTEJ7sTTNYQrNf0LCcnt1hUW+RIgUK+Uh3jbWvcIST7wAlYyNZiMlS9+PYyymWQ+Ykz/rOYSO0+A==} + dependencies: + '@supabase/node-fetch': 2.6.15 + dev: false + + /@supabase/node-fetch@2.6.15: + resolution: {integrity: sha512-1ibVeYUacxWYi9i0cf5efil6adJ9WRyZBLivgjs+AUpewx1F3xPi7gLgaASI2SmIQxPoCEjAsLAzKPgMJVgOUQ==} + engines: {node: 4.x || >=6.0.0} + dependencies: + whatwg-url: 5.0.0 + dev: false + + /@supabase/postgrest-js@1.9.2: + resolution: {integrity: sha512-I6yHo8CC9cxhOo6DouDMy9uOfW7hjdsnCxZiaJuIVZm1dBGTFiQPgfMa9zXCamEWzNyWRjZvupAUuX+tqcl5Sw==} + dependencies: + '@supabase/node-fetch': 2.6.15 + dev: false + + /@supabase/realtime-js@2.9.3: + resolution: {integrity: sha512-lAp50s2n3FhGJFq+wTSXLNIDPw5Y0Wxrgt44eM5nLSA3jZNUUP3Oq2Ccd1CbZdVntPCWLZvJaU//pAd2NE+QnQ==} + dependencies: + '@supabase/node-fetch': 2.6.15 + '@types/phoenix': 1.6.4 + '@types/ws': 8.5.10 + ws: 8.16.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + + /@supabase/storage-js@2.5.5: + resolution: {integrity: sha512-OpLoDRjFwClwc2cjTJZG8XviTiQH4Ik8sCiMK5v7et0MDu2QlXjCAW3ljxJB5+z/KazdMOTnySi+hysxWUPu3w==} + dependencies: + '@supabase/node-fetch': 2.6.15 + dev: false + + /@supabase/supabase-js@2.39.7: + resolution: {integrity: sha512-1vxsX10Uhc2b+Dv9pRjBjHfqmw2N2h1PyTg9LEfICR3x2xwE24By1MGCjDZuzDKH5OeHCsf4it6K8KRluAAEXA==} + dependencies: + '@supabase/functions-js': 2.1.5 + '@supabase/gotrue-js': 2.62.2 + '@supabase/node-fetch': 2.6.15 + '@supabase/postgrest-js': 1.9.2 + '@supabase/realtime-js': 2.9.3 + '@supabase/storage-js': 2.5.5 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + dev: false + /@svgr/babel-plugin-add-jsx-attribute@8.0.0(@babel/core@7.24.0): resolution: {integrity: sha512-b9MIk7yhdS1pMCZM8VeNfUlSKVRhsHZNMl5O9SfaX0l0t5wjdgu4IDzGB8bpnGBBOjGST3rRFVsaaEtI4W6f7g==} engines: {node: '>=14'} @@ -3052,12 +3112,15 @@ packages: /@types/node@18.16.9: resolution: {integrity: sha512-IeB32oIV4oGArLrd7znD2rkHQ6EDCM+2Sr76dJnrHwv9OHBTTM6nuDLK9bmikXzPa0ZlWMWtRGo/Uw4mrzQedA==} - dev: true /@types/parse-json@4.0.2: resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==} dev: true + /@types/phoenix@1.6.4: + resolution: {integrity: sha512-B34A7uot1Cv0XtaHRYDATltAdKx0BvVKNgYNqE4WjtPUa4VQJM7kxeXcVKaH+KS+kCmZ+6w+QaUdcljiheiBJA==} + dev: false + /@types/prop-types@15.7.11: resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==} dev: true @@ -3090,6 +3153,12 @@ packages: resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} dev: true + /@types/ws@8.5.10: + resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} + dependencies: + '@types/node': 18.16.9 + dev: false + /@typescript-eslint/eslint-plugin@6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.48.0)(typescript@5.3.3): resolution: {integrity: sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==} engines: {node: ^16.0.0 || >=18.0.0} @@ -7341,6 +7410,10 @@ packages: url-parse: 1.5.10 dev: true + /tr46@0.0.3: + resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + dev: false + /tr46@4.1.1: resolution: {integrity: sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==} engines: {node: '>=14'} @@ -7758,6 +7831,10 @@ packages: defaults: 1.0.4 dev: true + /webidl-conversions@3.0.1: + resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + dev: false + /webidl-conversions@7.0.0: resolution: {integrity: sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==} engines: {node: '>=12'} @@ -7783,6 +7860,13 @@ packages: webidl-conversions: 7.0.0 dev: true + /whatwg-url@5.0.0: + resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} + dependencies: + tr46: 0.0.3 + webidl-conversions: 3.0.1 + dev: false + /which-boxed-primitive@1.0.2: resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==} dependencies: @@ -7870,7 +7954,6 @@ packages: optional: true utf-8-validate: optional: true - dev: true /xml-name-validator@4.0.0: resolution: {integrity: sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==} From 20ce0d04c52c67ada5bbfacbec8b8bb6d8f22079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=9C=EB=AF=BC?= Date: Thu, 29 Feb 2024 16:21:09 +0900 Subject: [PATCH 2/3] feat(admin): setting supabase --- .gitignore | 3 +- apps/survey-admin/src/app/app.tsx | 4 +- apps/survey-admin/src/main.tsx | 5 +- apps/survey-admin/vite-env.d.ts | 9 ++ libs/supabase/.babelrc | 12 ++ libs/supabase/.eslintrc.json | 18 +++ libs/supabase/README.md | 7 + libs/supabase/package.json | 12 ++ libs/supabase/project.json | 8 + libs/supabase/src/index.ts | 2 + libs/supabase/src/supabase/index.tsx | 38 +++++ libs/supabase/src/types/index.ts | 214 +++++++++++++++++++++++++++ libs/supabase/tsconfig.json | 18 +++ libs/supabase/tsconfig.lib.json | 23 +++ libs/supabase/vite.config.ts | 49 ++++++ nx.json | 9 +- package.json | 1 + pnpm-lock.yaml | 158 ++++++++++++++++++++ tsconfig.base.json | 2 +- 19 files changed, 587 insertions(+), 5 deletions(-) create mode 100644 apps/survey-admin/vite-env.d.ts create mode 100644 libs/supabase/.babelrc create mode 100644 libs/supabase/.eslintrc.json create mode 100644 libs/supabase/README.md create mode 100644 libs/supabase/package.json create mode 100644 libs/supabase/project.json create mode 100644 libs/supabase/src/index.ts create mode 100644 libs/supabase/src/supabase/index.tsx create mode 100644 libs/supabase/src/types/index.ts create mode 100644 libs/supabase/tsconfig.json create mode 100644 libs/supabase/tsconfig.lib.json create mode 100644 libs/supabase/vite.config.ts diff --git a/.gitignore b/.gitignore index 3443c8f..d16dbcd 100644 --- a/.gitignore +++ b/.gitignore @@ -41,4 +41,5 @@ Thumbs.db .nx/cache # env -.env \ No newline at end of file +.env +.env.local \ No newline at end of file diff --git a/apps/survey-admin/src/app/app.tsx b/apps/survey-admin/src/app/app.tsx index 84e70fd..d30fe55 100644 --- a/apps/survey-admin/src/app/app.tsx +++ b/apps/survey-admin/src/app/app.tsx @@ -1,6 +1,8 @@ -import { useEffect } from 'react'; +import { useSupabaseContext } from '@ssoon-servey/supabase'; export function App() { + const { supabase } = useSupabaseContext(); + console.log('supabase', supabase); return
Admin!!
; } diff --git a/apps/survey-admin/src/main.tsx b/apps/survey-admin/src/main.tsx index 5b0ece9..f594e6b 100644 --- a/apps/survey-admin/src/main.tsx +++ b/apps/survey-admin/src/main.tsx @@ -1,5 +1,6 @@ import { StrictMode } from 'react'; import * as ReactDOM from 'react-dom/client'; +import { SupabaseProvider } from '@ssoon-servey/supabase'; import App from './app/app'; @@ -8,6 +9,8 @@ const root = ReactDOM.createRoot( ); root.render( - + + + ); diff --git a/apps/survey-admin/vite-env.d.ts b/apps/survey-admin/vite-env.d.ts new file mode 100644 index 0000000..f4e09fb --- /dev/null +++ b/apps/survey-admin/vite-env.d.ts @@ -0,0 +1,9 @@ +/// + +interface ImportMetaEnv { + readonly VITE_SUPABASE_KEY: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +} diff --git a/libs/supabase/.babelrc b/libs/supabase/.babelrc new file mode 100644 index 0000000..1ea870e --- /dev/null +++ b/libs/supabase/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/supabase/.eslintrc.json b/libs/supabase/.eslintrc.json new file mode 100644 index 0000000..a39ac5d --- /dev/null +++ b/libs/supabase/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/supabase/README.md b/libs/supabase/README.md new file mode 100644 index 0000000..6ffa166 --- /dev/null +++ b/libs/supabase/README.md @@ -0,0 +1,7 @@ +# supabase + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test supabase` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/libs/supabase/package.json b/libs/supabase/package.json new file mode 100644 index 0000000..e032da3 --- /dev/null +++ b/libs/supabase/package.json @@ -0,0 +1,12 @@ +{ + "name": "@ssoon-servey/supabase", + "version": "0.0.1", + "main": "./index.js", + "types": "./index.d.ts", + "exports": { + ".": { + "import": "./index.mjs", + "require": "./index.js" + } + } +} diff --git a/libs/supabase/project.json b/libs/supabase/project.json new file mode 100644 index 0000000..27249c2 --- /dev/null +++ b/libs/supabase/project.json @@ -0,0 +1,8 @@ +{ + "name": "supabase", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/supabase/src", + "projectType": "library", + "tags": [], + "targets": {} +} diff --git a/libs/supabase/src/index.ts b/libs/supabase/src/index.ts new file mode 100644 index 0000000..854f81f --- /dev/null +++ b/libs/supabase/src/index.ts @@ -0,0 +1,2 @@ +export * from './supabase'; +export * from './types'; diff --git a/libs/supabase/src/supabase/index.tsx b/libs/supabase/src/supabase/index.tsx new file mode 100644 index 0000000..dd3cc0f --- /dev/null +++ b/libs/supabase/src/supabase/index.tsx @@ -0,0 +1,38 @@ +import { createContext, useContext } from 'react'; +import { createClient } from '@supabase/supabase-js'; +import type { Database } from '../types'; + +export type SupabaseContextValue = { + supabase: ReturnType>; +}; + +export const SupabaseContext = createContext(null); +SupabaseContext.displayName = 'SupabaseContext'; + +export const SupabaseProvider = ({ + children, + supabaseKey, +}: { + children: React.ReactNode; + supabaseKey: string; +}) => { + const supabaseUrl = 'https://tmeoawlhihzuoqxebciw.supabase.co'; + const supabase = createClient(supabaseUrl, supabaseKey); + + return ( + + {children} + + ); +}; + +export const useSupabaseContext = () => { + const context = useContext(SupabaseContext); + + if (context === null) { + throw new Error( + 'useSupabaseContext must be used within a ' + ); + } + return context; +}; diff --git a/libs/supabase/src/types/index.ts b/libs/supabase/src/types/index.ts new file mode 100644 index 0000000..a60f223 --- /dev/null +++ b/libs/supabase/src/types/index.ts @@ -0,0 +1,214 @@ +export type Json = + | string + | number + | boolean + | null + | { [key: string]: Json | undefined } + | Json[] + +export type Database = { + public: { + Tables: { + question_options: { + Row: { + id: number + item_id: number | null + option_text: string + } + Insert: { + id?: never + item_id?: number | null + option_text: string + } + Update: { + id?: never + item_id?: number | null + option_text?: string + } + Relationships: [ + { + foreignKeyName: "question_options_item_id_fkey" + columns: ["item_id"] + isOneToOne: false + referencedRelation: "survey_items" + referencedColumns: ["id"] + } + ] + } + survey_items: { + Row: { + id: number + option: boolean | null + question_required: boolean + question_title: string + question_type: string + section_id: number | null + } + Insert: { + id?: never + option?: boolean | null + question_required: boolean + question_title: string + question_type: string + section_id?: number | null + } + Update: { + id?: never + option?: boolean | null + question_required?: boolean + question_title?: string + question_type?: string + section_id?: number | null + } + Relationships: [ + { + foreignKeyName: "survey_items_section_id_fkey" + columns: ["section_id"] + isOneToOne: false + referencedRelation: "survey_sections" + referencedColumns: ["id"] + } + ] + } + survey_sections: { + Row: { + id: number + section_id: number | null + servey_title: string | null + survey_id: number | null + } + Insert: { + id?: never + section_id?: number | null + servey_title?: string | null + survey_id?: number | null + } + Update: { + id?: never + section_id?: number | null + servey_title?: string | null + survey_id?: number | null + } + Relationships: [ + { + foreignKeyName: "survey_sections_survey_id_fkey" + columns: ["survey_id"] + isOneToOne: false + referencedRelation: "surveys" + referencedColumns: ["id"] + } + ] + } + surveys: { + Row: { + description: string | null + id: number + title: string + } + Insert: { + description?: string | null + id?: never + title: string + } + Update: { + description?: string | null + id?: never + title?: string + } + Relationships: [] + } + } + Views: { + [_ in never]: never + } + Functions: { + [_ in never]: never + } + Enums: { + [_ in never]: never + } + CompositeTypes: { + [_ in never]: never + } + } +} + +export type Tables< + PublicTableNameOrOptions extends + | keyof (Database["public"]["Tables"] & Database["public"]["Views"]) + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & + Database[PublicTableNameOrOptions["schema"]]["Views"]) + : never = never +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & + Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { + Row: infer R + } + ? R + : never + : PublicTableNameOrOptions extends keyof (Database["public"]["Tables"] & + Database["public"]["Views"]) + ? (Database["public"]["Tables"] & + Database["public"]["Views"])[PublicTableNameOrOptions] extends { + Row: infer R + } + ? R + : never + : never + +export type TablesInsert< + PublicTableNameOrOptions extends + | keyof Database["public"]["Tables"] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Insert: infer I + } + ? I + : never + : PublicTableNameOrOptions extends keyof Database["public"]["Tables"] + ? Database["public"]["Tables"][PublicTableNameOrOptions] extends { + Insert: infer I + } + ? I + : never + : never + +export type TablesUpdate< + PublicTableNameOrOptions extends + | keyof Database["public"]["Tables"] + | { schema: keyof Database }, + TableName extends PublicTableNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + : never = never +> = PublicTableNameOrOptions extends { schema: keyof Database } + ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { + Update: infer U + } + ? U + : never + : PublicTableNameOrOptions extends keyof Database["public"]["Tables"] + ? Database["public"]["Tables"][PublicTableNameOrOptions] extends { + Update: infer U + } + ? U + : never + : never + +export type Enums< + PublicEnumNameOrOptions extends + | keyof Database["public"]["Enums"] + | { schema: keyof Database }, + EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } + ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] + : never = never +> = PublicEnumNameOrOptions extends { schema: keyof Database } + ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] + : PublicEnumNameOrOptions extends keyof Database["public"]["Enums"] + ? Database["public"]["Enums"][PublicEnumNameOrOptions] + : never diff --git a/libs/supabase/tsconfig.json b/libs/supabase/tsconfig.json new file mode 100644 index 0000000..6734c59 --- /dev/null +++ b/libs/supabase/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": false, + "esModuleInterop": false, + "allowSyntheticDefaultImports": true, + "strict": true, + "types": ["vite/client"] + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ], + "extends": "../../tsconfig.base.json" +} diff --git a/libs/supabase/tsconfig.lib.json b/libs/supabase/tsconfig.lib.json new file mode 100644 index 0000000..8d6bbf7 --- /dev/null +++ b/libs/supabase/tsconfig.lib.json @@ -0,0 +1,23 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": [ + "node", + "@nx/react/typings/cssmodule.d.ts", + "@nx/react/typings/image.d.ts", + "vite/client" + ] + }, + "exclude": [ + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] +} diff --git a/libs/supabase/vite.config.ts b/libs/supabase/vite.config.ts new file mode 100644 index 0000000..d34dd6a --- /dev/null +++ b/libs/supabase/vite.config.ts @@ -0,0 +1,49 @@ +/// +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; +import dts from 'vite-plugin-dts'; +import * as path from 'path'; +import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; + +export default defineConfig({ + root: __dirname, + cacheDir: '../../node_modules/.vite/libs/supabase', + + plugins: [ + react(), + nxViteTsPaths(), + dts({ + entryRoot: 'src', + tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'), + skipDiagnostics: true, + }), + ], + + // Uncomment this if you are using workers. + // worker: { + // plugins: [ nxViteTsPaths() ], + // }, + + // Configuration for building your library. + // See: https://vitejs.dev/guide/build.html#library-mode + build: { + outDir: '../../dist/libs/supabase', + reportCompressedSize: true, + commonjsOptions: { + transformMixedEsModules: true, + }, + lib: { + // Could also be a dictionary or array of multiple entry points. + entry: 'src/index.ts', + name: 'supabase', + fileName: 'index', + // Change this to the formats you want to support. + // Don't forget to update your package.json as well. + formats: ['es', 'cjs'], + }, + rollupOptions: { + // External packages that should not be bundled into your library. + external: ['react', 'react-dom', 'react/jsx-runtime'], + }, + }, +}); diff --git a/nx.json b/nx.json index 77f0759..36d4ada 100644 --- a/nx.json +++ b/nx.json @@ -47,5 +47,12 @@ } } }, - "nxCloudAccessToken": "ZjgyN2VmY2EtZjljMy00NGNiLTllMGUtMWI3OGQ2ZDAxN2M3fHJlYWQtd3JpdGU=" + "nxCloudAccessToken": "ZjgyN2VmY2EtZjljMy00NGNiLTllMGUtMWI3OGQ2ZDAxN2M3fHJlYWQtd3JpdGU=", + "targetDefaults": { + "@nx/vite:build": { + "cache": true, + "dependsOn": ["^build"], + "inputs": ["production", "^production"] + } + } } diff --git a/package.json b/package.json index 002c48a..37abdf0 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "jsdom": "~22.1.0", "nx": "18.0.5", "prettier": "^2.6.2", + "supabase": ">=1.8.1", "typescript": "~5.3.2", "vite": "~5.0.0", "vite-plugin-dts": "~2.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe74388..43a1f6a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,6 +112,9 @@ devDependencies: prettier: specifier: ^2.6.2 version: 2.8.8 + supabase: + specifier: '>=1.8.1' + version: 1.145.4 typescript: specifier: ~5.3.2 version: 5.3.3 @@ -3441,6 +3444,15 @@ packages: - supports-color dev: true + /agent-base@7.1.0: + resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==} + engines: {node: '>= 14'} + dependencies: + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + dev: true + /ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} dependencies: @@ -3730,6 +3742,16 @@ packages: executable: 4.1.1 dev: true + /bin-links@4.0.3: + resolution: {integrity: sha512-obsRaULtJurnfox/MDwgq6Yo9kzbv1CPTk/1/s7Z/61Lezc8IKkFCOXNeVLXz0456WRzBQmSsDWlai2tIhBsfA==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dependencies: + cmd-shim: 6.0.2 + npm-normalize-package-bin: 3.0.1 + read-cmd-shim: 4.0.0 + write-file-atomic: 5.0.1 + dev: true + /bin-version-check@5.1.0: resolution: {integrity: sha512-bYsvMqJ8yNGILLz1KP9zKLzQ6YpljV3ln1gqhuLkUtyfGi3qXKGuK2p+U4NAvjVFzDFiBBtOpCOSFNuYYEGZ5g==} engines: {node: '>=12'} @@ -3891,6 +3913,11 @@ packages: get-func-name: 2.0.2 dev: true + /chownr@2.0.0: + resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} + engines: {node: '>=10'} + dev: true + /cli-cursor@3.1.0: resolution: {integrity: sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==} engines: {node: '>=8'} @@ -3928,6 +3955,11 @@ packages: engines: {node: '>=0.8'} dev: true + /cmd-shim@6.0.2: + resolution: {integrity: sha512-+FFYbB0YLaAkhkcrjkyNLYDiOsFSfRjwjY19LXk/psmMx1z00xlCv7hhQoTGXXIKi+YXHL/iiFo8NqMVQX9nOw==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dev: true + /code-block-writer@12.0.0: resolution: {integrity: sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w==} dev: true @@ -4120,6 +4152,11 @@ packages: resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} dev: true + /data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + dev: true + /data-urls@4.0.0: resolution: {integrity: sha512-/mMTei/JXPqvFqQtfyTowxmJVwr2PVAeCcDxyFf6LhoOu/09TX2OX3kb2wzi4DMXcfj4OItwDOnhl5oziPnT6g==} engines: {node: '>=14'} @@ -4900,6 +4937,14 @@ packages: reusify: 1.0.4 dev: true + /fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.3.3 + dev: true + /fflate@0.8.2: resolution: {integrity: sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==} dev: true @@ -5020,6 +5065,13 @@ packages: mime-types: 2.1.35 dev: true + /formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + dependencies: + fetch-blob: 3.2.0 + dev: true + /fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} dev: true @@ -5051,6 +5103,13 @@ packages: universalify: 0.1.2 dev: true + /fs-minipass@2.1.0: + resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.3.6 + dev: true + /fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true @@ -5375,6 +5434,16 @@ packages: - supports-color dev: true + /https-proxy-agent@7.0.4: + resolution: {integrity: sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==} + engines: {node: '>= 14'} + dependencies: + agent-base: 7.1.0 + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + dev: true + /human-signals@2.1.0: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} @@ -6120,11 +6189,31 @@ packages: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} dev: true + /minipass@3.3.6: + resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} + engines: {node: '>=8'} + dependencies: + yallist: 4.0.0 + dev: true + + /minipass@5.0.0: + resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==} + engines: {node: '>=8'} + dev: true + /minipass@7.0.4: resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} engines: {node: '>=16 || 14 >=14.17'} dev: true + /minizlib@2.1.2: + resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} + engines: {node: '>= 8'} + dependencies: + minipass: 3.3.6 + yallist: 4.0.0 + dev: true + /mkdirp@0.5.6: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true @@ -6132,6 +6221,12 @@ packages: minimist: 1.2.8 dev: true + /mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + dev: true + /mkdirp@2.1.6: resolution: {integrity: sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A==} engines: {node: '>=10'} @@ -6177,6 +6272,20 @@ packages: tslib: 2.6.2 dev: true + /node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + dev: true + + /node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + dev: true + /node-machine-id@1.1.12: resolution: {integrity: sha512-QNABxbrPa3qEIfrE6GOJ7BYIuignnJw7iQ2YPbc3Nla1HzRJjXzZOiikfF8m7eAMfichLt3M4VgLOetqgDmgGQ==} dev: true @@ -6190,6 +6299,11 @@ packages: engines: {node: '>=10'} dev: true + /npm-normalize-package-bin@3.0.1: + resolution: {integrity: sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dev: true + /npm-package-arg@11.0.1: resolution: {integrity: sha512-M7s1BD4NxdAvBKUPqqRW957Xwcl/4Zvo8Aj+ANrzvIPzGJZElrH7Z//rSaec2ORcND6FHHLnZeY8qgTpXDMFQQ==} engines: {node: ^16.14.0 || >=18.0.0} @@ -6734,6 +6848,11 @@ packages: dependencies: loose-envify: 1.4.0 + /read-cmd-shim@4.0.0: + resolution: {integrity: sha512-yILWifhaSEEytfXI76kB9xEEiG1AiozaCJZ83A87ytjRiN+jVibXjedjCRNjoZviinhG+4UkalO3mWTd8u5O0Q==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dev: true + /readable-stream@3.6.2: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} @@ -7278,6 +7397,20 @@ packages: peek-readable: 5.0.0 dev: true + /supabase@1.145.4: + resolution: {integrity: sha512-j6OvAQjTNcJ8SBlqZpUTFJ7C3iXliZ8VjcleFvUBAlFLqot1EhXT8tqSLZiOP1B91Ks2DPOxT8D94cAIWYWvLQ==} + engines: {npm: '>=8'} + hasBin: true + requiresBuild: true + dependencies: + bin-links: 4.0.3 + https-proxy-agent: 7.0.4 + node-fetch: 3.3.2 + tar: 6.2.0 + transitivePeerDependencies: + - supports-color + dev: true + /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'} @@ -7337,6 +7470,18 @@ packages: readable-stream: 3.6.2 dev: true + /tar@6.2.0: + resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==} + engines: {node: '>=10'} + dependencies: + chownr: 2.0.0 + fs-minipass: 2.1.0 + minipass: 5.0.0 + minizlib: 2.1.2 + mkdirp: 1.0.4 + yallist: 4.0.0 + dev: true + /test-exclude@6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -7831,6 +7976,11 @@ packages: defaults: 1.0.4 dev: true + /web-streams-polyfill@3.3.3: + resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} + engines: {node: '>= 8'} + dev: true + /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: false @@ -7943,6 +8093,14 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true + /write-file-atomic@5.0.1: + resolution: {integrity: sha512-+QU2zd6OTD8XWIJCbffaiQeH9U73qIqafo1x6V1snCWYGJf6cVE0cDR4D8xRzcEnfI21IFrUPzPGtcPf8AC+Rw==} + engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} + dependencies: + imurmurhash: 0.1.4 + signal-exit: 4.1.0 + dev: true + /ws@8.16.0: resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==} engines: {node: '>=10.0.0'} diff --git a/tsconfig.base.json b/tsconfig.base.json index ef42181..77b3fee 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -16,7 +16,7 @@ "baseUrl": ".", "paths": { "@ssoon-servey/shared-ui": ["./libs/shared/ui/src/index.ts"], - "@ssoon-servey/supabase": ["./libs/supabase/index.ts"] + "@ssoon-servey/supabase": ["libs/supabase/src/index.ts"] } }, "exclude": ["node_modules", "tmp"] From c1f5fd1e4094238a4d9f657c89740eb61e268bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=88=9C=EB=AF=BC?= Date: Thu, 29 Feb 2024 19:52:06 +0900 Subject: [PATCH 3/3] feat(admin): insert survey data format --- apps/survey-admin/src/app/app.tsx | 67 ++++- .../survey-admin/src/hooks/query/useServey.ts | 124 +++++++++ libs/supabase/src/types/index.ts | 258 +++++++++--------- 3 files changed, 316 insertions(+), 133 deletions(-) create mode 100644 apps/survey-admin/src/hooks/query/useServey.ts diff --git a/apps/survey-admin/src/app/app.tsx b/apps/survey-admin/src/app/app.tsx index d30fe55..58cafb5 100644 --- a/apps/survey-admin/src/app/app.tsx +++ b/apps/survey-admin/src/app/app.tsx @@ -1,9 +1,68 @@ -import { useSupabaseContext } from '@ssoon-servey/supabase'; +import { Survey, useCreateSurvey } from '../hooks/query/useServey'; + +const payload: Survey = { + title: '설문입니다.', + sections: [ + { + items: [ + { + title: 'radio input 1번째', + type: 'radio', + required: true, + options: [ + { text: 'radio option1 1번째' }, + { text: 'radio option2 1번째' }, + { text: 'radio option3 1번째' }, + ], + }, + { + title: 'checkbox input 1번째', + type: 'radio', + required: true, + options: [ + { text: 'checkbox option1 1번째' }, + { text: 'checkbox option2 1번째' }, + { text: 'checkbox option3 1번째' }, + ], + }, + ], + }, + { + items: [ + { + title: 'select 1번째', + type: 'select', + required: true, + options: [ + { + text: 'select option1 1번째', + }, + { + text: 'select option2 1번째', + }, + { + text: 'select option3 1번째', + }, + ], + }, + { title: 'select 1번째', type: 'textarea', required: true }, + ], + }, + ], +}; export function App() { - const { supabase } = useSupabaseContext(); - console.log('supabase', supabase); - return
Admin!!
; + const mutate = useCreateSurvey(); + + const onMutateSurvey = () => { + mutate(payload); + }; + return ( +
+

설문 만들기

+ +
+ ); } export default App; diff --git a/apps/survey-admin/src/hooks/query/useServey.ts b/apps/survey-admin/src/hooks/query/useServey.ts new file mode 100644 index 0000000..fd1f12e --- /dev/null +++ b/apps/survey-admin/src/hooks/query/useServey.ts @@ -0,0 +1,124 @@ +import { useSupabaseContext } from '@ssoon-servey/supabase'; + +interface Option { + text: string; +} + +interface Item { + title: string; + type: 'radio' | 'select' | 'checkbox' | 'textarea'; + required: boolean; + options?: Option[]; +} + +interface Section { + title?: string; + items: Item[]; +} + +export interface Survey { + title: string; + description?: string; + sections: Section[]; +} + +export const useCreateSurvey = () => { + const { supabase } = useSupabaseContext(); + + const createSurvey = async (title: string, description?: string) => { + const { data: survey } = await supabase + .from('surveys') + .insert([{ title, description }]) + .select(); + return survey; + }; + + const createSections = async (serveyId: number, sections: Section[]) => { + const { data: survey_section } = await supabase + .from('survey_sections') + .insert( + sections.map((section) => ({ + survey_title: section.title, + survey_id: serveyId, + })) + ) + .select(); + return survey_section; + }; + + const createSurveyItems = async ( + sectionIds: number[], + sections: Section[] + ) => { + const insertItems: { + section_id: number; + question_title: string; + question_type: 'radio' | 'select' | 'checkbox' | 'textarea'; + question_required: boolean; + hasOption: boolean; + }[] = []; + + sectionIds.forEach((id, i) => { + sections[i].items.forEach((item) => + insertItems.push({ + section_id: id, + question_title: item.title, + question_type: item.type, + question_required: item.required, + hasOption: !!item.options, + }) + ); + }); + + const { data: survey_items } = await supabase + .from('survey_items') + .insert(insertItems) + .select(); + + return survey_items; + }; + + const createItemOptions = async ( + surveyItemIds: number[], + sections: Section[] + ) => { + const insertOptions: { item_id: number; option_text: string }[] = []; + + surveyItemIds.forEach((id, i) => { + const options = sections.flatMap((section) => + section.items.map((item) => item.options) + ); + options[i]?.forEach((option) => { + insertOptions.push({ + item_id: id, + option_text: option.text, + }); + }); + }); + + await supabase.from('question_options').insert(insertOptions).select(); + }; + + const mutate = async (payload: Survey) => { + const { title, description, sections } = payload; + + const survey = await createSurvey(title, description); + if (!survey) return; + + const survey_section = await createSections(survey[0].id, sections); + if (!survey_section) return; + + const survey_items = await createSurveyItems( + survey_section.map((section) => section.id), + sections + ); + if (!survey_items) return; + + await createItemOptions( + survey_items.map((item) => item.id), + sections + ); + }; + + return mutate; +}; diff --git a/libs/supabase/src/types/index.ts b/libs/supabase/src/types/index.ts index a60f223..2364c1b 100644 --- a/libs/supabase/src/types/index.ts +++ b/libs/supabase/src/types/index.ts @@ -4,211 +4,211 @@ export type Json = | boolean | null | { [key: string]: Json | undefined } - | Json[] + | Json[]; export type Database = { public: { Tables: { question_options: { Row: { - id: number - item_id: number | null - option_text: string - } + id: number; + item_id: number | null; + option_text: string; + }; Insert: { - id?: never - item_id?: number | null - option_text: string - } + id?: never; + item_id?: number | null; + option_text: string; + }; Update: { - id?: never - item_id?: number | null - option_text?: string - } + id?: never; + item_id?: number | null; + option_text?: string; + }; Relationships: [ { - foreignKeyName: "question_options_item_id_fkey" - columns: ["item_id"] - isOneToOne: false - referencedRelation: "survey_items" - referencedColumns: ["id"] + foreignKeyName: 'question_options_item_id_fkey'; + columns: ['item_id']; + isOneToOne: false; + referencedRelation: 'survey_items'; + referencedColumns: ['id']; } - ] - } + ]; + }; survey_items: { Row: { - id: number - option: boolean | null - question_required: boolean - question_title: string - question_type: string - section_id: number | null - } + hasOption: boolean | null; + id: number; + question_required: boolean; + question_title: string; + question_type: string; + section_id: number | null; + }; Insert: { - id?: never - option?: boolean | null - question_required: boolean - question_title: string - question_type: string - section_id?: number | null - } + hasOption?: boolean | null; + id?: never; + question_required: boolean; + question_title: string; + question_type: string; + section_id?: number | null; + }; Update: { - id?: never - option?: boolean | null - question_required?: boolean - question_title?: string - question_type?: string - section_id?: number | null - } + hasOption?: boolean | null; + id?: never; + question_required?: boolean; + question_title?: string; + question_type?: string; + section_id?: number | null; + }; Relationships: [ { - foreignKeyName: "survey_items_section_id_fkey" - columns: ["section_id"] - isOneToOne: false - referencedRelation: "survey_sections" - referencedColumns: ["id"] + foreignKeyName: 'survey_items_section_id_fkey'; + columns: ['section_id']; + isOneToOne: false; + referencedRelation: 'survey_sections'; + referencedColumns: ['id']; } - ] - } + ]; + }; survey_sections: { Row: { - id: number - section_id: number | null - servey_title: string | null - survey_id: number | null - } + id: number; + section_id: number | null; + survey_id: number | null; + survey_title: string | null; + }; Insert: { - id?: never - section_id?: number | null - servey_title?: string | null - survey_id?: number | null - } + id?: never; + section_id?: number | null; + survey_id?: number | null; + survey_title?: string | null; + }; Update: { - id?: never - section_id?: number | null - servey_title?: string | null - survey_id?: number | null - } + id?: never; + section_id?: number | null; + survey_id?: number | null; + survey_title?: string | null; + }; Relationships: [ { - foreignKeyName: "survey_sections_survey_id_fkey" - columns: ["survey_id"] - isOneToOne: false - referencedRelation: "surveys" - referencedColumns: ["id"] + foreignKeyName: 'survey_sections_survey_id_fkey'; + columns: ['survey_id']; + isOneToOne: false; + referencedRelation: 'surveys'; + referencedColumns: ['id']; } - ] - } + ]; + }; surveys: { Row: { - description: string | null - id: number - title: string - } + description: string | null; + id: number; + title: string; + }; Insert: { - description?: string | null - id?: never - title: string - } + description?: string | null; + id?: never; + title: string; + }; Update: { - description?: string | null - id?: never - title?: string - } - Relationships: [] - } - } + description?: string | null; + id?: never; + title?: string; + }; + Relationships: []; + }; + }; Views: { - [_ in never]: never - } + [_ in never]: never; + }; Functions: { - [_ in never]: never - } + [_ in never]: never; + }; Enums: { - [_ in never]: never - } + [_ in never]: never; + }; CompositeTypes: { - [_ in never]: never - } - } -} + [_ in never]: never; + }; + }; +}; export type Tables< PublicTableNameOrOptions extends - | keyof (Database["public"]["Tables"] & Database["public"]["Views"]) + | keyof (Database['public']['Tables'] & Database['public']['Views']) | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"]) + ? keyof (Database[PublicTableNameOrOptions['schema']]['Tables'] & + Database[PublicTableNameOrOptions['schema']]['Views']) : never = never > = PublicTableNameOrOptions extends { schema: keyof Database } - ? (Database[PublicTableNameOrOptions["schema"]]["Tables"] & - Database[PublicTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R + ? (Database[PublicTableNameOrOptions['schema']]['Tables'] & + Database[PublicTableNameOrOptions['schema']]['Views'])[TableName] extends { + Row: infer R; } ? R : never - : PublicTableNameOrOptions extends keyof (Database["public"]["Tables"] & - Database["public"]["Views"]) - ? (Database["public"]["Tables"] & - Database["public"]["Views"])[PublicTableNameOrOptions] extends { - Row: infer R + : PublicTableNameOrOptions extends keyof (Database['public']['Tables'] & + Database['public']['Views']) + ? (Database['public']['Tables'] & + Database['public']['Views'])[PublicTableNameOrOptions] extends { + Row: infer R; } ? R : never - : never + : never; export type TablesInsert< PublicTableNameOrOptions extends - | keyof Database["public"]["Tables"] + | keyof Database['public']['Tables'] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] : never = never > = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Insert: infer I; } ? I : never - : PublicTableNameOrOptions extends keyof Database["public"]["Tables"] - ? Database["public"]["Tables"][PublicTableNameOrOptions] extends { - Insert: infer I + : PublicTableNameOrOptions extends keyof Database['public']['Tables'] + ? Database['public']['Tables'][PublicTableNameOrOptions] extends { + Insert: infer I; } ? I : never - : never + : never; export type TablesUpdate< PublicTableNameOrOptions extends - | keyof Database["public"]["Tables"] + | keyof Database['public']['Tables'] | { schema: keyof Database }, TableName extends PublicTableNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicTableNameOrOptions["schema"]]["Tables"] + ? keyof Database[PublicTableNameOrOptions['schema']]['Tables'] : never = never > = PublicTableNameOrOptions extends { schema: keyof Database } - ? Database[PublicTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U + ? Database[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Update: infer U; } ? U : never - : PublicTableNameOrOptions extends keyof Database["public"]["Tables"] - ? Database["public"]["Tables"][PublicTableNameOrOptions] extends { - Update: infer U + : PublicTableNameOrOptions extends keyof Database['public']['Tables'] + ? Database['public']['Tables'][PublicTableNameOrOptions] extends { + Update: infer U; } ? U : never - : never + : never; export type Enums< PublicEnumNameOrOptions extends - | keyof Database["public"]["Enums"] + | keyof Database['public']['Enums'] | { schema: keyof Database }, EnumName extends PublicEnumNameOrOptions extends { schema: keyof Database } - ? keyof Database[PublicEnumNameOrOptions["schema"]]["Enums"] + ? keyof Database[PublicEnumNameOrOptions['schema']]['Enums'] : never = never > = PublicEnumNameOrOptions extends { schema: keyof Database } - ? Database[PublicEnumNameOrOptions["schema"]]["Enums"][EnumName] - : PublicEnumNameOrOptions extends keyof Database["public"]["Enums"] - ? Database["public"]["Enums"][PublicEnumNameOrOptions] - : never + ? Database[PublicEnumNameOrOptions['schema']]['Enums'][EnumName] + : PublicEnumNameOrOptions extends keyof Database['public']['Enums'] + ? Database['public']['Enums'][PublicEnumNameOrOptions] + : never;