├── .github └── workflows │ ├── lint.yml │ └── tests.yml ├── .gitignore ├── LICENSE ├── README.md ├── docker-run.sh └── services ├── admin-console ├── .env ├── .env.example ├── .eslintrc.json ├── .gitignore ├── .prettierrc ├── README.md ├── components.json ├── dev.Dockerfile ├── docker-compose.yml ├── jest.config.js ├── next.config.js ├── package.json ├── pnpm-lock.yaml ├── postcss.config.js ├── prod.Dockerfile ├── public │ ├── favicon.ico │ └── images │ │ ├── billing │ │ ├── amex.svg │ │ ├── diners.svg │ │ ├── discover.svg │ │ ├── eftpos_au.svg │ │ ├── jcb.svg │ │ ├── mastercard.svg │ │ ├── unionpay.svg │ │ ├── unkown.svg │ │ └── visa.svg │ │ ├── databases │ │ ├── aws-athena.svg │ │ ├── bigquery.svg │ │ ├── clickhouse.svg │ │ ├── databricks.svg │ │ ├── mariadb.svg │ │ ├── postgresql.svg │ │ ├── redshift.png │ │ ├── redshift.svg │ │ ├── snowflake.svg │ │ ├── sql-server.png │ │ └── sql-server.svg │ │ ├── dh-logo-color.svg │ │ ├── dh-logo-symbol-color.svg │ │ ├── dh_ai_logo.svg │ │ ├── dh_background.png │ │ ├── discord.png │ │ ├── llm_models │ │ └── openai.png │ │ ├── openai.png │ │ ├── slack-black.png │ │ └── slack-color.png ├── src │ ├── components │ │ ├── api-keys │ │ │ ├── api-keys-list.tsx │ │ │ ├── columns.tsx │ │ │ ├── delete-api-key-dialog.tsx │ │ │ └── generate-api-key-dialog.tsx │ │ ├── billing │ │ │ ├── add-payment-method-dialog.tsx │ │ │ └── credit-card-logo.tsx │ │ ├── data-table │ │ │ ├── index.tsx │ │ │ ├── loading-rows.tsx │ │ │ └── loading-table.tsx │ │ ├── databases │ │ │ ├── column-resource.tsx │ │ │ ├── database-connection-form-dialog.tsx │ │ │ ├── database-connection-form.tsx │ │ │ ├── database-details.tsx │ │ │ ├── database-resource-sheet.tsx │ │ │ ├── database-resource.tsx │ │ │ ├── database-tree.tsx │ │ │ ├── databases-tree.tsx │ │ │ ├── first-database-connection.tsx │ │ │ ├── form-schema.ts │ │ │ ├── loading-resource.tsx │ │ │ ├── loading.tsx │ │ │ ├── sample-database-connection-dialog.tsx │ │ │ └── table-resource.tsx │ │ ├── error │ │ │ ├── error-details.tsx │ │ │ └── page-error-message.tsx │ │ ├── fine-tunnings │ │ │ └── columns.tsx │ │ ├── golden-sql │ │ │ └── columns.tsx │ │ ├── hoc │ │ │ ├── WithAnalytics.tsx │ │ │ ├── WithApiFetcher.tsx │ │ │ ├── WithBilling.tsx │ │ │ ├── WithMobileRedirect.tsx │ │ │ └── WithSubscription.tsx │ │ ├── layout │ │ │ ├── background-page-layout.tsx │ │ │ ├── breadcrum-header.tsx │ │ │ ├── loading-list.tsx │ │ │ ├── loading-page.tsx │ │ │ ├── page-layout.tsx │ │ │ └── sidebar-nav.tsx │ │ ├── organization │ │ │ ├── edit-organization-dialog.tsx │ │ │ ├── llm-api-key.tsx │ │ │ └── payment-methods-list.tsx │ │ ├── queries │ │ │ └── columns.tsx │ │ ├── query │ │ │ ├── custom-message-dialog.tsx │ │ │ ├── last-updated.tsx │ │ │ ├── loading-box.tsx │ │ │ ├── loading.tsx │ │ │ ├── message-section.tsx │ │ │ ├── process.tsx │ │ │ ├── query-metadata.tsx │ │ │ ├── question.tsx │ │ │ ├── section-header.tsx │ │ │ ├── send-message-dialog.tsx │ │ │ ├── sql-editor.tsx │ │ │ ├── sql-results-table.tsx │ │ │ └── workspace.tsx │ │ ├── ui │ │ │ ├── alert-dialog.tsx │ │ │ ├── alert.tsx │ │ │ ├── badge.tsx │ │ │ ├── button.tsx │ │ │ ├── checkbox.tsx │ │ │ ├── content-box.tsx │ │ │ ├── dialog.tsx │ │ │ ├── dropdown-menu.tsx │ │ │ ├── form.tsx │ │ │ ├── input.tsx │ │ │ ├── label.tsx │ │ │ ├── markdown-renderer.tsx │ │ │ ├── popover.tsx │ │ │ ├── radio-group.tsx │ │ │ ├── search-input.tsx │ │ │ ├── select.tsx │ │ │ ├── separator.tsx │ │ │ ├── sheet.tsx │ │ │ ├── skeleton.tsx │ │ │ ├── switch.tsx │ │ │ ├── table.tsx │ │ │ ├── tabs.tsx │ │ │ ├── textarea.tsx │ │ │ ├── toast.tsx │ │ │ ├── toaster.tsx │ │ │ ├── tooltip.tsx │ │ │ ├── tree-view-context.tsx │ │ │ ├── tree-view-global-context.tsx │ │ │ ├── tree-view.helpers.ts │ │ │ ├── tree-view.tsx │ │ │ └── use-toast.ts │ │ ├── usage │ │ │ ├── credits-chart.tsx │ │ │ ├── edit-spending-limit-dialog.tsx │ │ │ ├── monthly-usage.tsx │ │ │ ├── sub-blocked-dialog.tsx │ │ │ └── usage-chart.tsx │ │ └── user │ │ │ ├── invite-member-dialog.tsx │ │ │ ├── user-list.tsx │ │ │ └── user-picture.tsx │ ├── config.ts │ ├── constants │ │ ├── database-providers.ts │ │ └── llm-models.ts │ ├── contexts │ │ ├── app-context.tsx │ │ ├── auth-context.tsx │ │ ├── self-serve-context.tsx │ │ ├── subscription-context.tsx │ │ └── ui-context.tsx │ ├── hooks │ │ ├── api │ │ │ ├── api-keys │ │ │ │ ├── useApiKeys.ts │ │ │ │ ├── useDeleteApiKey.ts │ │ │ │ └── usePostApiKey.ts │ │ │ ├── billing │ │ │ │ ├── useDeletePaymentMethod.ts │ │ │ │ ├── usePaymentMethods.ts │ │ │ │ ├── usePostPaymentMethod.ts │ │ │ │ ├── usePutSpendingLimits.ts │ │ │ │ ├── useSpendingLimits.tsx │ │ │ │ └── useUsage.tsx │ │ │ ├── database-connection │ │ │ │ ├── useDatabaseConnection.ts │ │ │ │ ├── useDatabaseConnections.ts │ │ │ │ ├── useDatabases.ts │ │ │ │ ├── usePostDatabaseConnection.ts │ │ │ │ ├── usePostSampleDatabaseConnection.ts │ │ │ │ ├── useSampleDatabaseConnections.ts │ │ │ │ └── useSynchronizeSchemas.ts │ │ │ ├── fine-tuning │ │ │ │ └── useFinetunings.ts │ │ │ ├── generics │ │ │ │ ├── useApiFetcher.ts │ │ │ │ ├── useDelete.ts │ │ │ │ ├── useGet.ts │ │ │ │ ├── useMockGetter.ts │ │ │ │ ├── useMockPagination.ts │ │ │ │ ├── usePagination.ts │ │ │ │ ├── usePatch.ts │ │ │ │ ├── usePost.ts │ │ │ │ └── usePut.ts │ │ │ ├── organization │ │ │ │ ├── useGetOrganization.ts │ │ │ │ ├── useOrganizations.ts │ │ │ │ └── usePutOrganization.ts │ │ │ ├── query │ │ │ │ ├── useQueries.ts │ │ │ │ ├── useQuery.ts │ │ │ │ ├── useQueryExecution.ts │ │ │ │ ├── useQueryGenerateMessage.ts │ │ │ │ ├── useQueryPut.ts │ │ │ │ ├── useQueryResubmit.ts │ │ │ │ └── useQuerySendMessage.ts │ │ │ ├── useDeleteGoldenSql.ts │ │ │ ├── useDownloadFile.ts │ │ │ ├── useGoldenSqlList.ts │ │ │ └── user │ │ │ │ ├── useDeleteUser.ts │ │ │ │ ├── useGetUser.ts │ │ │ │ ├── usePatchUser.ts │ │ │ │ ├── usePostUser.ts │ │ │ │ ├── usePostUserToOrganization.ts │ │ │ │ └── useUsers.ts │ │ ├── database │ │ │ ├── useColumnResource.ts │ │ │ ├── useDatabaseOptions.tsx │ │ │ ├── useDatabaseResource.ts │ │ │ ├── useDatabaseResourceFromTree.ts │ │ │ └── useTableResource.ts │ │ ├── ui │ │ │ └── useIsMobile.tsx │ │ └── useDebounce.ts │ ├── lib │ │ ├── api │ │ │ ├── server-fetcher.test.ts │ │ │ └── server-fetcher.ts │ │ ├── domain │ │ │ ├── billing.tsx │ │ │ ├── database.tsx │ │ │ ├── error.tsx │ │ │ └── query.ts │ │ └── utils.tsx │ ├── models │ │ ├── api.ts │ │ ├── domain.ts │ │ └── errorCodes.ts │ ├── pages │ │ ├── _app.tsx │ │ ├── _document.tsx │ │ ├── api-keys │ │ │ └── index.tsx │ │ ├── api │ │ │ ├── auth │ │ │ │ ├── [...auth0].ts │ │ │ │ └── token.ts │ │ │ └── health-check.ts │ │ ├── auth │ │ │ └── error.tsx │ │ ├── billing │ │ │ └── index.tsx │ │ ├── change-organization │ │ │ └── index.tsx │ │ ├── databases │ │ │ └── index.tsx │ │ ├── fine-tuning │ │ │ └── index.tsx │ │ ├── golden-sql │ │ │ └── index.tsx │ │ ├── my-account │ │ │ └── index.tsx │ │ ├── organization │ │ │ └── index.tsx │ │ ├── playground │ │ │ └── index.tsx │ │ ├── queries │ │ │ ├── [queryId] │ │ │ │ ├── download-csv.tsx │ │ │ │ └── index.tsx │ │ │ └── index.tsx │ │ ├── switch-to-larger-screen │ │ │ └── index.tsx │ │ └── usage │ │ │ └── index.tsx │ └── styles │ │ └── globals.css ├── tailwind.config.js ├── tsconfig.json └── vercel.json ├── engine ├── .dockerignore ├── .env.example ├── .gitignore ├── .readthedocs.yaml ├── .test.env ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── dataherald │ ├── __init__.py │ ├── api │ │ ├── __init__.py │ │ ├── fastapi.py │ │ └── types │ │ │ ├── __init__.py │ │ │ ├── query.py │ │ │ ├── requests.py │ │ │ └── responses.py │ ├── app.py │ ├── config.py │ ├── context_store │ │ ├── __init__.py │ │ └── default.py │ ├── db │ │ ├── __init__.py │ │ └── mongo.py │ ├── db_scanner │ │ ├── __init__.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ └── types.py │ │ ├── repository │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ └── query_history.py │ │ ├── services │ │ │ ├── __init__.py │ │ │ ├── abstract_scanner.py │ │ │ ├── base_scanner.py │ │ │ ├── big_query_scanner.py │ │ │ ├── click_house_scanner.py │ │ │ ├── postgre_sql_scanner.py │ │ │ ├── redshift_scanner.py │ │ │ ├── snowflake_scanner.py │ │ │ └── sql_server_scanner.py │ │ └── sqlalchemy.py │ ├── eval │ │ ├── __init__.py │ │ ├── eval_agent.py │ │ └── simple_evaluator.py │ ├── finetuning │ │ ├── __init__.py │ │ └── openai_finetuning.py │ ├── model │ │ ├── __init__.py │ │ ├── base_model.py │ │ └── chat_model.py │ ├── repositories │ │ ├── __init__.py │ │ ├── database_connections.py │ │ ├── finetunings.py │ │ ├── golden_sqls.py │ │ ├── instructions.py │ │ ├── nl_generations.py │ │ ├── prompts.py │ │ └── sql_generations.py │ ├── scripts │ │ ├── __init__.py │ │ ├── delete_and_populate_golden_records.py │ │ ├── migrate_v001_to_v002.py │ │ ├── migrate_v002_to_v003.py │ │ ├── migrate_v003_to_v004.py │ │ ├── migrate_v004_to_v005.py │ │ ├── migrate_v006_to_v100.py │ │ ├── migrate_v100_to_v101.py │ │ └── populate_dialect_db_connection.py │ ├── server │ │ ├── __init__.py │ │ └── fastapi │ │ │ └── __init__.py │ ├── services │ │ ├── __init__.py │ │ ├── nl_generations.py │ │ ├── prompts.py │ │ └── sql_generations.py │ ├── smart_cache │ │ └── __init__.py │ ├── sql_database │ │ ├── __init__.py │ │ ├── base.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ └── types.py │ │ └── services │ │ │ ├── __init__.py │ │ │ └── database_connection.py │ ├── sql_generator │ │ ├── __init__.py │ │ ├── adaptive_agent_executor.py │ │ ├── create_sql_query_status.py │ │ ├── dataherald_finetuning_agent.py │ │ ├── dataherald_sqlagent.py │ │ └── generates_nl_answer.py │ ├── tests │ │ ├── __init__.py │ │ ├── conftest.py │ │ ├── db │ │ │ ├── __init__.py │ │ │ └── test_db.py │ │ ├── db_scanner │ │ │ ├── __init__.py │ │ │ ├── repository │ │ │ │ ├── __init__.py │ │ │ │ └── test_base.py │ │ │ └── test_sqlalchemy.py │ │ ├── evaluator │ │ │ ├── __init__.py │ │ │ └── test_eval.py │ │ ├── sql_generator │ │ │ ├── __init__.py │ │ │ └── test_generator.py │ │ ├── test_api.py │ │ └── vector_store │ │ │ ├── __init__.py │ │ │ └── test_vector_store.py │ ├── types.py │ ├── utils │ │ ├── __init__.py │ │ ├── agent_prompts.py │ │ ├── encrypt.py │ │ ├── error_codes.py │ │ ├── models_context_window.py │ │ ├── s3.py │ │ ├── sql_utils.py │ │ ├── strings.py │ │ └── timeout_utils.py │ └── vector_store │ │ ├── __init__.py │ │ ├── astra.py │ │ ├── chroma.py │ │ └── pinecone.py ├── docker-compose.yml ├── docs │ ├── Makefile │ ├── _static │ │ └── placeholder.txt │ ├── api.add_instructions.rst │ ├── api.cancel_finetuning.rst │ ├── api.create_database_connection.rst │ ├── api.create_nl_generation.rst │ ├── api.create_prompt.rst │ ├── api.create_prompt_sql_generation.rst │ ├── api.create_prompt_sql_generation_nl_generation.rst │ ├── api.create_sql_generation.rst │ ├── api.create_sql_generation_nl_generation.rst │ ├── api.delete_finetuning.rst │ ├── api.delete_instructions.rst │ ├── api.error_codes.rst │ ├── api.execute_sql_generation.rst │ ├── api.finetuning.rst │ ├── api.get_csv_file.rst │ ├── api.get_finetuning.rst │ ├── api.get_nl_generation.rst │ ├── api.get_prompt.rst │ ├── api.get_sql_generation.rst │ ├── api.get_table_description.rst │ ├── api.golden_sql.rst │ ├── api.list_database_connections.rst │ ├── api.list_finetunings.rst │ ├── api.list_instructions.rst │ ├── api.list_nl_generations.rst │ ├── api.list_prompts.rst │ ├── api.list_query_history.rst │ ├── api.list_sql_generations.rst │ ├── api.list_table_description.rst │ ├── api.refresh_table_description.rst │ ├── api.rst │ ├── api.scan_table_description.rst │ ├── api.update_database_connection.rst │ ├── api.update_instructions.rst │ ├── api.update_table_descriptions.rst │ ├── api_server.rst │ ├── architecture.png │ ├── conf.py │ ├── context_store.rst │ ├── contributing.projects.rst │ ├── db.rst │ ├── envars.rst │ ├── evaluator.rst │ ├── finetuning.rst │ ├── index.rst │ ├── introduction.rst │ ├── make.bat │ ├── modules.rst │ ├── quickstart.rst │ ├── requirements.txt │ ├── text_to_sql_engine.rst │ ├── tutorial.chatgpt_plugin.rst │ ├── tutorial.finetune_sql_generator.rst │ ├── tutorial.run_scripts.rst │ ├── tutorial.sample_database.rst │ ├── tutorial.streamlit_app.rst │ └── vector_store.rst ├── initdb.d │ └── init-mongo.sh ├── log_config.yml ├── pyproject.toml ├── requirements.txt ├── setup.py └── tmp │ └── __init__.py ├── enterprise ├── .dockerignore ├── .env.example ├── Dockerfile ├── Makefile ├── README.md ├── __init__.py ├── app.py ├── config.py ├── database │ ├── __init__.py │ ├── migrations │ │ ├── README.md │ │ ├── changelog.json │ │ ├── liquibase.advanced.flowfile.yaml │ │ ├── liquibase.checks-package.yaml │ │ ├── liquibase.endstage.flow │ │ ├── liquibase.flowfile.yaml │ │ ├── liquibase.flowvariables.yaml │ │ └── liquibase.properties │ ├── mongo.py │ └── scripts │ │ ├── __init__.py │ │ ├── copy_org_resources.py │ │ ├── data_report.py │ │ ├── delete_db_connection.py │ │ ├── migrate_org_resources │ │ ├── README.md │ │ ├── dump_org_resources.sh │ │ └── restore_org_resources.sh │ │ ├── populate_pinecone_db │ │ ├── requirements.txt │ │ └── script.py │ │ └── upload_ssh_key_file.py ├── docker-compose.yml ├── exceptions │ ├── error_codes.py │ ├── error_response.py │ ├── exception_handlers.py │ ├── exceptions.py │ └── utils.py ├── middleware │ └── error.py ├── modules │ ├── auth │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── db_connection │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── finetuning │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── generation │ │ ├── __init__.py │ │ ├── aggr_controller.py │ │ ├── aggr_service.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── golden_sql │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __ini__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── instruction │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── key │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── organization │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── invoice │ │ │ ├── controller.py │ │ │ ├── models │ │ │ │ ├── entities.py │ │ │ │ ├── exceptions.py │ │ │ │ ├── requests.py │ │ │ │ └── responses.py │ │ │ ├── repository.py │ │ │ ├── service.py │ │ │ └── webhook.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ ├── table_description │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── entities.py │ │ │ ├── exceptions.py │ │ │ ├── requests.py │ │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py │ └── user │ │ ├── __init__.py │ │ ├── controller.py │ │ ├── models │ │ ├── __init__.py │ │ ├── entities.py │ │ ├── exceptions.py │ │ ├── requests.py │ │ └── responses.py │ │ ├── repository.py │ │ └── service.py ├── pyproject.toml ├── requirements.txt ├── scripts │ ├── __init__.py │ └── record_usage.py ├── tmp │ └── __init__.py └── utils │ ├── __init__.py │ ├── analytics.py │ ├── auth.py │ ├── billing.py │ ├── encrypt.py │ ├── misc.py │ ├── s3.py │ ├── sample_db.py │ ├── slack.py │ └── validation.py └── slackbot ├── .aws ├── task-definition-prod.json └── task-definition-stage.json ├── .env.example ├── .eslintrc ├── .prettierrc ├── Dockerfile ├── README.md ├── auth └── index.js ├── config └── index.js ├── docker-compose.yml ├── handlers └── message │ └── index.js ├── package.json ├── pnpm-lock.yaml └── server └── index.js /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | on: [push] 3 | jobs: 4 | lint: 5 | runs-on: ubuntu-latest 6 | defaults: 7 | run: 8 | working-directory: ./services/engine 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: chartboost/ruff-action@v1 12 | - uses: psf/black@stable 13 | 14 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | defaults: 10 | run: 11 | working-directory: ./services/engine 12 | strategy: 13 | matrix: 14 | python-version: ["3.11"] 15 | 16 | steps: 17 | - uses: actions/checkout@v3 18 | - name: Set up Python ${{ matrix.python-version }} 19 | uses: actions/setup-python@v4 20 | with: 21 | python-version: ${{ matrix.python-version }} 22 | - name: Install dependencies 23 | run: | 24 | python -m pip install --upgrade pip 25 | pip install ruff pytest 26 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 27 | - name: Test with pytest 28 | run: | 29 | pytest 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /home/aazo11/CYCPrototype/env 2 | __pycache__/ 3 | .vscode/ 4 | venv/ 5 | *.zip 6 | .idea/* 7 | id_rsa 8 | dbdata/ 9 | 10 | **/node_modules 11 | 12 | # Environments 13 | .env 14 | .env.test 15 | .venv 16 | env/ 17 | ENV/ 18 | env.bak/ 19 | .DS_Store 20 | 21 | 22 | # .tfstate files 23 | *.tfstate 24 | *.tfstate.* 25 | 26 | # Crash log files 27 | crash.log 28 | crash.*.log 29 | 30 | **/.terraform/* 31 | .vercel 32 | -------------------------------------------------------------------------------- /docker-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Create Docker network 4 | docker network create dataherald_network 5 | 6 | # Bring up services with Docker Compose 7 | docker-compose -p dataherald -f services/engine/docker-compose.yml up --build -d 8 | docker-compose -p dataherald -f services/enterprise/docker-compose.yml up --build -d 9 | docker-compose -p dataherald -f services/slackbot/docker-compose.yml up --build -d 10 | docker-compose -p dataherald -f services/admin-console/docker-compose.yml up --build -d -------------------------------------------------------------------------------- /services/admin-console/.env: -------------------------------------------------------------------------------- 1 | AUTH0_SCOPE="openid profile email offline_access" 2 | -------------------------------------------------------------------------------- /services/admin-console/.env.example: -------------------------------------------------------------------------------- 1 | NODE_ENV="development" # development | production 2 | 3 | # API URL 4 | NEXT_PUBLIC_API_URL='http://localhost:3001' # enterprise API service url 5 | 6 | # AUTH 0 CONFIG 7 | AUTH0_BASE_URL='http://localhost:3000' # admin-console url 8 | AUTH0_SECRET= # use [openssl rand -hex 32] to generate a 32 bytes value 9 | AUTH0_ISSUER_BASE_URL= # your auth0 issuer url, i.e.: https://auth.dataherald.com/ 10 | AUTH0_API_AUDIENCE= # your auth0 API audience, i.e.: https://dataherald.us.auth0.com/api/v2/ 11 | AUTH0_CLIENT_ID= # your auth0 application client ID 12 | AUTH0_CLIENT_SECRET= # your auth0 application client secret 13 | 14 | # (OPTIONAL) Posthog Analytics 15 | NEXT_PUBLIC_POSTHOG_DISABLED='true' 16 | NEXT_PUBLIC_POSTHOG_KEY= 17 | NEXT_PUBLIC_POSTHOG_HOST="https://app.posthog.com" 18 | 19 | 20 | # (OPTIONAL) STRIPE 21 | NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY= 22 | -------------------------------------------------------------------------------- /services/admin-console/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "next/core-web-vitals", 4 | "eslint:recommended", 5 | "plugin:@typescript-eslint/recommended", 6 | "plugin:react/recommended", 7 | "plugin:prettier/recommended", 8 | "prettier" 9 | ], 10 | "plugins": ["react", "prettier", "@typescript-eslint"], 11 | "rules": { 12 | "prettier/prettier": [ 13 | "error", 14 | { 15 | "semi": false 16 | } 17 | ], 18 | "react/react-in-jsx-scope": "off", 19 | "react/prop-types": "off" 20 | }, 21 | "settings": { 22 | "react": { 23 | "version": "detect" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /services/admin-console/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | !.env 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /services/admin-console/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "trailingComma": "all", 4 | "singleQuote": true, 5 | "printWidth": 80, 6 | "tabWidth": 2 7 | } 8 | -------------------------------------------------------------------------------- /services/admin-console/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "default", 4 | "rsc": false, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "src/styles/globals.css", 9 | "baseColor": "slate", 10 | "cssVariables": true 11 | }, 12 | "aliases": { 13 | "components": "@/components", 14 | "utils": "@/lib/utils" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /services/admin-console/dev.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-alpine 2 | 3 | LABEL Author="Juan Sebastian Valacco" 4 | 5 | WORKDIR /app 6 | 7 | # Install dependencies based on the preferred package manager 8 | COPY package.json pnpm-lock.yaml* ./ 9 | RUN corepack enable pnpm && pnpm i 10 | 11 | COPY . . 12 | 13 | # Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry 14 | # Uncomment the following line to disable telemetry at run time 15 | ENV NEXT_TELEMETRY_DISABLED 1 16 | 17 | # Docker network URL for the API -- used for nextjs server side API calls inside the docker network 18 | # The browser needs to access the API from the exposed port in the docker host (i.e.: localhost:3001) 19 | ENV DOCKER_API_URL='http://api:3001' 20 | 21 | # Note: Don't expose ports here, Compose will handle that for us 22 | 23 | # Start Next.js in development mode based on the preferred package manager 24 | CMD pnpm dev -------------------------------------------------------------------------------- /services/admin-console/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | next-app: 3 | container_name: console 4 | build: 5 | context: . 6 | dockerfile: dev.Dockerfile 7 | env_file: 8 | - .env.local 9 | volumes: 10 | - ./src:/app/src 11 | - ./public:/app/public 12 | ports: 13 | - 3000:3000 14 | restart: always 15 | networks: 16 | - dataherald_network 17 | networks: 18 | dataherald_network: 19 | external: true 20 | -------------------------------------------------------------------------------- /services/admin-console/jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testEnvironment: 'node', 5 | } 6 | -------------------------------------------------------------------------------- /services/admin-console/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | output: 'standalone', 4 | reactStrictMode: true, 5 | images: { 6 | remotePatterns: [ 7 | { 8 | protocol: 'https', 9 | hostname: 'lh3.googleusercontent.com', 10 | }, 11 | { 12 | protocol: 'https', 13 | hostname: 's.gravatar.com', 14 | }, 15 | ], 16 | }, 17 | async redirects() { 18 | return [ 19 | { 20 | source: '/', 21 | destination: '/databases', 22 | permanent: true, 23 | }, 24 | ] 25 | }, 26 | } 27 | 28 | module.exports = nextConfig 29 | -------------------------------------------------------------------------------- /services/admin-console/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /services/admin-console/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/favicon.ico -------------------------------------------------------------------------------- /services/admin-console/public/images/billing/mastercard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /services/admin-console/public/images/billing/unkown.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /services/admin-console/public/images/databases/clickhouse.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /services/admin-console/public/images/databases/redshift.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/databases/redshift.png -------------------------------------------------------------------------------- /services/admin-console/public/images/databases/sql-server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/databases/sql-server.png -------------------------------------------------------------------------------- /services/admin-console/public/images/dh_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/dh_background.png -------------------------------------------------------------------------------- /services/admin-console/public/images/discord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/discord.png -------------------------------------------------------------------------------- /services/admin-console/public/images/llm_models/openai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/llm_models/openai.png -------------------------------------------------------------------------------- /services/admin-console/public/images/openai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/openai.png -------------------------------------------------------------------------------- /services/admin-console/public/images/slack-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/slack-black.png -------------------------------------------------------------------------------- /services/admin-console/public/images/slack-color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dataherald/dataherald/f8946182e6db55522b88cd5a831c788339b8fc42/services/admin-console/public/images/slack-color.png -------------------------------------------------------------------------------- /services/admin-console/src/components/api-keys/columns.tsx: -------------------------------------------------------------------------------- 1 | import DeleteApiKeyDialog from '@/components/api-keys/delete-api-key-dialog' 2 | import { ApiKey } from '@/models/api' 3 | import { ColumnDef } from '@tanstack/react-table' 4 | import { format } from 'date-fns' 5 | 6 | export const getApiKeysColumns: (actions: { 7 | remove: (id: string) => void | Promise 8 | }) => ColumnDef[] = ({ remove }) => [ 9 | { 10 | id: 'name', 11 | header: 'Name', 12 | accessorKey: 'name', 13 | }, 14 | { 15 | id: 'key_preview', 16 | header: 'Secret key', 17 | accessorKey: 'key_preview', 18 | }, 19 | { 20 | id: 'created_at', 21 | header: () =>
Created at
, 22 | accessorKey: 'created_at', 23 | cell: ({ row }) => { 24 | const date: string = row.getValue('created_at') 25 | return date ? format(new Date(date), 'PP') : '-' 26 | }, 27 | }, 28 | { 29 | id: 'delete', 30 | width: 'auto', 31 | size: 20, 32 | cell: ({ row }) => { 33 | const { id } = row.original 34 | return remove(id)} /> 35 | }, 36 | }, 37 | ] 38 | -------------------------------------------------------------------------------- /services/admin-console/src/components/billing/credit-card-logo.tsx: -------------------------------------------------------------------------------- 1 | import { CreditCardBrand } from '@/models/api' 2 | import Image from 'next/image' 3 | import { FC } from 'react' 4 | 5 | interface CreditCardLogoProps { 6 | brand: CreditCardBrand 7 | } 8 | 9 | const CreditCardLogo: FC = ({ brand }) => ( 10 | {brand} 16 | ) 17 | 18 | export default CreditCardLogo 19 | -------------------------------------------------------------------------------- /services/admin-console/src/components/data-table/loading-rows.tsx: -------------------------------------------------------------------------------- 1 | import { Skeleton } from '@/components/ui/skeleton' 2 | import { TableCell, TableRow } from '@/components/ui/table' 3 | 4 | interface LoadingTableRowsProps { 5 | columnLength?: number 6 | rowLength?: number 7 | } 8 | 9 | export function LoadingTableRows({ 10 | columnLength = 5, 11 | rowLength = 3, 12 | }: LoadingTableRowsProps) { 13 | const rows = Array.from({ length: rowLength }) 14 | const columns = Array.from({ length: columnLength }) 15 | return ( 16 | <> 17 | {rows.map((_, rowIndex) => ( 18 | 19 | {columns.map((_, colIdx) => ( 20 | 21 | 22 | 23 | ))} 24 | 25 | ))} 26 | 27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /services/admin-console/src/components/databases/databases-tree.tsx: -------------------------------------------------------------------------------- 1 | import DatabaseResourceSheet from '@/components/databases/database-resource-sheet' 2 | import DatabaseTree from '@/components/databases/database-tree' 3 | import { TreeProvider } from '@/components/ui/tree-view-context' 4 | import { Databases } from '@/models/api' 5 | import { FC } from 'react' 6 | 7 | interface DatabasesTreeProps { 8 | databases: Databases 9 | } 10 | 11 | const DatabasesTree: FC = ({ databases }) => { 12 | return ( 13 |
14 | {databases && 15 | databases.map((database) => ( 16 | 17 | 18 | 19 | 20 | ))} 21 |
22 | ) 23 | } 24 | 25 | export default DatabasesTree 26 | -------------------------------------------------------------------------------- /services/admin-console/src/components/databases/loading-resource.tsx: -------------------------------------------------------------------------------- 1 | import { Skeleton } from '@/components/ui/skeleton' 2 | import { FC } from 'react' 3 | 4 | const LoadingDatabaseResource: FC = () => ( 5 |
6 |
7 | 8 | 9 | 10 |
11 |
12 | ) 13 | 14 | export default LoadingDatabaseResource 15 | -------------------------------------------------------------------------------- /services/admin-console/src/components/error/page-error-message.tsx: -------------------------------------------------------------------------------- 1 | import ErrorDetails from '@/components/error/error-details' 2 | import { Toaster } from '@/components/ui/toaster' 3 | import { ErrorResponse } from '@/models/api' 4 | import { AlertOctagon } from 'lucide-react' 5 | import { FC, HTMLAttributes } from 'react' 6 | 7 | export type PageErrorMessageProps = HTMLAttributes & { 8 | message: string 9 | error?: ErrorResponse 10 | } 11 | 12 | const PageErrorMessage: FC = ({ 13 | message, 14 | error, 15 | ...props 16 | }) => ( 17 |
18 |
19 | 20 | {message} 21 |
22 | {error && } 23 | 24 |
25 | ) 26 | 27 | export default PageErrorMessage 28 | -------------------------------------------------------------------------------- /services/admin-console/src/components/fine-tunnings/columns.tsx: -------------------------------------------------------------------------------- 1 | import { formatStatus } from '@/lib/utils' 2 | import { FineTuningModel } from '@/models/api' 3 | import { ColumnDef } from '@tanstack/react-table' 4 | import { format } from 'date-fns' 5 | 6 | export const finetunningsColumns: ColumnDef[] = [ 7 | { 8 | id: 'alias', 9 | header: 'Name', 10 | cell: ({ row }) => { 11 | const { id, alias } = row.original 12 | return
{alias || id}
13 | }, 14 | }, 15 | { 16 | id: 'db_connection_alias', 17 | header: 'Database', 18 | accessorKey: 'db_connection_alias', 19 | }, 20 | { 21 | id: 'model_name', 22 | header: 'Model', 23 | accessorKey: 'base_llm.model_name', 24 | }, 25 | { 26 | id: 'created_at', 27 | header: () =>
Created at
, 28 | accessorKey: 'created_at', 29 | cell: ({ row }) => { 30 | const date: string = row.getValue('created_at') 31 | return date ? format(new Date(date), 'PP') : '-' 32 | }, 33 | }, 34 | { 35 | id: 'status', 36 | header: 'Status', 37 | accessorKey: 'status', 38 | cell: ({ row }) => formatStatus(row.getValue('status')), 39 | }, 40 | ] 41 | -------------------------------------------------------------------------------- /services/admin-console/src/components/hoc/WithAnalytics.tsx: -------------------------------------------------------------------------------- 1 | import { POSTHOG_DISABLED, POSTHOG_HOST, POSTHOG_KEY } from '@/config' 2 | import { useAppContext } from '@/contexts/app-context' 3 | import { posthog } from 'posthog-js' 4 | import { PostHogProvider } from 'posthog-js/react' 5 | import { FC, ReactNode, useEffect } from 'react' 6 | 7 | type WithAnalyticsProps = { 8 | children: ReactNode 9 | } 10 | 11 | const WithAnalytics: FC = ({ children }) => { 12 | const { user, organization } = useAppContext() 13 | 14 | // Check that PostHog is client-side (used to handle Next.js SSR) 15 | if (!POSTHOG_DISABLED && typeof window !== 'undefined') { 16 | posthog.init(POSTHOG_KEY || '', { 17 | api_host: POSTHOG_HOST || 'https://app.posthog.com', 18 | // Enable debug mode in development 19 | loaded: (posthog) => { 20 | if (process.env.NODE_ENV === 'development') posthog.debug() 21 | }, 22 | }) 23 | } 24 | 25 | useEffect(() => { 26 | if (POSTHOG_DISABLED || !user || !organization) return 27 | if (user.email) { 28 | posthog.identify(user.email, { 29 | email: user.email, 30 | name: user.name, 31 | organization_name: organization.name, 32 | }) 33 | } 34 | }, [organization, user]) 35 | 36 | return !POSTHOG_DISABLED ? ( 37 | {children} 38 | ) : ( 39 | children 40 | ) 41 | } 42 | 43 | export default WithAnalytics 44 | -------------------------------------------------------------------------------- /services/admin-console/src/components/hoc/WithApiFetcher.tsx: -------------------------------------------------------------------------------- 1 | import useApiFetcher from '@/hooks/api/generics/useApiFetcher' 2 | import { FC, ReactNode } from 'react' 3 | import { SWRConfig } from 'swr' 4 | 5 | const WithApiFetcher: FC<{ children: ReactNode }> = ({ children }) => { 6 | const { apiFetcher } = useApiFetcher() 7 | return ( 8 | 14 | {children} 15 | 16 | ) 17 | } 18 | 19 | export default WithApiFetcher 20 | -------------------------------------------------------------------------------- /services/admin-console/src/components/hoc/WithBilling.tsx: -------------------------------------------------------------------------------- 1 | import { STRIPE_PUBLIC_KEY } from '@/config' 2 | import { Elements, useStripe } from '@stripe/react-stripe-js' 3 | import { loadStripe } from '@stripe/stripe-js' 4 | import { FC, ReactNode } from 'react' 5 | 6 | // Make sure to call `loadStripe` outside of a component’s render to avoid 7 | // recreating the `Stripe` object on every render. 8 | if (!STRIPE_PUBLIC_KEY) { 9 | throw new Error('Missing Stripe public key') 10 | } 11 | 12 | const stripe = loadStripe(STRIPE_PUBLIC_KEY) 13 | 14 | type WithBillingProps = { 15 | children: ReactNode 16 | } 17 | 18 | const WithBilling: FC = ({ children }) => ( 19 | 30 | {children} 31 | 32 | ) 33 | 34 | export default WithBilling 35 | 36 | export const useBilling = useStripe 37 | -------------------------------------------------------------------------------- /services/admin-console/src/components/hoc/WithMobileRedirect.tsx: -------------------------------------------------------------------------------- 1 | import useIsMobile from '@/hooks/ui/useIsMobile' 2 | import { useRouter } from 'next/navigation' 3 | import { FC, ReactNode, useEffect } from 'react' 4 | 5 | interface WithMobileRedirectProps { 6 | children: ReactNode 7 | } 8 | 9 | const WithMobileRedirect: FC = ({ children }) => { 10 | const isMobile = useIsMobile() 11 | const router = useRouter() 12 | 13 | useEffect(() => { 14 | if (isMobile) { 15 | router.push('/switch-to-larger-screen') 16 | } 17 | }, [isMobile, router]) 18 | 19 | return <>{children} 20 | } 21 | 22 | export default WithMobileRedirect 23 | -------------------------------------------------------------------------------- /services/admin-console/src/components/hoc/WithSubscription.tsx: -------------------------------------------------------------------------------- 1 | import SubscriptionBlockedDialog from '@/components/usage/sub-blocked-dialog' 2 | import { useSubscription } from '@/contexts/subscription-context' 3 | import { FC, ReactNode } from 'react' 4 | 5 | interface WithSubscriptionProps { 6 | children: ReactNode 7 | } 8 | 9 | const WithSubscription: FC = ({ children }) => { 10 | const { subscriptionStatus, setSubscriptionStatus } = useSubscription() 11 | 12 | return subscriptionStatus === null ? ( 13 | <>{children} 14 | ) : ( 15 | <> 16 | {children} 17 | setSubscriptionStatus(null)} 20 | > 21 | 22 | ) 23 | } 24 | 25 | export default WithSubscription 26 | -------------------------------------------------------------------------------- /services/admin-console/src/components/layout/background-page-layout.tsx: -------------------------------------------------------------------------------- 1 | import Image from 'next/image' 2 | import { FC, ReactNode } from 'react' 3 | 4 | interface BackgroundPageLayoutProps { 5 | children: ReactNode 6 | } 7 | 8 | const BackgroundPageLayout: FC = ({ children }) => ( 9 |
10 | Background 17 |
18 | {children} 19 |
20 |
21 | ) 22 | 23 | export default BackgroundPageLayout 24 | -------------------------------------------------------------------------------- /services/admin-console/src/components/layout/loading-list.tsx: -------------------------------------------------------------------------------- 1 | import { Skeleton } from '@/components/ui/skeleton' 2 | import { cn } from '@/lib/utils' 3 | import { FC, HTMLAttributes } from 'react' 4 | 5 | export interface LoadingListProps { 6 | length?: number 7 | height?: number 8 | } 9 | 10 | const LoadingList: FC> = ({ 11 | length = 5, 12 | height, 13 | className, 14 | }) => { 15 | const skeletonHeight = height ? `h-${height}` : 'h-8' 16 | return ( 17 |
18 | {[...Array(length)].map((_, index) => ( 19 | 20 | ))} 21 |
22 | ) 23 | } 24 | 25 | export default LoadingList 26 | -------------------------------------------------------------------------------- /services/admin-console/src/components/layout/loading-page.tsx: -------------------------------------------------------------------------------- 1 | import { Loader } from 'lucide-react' 2 | import { FC } from 'react' 3 | 4 | const LoadingPage: FC = () => ( 5 |
6 | 7 |
8 | ) 9 | 10 | export default LoadingPage 11 | -------------------------------------------------------------------------------- /services/admin-console/src/components/layout/page-layout.tsx: -------------------------------------------------------------------------------- 1 | import BreadcrumbHeader from '@/components/layout/breadcrum-header' 2 | import LoadingPage from '@/components/layout/loading-page' 3 | import SidebarNav from '@/components/layout/sidebar-nav' 4 | import { Separator } from '@/components/ui/separator' 5 | import { useAppContext } from '@/contexts/app-context' 6 | import { cn } from '@/lib/utils' 7 | import { FC, HTMLAttributes } from 'react' 8 | 9 | interface PageLayoutProps extends HTMLAttributes { 10 | disableBreadcrumb?: boolean 11 | } 12 | 13 | const PageLayout: FC = ({ 14 | className, 15 | children, 16 | disableBreadcrumb = false, 17 | ...props 18 | }: PageLayoutProps) => { 19 | const { user, organization } = useAppContext() 20 | 21 | return ( 22 |
23 | {!user || !organization ? ( 24 | 25 | ) : ( 26 | <> 27 | 28 |
29 | {!disableBreadcrumb && } 30 | 31 |
{children}
32 |
33 | 34 | )} 35 |
36 | ) 37 | } 38 | 39 | export default PageLayout 40 | -------------------------------------------------------------------------------- /services/admin-console/src/components/query/last-updated.tsx: -------------------------------------------------------------------------------- 1 | import { format } from 'date-fns' 2 | import { RefreshCcw } from 'lucide-react' 3 | import { FC } from 'react' 4 | 5 | export interface LastUpdatedProps { 6 | responsible?: string 7 | date: Date 8 | } 9 | 10 | const QueryLastUpdated: FC = ({ responsible, date }) => ( 11 |
15 | Last updated at {format(date, 'yyyy/dd/MM HH:mm a')}{' '} 16 | {responsible && `by ${responsible}`} 17 | 18 |
19 | ) 20 | 21 | export default QueryLastUpdated 22 | -------------------------------------------------------------------------------- /services/admin-console/src/components/query/loading-box.tsx: -------------------------------------------------------------------------------- 1 | import { Skeleton } from '@/components/ui/skeleton' 2 | import { cn } from '@/lib/utils' 3 | import { FC, HTMLAttributes } from 'react' 4 | 5 | export type LoadingBoxProps = HTMLAttributes 6 | 7 | const LoadingBox: FC = ({ className }) => { 8 | return ( 9 |
15 | 16 |
17 | ) 18 | } 19 | 20 | export default LoadingBox 21 | -------------------------------------------------------------------------------- /services/admin-console/src/components/query/loading.tsx: -------------------------------------------------------------------------------- 1 | import { Skeleton } from '@/components/ui/skeleton' 2 | import { FC } from 'react' 3 | 4 | interface LoadingQueryProps { 5 | enableHeader?: boolean 6 | } 7 | 8 | const LoadingQuery: FC = ({ enableHeader = true }) => { 9 | return ( 10 |
11 | {enableHeader && ( 12 |
13 |
14 | 15 | 16 |
17 |
18 | 19 | 20 |
21 |
22 | )} 23 | 24 | 25 |
26 | ) 27 | } 28 | 29 | export default LoadingQuery 30 | -------------------------------------------------------------------------------- /services/admin-console/src/components/query/process.tsx: -------------------------------------------------------------------------------- 1 | import { FC } from 'react' 2 | 3 | export interface QueryProcessProps { 4 | processSteps: string[] 5 | } 6 | 7 | const QueryProcess: FC = ({ processSteps }) => ( 8 |
    9 | {processSteps.map((step, idx) => ( 10 |
  1. 11 |
    12 | {idx + 1}. 13 | {step} 14 |
    15 |
  2. 16 | ))} 17 |
18 | ) 19 | 20 | export default QueryProcess 21 | -------------------------------------------------------------------------------- /services/admin-console/src/components/query/question.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils' 2 | import { format } from 'date-fns' 3 | import { Calendar, Clock, Database, UserRound } from 'lucide-react' 4 | import { FC, HTMLAttributes } from 'react' 5 | 6 | export interface QueryQuestionProps extends HTMLAttributes { 7 | created_by: string 8 | prompt_text: string 9 | db_connection_alias: string 10 | questionDate: Date 11 | } 12 | 13 | const QueryQuestion: FC = ({ 14 | created_by, 15 | prompt_text, 16 | db_connection_alias, 17 | questionDate, 18 | className, 19 | }) => ( 20 |
21 |

{prompt_text}

22 |
23 | {[ 24 | { icon: Database, text: db_connection_alias }, 25 | { icon: UserRound, text: created_by }, 26 | { icon: Calendar, text: format(questionDate, 'MMMM dd, yyyy') }, 27 | { icon: Clock, text: format(questionDate, 'hh:mm a') }, 28 | ].map((item, index) => ( 29 |
30 | 31 | {item.text} 32 |
33 | ))} 34 |
35 |
36 | ) 37 | 38 | export default QueryQuestion 39 | -------------------------------------------------------------------------------- /services/admin-console/src/components/query/section-header.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils' 2 | import { FC, ReactNode } from 'react' 3 | 4 | export const SectionHeader: FC<{ children: ReactNode; className?: string }> = ({ 5 | children, 6 | className = '', 7 | }) => ( 8 |
14 | {children} 15 |
16 | ) 17 | 18 | export const SectionHeaderTitle: FC<{ 19 | children: ReactNode 20 | className?: string 21 | }> = ({ children, className = '' }) => ( 22 |
23 | {children} 24 |
25 | ) 26 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/badge.tsx: -------------------------------------------------------------------------------- 1 | import { cva, type VariantProps } from 'class-variance-authority' 2 | import * as React from 'react' 3 | 4 | import { cn } from '@/lib/utils' 5 | 6 | const badgeVariants = cva( 7 | 'h-fit inline-flex items-center rounded-lg border px-3 py-1 font-semibold transition-colors focus:outline-none focus:ring-1 focus:ring-ring focus:ring-offset-1', 8 | { 9 | variants: { 10 | variant: { 11 | default: 'border-transparent bg-slate-300 text-slate-900', 12 | sky: 'border-transparent bg-sky-200 text-slate-900', 13 | secondary: 'border-transparent bg-secondary text-secondary-foreground', 14 | success: 'border-transparent bg-green-200 text-green-900', 15 | destructive: 16 | 'border-transparent bg-destructive text-destructive-foreground', 17 | outline: 'text-foreground', 18 | }, 19 | shape: { 20 | rounded: 'rounded-full h-fit', 21 | }, 22 | }, 23 | defaultVariants: { 24 | variant: 'default', 25 | }, 26 | }, 27 | ) 28 | 29 | export interface BadgeProps 30 | extends React.HTMLAttributes, 31 | VariantProps {} 32 | 33 | function Badge({ className, variant, shape, ...props }: BadgeProps) { 34 | return ( 35 |
39 | ) 40 | } 41 | 42 | export { Badge, badgeVariants } 43 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/checkbox.tsx: -------------------------------------------------------------------------------- 1 | import * as CheckboxPrimitive from '@radix-ui/react-checkbox' 2 | import { Check, Minus } from 'lucide-react' 3 | import * as React from 'react' 4 | 5 | import { cn } from '@/lib/utils' 6 | 7 | const Checkbox = React.forwardRef< 8 | React.ElementRef, 9 | React.ComponentPropsWithoutRef & { 10 | checked: boolean | 'indeterminate' 11 | } 12 | >(({ className, checked, ...props }, ref) => ( 13 | 26 |
27 | {checked === true && } 28 | {checked === 'indeterminate' && } 29 |
30 |
31 | )) 32 | 33 | Checkbox.displayName = CheckboxPrimitive.Root.displayName 34 | 35 | export { Checkbox } 36 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/content-box.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils' 2 | 3 | function ContentBox({ 4 | className, 5 | ...props 6 | }: React.HTMLAttributes) { 7 | return ( 8 |
15 | ) 16 | } 17 | 18 | export { ContentBox } 19 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/input.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | import { cn } from '@/lib/utils' 4 | 5 | export type InputProps = React.InputHTMLAttributes 6 | 7 | const Input = React.forwardRef( 8 | ({ className, type, ...props }, ref) => { 9 | return ( 10 | 19 | ) 20 | }, 21 | ) 22 | Input.displayName = 'Input' 23 | 24 | export { Input } 25 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import * as LabelPrimitive from '@radix-ui/react-label' 3 | import { cva, type VariantProps } from 'class-variance-authority' 4 | 5 | import { cn } from '@/lib/utils' 6 | 7 | const labelVariants = cva( 8 | 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', 9 | ) 10 | 11 | const Label = React.forwardRef< 12 | React.ElementRef, 13 | React.ComponentPropsWithoutRef & 14 | VariantProps 15 | >(({ className, ...props }, ref) => ( 16 | 21 | )) 22 | Label.displayName = LabelPrimitive.Root.displayName 23 | 24 | export { Label } 25 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/popover.tsx: -------------------------------------------------------------------------------- 1 | import * as PopoverPrimitive from '@radix-ui/react-popover' 2 | import * as React from 'react' 3 | 4 | import { cn } from '@/lib/utils' 5 | 6 | const Popover = PopoverPrimitive.Root 7 | 8 | const PopoverTrigger = PopoverPrimitive.Trigger 9 | 10 | const PopoverClose = PopoverPrimitive.Close 11 | 12 | const PopoverContent = React.forwardRef< 13 | React.ElementRef, 14 | React.ComponentPropsWithoutRef 15 | >(({ className, align = 'center', sideOffset = 4, ...props }, ref) => ( 16 | 17 | 27 | 28 | )) 29 | PopoverContent.displayName = PopoverPrimitive.Content.displayName 30 | 31 | export { Popover, PopoverClose, PopoverContent, PopoverTrigger } 32 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/search-input.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from '@/components/ui/button' 2 | import { Eraser, Search } from 'lucide-react' 3 | import { FC, InputHTMLAttributes } from 'react' 4 | 5 | type SearchInputProps = InputHTMLAttributes & { 6 | value: string 7 | onClear?: () => void 8 | } 9 | 10 | const SearchInput: FC = ({ 11 | className, 12 | value = '', 13 | onClear, 14 | ...props 15 | }) => { 16 | const handleClear = () => { 17 | onClear?.() 18 | } 19 | 20 | return ( 21 |
24 | 25 | 31 | {value && ( 32 | 39 | )} 40 |
41 | ) 42 | } 43 | 44 | export default SearchInput 45 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/separator.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import * as SeparatorPrimitive from '@radix-ui/react-separator' 3 | 4 | import { cn } from '@/lib/utils' 5 | 6 | const Separator = React.forwardRef< 7 | React.ElementRef, 8 | React.ComponentPropsWithoutRef & { 9 | rounded?: boolean 10 | } 11 | >( 12 | ( 13 | { 14 | className, 15 | orientation = 'horizontal', 16 | decorative = true, 17 | rounded = false, 18 | ...props 19 | }, 20 | ref, 21 | ) => ( 22 | 34 | ), 35 | ) 36 | Separator.displayName = SeparatorPrimitive.Root.displayName 37 | 38 | export { Separator } 39 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/skeleton.tsx: -------------------------------------------------------------------------------- 1 | import { cn } from '@/lib/utils' 2 | 3 | function Skeleton({ 4 | className, 5 | ...props 6 | }: React.HTMLAttributes) { 7 | return ( 8 |
12 | ) 13 | } 14 | 15 | export { Skeleton } 16 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/switch.tsx: -------------------------------------------------------------------------------- 1 | import * as SwitchPrimitives from '@radix-ui/react-switch' 2 | import * as React from 'react' 3 | 4 | import { cn } from '@/lib/utils' 5 | 6 | const Switch = React.forwardRef< 7 | React.ElementRef, 8 | React.ComponentPropsWithoutRef 9 | >(({ className, ...props }, ref) => ( 10 | 18 | 23 | 24 | )) 25 | Switch.displayName = SwitchPrimitives.Root.displayName 26 | 27 | export { Switch } 28 | -------------------------------------------------------------------------------- /services/admin-console/src/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | import { cn } from '@/lib/utils' 4 | 5 | export type TextareaProps = React.TextareaHTMLAttributes 6 | 7 | const Textarea = React.forwardRef( 8 | ({ className, ...props }, ref) => { 9 | return ( 10 |