@graphoria/server 0.1.0
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/LICENSE +201 -0
- package/NOTICE +10 -0
- package/README.md +129 -0
- package/cli.ts +105 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/src/ai/agent/agent.d.ts +37 -0
- package/dist/src/ai/agent/agent.d.ts.map +1 -0
- package/dist/src/ai/agent/index.d.ts +3 -0
- package/dist/src/ai/agent/index.d.ts.map +1 -0
- package/dist/src/ai/agent/providers/anthropic.d.ts +10 -0
- package/dist/src/ai/agent/providers/anthropic.d.ts.map +1 -0
- package/dist/src/ai/agent/providers/index.d.ts +8 -0
- package/dist/src/ai/agent/providers/index.d.ts.map +1 -0
- package/dist/src/ai/agent/providers/ollama.d.ts +11 -0
- package/dist/src/ai/agent/providers/ollama.d.ts.map +1 -0
- package/dist/src/ai/agent/providers/openai.d.ts +14 -0
- package/dist/src/ai/agent/providers/openai.d.ts.map +1 -0
- package/dist/src/ai/agent/types.d.ts +51 -0
- package/dist/src/ai/agent/types.d.ts.map +1 -0
- package/dist/src/ai/ask-field.test.d.ts +2 -0
- package/dist/src/ai/ask-field.test.d.ts.map +1 -0
- package/dist/src/ai/index.d.ts +7 -0
- package/dist/src/ai/index.d.ts.map +1 -0
- package/dist/src/ai/mcp/create-server.d.ts +14 -0
- package/dist/src/ai/mcp/create-server.d.ts.map +1 -0
- package/dist/src/ai/mcp/create-server.test.d.ts +2 -0
- package/dist/src/ai/mcp/create-server.test.d.ts.map +1 -0
- package/dist/src/ai/mcp/index.d.ts +13 -0
- package/dist/src/ai/mcp/index.d.ts.map +1 -0
- package/dist/src/ai/mcp/index.test.d.ts +2 -0
- package/dist/src/ai/mcp/index.test.d.ts.map +1 -0
- package/dist/src/ai/mcp/instructions.d.ts +2 -0
- package/dist/src/ai/mcp/instructions.d.ts.map +1 -0
- package/dist/src/ai/tools/agent.d.ts +4 -0
- package/dist/src/ai/tools/agent.d.ts.map +1 -0
- package/dist/src/ai/tools/agent.test.d.ts +2 -0
- package/dist/src/ai/tools/agent.test.d.ts.map +1 -0
- package/dist/src/ai/tools/core.d.ts +75 -0
- package/dist/src/ai/tools/core.d.ts.map +1 -0
- package/dist/src/ai/tools/query-data.d.ts +35 -0
- package/dist/src/ai/tools/query-data.d.ts.map +1 -0
- package/dist/src/analyzeQuery/analyzers/fragmentAnalyzer.d.ts +5 -0
- package/dist/src/analyzeQuery/analyzers/fragmentAnalyzer.d.ts.map +1 -0
- package/dist/src/analyzeQuery/analyzers/operationAnalyzer.d.ts +6 -0
- package/dist/src/analyzeQuery/analyzers/operationAnalyzer.d.ts.map +1 -0
- package/dist/src/analyzeQuery/analyzers/selectionAnalyzer.d.ts +6 -0
- package/dist/src/analyzeQuery/analyzers/selectionAnalyzer.d.ts.map +1 -0
- package/dist/src/analyzeQuery/analyzers/variableAnalyzer.d.ts +4 -0
- package/dist/src/analyzeQuery/analyzers/variableAnalyzer.d.ts.map +1 -0
- package/dist/src/analyzeQuery/depthLimit.d.ts +16 -0
- package/dist/src/analyzeQuery/depthLimit.d.ts.map +1 -0
- package/dist/src/analyzeQuery/depthLimit.test.d.ts +2 -0
- package/dist/src/analyzeQuery/depthLimit.test.d.ts.map +1 -0
- package/dist/src/analyzeQuery/directiveUtils.d.ts +4 -0
- package/dist/src/analyzeQuery/directiveUtils.d.ts.map +1 -0
- package/dist/src/analyzeQuery/directiveUtils.test.d.ts +2 -0
- package/dist/src/analyzeQuery/directiveUtils.test.d.ts.map +1 -0
- package/dist/src/analyzeQuery/index.d.ts +5 -0
- package/dist/src/analyzeQuery/index.d.ts.map +1 -0
- package/dist/src/analyzeQuery/index.test.d.ts +2 -0
- package/dist/src/analyzeQuery/index.test.d.ts.map +1 -0
- package/dist/src/analyzeQuery/resolveVariables.d.ts +71 -0
- package/dist/src/analyzeQuery/resolveVariables.d.ts.map +1 -0
- package/dist/src/analyzeQuery/resolveVariables.test.d.ts +2 -0
- package/dist/src/analyzeQuery/resolveVariables.test.d.ts.map +1 -0
- package/dist/src/analyzeQuery/staticValues.test.d.ts +2 -0
- package/dist/src/analyzeQuery/staticValues.test.d.ts.map +1 -0
- package/dist/src/analyzeQuery/typeUtils.d.ts +9 -0
- package/dist/src/analyzeQuery/typeUtils.d.ts.map +1 -0
- package/dist/src/analyzeQuery/types.d.ts +54 -0
- package/dist/src/analyzeQuery/types.d.ts.map +1 -0
- package/dist/src/analyzeQuery/valueExtractors.d.ts +4 -0
- package/dist/src/analyzeQuery/valueExtractors.d.ts.map +1 -0
- package/dist/src/authentication/duration.d.ts +14 -0
- package/dist/src/authentication/duration.d.ts.map +1 -0
- package/dist/src/authentication/duration.test.d.ts +2 -0
- package/dist/src/authentication/duration.test.d.ts.map +1 -0
- package/dist/src/authentication/index.d.ts +4 -0
- package/dist/src/authentication/index.d.ts.map +1 -0
- package/dist/src/authentication/index.test.d.ts +2 -0
- package/dist/src/authentication/index.test.d.ts.map +1 -0
- package/dist/src/authentication/jwt.d.ts +10 -0
- package/dist/src/authentication/jwt.d.ts.map +1 -0
- package/dist/src/authentication/jwt.test.d.ts +2 -0
- package/dist/src/authentication/jwt.test.d.ts.map +1 -0
- package/dist/src/authentication/paseto.d.ts +7 -0
- package/dist/src/authentication/paseto.d.ts.map +1 -0
- package/dist/src/authentication/paseto.test.d.ts +2 -0
- package/dist/src/authentication/paseto.test.d.ts.map +1 -0
- package/dist/src/authentication/tokenRepository.d.ts +14 -0
- package/dist/src/authentication/tokenRepository.d.ts.map +1 -0
- package/dist/src/authentication/tokenRepository.test.d.ts +2 -0
- package/dist/src/authentication/tokenRepository.test.d.ts.map +1 -0
- package/dist/src/authentication/types.d.ts +42 -0
- package/dist/src/authentication/types.d.ts.map +1 -0
- package/dist/src/cli/seedAuth.d.ts +4 -0
- package/dist/src/cli/seedAuth.d.ts.map +1 -0
- package/dist/src/cli/seedAuth.test.d.ts +2 -0
- package/dist/src/cli/seedAuth.test.d.ts.map +1 -0
- package/dist/src/cli/seedAuthArgs.d.ts +9 -0
- package/dist/src/cli/seedAuthArgs.d.ts.map +1 -0
- package/dist/src/config/helpers/cronHelper.d.ts +21 -0
- package/dist/src/config/helpers/cronHelper.d.ts.map +1 -0
- package/dist/src/config/helpers/cronHelper.test.d.ts +2 -0
- package/dist/src/config/helpers/cronHelper.test.d.ts.map +1 -0
- package/dist/src/config/helpers/index.d.ts +4 -0
- package/dist/src/config/helpers/index.d.ts.map +1 -0
- package/dist/src/config/helpers/operationHelper.d.ts +44 -0
- package/dist/src/config/helpers/operationHelper.d.ts.map +1 -0
- package/dist/src/config/helpers/queueHelper.d.ts +20 -0
- package/dist/src/config/helpers/queueHelper.d.ts.map +1 -0
- package/dist/src/config/helpers/queueHelper.test.d.ts +2 -0
- package/dist/src/config/helpers/queueHelper.test.d.ts.map +1 -0
- package/dist/src/config/index.d.ts +236 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/types/ai.d.ts +29 -0
- package/dist/src/config/types/ai.d.ts.map +1 -0
- package/dist/src/config/types/auth.d.ts +112 -0
- package/dist/src/config/types/auth.d.ts.map +1 -0
- package/dist/src/config/types/configuration.d.ts +61 -0
- package/dist/src/config/types/configuration.d.ts.map +1 -0
- package/dist/src/config/types/cron.d.ts +81 -0
- package/dist/src/config/types/cron.d.ts.map +1 -0
- package/dist/src/config/types/db.d.ts +210 -0
- package/dist/src/config/types/db.d.ts.map +1 -0
- package/dist/src/config/types/index.d.ts +17 -0
- package/dist/src/config/types/index.d.ts.map +1 -0
- package/dist/src/config/types/operation.d.ts +226 -0
- package/dist/src/config/types/operation.d.ts.map +1 -0
- package/dist/src/config/types/queue.d.ts +142 -0
- package/dist/src/config/types/queue.d.ts.map +1 -0
- package/dist/src/config/types/remote-rest.d.ts +18 -0
- package/dist/src/config/types/remote-rest.d.ts.map +1 -0
- package/dist/src/config/types/remote-schema.d.ts +27 -0
- package/dist/src/config/types/remote-schema.d.ts.map +1 -0
- package/dist/src/config/types/virtual-columns.d.ts +89 -0
- package/dist/src/config/types/virtual-columns.d.ts.map +1 -0
- package/dist/src/config/types/virtual-columns.test.d.ts +2 -0
- package/dist/src/config/types/virtual-columns.test.d.ts.map +1 -0
- package/dist/src/configuration/getSchemas/index.d.ts +867 -0
- package/dist/src/configuration/getSchemas/index.d.ts.map +1 -0
- package/dist/src/configuration/getSchemas/mergeEntities/index.d.ts +412 -0
- package/dist/src/configuration/getSchemas/mergeEntities/index.d.ts.map +1 -0
- package/dist/src/configuration/getSchemas/type-definition-generator/index.d.ts +16 -0
- package/dist/src/configuration/getSchemas/type-definition-generator/index.d.ts.map +1 -0
- package/dist/src/configuration/getSchemas/type-definition-generator/index.test.d.ts +2 -0
- package/dist/src/configuration/getSchemas/type-definition-generator/index.test.d.ts.map +1 -0
- package/dist/src/configuration/gql/buildExecute.d.ts +31 -0
- package/dist/src/configuration/gql/buildExecute.d.ts.map +1 -0
- package/dist/src/configuration/gql/buildExecute.test.d.ts +2 -0
- package/dist/src/configuration/gql/buildExecute.test.d.ts.map +1 -0
- package/dist/src/configuration/gql/gqlAuthOperations.d.ts +9 -0
- package/dist/src/configuration/gql/gqlAuthOperations.d.ts.map +1 -0
- package/dist/src/configuration/gql/gqlAuthOperations.test.d.ts +2 -0
- package/dist/src/configuration/gql/gqlAuthOperations.test.d.ts.map +1 -0
- package/dist/src/configuration/gql/handleGraphQLRequestFactory.d.ts +28 -0
- package/dist/src/configuration/gql/handleGraphQLRequestFactory.d.ts.map +1 -0
- package/dist/src/configuration/gql/handleGraphQLRequestFactory.test.d.ts +2 -0
- package/dist/src/configuration/gql/handleGraphQLRequestFactory.test.d.ts.map +1 -0
- package/dist/src/configuration/gql/handleGraphQLSubscriptionFactory.d.ts +19 -0
- package/dist/src/configuration/gql/handleGraphQLSubscriptionFactory.d.ts.map +1 -0
- package/dist/src/configuration/index.d.ts +719 -0
- package/dist/src/configuration/index.d.ts.map +1 -0
- package/dist/src/configuration/rest/generateOpenAPI.d.ts +19 -0
- package/dist/src/configuration/rest/generateOpenAPI.d.ts.map +1 -0
- package/dist/src/configuration/rest/handleRESTRequestFactory.d.ts +12 -0
- package/dist/src/configuration/rest/handleRESTRequestFactory.d.ts.map +1 -0
- package/dist/src/configuration/rest/handleRESTRequestFactory.test.d.ts +2 -0
- package/dist/src/configuration/rest/handleRESTRequestFactory.test.d.ts.map +1 -0
- package/dist/src/configuration/rest/index.d.ts +20 -0
- package/dist/src/configuration/rest/index.d.ts.map +1 -0
- package/dist/src/configuration/rest/openApiErrors.d.ts +71 -0
- package/dist/src/configuration/rest/openApiErrors.d.ts.map +1 -0
- package/dist/src/console/App.d.ts +3 -0
- package/dist/src/console/App.d.ts.map +1 -0
- package/dist/src/console/Login.d.ts +6 -0
- package/dist/src/console/Login.d.ts.map +1 -0
- package/dist/src/console/api.d.ts +17 -0
- package/dist/src/console/api.d.ts.map +1 -0
- package/dist/src/console/api.test.d.ts +2 -0
- package/dist/src/console/api.test.d.ts.map +1 -0
- package/dist/src/console/client.d.ts +67 -0
- package/dist/src/console/client.d.ts.map +1 -0
- package/dist/src/console/frontend.d.ts +8 -0
- package/dist/src/console/frontend.d.ts.map +1 -0
- package/dist/src/console/pages/ConfigPage.d.ts +2 -0
- package/dist/src/console/pages/ConfigPage.d.ts.map +1 -0
- package/dist/src/console/pages/RolesPage.d.ts +2 -0
- package/dist/src/console/pages/RolesPage.d.ts.map +1 -0
- package/dist/src/console/pages/StatusPage.d.ts +2 -0
- package/dist/src/console/pages/StatusPage.d.ts.map +1 -0
- package/dist/src/console/pages/TablesPage.d.ts +2 -0
- package/dist/src/console/pages/TablesPage.d.ts.map +1 -0
- package/dist/src/console/useApi.d.ts +8 -0
- package/dist/src/console/useApi.d.ts.map +1 -0
- package/dist/src/cron/index.d.ts +63 -0
- package/dist/src/cron/index.d.ts.map +1 -0
- package/dist/src/databases/auth/auth-operations.d.ts +11 -0
- package/dist/src/databases/auth/auth-operations.d.ts.map +1 -0
- package/dist/src/databases/auth/password.d.ts +3 -0
- package/dist/src/databases/auth/password.d.ts.map +1 -0
- package/dist/src/databases/auth/password.test.d.ts +2 -0
- package/dist/src/databases/auth/password.test.d.ts.map +1 -0
- package/dist/src/databases/common.d.ts +53 -0
- package/dist/src/databases/common.d.ts.map +1 -0
- package/dist/src/databases/common.test.d.ts +2 -0
- package/dist/src/databases/common.test.d.ts.map +1 -0
- package/dist/src/databases/core/executor.d.ts +10 -0
- package/dist/src/databases/core/executor.d.ts.map +1 -0
- package/dist/src/databases/core/executor.test.d.ts +2 -0
- package/dist/src/databases/core/executor.test.d.ts.map +1 -0
- package/dist/src/databases/core/function-mapping.d.ts +38 -0
- package/dist/src/databases/core/function-mapping.d.ts.map +1 -0
- package/dist/src/databases/core/identifier.d.ts +2 -0
- package/dist/src/databases/core/identifier.d.ts.map +1 -0
- package/dist/src/databases/core/identifier.test.d.ts +2 -0
- package/dist/src/databases/core/identifier.test.d.ts.map +1 -0
- package/dist/src/databases/core/query-builder.d.ts +64 -0
- package/dist/src/databases/core/query-builder.d.ts.map +1 -0
- package/dist/src/databases/core/query-builder.test.d.ts +2 -0
- package/dist/src/databases/core/query-builder.test.d.ts.map +1 -0
- package/dist/src/databases/directives.d.ts +16 -0
- package/dist/src/databases/directives.d.ts.map +1 -0
- package/dist/src/databases/directives.test.d.ts +2 -0
- package/dist/src/databases/directives.test.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/auth.d.ts +9 -0
- package/dist/src/databases/engines/mssql/auth.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/auth.test.d.ts +2 -0
- package/dist/src/databases/engines/mssql/auth.test.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/connection.d.ts +14 -0
- package/dist/src/databases/engines/mssql/connection.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/format.d.ts +5 -0
- package/dist/src/databases/engines/mssql/format.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/getStructure.d.ts +48 -0
- package/dist/src/databases/engines/mssql/getStructure.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/getViews.d.ts +7 -0
- package/dist/src/databases/engines/mssql/getViews.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/query/index.d.ts +7 -0
- package/dist/src/databases/engines/mssql/query/index.d.ts.map +1 -0
- package/dist/src/databases/engines/mssql/query/index.test.d.ts +2 -0
- package/dist/src/databases/engines/mssql/query/index.test.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/auth.d.ts +9 -0
- package/dist/src/databases/engines/mysql/auth.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/auth.test.d.ts +2 -0
- package/dist/src/databases/engines/mysql/auth.test.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/connection.d.ts +14 -0
- package/dist/src/databases/engines/mysql/connection.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/format.d.ts +5 -0
- package/dist/src/databases/engines/mysql/format.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/getStructure.d.ts +48 -0
- package/dist/src/databases/engines/mysql/getStructure.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/getViews.d.ts +7 -0
- package/dist/src/databases/engines/mysql/getViews.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/query/index.d.ts +7 -0
- package/dist/src/databases/engines/mysql/query/index.d.ts.map +1 -0
- package/dist/src/databases/engines/mysql/query/index.test.d.ts +2 -0
- package/dist/src/databases/engines/mysql/query/index.test.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/auth.d.ts +9 -0
- package/dist/src/databases/engines/postgresql/auth.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/auth.test.d.ts +2 -0
- package/dist/src/databases/engines/postgresql/auth.test.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/connection.d.ts +14 -0
- package/dist/src/databases/engines/postgresql/connection.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/format.d.ts +5 -0
- package/dist/src/databases/engines/postgresql/format.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/getStructure.d.ts +48 -0
- package/dist/src/databases/engines/postgresql/getStructure.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/getViews.d.ts +7 -0
- package/dist/src/databases/engines/postgresql/getViews.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/query/index.d.ts +7 -0
- package/dist/src/databases/engines/postgresql/query/index.d.ts.map +1 -0
- package/dist/src/databases/engines/postgresql/query/index.test.d.ts +2 -0
- package/dist/src/databases/engines/postgresql/query/index.test.d.ts.map +1 -0
- package/dist/src/databases/engines/shared/claims.d.ts +2 -0
- package/dist/src/databases/engines/shared/claims.d.ts.map +1 -0
- package/dist/src/databases/engines/shared/types.d.ts +8 -0
- package/dist/src/databases/engines/shared/types.d.ts.map +1 -0
- package/dist/src/databases/high-level-operations.d.ts +146 -0
- package/dist/src/databases/high-level-operations.d.ts.map +1 -0
- package/dist/src/databases/high-level-operations.test.d.ts +2 -0
- package/dist/src/databases/high-level-operations.test.d.ts.map +1 -0
- package/dist/src/databases/index.d.ts +8 -0
- package/dist/src/databases/index.d.ts.map +1 -0
- package/dist/src/databases/metadata/structure.d.ts +56 -0
- package/dist/src/databases/metadata/structure.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/convert.d.ts +2 -0
- package/dist/src/databases/schemaBuilder/convert.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/generateCreateTable/index.d.ts +15 -0
- package/dist/src/databases/schemaBuilder/generateCreateTable/index.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/generateCreateTable/index.test.d.ts +2 -0
- package/dist/src/databases/schemaBuilder/generateCreateTable/index.test.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/generateCreateView/index.d.ts +18 -0
- package/dist/src/databases/schemaBuilder/generateCreateView/index.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/generateInsert/index.d.ts +8 -0
- package/dist/src/databases/schemaBuilder/generateInsert/index.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/generateInsert/index.test.d.ts +2 -0
- package/dist/src/databases/schemaBuilder/generateInsert/index.test.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/generateSchemaCreation/index.d.ts +7 -0
- package/dist/src/databases/schemaBuilder/generateSchemaCreation/index.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/generateSchemaCreation/index.test.d.ts +2 -0
- package/dist/src/databases/schemaBuilder/generateSchemaCreation/index.test.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/mssqlToPostgres/convertView.d.ts +2 -0
- package/dist/src/databases/schemaBuilder/mssqlToPostgres/convertView.d.ts.map +1 -0
- package/dist/src/databases/schemaBuilder/utils.d.ts +8 -0
- package/dist/src/databases/schemaBuilder/utils.d.ts.map +1 -0
- package/dist/src/databases/sqlTypeUtils.d.ts +24 -0
- package/dist/src/databases/sqlTypeUtils.d.ts.map +1 -0
- package/dist/src/databases/sqlTypeUtils.test.d.ts +2 -0
- package/dist/src/databases/sqlTypeUtils.test.d.ts.map +1 -0
- package/dist/src/databases/transformers/data-transformers.d.ts +215 -0
- package/dist/src/databases/transformers/data-transformers.d.ts.map +1 -0
- package/dist/src/databases/transformers/data-transformers.test.d.ts +2 -0
- package/dist/src/databases/transformers/data-transformers.test.d.ts.map +1 -0
- package/dist/src/databases/transformers/genResolverName.d.ts +2 -0
- package/dist/src/databases/transformers/genResolverName.d.ts.map +1 -0
- package/dist/src/databases/transformers/genResolverName.test.d.ts +2 -0
- package/dist/src/databases/transformers/genResolverName.test.d.ts.map +1 -0
- package/dist/src/index.d.ts +139 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/logging/index.d.ts +21 -0
- package/dist/src/logging/index.d.ts.map +1 -0
- package/dist/src/queues/kafka.d.ts +22 -0
- package/dist/src/queues/kafka.d.ts.map +1 -0
- package/dist/src/queues/rabbitmq.d.ts +34 -0
- package/dist/src/queues/rabbitmq.d.ts.map +1 -0
- package/dist/src/queues/rabbitmq.test.d.ts +2 -0
- package/dist/src/queues/rabbitmq.test.d.ts.map +1 -0
- package/dist/src/remoteREST/index.d.ts +13 -0
- package/dist/src/remoteREST/index.d.ts.map +1 -0
- package/dist/src/remoteREST/parse.d.ts +8 -0
- package/dist/src/remoteREST/parse.d.ts.map +1 -0
- package/dist/src/remoteREST/parse.test.d.ts +2 -0
- package/dist/src/remoteREST/parse.test.d.ts.map +1 -0
- package/dist/src/remoteREST/proxy.d.ts +6 -0
- package/dist/src/remoteREST/proxy.d.ts.map +1 -0
- package/dist/src/remoteREST/proxy.test.d.ts +2 -0
- package/dist/src/remoteREST/proxy.test.d.ts.map +1 -0
- package/dist/src/remoteREST/transform.d.ts +8 -0
- package/dist/src/remoteREST/transform.d.ts.map +1 -0
- package/dist/src/remoteREST/transform.test.d.ts +2 -0
- package/dist/src/remoteREST/transform.test.d.ts.map +1 -0
- package/dist/src/remoteREST/types.d.ts +37 -0
- package/dist/src/remoteREST/types.d.ts.map +1 -0
- package/dist/src/remoteSchemas/index.d.ts +13 -0
- package/dist/src/remoteSchemas/index.d.ts.map +1 -0
- package/dist/src/remoteSchemas/introspect.d.ts +7 -0
- package/dist/src/remoteSchemas/introspect.d.ts.map +1 -0
- package/dist/src/remoteSchemas/introspect.test.d.ts +2 -0
- package/dist/src/remoteSchemas/introspect.test.d.ts.map +1 -0
- package/dist/src/remoteSchemas/proxy.d.ts +7 -0
- package/dist/src/remoteSchemas/proxy.d.ts.map +1 -0
- package/dist/src/remoteSchemas/proxy.test.d.ts +2 -0
- package/dist/src/remoteSchemas/proxy.test.d.ts.map +1 -0
- package/dist/src/remoteSchemas/transform.d.ts +9 -0
- package/dist/src/remoteSchemas/transform.d.ts.map +1 -0
- package/dist/src/remoteSchemas/transform.test.d.ts +2 -0
- package/dist/src/remoteSchemas/transform.test.d.ts.map +1 -0
- package/dist/src/remoteSchemas/types.d.ts +41 -0
- package/dist/src/remoteSchemas/types.d.ts.map +1 -0
- package/dist/src/singletons/ai.d.ts +25 -0
- package/dist/src/singletons/ai.d.ts.map +1 -0
- package/dist/src/singletons/ai.test.d.ts +2 -0
- package/dist/src/singletons/ai.test.d.ts.map +1 -0
- package/dist/src/singletons/authentication.d.ts +4 -0
- package/dist/src/singletons/authentication.d.ts.map +1 -0
- package/dist/src/singletons/cache/index.d.ts +5 -0
- package/dist/src/singletons/cache/index.d.ts.map +1 -0
- package/dist/src/singletons/cache/lruCacheStore.d.ts +12 -0
- package/dist/src/singletons/cache/lruCacheStore.d.ts.map +1 -0
- package/dist/src/singletons/cache/lruCacheStore.test.d.ts +2 -0
- package/dist/src/singletons/cache/lruCacheStore.test.d.ts.map +1 -0
- package/dist/src/singletons/cache/redisCacheStore.d.ts +16 -0
- package/dist/src/singletons/cache/redisCacheStore.d.ts.map +1 -0
- package/dist/src/singletons/cache/redisClient.d.ts +3 -0
- package/dist/src/singletons/cache/redisClient.d.ts.map +1 -0
- package/dist/src/singletons/cache/registry.d.ts +7 -0
- package/dist/src/singletons/cache/registry.d.ts.map +1 -0
- package/dist/src/singletons/cache/registry.test.d.ts +2 -0
- package/dist/src/singletons/cache/registry.test.d.ts.map +1 -0
- package/dist/src/singletons/cache/types.d.ts +8 -0
- package/dist/src/singletons/cache/types.d.ts.map +1 -0
- package/dist/src/singletons/cron.d.ts +69 -0
- package/dist/src/singletons/cron.d.ts.map +1 -0
- package/dist/src/singletons/databases.d.ts +27 -0
- package/dist/src/singletons/databases.d.ts.map +1 -0
- package/dist/src/singletons/databases.test.d.ts +2 -0
- package/dist/src/singletons/databases.test.d.ts.map +1 -0
- package/dist/src/singletons/env.d.ts +494 -0
- package/dist/src/singletons/env.d.ts.map +1 -0
- package/dist/src/singletons/queues.d.ts +17 -0
- package/dist/src/singletons/queues.d.ts.map +1 -0
- package/dist/src/subscriptions/index.d.ts +4 -0
- package/dist/src/subscriptions/index.d.ts.map +1 -0
- package/dist/src/subscriptions/strategies/database.d.ts +12 -0
- package/dist/src/subscriptions/strategies/database.d.ts.map +1 -0
- package/dist/src/subscriptions/strategies/index.d.ts +12 -0
- package/dist/src/subscriptions/strategies/index.d.ts.map +1 -0
- package/dist/src/subscriptions/strategies/queue.d.ts +11 -0
- package/dist/src/subscriptions/strategies/queue.d.ts.map +1 -0
- package/dist/src/subscriptions/types.d.ts +67 -0
- package/dist/src/subscriptions/types.d.ts.map +1 -0
- package/dist/src/subscriptions/utils/polling.d.ts +17 -0
- package/dist/src/subscriptions/utils/polling.d.ts.map +1 -0
- package/dist/src/types/common.d.ts +44 -0
- package/dist/src/types/common.d.ts.map +1 -0
- package/dist/src/types/configuration.d.ts +28 -0
- package/dist/src/types/configuration.d.ts.map +1 -0
- package/dist/src/types/db.d.ts +43 -0
- package/dist/src/types/db.d.ts.map +1 -0
- package/dist/src/types/env.d.ts +2302 -0
- package/dist/src/types/env.d.ts.map +1 -0
- package/dist/src/types/env.test.d.ts +2 -0
- package/dist/src/types/env.test.d.ts.map +1 -0
- package/dist/src/types/resolver.d.ts +121 -0
- package/dist/src/types/resolver.d.ts.map +1 -0
- package/dist/src/types/zod/ai.d.ts +6 -0
- package/dist/src/types/zod/ai.d.ts.map +1 -0
- package/dist/src/types/zod/auth.d.ts +76 -0
- package/dist/src/types/zod/auth.d.ts.map +1 -0
- package/dist/src/types/zod/configuration.d.ts +1278 -0
- package/dist/src/types/zod/configuration.d.ts.map +1 -0
- package/dist/src/types/zod/configuration.test.d.ts +2 -0
- package/dist/src/types/zod/configuration.test.d.ts.map +1 -0
- package/dist/src/types/zod/cron.d.ts +32 -0
- package/dist/src/types/zod/cron.d.ts.map +1 -0
- package/dist/src/types/zod/db.d.ts +441 -0
- package/dist/src/types/zod/db.d.ts.map +1 -0
- package/dist/src/types/zod/db.test.d.ts +2 -0
- package/dist/src/types/zod/db.test.d.ts.map +1 -0
- package/dist/src/types/zod/mcp.d.ts +6 -0
- package/dist/src/types/zod/mcp.d.ts.map +1 -0
- package/dist/src/types/zod/operation.d.ts +9 -0
- package/dist/src/types/zod/operation.d.ts.map +1 -0
- package/dist/src/types/zod/queue.d.ts +656 -0
- package/dist/src/types/zod/queue.d.ts.map +1 -0
- package/dist/src/types/zod/queue.test.d.ts +2 -0
- package/dist/src/types/zod/queue.test.d.ts.map +1 -0
- package/dist/src/types/zod/remoteREST.d.ts +6 -0
- package/dist/src/types/zod/remoteREST.d.ts.map +1 -0
- package/dist/src/types/zod/remoteSchema.d.ts +6 -0
- package/dist/src/types/zod/remoteSchema.d.ts.map +1 -0
- package/dist/src/utils/benchmark.d.ts +2 -0
- package/dist/src/utils/benchmark.d.ts.map +1 -0
- package/dist/src/utils/event-emitter.d.ts +19 -0
- package/dist/src/utils/event-emitter.d.ts.map +1 -0
- package/dist/src/utils/responses.d.ts +19 -0
- package/dist/src/utils/responses.d.ts.map +1 -0
- package/dist/src/utils/responses.test.d.ts +2 -0
- package/dist/src/utils/responses.test.d.ts.map +1 -0
- package/dist/src/utils/safeJSONParse.d.ts +2 -0
- package/dist/src/utils/safeJSONParse.d.ts.map +1 -0
- package/dist/src/utils/selection.d.ts +3 -0
- package/dist/src/utils/selection.d.ts.map +1 -0
- package/dist/src/utils/selection.test.d.ts +2 -0
- package/dist/src/utils/selection.test.d.ts.map +1 -0
- package/dist/src/utils/sessionVariables.d.ts +47 -0
- package/dist/src/utils/sessionVariables.d.ts.map +1 -0
- package/dist/src/utils/sessionVariables.test.d.ts +2 -0
- package/dist/src/utils/sessionVariables.test.d.ts.map +1 -0
- package/dist/src/utils/writeSchema.d.ts +3 -0
- package/dist/src/utils/writeSchema.d.ts.map +1 -0
- package/dist/standalone.d.ts +3 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +119 -0
- package/playgrounds/console/index.html +25 -0
- package/playgrounds/graphiql/index.html +1144 -0
- package/playgrounds/scalar/index.html +19 -0
- package/src/ai/agent/agent.ts +222 -0
- package/src/ai/agent/index.ts +2 -0
- package/src/ai/agent/providers/anthropic.ts +113 -0
- package/src/ai/agent/providers/index.ts +62 -0
- package/src/ai/agent/providers/ollama.ts +128 -0
- package/src/ai/agent/providers/openai.ts +100 -0
- package/src/ai/agent/types.ts +65 -0
- package/src/ai/index.ts +8 -0
- package/src/ai/mcp/create-server.ts +444 -0
- package/src/ai/mcp/index.ts +80 -0
- package/src/ai/mcp/instructions.ts +103 -0
- package/src/ai/tools/agent.ts +111 -0
- package/src/ai/tools/core.ts +486 -0
- package/src/ai/tools/query-data.ts +109 -0
- package/src/analyzeQuery/analyzers/fragmentAnalyzer.ts +29 -0
- package/src/analyzeQuery/analyzers/operationAnalyzer.ts +50 -0
- package/src/analyzeQuery/analyzers/selectionAnalyzer.ts +135 -0
- package/src/analyzeQuery/analyzers/variableAnalyzer.ts +17 -0
- package/src/analyzeQuery/depthLimit.ts +124 -0
- package/src/analyzeQuery/directiveUtils.ts +99 -0
- package/src/analyzeQuery/index.ts +66 -0
- package/src/analyzeQuery/resolveVariables.ts +394 -0
- package/src/analyzeQuery/typeUtils.ts +47 -0
- package/src/analyzeQuery/types.ts +57 -0
- package/src/analyzeQuery/valueExtractors.ts +96 -0
- package/src/authentication/duration.ts +50 -0
- package/src/authentication/index.ts +34 -0
- package/src/authentication/jwt.ts +220 -0
- package/src/authentication/paseto.ts +256 -0
- package/src/authentication/tokenRepository.ts +75 -0
- package/src/authentication/types.ts +78 -0
- package/src/cli/seedAuth.ts +51 -0
- package/src/cli/seedAuthArgs.ts +50 -0
- package/src/config/helpers/cronHelper.ts +29 -0
- package/src/config/helpers/index.ts +8 -0
- package/src/config/helpers/operationHelper.ts +146 -0
- package/src/config/helpers/queueHelper.ts +27 -0
- package/src/config/index.ts +315 -0
- package/src/config/types/ai.ts +35 -0
- package/src/config/types/auth.ts +147 -0
- package/src/config/types/configuration.ts +69 -0
- package/src/config/types/cron.ts +140 -0
- package/src/config/types/db.ts +256 -0
- package/src/config/types/index.ts +129 -0
- package/src/config/types/operation.ts +253 -0
- package/src/config/types/queue.ts +172 -0
- package/src/config/types/remote-rest.ts +28 -0
- package/src/config/types/remote-schema.ts +39 -0
- package/src/config/types/virtual-columns.ts +157 -0
- package/src/configuration/getSchemas/index.ts +82 -0
- package/src/configuration/getSchemas/mergeEntities/index.ts +221 -0
- package/src/configuration/getSchemas/type-definition-generator/index.ts +511 -0
- package/src/configuration/gql/buildExecute.ts +54 -0
- package/src/configuration/gql/gqlAuthOperations.ts +150 -0
- package/src/configuration/gql/handleGraphQLRequestFactory.ts +415 -0
- package/src/configuration/gql/handleGraphQLSubscriptionFactory.ts +249 -0
- package/src/configuration/index.ts +138 -0
- package/src/configuration/rest/generateOpenAPI.ts +361 -0
- package/src/configuration/rest/handleRESTRequestFactory.ts +335 -0
- package/src/configuration/rest/index.ts +167 -0
- package/src/configuration/rest/openApiErrors.ts +106 -0
- package/src/console/api.ts +270 -0
- package/src/cron/index.ts +251 -0
- package/src/databases/auth/auth-operations.ts +36 -0
- package/src/databases/auth/password.ts +4 -0
- package/src/databases/common.ts +642 -0
- package/src/databases/core/executor.ts +97 -0
- package/src/databases/core/function-mapping.ts +176 -0
- package/src/databases/core/identifier.ts +8 -0
- package/src/databases/core/query-builder.ts +47 -0
- package/src/databases/directives.ts +112 -0
- package/src/databases/engines/mssql/auth.ts +112 -0
- package/src/databases/engines/mssql/connection.ts +151 -0
- package/src/databases/engines/mssql/format.ts +23 -0
- package/src/databases/engines/mssql/getStructure.ts +112 -0
- package/src/databases/engines/mssql/getViews.ts +17 -0
- package/src/databases/engines/mssql/query/index.ts +306 -0
- package/src/databases/engines/mysql/auth.ts +100 -0
- package/src/databases/engines/mysql/connection.ts +100 -0
- package/src/databases/engines/mysql/format.ts +23 -0
- package/src/databases/engines/mysql/getStructure.ts +116 -0
- package/src/databases/engines/mysql/getViews.ts +20 -0
- package/src/databases/engines/mysql/query/index.ts +291 -0
- package/src/databases/engines/postgresql/auth.ts +98 -0
- package/src/databases/engines/postgresql/connection.ts +99 -0
- package/src/databases/engines/postgresql/format.ts +23 -0
- package/src/databases/engines/postgresql/getStructure.ts +149 -0
- package/src/databases/engines/postgresql/getViews.ts +20 -0
- package/src/databases/engines/postgresql/query/index.ts +291 -0
- package/src/databases/engines/shared/claims.ts +26 -0
- package/src/databases/engines/shared/types.ts +7 -0
- package/src/databases/high-level-operations.ts +272 -0
- package/src/databases/index.ts +28 -0
- package/src/databases/metadata/structure.ts +12 -0
- package/src/databases/schemaBuilder/convert.ts +121 -0
- package/src/databases/schemaBuilder/generateCreateTable/index.ts +133 -0
- package/src/databases/schemaBuilder/generateCreateView/index.ts +101 -0
- package/src/databases/schemaBuilder/generateInsert/index.ts +47 -0
- package/src/databases/schemaBuilder/generateSchemaCreation/index.ts +29 -0
- package/src/databases/schemaBuilder/mssqlToPostgres/convertView.ts +47 -0
- package/src/databases/schemaBuilder/utils.ts +17 -0
- package/src/databases/sqlTypeUtils.ts +91 -0
- package/src/databases/transformers/data-transformers.ts +128 -0
- package/src/databases/transformers/genResolverName.ts +18 -0
- package/src/index.ts +461 -0
- package/src/logging/index.ts +69 -0
- package/src/queues/kafka.ts +409 -0
- package/src/queues/rabbitmq.ts +331 -0
- package/src/remoteREST/index.ts +46 -0
- package/src/remoteREST/parse.ts +68 -0
- package/src/remoteREST/proxy.ts +92 -0
- package/src/remoteREST/transform.ts +121 -0
- package/src/remoteREST/types.ts +38 -0
- package/src/remoteSchemas/index.ts +48 -0
- package/src/remoteSchemas/introspect.ts +44 -0
- package/src/remoteSchemas/proxy.ts +146 -0
- package/src/remoteSchemas/transform.ts +210 -0
- package/src/remoteSchemas/types.ts +43 -0
- package/src/singletons/ai.ts +91 -0
- package/src/singletons/authentication.ts +13 -0
- package/src/singletons/cache/index.ts +4 -0
- package/src/singletons/cache/lruCacheStore.ts +34 -0
- package/src/singletons/cache/redisCacheStore.ts +81 -0
- package/src/singletons/cache/redisClient.ts +12 -0
- package/src/singletons/cache/registry.ts +51 -0
- package/src/singletons/cache/types.ts +7 -0
- package/src/singletons/cron.ts +21 -0
- package/src/singletons/databases.ts +68 -0
- package/src/singletons/env.ts +3 -0
- package/src/singletons/queues.ts +101 -0
- package/src/subscriptions/index.ts +20 -0
- package/src/subscriptions/strategies/database.ts +68 -0
- package/src/subscriptions/strategies/index.ts +38 -0
- package/src/subscriptions/strategies/queue.ts +61 -0
- package/src/subscriptions/types.ts +74 -0
- package/src/subscriptions/utils/polling.ts +119 -0
- package/src/types/common.ts +57 -0
- package/src/types/configuration.ts +52 -0
- package/src/types/db.ts +87 -0
- package/src/types/env.ts +137 -0
- package/src/types/resolver.ts +181 -0
- package/src/types/zod/ai.ts +8 -0
- package/src/types/zod/auth.ts +96 -0
- package/src/types/zod/configuration.ts +46 -0
- package/src/types/zod/cron.ts +35 -0
- package/src/types/zod/db.ts +146 -0
- package/src/types/zod/mcp.ts +8 -0
- package/src/types/zod/operation.ts +37 -0
- package/src/types/zod/queue.ts +182 -0
- package/src/types/zod/remoteREST.ts +8 -0
- package/src/types/zod/remoteSchema.ts +11 -0
- package/src/utils/benchmark.ts +13 -0
- package/src/utils/event-emitter.ts +217 -0
- package/src/utils/responses.ts +42 -0
- package/src/utils/safeJSONParse.ts +10 -0
- package/src/utils/selection.ts +35 -0
- package/src/utils/sessionVariables.ts +131 -0
- package/src/utils/writeSchema.ts +13 -0
- package/standalone.ts +32 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DatabaseType } from "../../../types/configuration";
|
|
2
|
+
import type { TableResolver } from "../../../types/db";
|
|
3
|
+
|
|
4
|
+
export const generateInsertSQL =
|
|
5
|
+
(toDb: DatabaseType) =>
|
|
6
|
+
// oxlint-disable-next-line typescript/no-explicit-any
|
|
7
|
+
(table: TableResolver, data: Record<string, any>[]) => {
|
|
8
|
+
const columnNames = table.columns.map((column) => {
|
|
9
|
+
if (toDb === "mssql") {
|
|
10
|
+
return column.name;
|
|
11
|
+
} else if (toDb === "mysql") {
|
|
12
|
+
return `\`${column.name}\``;
|
|
13
|
+
} else {
|
|
14
|
+
return `"${column.name}"`;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const valueRows = data.map((row) => {
|
|
19
|
+
const values = table.columns.map((column) => {
|
|
20
|
+
const value = row[column.name];
|
|
21
|
+
if (typeof value === "string") {
|
|
22
|
+
return toDb === "mssql" ? `N'${value}'` : `'${value}'`;
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
});
|
|
26
|
+
return `(${values.join(",")})`;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (toDb === "pg") {
|
|
30
|
+
return `INSERT INTO ${table?.dottedQuotedName} (${columnNames.join(",")}) VALUES\n${valueRows.join(",\n")}`;
|
|
31
|
+
} else if (toDb === "mssql") {
|
|
32
|
+
return `INSERT INTO ${table?.dottedName} (${columnNames.join(",")}) VALUES\n${valueRows.join(",\n")}`;
|
|
33
|
+
} else if (toDb === "mysql") {
|
|
34
|
+
// Generate backtick version of dotted name
|
|
35
|
+
const parts = table.dottedName.split(".");
|
|
36
|
+
const dottedBacktickName = parts.map((p) => `\`${p}\``).join(".");
|
|
37
|
+
return `INSERT INTO ${dottedBacktickName} (${columnNames.join(",")}) VALUES\n${valueRows.join(",\n")}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return "";
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type GenerateInsertSQL = ReturnType<typeof generateInsertSQL>;
|
|
44
|
+
|
|
45
|
+
export const generateInsertSQLMSSQL = generateInsertSQL("mssql");
|
|
46
|
+
export const generateInsertSQLPostgreSQL = generateInsertSQL("pg");
|
|
47
|
+
export const generateInsertSQLMySQL = generateInsertSQL("mysql");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DatabaseType } from "../../../types/configuration";
|
|
2
|
+
|
|
3
|
+
export const generateSchemaCreationSQL =
|
|
4
|
+
(toDb: DatabaseType) =>
|
|
5
|
+
(schema: string, schemaCreationIfExists = true) => {
|
|
6
|
+
let sql = "";
|
|
7
|
+
|
|
8
|
+
if (toDb === "pg") {
|
|
9
|
+
sql += `CREATE SCHEMA ${schemaCreationIfExists ? "IF NOT EXISTS " : ""}"${schema}";`;
|
|
10
|
+
} else if (toDb === "mssql") {
|
|
11
|
+
if (schemaCreationIfExists) {
|
|
12
|
+
sql += `IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '${schema}')\n`;
|
|
13
|
+
sql += ` EXEC('CREATE SCHEMA [${schema}]');`;
|
|
14
|
+
} else {
|
|
15
|
+
sql += `CREATE SCHEMA ${schema};`;
|
|
16
|
+
}
|
|
17
|
+
} else if (toDb === "mysql") {
|
|
18
|
+
// In MySQL, schemas and databases are the same thing
|
|
19
|
+
sql += `CREATE DATABASE ${schemaCreationIfExists ? "IF NOT EXISTS " : ""}\`${schema}\`;`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return sql;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type GenerateSchemaCreationSQL = ReturnType<typeof generateSchemaCreationSQL>;
|
|
26
|
+
|
|
27
|
+
export const generateSchemaCreationMSSQL = generateSchemaCreationSQL("mssql");
|
|
28
|
+
export const generateSchemaCreationPostgreSQL = generateSchemaCreationSQL("pg");
|
|
29
|
+
export const generateSchemaCreationMySQL = generateSchemaCreationSQL("mysql");
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const convertMSSQLViewToPostgres = (viewDefinition: string): string => {
|
|
2
|
+
return (
|
|
3
|
+
viewDefinition
|
|
4
|
+
// Fix CAST syntax
|
|
5
|
+
.replace(/cast\(([^)]+)\s+as\s+([^)]+)\)/gi, "$1::$2")
|
|
6
|
+
|
|
7
|
+
// Replace ISNULL with COALESCE
|
|
8
|
+
.replace(/ISNULL\s*\(([^,]+),([^)]+)\)/gi, "COALESCE($1,$2)")
|
|
9
|
+
|
|
10
|
+
// Replace string concatenation + with ||
|
|
11
|
+
.replace(/\s*\+\s*(?=('[^']*'|[^']+))/g, " || ")
|
|
12
|
+
|
|
13
|
+
// Replace TOP with LIMIT
|
|
14
|
+
.replace(/TOP\s+(\d+)/gi, "LIMIT $1")
|
|
15
|
+
|
|
16
|
+
// Replace LEN with LENGTH
|
|
17
|
+
.replace(/LEN\s*\(([^)]+)\)/gi, "LENGTH($1)")
|
|
18
|
+
|
|
19
|
+
// Remove square brackets from identifiers
|
|
20
|
+
.replace(/\[([^\]]+)\]/g, '"$1"')
|
|
21
|
+
|
|
22
|
+
// Replace CHARINDEX with POSITION
|
|
23
|
+
.replace(/CHARINDEX\s*\(([^,]+),([^)]+)\)/gi, "POSITION($1 IN $2)")
|
|
24
|
+
|
|
25
|
+
// Replace GETDATE() with CURRENT_TIMESTAMP
|
|
26
|
+
.replace(/GETDATE\(\)/gi, "CURRENT_TIMESTAMP")
|
|
27
|
+
|
|
28
|
+
// Replace SUBSTRING with proper syntax
|
|
29
|
+
.replace(/substring\s*\(([^,]+),([^,)]+)\)/gi, "substring($1 from $2)")
|
|
30
|
+
|
|
31
|
+
// Fix numeric types
|
|
32
|
+
.replace(/numeric\s*\(([^)]+)\)/gi, "numeric($1)")
|
|
33
|
+
|
|
34
|
+
// Fix boolean comparisons
|
|
35
|
+
.replace(/=\s*1/g, " = true")
|
|
36
|
+
.replace(/=\s*0/g, " = false")
|
|
37
|
+
|
|
38
|
+
// Fix CONVERT
|
|
39
|
+
.replace(/CONVERT\s*\(\s*([^,]+)\s*,\s*([^)]+)\s*\)/gi, "$2::$1")
|
|
40
|
+
|
|
41
|
+
// Fix CREATE VIEW syntax
|
|
42
|
+
.replace(
|
|
43
|
+
/CREATE\s+VIEW\s+(\[?)(\w+)(\]?)\.(\[?)(\w+)(\]?)/gi,
|
|
44
|
+
'CREATE OR REPLACE VIEW "$2"."$5"',
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const splitInternalName = (internalName: string, helpers: boolean = false) => {
|
|
2
|
+
const [schema, ...nameSegments] = internalName.split("_");
|
|
3
|
+
|
|
4
|
+
const name = nameSegments.join("_");
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
schema,
|
|
8
|
+
name,
|
|
9
|
+
...(helpers
|
|
10
|
+
? {
|
|
11
|
+
nameDashed: `${schema}_${name}`,
|
|
12
|
+
nameDotted: `${schema}.${name}`,
|
|
13
|
+
nameDottedQuoted: `"${schema}"."${name}"`,
|
|
14
|
+
}
|
|
15
|
+
: {}),
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for SQL data type categorization and mapping
|
|
3
|
+
* Supports MSSQL, MySQL, and PostgreSQL data types
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export enum SqlTypeCategory {
|
|
7
|
+
INTEGER = "INTEGER",
|
|
8
|
+
FLOAT = "FLOAT",
|
|
9
|
+
BOOLEAN = "BOOLEAN",
|
|
10
|
+
DATE_TIME = "DATE_TIME",
|
|
11
|
+
STRING = "STRING",
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Categorizes a SQL data type into one of the standard categories
|
|
16
|
+
* @param dataType - The SQL data type to categorize (case-insensitive)
|
|
17
|
+
* @returns The category of the data type
|
|
18
|
+
*/
|
|
19
|
+
export const categorizeSqlType = (dataType: string): SqlTypeCategory => {
|
|
20
|
+
const lowerType = dataType.toLowerCase();
|
|
21
|
+
|
|
22
|
+
// Integer types (all databases)
|
|
23
|
+
if (
|
|
24
|
+
lowerType === "int" ||
|
|
25
|
+
lowerType === "integer" ||
|
|
26
|
+
lowerType === "smallint" ||
|
|
27
|
+
lowerType === "bigint" ||
|
|
28
|
+
lowerType === "tinyint" ||
|
|
29
|
+
lowerType === "mediumint" ||
|
|
30
|
+
lowerType === "numeric" ||
|
|
31
|
+
lowerType === "number"
|
|
32
|
+
) {
|
|
33
|
+
return SqlTypeCategory.INTEGER;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Floating-point types (all databases)
|
|
37
|
+
if (
|
|
38
|
+
lowerType === "float" ||
|
|
39
|
+
lowerType === "real" ||
|
|
40
|
+
lowerType === "double" ||
|
|
41
|
+
lowerType === "double precision" ||
|
|
42
|
+
lowerType === "decimal" ||
|
|
43
|
+
lowerType === "money" ||
|
|
44
|
+
lowerType === "smallmoney"
|
|
45
|
+
) {
|
|
46
|
+
return SqlTypeCategory.FLOAT;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Boolean types (all databases)
|
|
50
|
+
if (lowerType === "bit" || lowerType === "bool" || lowerType === "boolean") {
|
|
51
|
+
return SqlTypeCategory.BOOLEAN;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Date and time types (all databases)
|
|
55
|
+
if (
|
|
56
|
+
lowerType === "date" ||
|
|
57
|
+
lowerType === "time" ||
|
|
58
|
+
lowerType === "datetime" ||
|
|
59
|
+
lowerType === "datetime2" ||
|
|
60
|
+
lowerType === "smalldatetime" ||
|
|
61
|
+
lowerType === "timestamp" ||
|
|
62
|
+
lowerType === "timestamptz" ||
|
|
63
|
+
lowerType === "timestamp with time zone" ||
|
|
64
|
+
lowerType === "timestamp without time zone" ||
|
|
65
|
+
lowerType === "time with time zone" ||
|
|
66
|
+
lowerType === "time without time zone" ||
|
|
67
|
+
lowerType === "timetz" ||
|
|
68
|
+
lowerType === "year" ||
|
|
69
|
+
lowerType === "interval"
|
|
70
|
+
) {
|
|
71
|
+
return SqlTypeCategory.DATE_TIME;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// All other types default to STRING
|
|
75
|
+
// This includes:
|
|
76
|
+
// - Character strings: char, varchar, nchar, nvarchar, text, ntext, tinytext, mediumtext, longtext
|
|
77
|
+
// - Binary types: binary, varbinary, image, blob, tinyblob, mediumblob, longblob, bytea
|
|
78
|
+
// - Special types: uniqueidentifier, uuid, guid, xml, json, jsonb, sql_variant, geography, geometry, hierarchyid, datetimeoffset, cursor, table, vector, enum, set
|
|
79
|
+
// - PostgreSQL-specific: inet, cidr, macaddr, macaddr8, point, line, lseg, box, path, polygon, circle, tsquery, tsvector, ranges, array types
|
|
80
|
+
return SqlTypeCategory.STRING;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Checks if a SQL data type is numeric (integer or floating-point)
|
|
85
|
+
* @param dataType - The SQL data type to check
|
|
86
|
+
* @returns True if the type is numeric, false otherwise
|
|
87
|
+
*/
|
|
88
|
+
export const isNumericType = (dataType: string): boolean => {
|
|
89
|
+
const category = categorizeSqlType(dataType);
|
|
90
|
+
return category === SqlTypeCategory.INTEGER || category === SqlTypeCategory.FLOAT;
|
|
91
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Database, Relationships } from "../../types/configuration";
|
|
2
|
+
import type { RelationshipResolver, StoredProcedure, Table, Tables } from "../../types/db";
|
|
3
|
+
|
|
4
|
+
import { genResolverName } from "./genResolverName";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Data transformation functions for converting database objects to internal formats
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const buildRelationshipResolver = (
|
|
11
|
+
table: Table,
|
|
12
|
+
foreignKey: Relationships[number],
|
|
13
|
+
db: Database,
|
|
14
|
+
reversed = false,
|
|
15
|
+
) => {
|
|
16
|
+
const internalName = genResolverName(
|
|
17
|
+
table.schema,
|
|
18
|
+
table.name,
|
|
19
|
+
table.entityType,
|
|
20
|
+
db.fieldNaming,
|
|
21
|
+
db.name,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const multipleRelationshipsWithTheSameTable =
|
|
25
|
+
table.foreignKeys.filter((fk) => fk.name === foreignKey.name && fk.schema === foreignKey.schema)
|
|
26
|
+
.length > 1;
|
|
27
|
+
|
|
28
|
+
const hasRelationshipsWithItself =
|
|
29
|
+
table.schema === foreignKey.schema && table.name === foreignKey.name;
|
|
30
|
+
|
|
31
|
+
let suffix = "";
|
|
32
|
+
|
|
33
|
+
if (multipleRelationshipsWithTheSameTable && hasRelationshipsWithItself) {
|
|
34
|
+
// Multiple self-referential FKs: use column names + direction to distinguish
|
|
35
|
+
const columnSuffix = foreignKey.columns.map((c) => c.source).join("_");
|
|
36
|
+
suffix = reversed ? `${columnSuffix}_list` : columnSuffix;
|
|
37
|
+
} else if (multipleRelationshipsWithTheSameTable) {
|
|
38
|
+
suffix = foreignKey.columns.map((c) => c.source).join("_");
|
|
39
|
+
} else if (hasRelationshipsWithItself) {
|
|
40
|
+
// Single self-referential FK: use ref/list pattern
|
|
41
|
+
suffix = reversed ? "list" : "ref";
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...foreignKey,
|
|
46
|
+
internalName,
|
|
47
|
+
fromInternalName: genResolverName(
|
|
48
|
+
table.schema,
|
|
49
|
+
table.name,
|
|
50
|
+
table.entityType,
|
|
51
|
+
db.fieldNaming,
|
|
52
|
+
db.name,
|
|
53
|
+
),
|
|
54
|
+
toInternalName: genResolverName(
|
|
55
|
+
foreignKey.schema,
|
|
56
|
+
foreignKey.name,
|
|
57
|
+
table.entityType,
|
|
58
|
+
db.fieldNaming,
|
|
59
|
+
db.name,
|
|
60
|
+
),
|
|
61
|
+
fromResolverName: genResolverName(
|
|
62
|
+
table.schema,
|
|
63
|
+
table.name,
|
|
64
|
+
table.entityType,
|
|
65
|
+
db.fieldNaming,
|
|
66
|
+
db.name,
|
|
67
|
+
suffix,
|
|
68
|
+
),
|
|
69
|
+
toResolverName: genResolverName(
|
|
70
|
+
foreignKey.schema,
|
|
71
|
+
foreignKey.name,
|
|
72
|
+
table.entityType,
|
|
73
|
+
db.fieldNaming,
|
|
74
|
+
db.name,
|
|
75
|
+
suffix,
|
|
76
|
+
),
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const buildTableResolver = (tables: Tables, table: Table, db: Database) => {
|
|
81
|
+
const internalName = genResolverName(
|
|
82
|
+
table.schema,
|
|
83
|
+
table.name,
|
|
84
|
+
table.entityType,
|
|
85
|
+
db.fieldNaming,
|
|
86
|
+
db.name,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const relationships = table.foreignKeys.map((fk) => buildRelationshipResolver(table, fk, db));
|
|
90
|
+
|
|
91
|
+
const relationshipsReversed = tables.reduce<RelationshipResolver[]>((acc, t) => {
|
|
92
|
+
const reversed = t.foreignKeys.filter(
|
|
93
|
+
(f) => f.schema === table.schema && f.name === table.name,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
if (reversed.length) {
|
|
97
|
+
acc.push(...reversed.map((fk) => buildRelationshipResolver(t, fk, db, true)));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return acc;
|
|
101
|
+
}, []);
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
...table,
|
|
105
|
+
db,
|
|
106
|
+
internalName,
|
|
107
|
+
resolverName: internalName,
|
|
108
|
+
relationships,
|
|
109
|
+
relationshipsReversed,
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const buildProcedureResolver = (sp: StoredProcedure, db: Database) => {
|
|
114
|
+
const internalName = genResolverName(sp.schema, sp.name, "sp", db.fieldNaming, db.name);
|
|
115
|
+
const dottedName = `${sp.schema}.${sp.name}`;
|
|
116
|
+
|
|
117
|
+
const resolverName = !db.fieldNaming
|
|
118
|
+
? internalName
|
|
119
|
+
: genResolverName(sp.schema, sp.name, "sp", db.fieldNaming, db.name);
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
...sp,
|
|
123
|
+
db,
|
|
124
|
+
internalName,
|
|
125
|
+
resolverName,
|
|
126
|
+
dottedName,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const genResolverName = (
|
|
2
|
+
schema: string,
|
|
3
|
+
name: string,
|
|
4
|
+
type: "table" | "view" | "sp",
|
|
5
|
+
fieldNaming: string = "{schema}_{name}",
|
|
6
|
+
dbName: string = "",
|
|
7
|
+
suffix?: string,
|
|
8
|
+
) => {
|
|
9
|
+
const baseName = fieldNaming
|
|
10
|
+
.replace("{database}", dbName)
|
|
11
|
+
.replace("{type}", type)
|
|
12
|
+
.replace("{schema}", schema)
|
|
13
|
+
.replace("{name}", name);
|
|
14
|
+
|
|
15
|
+
if (suffix) return `${baseName}_${suffix}`;
|
|
16
|
+
|
|
17
|
+
return baseName;
|
|
18
|
+
};
|