insforge 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +58 -0
- package/.env.example +49 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +83 -0
- package/.github/ISSUE_TEMPLATE/config.yml +11 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +79 -0
- package/.github/copilot-instructions.md +147 -0
- package/.github/workflows/build-image.yml +65 -0
- package/.github/workflows/ci-premerge-check.yml +24 -0
- package/.github/workflows/deploy-aws.yml +130 -0
- package/.github/workflows/lint-and-format.yml +33 -0
- package/.prettierignore +65 -0
- package/.prettierrc +9 -0
- package/CHANGELOG.md +3 -0
- package/CONTRIBUTING.md +126 -0
- package/Dockerfile +27 -0
- package/GITHUB_OAUTH_SETUP.md +49 -0
- package/GOOGLE_OAUTH_SETUP.md +148 -0
- package/LICENSE +201 -0
- package/README.md +134 -0
- package/assets/Dark.svg +23 -0
- package/assets/archDiagram.png +0 -0
- package/assets/banner.png +0 -0
- package/assets/mcpInstallv2.png +0 -0
- package/assets/sampleResponse.png +0 -0
- package/assets/signin.png +0 -0
- package/assets/userflow.png +0 -0
- package/backend/migrations/000_create-base-tables.sql +142 -0
- package/backend/migrations/001_create-helper-functions.sql +41 -0
- package/backend/migrations/002_rename-auth-tables.sql +30 -0
- package/backend/migrations/003_create-users-table.sql +56 -0
- package/backend/migrations/004_add-reload-postgrest-func.sql +24 -0
- package/backend/migrations/005_enable-project-admin-modify-users.sql +30 -0
- package/backend/migrations/006_modify-ai-usage-table.sql +25 -0
- package/backend/migrations/007_drop-metadata-table.sql +2 -0
- package/backend/migrations/008_add-system-tables.sql +77 -0
- package/backend/migrations/009_add-function-secrets.sql +24 -0
- package/backend/migrations/010_modify-ai-config-modalities.sql +93 -0
- package/backend/migrations/011_refactor-secrets-table.sql +15 -0
- package/backend/migrations/012_add-storage-uploaded-by.sql +8 -0
- package/backend/package.json +75 -0
- package/backend/src/api/middleware/auth.ts +240 -0
- package/backend/src/api/middleware/error.ts +231 -0
- package/backend/src/api/middleware/upload.ts +59 -0
- package/backend/src/api/routes/agent.ts +29 -0
- package/backend/src/api/routes/ai.ts +472 -0
- package/backend/src/api/routes/auth.oauth.ts +482 -0
- package/backend/src/api/routes/auth.ts +386 -0
- package/backend/src/api/routes/database.advance.ts +275 -0
- package/backend/src/api/routes/database.records.ts +246 -0
- package/backend/src/api/routes/database.tables.ts +161 -0
- package/backend/src/api/routes/docs.ts +66 -0
- package/backend/src/api/routes/functions.ts +183 -0
- package/backend/src/api/routes/logs.ts +150 -0
- package/backend/src/api/routes/metadata.ts +160 -0
- package/backend/src/api/routes/openapi.ts +82 -0
- package/backend/src/api/routes/secrets.ts +199 -0
- package/backend/src/api/routes/storage.ts +547 -0
- package/backend/src/api/routes/usage.ts +96 -0
- package/backend/src/core/ai/chat.ts +207 -0
- package/backend/src/core/ai/client.ts +242 -0
- package/backend/src/core/ai/config.ts +187 -0
- package/backend/src/core/ai/image.ts +156 -0
- package/backend/src/core/ai/model.ts +117 -0
- package/backend/src/core/ai/usage.ts +290 -0
- package/backend/src/core/auth/auth.ts +781 -0
- package/backend/src/core/auth/oauth.ts +398 -0
- package/backend/src/core/database/advance.ts +1074 -0
- package/backend/src/core/database/manager.ts +178 -0
- package/backend/src/core/database/table.ts +772 -0
- package/backend/src/core/documentation/agent.ts +689 -0
- package/backend/src/core/documentation/openapi.ts +856 -0
- package/backend/src/core/functions/functions.ts +310 -0
- package/backend/src/core/logs/analytics.ts +76 -0
- package/backend/src/core/logs/audit.ts +255 -0
- package/backend/src/core/logs/providers/base.provider.ts +83 -0
- package/backend/src/core/logs/providers/cloudwatch.provider.ts +510 -0
- package/backend/src/core/logs/providers/localdb.provider.ts +246 -0
- package/backend/src/core/secrets/encryption.ts +58 -0
- package/backend/src/core/secrets/secrets.ts +410 -0
- package/backend/src/core/socket/socket.ts +388 -0
- package/backend/src/core/socket/types.ts +79 -0
- package/backend/src/core/storage/storage.ts +923 -0
- package/backend/src/server.ts +288 -0
- package/backend/src/types/ai.ts +46 -0
- package/backend/src/types/auth.ts +90 -0
- package/backend/src/types/database.ts +136 -0
- package/backend/src/types/error-constants.ts +86 -0
- package/backend/src/types/logs.ts +47 -0
- package/backend/src/types/profile.ts +55 -0
- package/backend/src/types/storage.ts +23 -0
- package/backend/src/utils/cloud-token.ts +39 -0
- package/backend/src/utils/constants.ts +1 -0
- package/backend/src/utils/environment.ts +35 -0
- package/backend/src/utils/helpers.ts +49 -0
- package/backend/src/utils/logger.ts +13 -0
- package/backend/src/utils/response.ts +62 -0
- package/backend/src/utils/seed.ts +205 -0
- package/backend/src/utils/sql-parser.ts +63 -0
- package/backend/src/utils/uuid.ts +9 -0
- package/backend/src/utils/validations.ts +129 -0
- package/backend/tests/README.md +134 -0
- package/backend/tests/cleanup-all-test-data.sh +231 -0
- package/backend/tests/cloud/test-s3-multitenant.sh +132 -0
- package/backend/tests/local/comprehensive-curl-tests.sh +156 -0
- package/backend/tests/local/test-auth-router.sh +144 -0
- package/backend/tests/local/test-database-router.sh +222 -0
- package/backend/tests/local/test-e2e.sh +241 -0
- package/backend/tests/local/test-fk-errors.sh +97 -0
- package/backend/tests/local/test-id-field.sh +201 -0
- package/backend/tests/local/test-public-bucket.sh +265 -0
- package/backend/tests/local/test-secrets.sh +248 -0
- package/backend/tests/local/test-serverless-functions.sh.disabled +325 -0
- package/backend/tests/local/test-traditional-rest.sh +209 -0
- package/backend/tests/manual/README.md +51 -0
- package/backend/tests/manual/create-large-table-simple.sql +11 -0
- package/backend/tests/manual/seed-large-table.sql +101 -0
- package/backend/tests/manual/setup-large-table-extras.sql +34 -0
- package/backend/tests/manual/test-better-auth.sh +303 -0
- package/backend/tests/manual/test-bulk-upsert.sh +410 -0
- package/backend/tests/manual/test-database-advance.sh +297 -0
- package/backend/tests/manual/test-postgrest-stability.sh +192 -0
- package/backend/tests/manual/test-rawsql-export-import.sh +412 -0
- package/backend/tests/manual/test-universal-storage.sh +264 -0
- package/backend/tests/manual/test-users.sql +18 -0
- package/backend/tests/run-all-tests.sh +140 -0
- package/backend/tests/setup.ts +22 -0
- package/backend/tests/test-config.sh +303 -0
- package/backend/tsconfig.json +23 -0
- package/backend/tsup.config.ts +18 -0
- package/backend/vitest.config.ts +22 -0
- package/docker-compose.prod.yml +145 -0
- package/docker-compose.yml +167 -0
- package/docker-init/db/db-init.sql +125 -0
- package/docker-init/db/jwt.sql +5 -0
- package/docker-init/db/logs.sql +9 -0
- package/docker-init/db/postgresql.conf +17 -0
- package/docs/deprecated/insforge-auth-api.md +215 -0
- package/docs/deprecated/insforge-auth-sdk.md +100 -0
- package/docs/deprecated/insforge-db-api.md +359 -0
- package/docs/deprecated/insforge-db-sdk.md +140 -0
- package/docs/deprecated/insforge-debug-sdk.md +157 -0
- package/docs/deprecated/insforge-debug.md +65 -0
- package/docs/deprecated/insforge-instructions.md +124 -0
- package/docs/deprecated/insforge-project.md +118 -0
- package/docs/deprecated/insforge-storage-api.md +279 -0
- package/docs/deprecated/insforge-storage-sdk.md +159 -0
- package/docs/insforge-instructions-sdk.md +407 -0
- package/eslint.config.js +317 -0
- package/examples/oauth/frontend-oauth-example.html +251 -0
- package/examples/response-examples.md +444 -0
- package/frontend/README.md +112 -0
- package/frontend/components.json +17 -0
- package/frontend/index.html +13 -0
- package/frontend/package.json +63 -0
- package/frontend/public/favicon.ico +0 -0
- package/frontend/src/App.tsx +106 -0
- package/frontend/src/assets/icons/checkbox_checked.svg +6 -0
- package/frontend/src/assets/icons/checkbox_undetermined.svg +6 -0
- package/frontend/src/assets/icons/checked.svg +3 -0
- package/frontend/src/assets/icons/error.svg +3 -0
- package/frontend/src/assets/icons/pencil.svg +4 -0
- package/frontend/src/assets/icons/refresh.svg +4 -0
- package/frontend/src/assets/icons/step_active.svg +3 -0
- package/frontend/src/assets/icons/step_inactive.svg +11 -0
- package/frontend/src/assets/icons/warning.svg +3 -0
- package/frontend/src/assets/logos/amazon.svg +1 -0
- package/frontend/src/assets/logos/claude_code.svg +3 -0
- package/frontend/src/assets/logos/cline.svg +6 -0
- package/frontend/src/assets/logos/cursor.svg +20 -0
- package/frontend/src/assets/logos/discord.svg +9 -0
- package/frontend/src/assets/logos/gemini.svg +19 -0
- package/frontend/src/assets/logos/github.svg +5 -0
- package/frontend/src/assets/logos/google.svg +13 -0
- package/frontend/src/assets/logos/grok.svg +10 -0
- package/frontend/src/assets/logos/insforge_dark.svg +15 -0
- package/frontend/src/assets/logos/insforge_light.svg +15 -0
- package/frontend/src/assets/logos/openai.svg +10 -0
- package/frontend/src/assets/logos/roo_code.svg +9 -0
- package/frontend/src/assets/logos/trae.svg +3 -0
- package/frontend/src/assets/logos/windsurf.svg +10 -0
- package/frontend/src/components/ButtonWithLoading.tsx +27 -0
- package/frontend/src/components/Checkbox.tsx +61 -0
- package/frontend/src/components/CodeBlock.tsx +32 -0
- package/frontend/src/components/ConfirmDialog.tsx +96 -0
- package/frontend/src/components/CopyButton.tsx +69 -0
- package/frontend/src/components/DeleteActionButton.tsx +42 -0
- package/frontend/src/components/EmptyState.tsx +41 -0
- package/frontend/src/components/ErrorState.tsx +35 -0
- package/frontend/src/components/FeatureSidebar.tsx +126 -0
- package/frontend/src/components/FeatureSidebarItem.tsx +101 -0
- package/frontend/src/components/JsonHighlight.tsx +61 -0
- package/frontend/src/components/LoadingState.tsx +16 -0
- package/frontend/src/components/PaginationControls.tsx +54 -0
- package/frontend/src/components/PromptDialog.tsx +68 -0
- package/frontend/src/components/SearchInput.tsx +90 -0
- package/frontend/src/components/SelectionClearButton.tsx +26 -0
- package/frontend/src/components/Stepper.tsx +139 -0
- package/frontend/src/components/ThemeToggle.tsx +58 -0
- package/frontend/src/components/TypeBadge.tsx +20 -0
- package/frontend/src/components/datagrid/DataGrid.tsx +264 -0
- package/frontend/src/components/datagrid/DefaultCellRenderer.tsx +114 -0
- package/frontend/src/components/datagrid/IdCell.tsx +44 -0
- package/frontend/src/components/datagrid/SortableHeader.tsx +74 -0
- package/frontend/src/components/datagrid/cell-editors/BooleanCellEditor.tsx +54 -0
- package/frontend/src/components/datagrid/cell-editors/DateCellEditor.tsx +483 -0
- package/frontend/src/components/datagrid/cell-editors/JsonCellEditor.tsx +362 -0
- package/frontend/src/components/datagrid/cell-editors/TextCellEditor.tsx +38 -0
- package/frontend/src/components/datagrid/cell-editors/index.ts +14 -0
- package/frontend/src/components/datagrid/cell-editors/types.ts +43 -0
- package/frontend/src/components/datagrid/datagridTypes.tsx +72 -0
- package/frontend/src/components/datagrid/index.tsx +20 -0
- package/frontend/src/components/index.ts +39 -0
- package/frontend/src/components/layout/AppHeader.tsx +146 -0
- package/frontend/src/components/layout/AppSidebar.tsx +190 -0
- package/frontend/src/components/layout/CloudLayout.tsx +95 -0
- package/frontend/src/components/layout/Layout.tsx +43 -0
- package/frontend/src/components/radix/Alert.tsx +45 -0
- package/frontend/src/components/radix/AlertDialog.tsx +115 -0
- package/frontend/src/components/radix/Avatar.tsx +45 -0
- package/frontend/src/components/radix/Badge.tsx +33 -0
- package/frontend/src/components/radix/Button.tsx +50 -0
- package/frontend/src/components/radix/Card.tsx +58 -0
- package/frontend/src/components/radix/Dialog.tsx +98 -0
- package/frontend/src/components/radix/DropdownMenu.tsx +185 -0
- package/frontend/src/components/radix/Form.tsx +167 -0
- package/frontend/src/components/radix/Input.tsx +22 -0
- package/frontend/src/components/radix/Label.tsx +19 -0
- package/frontend/src/components/radix/Popover.tsx +29 -0
- package/frontend/src/components/radix/ScrollArea.tsx +44 -0
- package/frontend/src/components/radix/Select.tsx +151 -0
- package/frontend/src/components/radix/Separator.tsx +26 -0
- package/frontend/src/components/radix/Sheet.tsx +119 -0
- package/frontend/src/components/radix/Skeleton.tsx +7 -0
- package/frontend/src/components/radix/Switch.tsx +29 -0
- package/frontend/src/components/radix/Tabs.tsx +50 -0
- package/frontend/src/components/radix/Textarea.tsx +21 -0
- package/frontend/src/components/radix/Tooltip.tsx +28 -0
- package/frontend/src/features/ai/components/AIConfigCard.tsx +154 -0
- package/frontend/src/features/ai/components/AIConfigDialog.tsx +76 -0
- package/frontend/src/features/ai/components/AIConfigForm.tsx +222 -0
- package/frontend/src/features/ai/components/AIEmptyState.tsx +18 -0
- package/frontend/src/features/ai/components/fields/ModalityField.tsx +87 -0
- package/frontend/src/features/ai/components/fields/ModelSelectionField.tsx +134 -0
- package/frontend/src/features/ai/components/fields/SystemPromptField.tsx +33 -0
- package/frontend/src/features/ai/helpers.ts +155 -0
- package/frontend/src/features/ai/hooks/useAIConfigs.ts +221 -0
- package/frontend/src/features/ai/hooks/useAIUsage.ts +77 -0
- package/frontend/src/features/ai/page/AIPage.tsx +178 -0
- package/frontend/src/features/ai/services/ai.service.ts +148 -0
- package/frontend/src/features/auth/components/AddOAuthDialog.tsx +106 -0
- package/frontend/src/features/auth/components/AuthMethodTab.tsx +238 -0
- package/frontend/src/features/auth/components/OAuthConfigDialog.tsx +303 -0
- package/frontend/src/features/auth/components/OAuthEmptyState.tsx +15 -0
- package/frontend/src/features/auth/components/UserFormDialog.tsx +248 -0
- package/frontend/src/features/auth/components/UsersDataGrid.tsx +183 -0
- package/frontend/src/features/auth/components/UsersTab.tsx +114 -0
- package/frontend/src/features/auth/hooks/useOAuthConfig.ts +129 -0
- package/frontend/src/features/auth/hooks/useUsers.ts +57 -0
- package/frontend/src/features/auth/index.ts +9 -0
- package/frontend/src/features/auth/page/AuthenticationPage.tsx +169 -0
- package/frontend/src/features/auth/services/auth.service.ts +112 -0
- package/frontend/src/features/auth/services/oauth.service.ts +49 -0
- package/frontend/src/features/dashboard/page/DashboardPage.tsx +194 -0
- package/frontend/src/features/database/components/ColumnTypeSelect.tsx +64 -0
- package/frontend/src/features/database/components/DatabaseDataGrid.tsx +282 -0
- package/frontend/src/features/database/components/ForeignKeyCell.tsx +187 -0
- package/frontend/src/features/database/components/ForeignKeyPopover.tsx +378 -0
- package/frontend/src/features/database/components/LinkRecordModal.tsx +288 -0
- package/frontend/src/features/database/components/RecordFormDialog.tsx +164 -0
- package/frontend/src/features/database/components/RecordFormField.tsx +568 -0
- package/frontend/src/features/database/components/TableEmptyState.tsx +21 -0
- package/frontend/src/features/database/components/TableForm.tsx +656 -0
- package/frontend/src/features/database/components/TableFormColumn.tsx +137 -0
- package/frontend/src/features/database/components/TableListSkeleton.tsx +9 -0
- package/frontend/src/features/database/components/TableSidebar.tsx +47 -0
- package/frontend/src/features/database/constants.ts +26 -0
- package/frontend/src/features/database/helpers.ts +125 -0
- package/frontend/src/features/database/hooks/UseLinkModal.tsx +78 -0
- package/frontend/src/features/database/index.ts +12 -0
- package/frontend/src/features/database/page/DatabasePage.tsx +626 -0
- package/frontend/src/features/database/schema.ts +25 -0
- package/frontend/src/features/database/services/database.service.ts +216 -0
- package/frontend/src/features/functions/components/FunctionEmptyState.tsx +15 -0
- package/frontend/src/features/functions/components/FunctionRow.tsx +71 -0
- package/frontend/src/features/functions/components/FunctionViewer.tsx +46 -0
- package/frontend/src/features/functions/components/FunctionsContent.tsx +88 -0
- package/frontend/src/features/functions/components/FunctionsSidebar.tsx +56 -0
- package/frontend/src/features/functions/components/SecretEmptyState.tsx +23 -0
- package/frontend/src/features/functions/components/SecretRow.tsx +68 -0
- package/frontend/src/features/functions/components/SecretsContent.tsx +120 -0
- package/frontend/src/features/functions/hooks/useFunctions.ts +106 -0
- package/frontend/src/features/functions/page/FunctionsPage.tsx +28 -0
- package/frontend/src/features/functions/services/functions.service.ts +48 -0
- package/frontend/src/features/login/components/AuthErrorBoundary.tsx +87 -0
- package/frontend/src/features/login/components/PrivateRoute.tsx +24 -0
- package/frontend/src/features/login/page/CloudLoginPage.tsx +93 -0
- package/frontend/src/features/login/page/LoginPage.tsx +174 -0
- package/frontend/src/features/logs/components/AnalyticsLogsTable.tsx +313 -0
- package/frontend/src/features/logs/components/LogsTable.tsx +199 -0
- package/frontend/src/features/logs/hooks/useAuditLogs.ts +39 -0
- package/frontend/src/features/logs/index.ts +5 -0
- package/frontend/src/features/logs/page/AnalyticsLogsPage.tsx +530 -0
- package/frontend/src/features/logs/page/AuditsPage.tsx +192 -0
- package/frontend/src/features/logs/services/log.service.ts +171 -0
- package/frontend/src/features/metadata/hooks/useMetadata.ts +53 -0
- package/frontend/src/features/metadata/index.ts +0 -0
- package/frontend/src/features/metadata/page/MetadataPage.tsx +136 -0
- package/frontend/src/features/metadata/services/metadata.service.ts +17 -0
- package/frontend/src/features/onboard/components/CompletionCard.tsx +41 -0
- package/frontend/src/features/onboard/components/OnboardButton.tsx +84 -0
- package/frontend/src/features/onboard/components/StepContent.tsx +91 -0
- package/frontend/src/features/onboard/components/TestConnectionStep.tsx +53 -0
- package/frontend/src/features/onboard/components/mcp/CursorDeeplinkGenerator.tsx +35 -0
- package/frontend/src/features/onboard/components/mcp/McpInstallation.tsx +144 -0
- package/frontend/src/features/onboard/components/mcp/index.ts +4 -0
- package/frontend/src/features/onboard/components/mcp/mcp-helper.tsx +98 -0
- package/frontend/src/features/onboard/index.ts +3 -0
- package/frontend/src/features/onboard/page/OnBoardPage.tsx +104 -0
- package/frontend/src/features/onboard/types.ts +8 -0
- package/frontend/src/features/secrets/hooks/useSecrets.ts +139 -0
- package/frontend/src/features/secrets/services/secrets.service.ts +57 -0
- package/frontend/src/features/storage/components/BucketEmptyState.tsx +19 -0
- package/frontend/src/features/storage/components/BucketFormDialog.tsx +194 -0
- package/frontend/src/features/storage/components/BucketListSkeleton.tsx +17 -0
- package/frontend/src/features/storage/components/FilePreviewDialog.tsx +287 -0
- package/frontend/src/features/storage/components/StorageDataGrid.tsx +239 -0
- package/frontend/src/features/storage/components/StorageManager.tsx +236 -0
- package/frontend/src/features/storage/components/StorageSidebar.tsx +44 -0
- package/frontend/src/features/storage/components/UploadToast.tsx +46 -0
- package/frontend/src/features/storage/index.ts +3 -0
- package/frontend/src/features/storage/page/StoragePage.tsx +553 -0
- package/frontend/src/features/storage/services/storage.service.ts +144 -0
- package/frontend/src/features/visualizer/components/AuthNode.tsx +107 -0
- package/frontend/src/features/visualizer/components/BucketNode.tsx +34 -0
- package/frontend/src/features/visualizer/components/SchemaVisualizer.tsx +359 -0
- package/frontend/src/features/visualizer/components/TableNode.tsx +152 -0
- package/frontend/src/features/visualizer/components/VisualizerSkeleton.tsx +24 -0
- package/frontend/src/features/visualizer/components/index.ts +5 -0
- package/frontend/src/features/visualizer/page/VisualizerPage.tsx +127 -0
- package/frontend/src/index.css +248 -0
- package/frontend/src/lib/api/client.ts +163 -0
- package/frontend/src/lib/contexts/AuthContext.tsx +157 -0
- package/frontend/src/lib/contexts/OnboardStepContext.tsx +68 -0
- package/frontend/src/lib/contexts/SocketContext.tsx +303 -0
- package/frontend/src/lib/contexts/ThemeContext.tsx +125 -0
- package/frontend/src/lib/hooks/useAuth.ts +4 -0
- package/frontend/src/lib/hooks/useConfirm.ts +55 -0
- package/frontend/src/lib/hooks/useInterval.ts +27 -0
- package/frontend/src/lib/hooks/useMediaQuery.ts +59 -0
- package/frontend/src/lib/hooks/useOnboardingCompletion.ts +29 -0
- package/frontend/src/lib/hooks/usePagination.ts +27 -0
- package/frontend/src/lib/hooks/useTimeout.ts +27 -0
- package/frontend/src/lib/hooks/useToast.tsx +229 -0
- package/frontend/src/lib/utils/constants.ts +38 -0
- package/frontend/src/lib/utils/utils.ts +165 -0
- package/frontend/src/lib/utils/validation-schemas.ts +126 -0
- package/frontend/src/main.tsx +16 -0
- package/frontend/src/rdg.css +194 -0
- package/frontend/src/vite-env.d.ts +12 -0
- package/frontend/tailwind.config.js +97 -0
- package/frontend/tsconfig.json +26 -0
- package/frontend/tsconfig.node.json +10 -0
- package/frontend/vite.config.ts +37 -0
- package/frontend/vitest.config.ts +36 -0
- package/functions/deno.json +25 -0
- package/functions/server.ts +290 -0
- package/functions/worker-template.js +126 -0
- package/openapi/ai.yaml +689 -0
- package/openapi/auth.yaml +563 -0
- package/openapi/functions.yaml +476 -0
- package/openapi/health.yaml +30 -0
- package/openapi/logs.yaml +224 -0
- package/openapi/metadata.yaml +178 -0
- package/openapi/records.yaml +382 -0
- package/openapi/secrets.yaml +371 -0
- package/openapi/storage.yaml +876 -0
- package/openapi/tables.yaml +464 -0
- package/package.json +88 -0
- package/shared-schemas/package.json +31 -0
- package/shared-schemas/src/ai-api.schema.ts +167 -0
- package/shared-schemas/src/ai.schema.ts +54 -0
- package/shared-schemas/src/auth-api.schema.ts +193 -0
- package/shared-schemas/src/auth.schema.ts +94 -0
- package/shared-schemas/src/database-api.schema.ts +259 -0
- package/shared-schemas/src/database.schema.ts +69 -0
- package/shared-schemas/src/functions-api.schema.ts +25 -0
- package/shared-schemas/src/functions.schema.ts +16 -0
- package/shared-schemas/src/index.ts +13 -0
- package/shared-schemas/src/logs-api.schema.ts +49 -0
- package/shared-schemas/src/logs.schema.ts +14 -0
- package/shared-schemas/src/metadata.schema.ts +56 -0
- package/shared-schemas/src/storage-api.schema.ts +65 -0
- package/shared-schemas/src/storage.schema.ts +19 -0
- package/shared-schemas/tsconfig.json +21 -0
- package/tsconfig.json +8 -0
package/eslint.config.js
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import tseslint from 'typescript-eslint';
|
|
4
|
+
import prettierConfig from 'eslint-config-prettier';
|
|
5
|
+
import prettierPlugin from 'eslint-plugin-prettier';
|
|
6
|
+
import react from 'eslint-plugin-react';
|
|
7
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
8
|
+
import globals from 'globals';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { fileURLToPath } from 'url';
|
|
11
|
+
|
|
12
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
|
|
14
|
+
export default defineConfig(
|
|
15
|
+
js.configs.recommended,
|
|
16
|
+
...tseslint.configs.recommended,
|
|
17
|
+
prettierConfig,
|
|
18
|
+
// Frontend configuration
|
|
19
|
+
{
|
|
20
|
+
files: ['frontend/**/*.ts', 'frontend/**/*.tsx'],
|
|
21
|
+
ignores: ['frontend/tests/**/*', 'frontend/**/*.test.*', 'frontend/**/*.spec.*'],
|
|
22
|
+
languageOptions: {
|
|
23
|
+
ecmaVersion: 'latest',
|
|
24
|
+
sourceType: 'module',
|
|
25
|
+
parserOptions: {
|
|
26
|
+
project: './frontend/tsconfig.json',
|
|
27
|
+
tsconfigRootDir: __dirname,
|
|
28
|
+
ecmaFeatures: {
|
|
29
|
+
jsx: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
globals: {
|
|
33
|
+
...globals.browser,
|
|
34
|
+
...globals.es2021,
|
|
35
|
+
...globals.node,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
plugins: {
|
|
39
|
+
react: react,
|
|
40
|
+
'react-hooks': reactHooks,
|
|
41
|
+
prettier: prettierPlugin,
|
|
42
|
+
},
|
|
43
|
+
settings: {
|
|
44
|
+
react: {
|
|
45
|
+
version: 'detect',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
rules: {
|
|
49
|
+
// TypeScript rules
|
|
50
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
51
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
52
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
53
|
+
'@typescript-eslint/no-unused-vars': [
|
|
54
|
+
'error',
|
|
55
|
+
{
|
|
56
|
+
argsIgnorePattern: '^_',
|
|
57
|
+
varsIgnorePattern: '^_',
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
61
|
+
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
62
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
63
|
+
'@typescript-eslint/no-misused-promises': 'error',
|
|
64
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
65
|
+
'@typescript-eslint/require-await': 'error',
|
|
66
|
+
|
|
67
|
+
// Naming conventions
|
|
68
|
+
'@typescript-eslint/naming-convention': [
|
|
69
|
+
'error',
|
|
70
|
+
// Variables and parameters - camelCase
|
|
71
|
+
{
|
|
72
|
+
selector: ['parameter', 'function'],
|
|
73
|
+
format: ['camelCase', 'PascalCase'],
|
|
74
|
+
leadingUnderscore: 'allow',
|
|
75
|
+
trailingUnderscore: 'forbid',
|
|
76
|
+
},
|
|
77
|
+
// Types, interfaces, type parameters, classes - PascalCase
|
|
78
|
+
{
|
|
79
|
+
selector: ['typeLike', 'class'],
|
|
80
|
+
format: ['PascalCase'],
|
|
81
|
+
},
|
|
82
|
+
// Enum members - UPPER_CASE
|
|
83
|
+
{
|
|
84
|
+
selector: 'enumMember',
|
|
85
|
+
format: ['UPPER_CASE'],
|
|
86
|
+
},
|
|
87
|
+
// React components (functions starting with capital letter) - PascalCase
|
|
88
|
+
{
|
|
89
|
+
selector: 'variable',
|
|
90
|
+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
|
91
|
+
leadingUnderscore: 'allow',
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
|
|
95
|
+
// React rules
|
|
96
|
+
'react/react-in-jsx-scope': 'off',
|
|
97
|
+
'react/prop-types': 'off',
|
|
98
|
+
'react/jsx-uses-react': 'off',
|
|
99
|
+
'react/jsx-uses-vars': 'error',
|
|
100
|
+
'react/jsx-no-duplicate-props': 'error',
|
|
101
|
+
'react/jsx-no-undef': 'error',
|
|
102
|
+
'react/jsx-pascal-case': 'error',
|
|
103
|
+
'react/no-children-prop': 'error',
|
|
104
|
+
'react/no-danger-with-children': 'error',
|
|
105
|
+
'react/no-deprecated': 'error',
|
|
106
|
+
'react/no-direct-mutation-state': 'error',
|
|
107
|
+
'react/no-find-dom-node': 'error',
|
|
108
|
+
'react/no-is-mounted': 'error',
|
|
109
|
+
'react/no-render-return-value': 'error',
|
|
110
|
+
'react/no-string-refs': 'error',
|
|
111
|
+
'react/no-unescaped-entities': 'error',
|
|
112
|
+
'react/no-unknown-property': 'error',
|
|
113
|
+
'react/require-render-return': 'error',
|
|
114
|
+
'react/self-closing-comp': 'error',
|
|
115
|
+
|
|
116
|
+
// React Hooks rules
|
|
117
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
118
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
119
|
+
|
|
120
|
+
// General rules
|
|
121
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
122
|
+
'no-debugger': 'error',
|
|
123
|
+
'no-duplicate-imports': 'error',
|
|
124
|
+
'no-unused-expressions': 'error',
|
|
125
|
+
'prefer-const': 'error',
|
|
126
|
+
'no-var': 'error',
|
|
127
|
+
eqeqeq: ['error', 'always'],
|
|
128
|
+
curly: ['error', 'all'],
|
|
129
|
+
|
|
130
|
+
// Prettier integration
|
|
131
|
+
'prettier/prettier': 'error',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
// Backend configuration
|
|
135
|
+
{
|
|
136
|
+
files: ['backend/**/*.ts', 'backend/**/*.tsx'],
|
|
137
|
+
ignores: ['backend/tests/**/*', 'backend/**/*.test.*', 'backend/**/*.spec.*'],
|
|
138
|
+
languageOptions: {
|
|
139
|
+
ecmaVersion: 'latest',
|
|
140
|
+
sourceType: 'module',
|
|
141
|
+
parserOptions: {
|
|
142
|
+
project: './backend/tsconfig.json',
|
|
143
|
+
tsconfigRootDir: __dirname,
|
|
144
|
+
},
|
|
145
|
+
globals: {
|
|
146
|
+
...globals.node,
|
|
147
|
+
...globals.es2021,
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
plugins: {
|
|
151
|
+
prettier: prettierPlugin,
|
|
152
|
+
},
|
|
153
|
+
rules: {
|
|
154
|
+
// TypeScript rules
|
|
155
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
156
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
157
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
158
|
+
'@typescript-eslint/no-unused-vars': [
|
|
159
|
+
'error',
|
|
160
|
+
{
|
|
161
|
+
argsIgnorePattern: '^_',
|
|
162
|
+
varsIgnorePattern: '^_',
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
166
|
+
'@typescript-eslint/strict-boolean-expressions': 'off',
|
|
167
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
168
|
+
'@typescript-eslint/no-misused-promises': [
|
|
169
|
+
'error',
|
|
170
|
+
{
|
|
171
|
+
checksVoidReturn: {
|
|
172
|
+
arguments: false,
|
|
173
|
+
attributes: false,
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
178
|
+
'@typescript-eslint/require-await': 'error',
|
|
179
|
+
|
|
180
|
+
// General rules
|
|
181
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
182
|
+
'no-debugger': 'error',
|
|
183
|
+
'no-duplicate-imports': 'error',
|
|
184
|
+
'no-unused-expressions': 'error',
|
|
185
|
+
'prefer-const': 'error',
|
|
186
|
+
'no-var': 'error',
|
|
187
|
+
eqeqeq: ['error', 'always'],
|
|
188
|
+
curly: ['error', 'all'],
|
|
189
|
+
|
|
190
|
+
// Prettier integration
|
|
191
|
+
'prettier/prettier': 'error',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
// Shared schemas configuration - minimal rules for schema definitions
|
|
195
|
+
{
|
|
196
|
+
files: ['shared-schemas/**/*.ts'],
|
|
197
|
+
languageOptions: {
|
|
198
|
+
ecmaVersion: 'latest',
|
|
199
|
+
sourceType: 'module',
|
|
200
|
+
parserOptions: {
|
|
201
|
+
project: './shared-schemas/tsconfig.json',
|
|
202
|
+
tsconfigRootDir: __dirname,
|
|
203
|
+
},
|
|
204
|
+
globals: {
|
|
205
|
+
...globals.node,
|
|
206
|
+
...globals.es2021,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
plugins: {
|
|
210
|
+
prettier: prettierPlugin,
|
|
211
|
+
},
|
|
212
|
+
rules: {
|
|
213
|
+
// Minimal TypeScript rules for schema definitions
|
|
214
|
+
'@typescript-eslint/no-explicit-any': 'error', // Schemas should be strongly typed
|
|
215
|
+
'@typescript-eslint/no-unused-vars': [
|
|
216
|
+
'error',
|
|
217
|
+
{
|
|
218
|
+
argsIgnorePattern: '^_',
|
|
219
|
+
varsIgnorePattern: '^_',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
|
|
223
|
+
// Naming conventions for schemas
|
|
224
|
+
'@typescript-eslint/naming-convention': [
|
|
225
|
+
'error',
|
|
226
|
+
// Exported types - PascalCase
|
|
227
|
+
{
|
|
228
|
+
selector: ['typeLike', 'class'],
|
|
229
|
+
format: ['PascalCase'],
|
|
230
|
+
},
|
|
231
|
+
// Enum members - UPPER_CASE
|
|
232
|
+
{
|
|
233
|
+
selector: 'enumMember',
|
|
234
|
+
format: ['UPPER_CASE'],
|
|
235
|
+
},
|
|
236
|
+
// Default for everything else - camelCase
|
|
237
|
+
{
|
|
238
|
+
selector: 'default',
|
|
239
|
+
format: ['camelCase'],
|
|
240
|
+
leadingUnderscore: 'allow',
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
|
|
244
|
+
// Essential rules
|
|
245
|
+
'no-duplicate-imports': 'error',
|
|
246
|
+
'prefer-const': 'error',
|
|
247
|
+
|
|
248
|
+
// Prettier integration
|
|
249
|
+
'prettier/prettier': 'error',
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
// MCP configuration - minimal linting without TypeScript project
|
|
253
|
+
{
|
|
254
|
+
files: ['mcp/**/*.ts'],
|
|
255
|
+
languageOptions: {
|
|
256
|
+
ecmaVersion: 'latest',
|
|
257
|
+
sourceType: 'module',
|
|
258
|
+
globals: {
|
|
259
|
+
...globals.node,
|
|
260
|
+
...globals.es2021,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
plugins: {
|
|
264
|
+
prettier: prettierPlugin,
|
|
265
|
+
},
|
|
266
|
+
rules: {
|
|
267
|
+
// Basic TypeScript rules that don't require type checking
|
|
268
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
269
|
+
'@typescript-eslint/no-unused-vars': [
|
|
270
|
+
'error',
|
|
271
|
+
{
|
|
272
|
+
argsIgnorePattern: '^_',
|
|
273
|
+
varsIgnorePattern: '^_',
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
|
|
277
|
+
// General rules
|
|
278
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
279
|
+
'no-debugger': 'error',
|
|
280
|
+
'no-duplicate-imports': 'error',
|
|
281
|
+
'no-unused-expressions': 'error',
|
|
282
|
+
'prefer-const': 'error',
|
|
283
|
+
'no-var': 'error',
|
|
284
|
+
eqeqeq: ['error', 'always'],
|
|
285
|
+
curly: ['error', 'all'],
|
|
286
|
+
|
|
287
|
+
// Prettier integration
|
|
288
|
+
'prettier/prettier': 'error',
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
// Global ignores
|
|
292
|
+
{
|
|
293
|
+
ignores: [
|
|
294
|
+
'**/node_modules/**',
|
|
295
|
+
'**/dist/**',
|
|
296
|
+
'**/build/**',
|
|
297
|
+
'**/.next/**',
|
|
298
|
+
'**/coverage/**',
|
|
299
|
+
'**/.turbo/**',
|
|
300
|
+
'**/public/**',
|
|
301
|
+
'**/*.config.js',
|
|
302
|
+
'**/*.config.ts',
|
|
303
|
+
'**/vite.config.ts',
|
|
304
|
+
'**/vitest.config.ts',
|
|
305
|
+
'tailwind.config.js',
|
|
306
|
+
'eslint.config.js',
|
|
307
|
+
'**/*.md',
|
|
308
|
+
'**/*.yaml',
|
|
309
|
+
'**/*.yml',
|
|
310
|
+
'**/*.json',
|
|
311
|
+
'docs/**',
|
|
312
|
+
'examples/**',
|
|
313
|
+
'openapi/**',
|
|
314
|
+
'functions/',
|
|
315
|
+
],
|
|
316
|
+
}
|
|
317
|
+
);
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>OAuth Login Example</title>
|
|
7
|
+
<style>
|
|
8
|
+
body {
|
|
9
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
10
|
+
max-width: 600px;
|
|
11
|
+
margin: 0 auto;
|
|
12
|
+
padding: 20px;
|
|
13
|
+
background-color: #f5f5f5;
|
|
14
|
+
}
|
|
15
|
+
.container {
|
|
16
|
+
background: white;
|
|
17
|
+
padding: 30px;
|
|
18
|
+
border-radius: 8px;
|
|
19
|
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
20
|
+
}
|
|
21
|
+
.btn {
|
|
22
|
+
background: #4285f4;
|
|
23
|
+
color: white;
|
|
24
|
+
border: none;
|
|
25
|
+
padding: 12px 24px;
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
font-size: 16px;
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 8px;
|
|
32
|
+
}
|
|
33
|
+
.btn:hover {
|
|
34
|
+
background: #3367d6;
|
|
35
|
+
}
|
|
36
|
+
.btn:disabled {
|
|
37
|
+
background: #ccc;
|
|
38
|
+
cursor: not-allowed;
|
|
39
|
+
}
|
|
40
|
+
.status {
|
|
41
|
+
margin-top: 20px;
|
|
42
|
+
padding: 15px;
|
|
43
|
+
border-radius: 4px;
|
|
44
|
+
}
|
|
45
|
+
.status.success {
|
|
46
|
+
background: #d4edda;
|
|
47
|
+
color: #155724;
|
|
48
|
+
border: 1px solid #c3e6cb;
|
|
49
|
+
}
|
|
50
|
+
.status.error {
|
|
51
|
+
background: #f8d7da;
|
|
52
|
+
color: #721c24;
|
|
53
|
+
border: 1px solid #f5c6cb;
|
|
54
|
+
}
|
|
55
|
+
.status.info {
|
|
56
|
+
background: #d1ecf1;
|
|
57
|
+
color: #0c5460;
|
|
58
|
+
border: 1px solid #bee5eb;
|
|
59
|
+
}
|
|
60
|
+
.user-info {
|
|
61
|
+
margin-top: 20px;
|
|
62
|
+
padding: 15px;
|
|
63
|
+
background: #f8f9fa;
|
|
64
|
+
border-radius: 4px;
|
|
65
|
+
border-left: 4px solid #4285f4;
|
|
66
|
+
}
|
|
67
|
+
.loading {
|
|
68
|
+
display: inline-block;
|
|
69
|
+
width: 20px;
|
|
70
|
+
height: 20px;
|
|
71
|
+
border: 3px solid #f3f3f3;
|
|
72
|
+
border-top: 3px solid #4285f4;
|
|
73
|
+
border-radius: 50%;
|
|
74
|
+
animation: spin 1s linear infinite;
|
|
75
|
+
}
|
|
76
|
+
@keyframes spin {
|
|
77
|
+
0% { transform: rotate(0deg); }
|
|
78
|
+
100% { transform: rotate(360deg); }
|
|
79
|
+
}
|
|
80
|
+
</style>
|
|
81
|
+
</head>
|
|
82
|
+
<body>
|
|
83
|
+
<div class="container">
|
|
84
|
+
<h1>OAuth Login Example</h1>
|
|
85
|
+
|
|
86
|
+
<div id="loginSection">
|
|
87
|
+
<p>Click the buttons below to sign in with your account:</p>
|
|
88
|
+
<button id="googleLoginBtn" class="btn" onclick="initiateGoogleLogin()">
|
|
89
|
+
<svg width="18" height="18" viewBox="0 0 24 24">
|
|
90
|
+
<path fill="currentColor" d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"/>
|
|
91
|
+
<path fill="currentColor" d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"/>
|
|
92
|
+
<path fill="currentColor" d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"/>
|
|
93
|
+
<path fill="currentColor" d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"/>
|
|
94
|
+
</svg>
|
|
95
|
+
Sign in with Google
|
|
96
|
+
</button>
|
|
97
|
+
<button id="githubLoginBtn" class="btn" onclick="initiateGitHubLogin()" style="background: #333; margin-top: 10px;">
|
|
98
|
+
<svg width="18" height="18" viewBox="0 0 16 16">
|
|
99
|
+
<path fill="currentColor" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/>
|
|
100
|
+
</svg>
|
|
101
|
+
Sign in with GitHub
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div id="statusSection"></div>
|
|
106
|
+
<div id="userSection"></div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<script>
|
|
110
|
+
const API_BASE = 'http://localhost:7130/api';
|
|
111
|
+
|
|
112
|
+
// Check if there's OAuth callback data in URL parameters
|
|
113
|
+
function checkOAuthCallback() {
|
|
114
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
115
|
+
const token = urlParams.get('token');
|
|
116
|
+
const userId = urlParams.get('user_id');
|
|
117
|
+
const email = urlParams.get('email');
|
|
118
|
+
const name = urlParams.get('name');
|
|
119
|
+
|
|
120
|
+
console.log('Checking OAuth callback:', { token: !!token, userId, email, name });
|
|
121
|
+
|
|
122
|
+
if (token && userId) {
|
|
123
|
+
// Clear URL parameters
|
|
124
|
+
window.history.replaceState({}, document.title, window.location.pathname);
|
|
125
|
+
|
|
126
|
+
// Store user information
|
|
127
|
+
localStorage.setItem('auth_token', token);
|
|
128
|
+
localStorage.setItem('user_id', userId);
|
|
129
|
+
localStorage.setItem('user_email', email);
|
|
130
|
+
localStorage.setItem('user_name', name);
|
|
131
|
+
|
|
132
|
+
showStatus('Login successful!', 'success');
|
|
133
|
+
showUserInfo({ id: userId, email, name });
|
|
134
|
+
|
|
135
|
+
// Hide login button
|
|
136
|
+
document.getElementById('loginSection').style.display = 'none';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Initiate Google login
|
|
141
|
+
async function initiateGoogleLogin() {
|
|
142
|
+
const btn = document.getElementById('googleLoginBtn');
|
|
143
|
+
const originalText = btn.innerHTML;
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
btn.disabled = true;
|
|
147
|
+
btn.innerHTML = '<div class="loading"></div> Getting authorization link...';
|
|
148
|
+
|
|
149
|
+
showStatus('Getting Google authorization link...', 'info');
|
|
150
|
+
redirect_url = 'http://localhost/'; // window.location.href
|
|
151
|
+
// Get authorization URL
|
|
152
|
+
const response = await fetch(`${API_BASE}/auth/oauth/google?redirect_uri=${encodeURIComponent(redirect_url)}`);
|
|
153
|
+
const data = await response.json();
|
|
154
|
+
|
|
155
|
+
if (data.authUrl) {
|
|
156
|
+
showStatus('Redirecting to Google authorization page...', 'info');
|
|
157
|
+
// Redirect to Google authorization page
|
|
158
|
+
window.location.href = data.authUrl;
|
|
159
|
+
} else {
|
|
160
|
+
throw new Error(data.error?.message || 'Failed to get authorization link');
|
|
161
|
+
}
|
|
162
|
+
} catch (error) {
|
|
163
|
+
showStatus(`Error: ${error.message}`, 'error');
|
|
164
|
+
btn.disabled = false;
|
|
165
|
+
btn.innerHTML = originalText;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Initiate GitHub login
|
|
170
|
+
async function initiateGitHubLogin() {
|
|
171
|
+
const btn = document.getElementById('githubLoginBtn');
|
|
172
|
+
const originalText = btn.innerHTML;
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
btn.disabled = true;
|
|
176
|
+
btn.innerHTML = '<div class="loading"></div> Getting authorization link...';
|
|
177
|
+
|
|
178
|
+
showStatus('Getting GitHub authorization link...', 'info');
|
|
179
|
+
redirect_url = 'http://localhost/';
|
|
180
|
+
const response = await fetch(`${API_BASE}/auth/oauth/github?redirect_uri=${encodeURIComponent(redirect_url)}`);
|
|
181
|
+
const data = await response.json();
|
|
182
|
+
console.log('GitHub OAuth response:', data);
|
|
183
|
+
|
|
184
|
+
if (data.authUrl) {
|
|
185
|
+
showStatus('Redirecting to GitHub authorization page...', 'info');
|
|
186
|
+
window.location.href = data.authUrl;
|
|
187
|
+
} else {
|
|
188
|
+
throw new Error(data.error?.message || 'Failed to get authorization link');
|
|
189
|
+
}
|
|
190
|
+
} catch (error) {
|
|
191
|
+
showStatus(`Error: ${error.message}`, 'error');
|
|
192
|
+
btn.disabled = false;
|
|
193
|
+
btn.innerHTML = originalText;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Show status information
|
|
198
|
+
function showStatus(message, type = 'info') {
|
|
199
|
+
const statusSection = document.getElementById('statusSection');
|
|
200
|
+
statusSection.innerHTML = `<div class="status ${type}">${message}</div>`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Show user information
|
|
204
|
+
function showUserInfo(user) {
|
|
205
|
+
const userSection = document.getElementById('userSection');
|
|
206
|
+
userSection.innerHTML = `
|
|
207
|
+
<div class="user-info">
|
|
208
|
+
<h3>User Information</h3>
|
|
209
|
+
<p><strong>ID:</strong> ${user.id}</p>
|
|
210
|
+
<p><strong>Email:</strong> ${user.email}</p>
|
|
211
|
+
<p><strong>Name:</strong> ${user.name}</p>
|
|
212
|
+
<button class="btn" onclick="logout()" style="background: #dc3545;">Sign Out</button>
|
|
213
|
+
</div>
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Sign out
|
|
218
|
+
function logout() {
|
|
219
|
+
localStorage.removeItem('auth_token');
|
|
220
|
+
localStorage.removeItem('user_id');
|
|
221
|
+
localStorage.removeItem('user_email');
|
|
222
|
+
localStorage.removeItem('user_name');
|
|
223
|
+
|
|
224
|
+
document.getElementById('loginSection').style.display = 'block';
|
|
225
|
+
document.getElementById('statusSection').innerHTML = '';
|
|
226
|
+
document.getElementById('userSection').innerHTML = '';
|
|
227
|
+
|
|
228
|
+
showStatus('Signed out successfully', 'info');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Check login status
|
|
232
|
+
function checkLoginStatus() {
|
|
233
|
+
const token = localStorage.getItem('auth_token');
|
|
234
|
+
const userId = localStorage.getItem('user_id');
|
|
235
|
+
const email = localStorage.getItem('user_email');
|
|
236
|
+
const name = localStorage.getItem('user_name');
|
|
237
|
+
|
|
238
|
+
if (token && userId) {
|
|
239
|
+
document.getElementById('loginSection').style.display = 'none';
|
|
240
|
+
showUserInfo({ id: userId, email, name });
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Execute when page loads
|
|
245
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
246
|
+
checkOAuthCallback();
|
|
247
|
+
checkLoginStatus();
|
|
248
|
+
});
|
|
249
|
+
</script>
|
|
250
|
+
</body>
|
|
251
|
+
</html>
|