@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,29 @@
|
|
|
1
|
+
import type { FragmentDefinitionNode, GraphQLObjectType, GraphQLSchema } from "graphql";
|
|
2
|
+
import type { MergedEntities } from "../../configuration/getSchemas/mergeEntities";
|
|
3
|
+
import type { FragmentAnalysis, VariableDefinition } from "../types";
|
|
4
|
+
|
|
5
|
+
import { analyzeSelections } from "./selectionAnalyzer";
|
|
6
|
+
|
|
7
|
+
export const analyzeFragment = (
|
|
8
|
+
fragmentDef: FragmentDefinitionNode,
|
|
9
|
+
entities: MergedEntities,
|
|
10
|
+
gqlSchema: GraphQLSchema,
|
|
11
|
+
generatedVariables: VariableDefinition[],
|
|
12
|
+
): FragmentAnalysis => {
|
|
13
|
+
const typeCondition = gqlSchema.getType(
|
|
14
|
+
fragmentDef.typeCondition.name.value,
|
|
15
|
+
) as GraphQLObjectType;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
name: fragmentDef.name.value,
|
|
19
|
+
typeCondition: fragmentDef.typeCondition.name.value,
|
|
20
|
+
fields: analyzeSelections(
|
|
21
|
+
fragmentDef.selectionSet.selections,
|
|
22
|
+
typeCondition,
|
|
23
|
+
entities,
|
|
24
|
+
gqlSchema,
|
|
25
|
+
[],
|
|
26
|
+
generatedVariables,
|
|
27
|
+
),
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { GraphQLObjectType, GraphQLSchema } from "graphql";
|
|
2
|
+
|
|
3
|
+
import type { OperationDefinitionNode } from "graphql";
|
|
4
|
+
import type { Maybe } from "graphql/jsutils/Maybe";
|
|
5
|
+
import type { MergedEntities } from "../../configuration/getSchemas/mergeEntities";
|
|
6
|
+
import type { OperationAnalysis, VariableDefinition } from "../types";
|
|
7
|
+
|
|
8
|
+
import { analyzeSelections } from "./selectionAnalyzer";
|
|
9
|
+
import { analyzeVariables } from "./variableAnalyzer";
|
|
10
|
+
|
|
11
|
+
export const analyzeOperation = (
|
|
12
|
+
operationDef: OperationDefinitionNode,
|
|
13
|
+
entities: MergedEntities,
|
|
14
|
+
gqlSchema: GraphQLSchema,
|
|
15
|
+
generatedVariables: VariableDefinition[],
|
|
16
|
+
): OperationAnalysis | null => {
|
|
17
|
+
let rootType: Maybe<GraphQLObjectType> | undefined;
|
|
18
|
+
|
|
19
|
+
if (operationDef.operation === "query") {
|
|
20
|
+
rootType = gqlSchema.getQueryType();
|
|
21
|
+
} else if (operationDef.operation === "mutation") {
|
|
22
|
+
rootType = gqlSchema.getMutationType();
|
|
23
|
+
} else if (operationDef.operation === "subscription") {
|
|
24
|
+
rootType = gqlSchema.getSubscriptionType();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!rootType) return null;
|
|
28
|
+
|
|
29
|
+
const { name, operation, variableDefinitions, selectionSet } = operationDef;
|
|
30
|
+
|
|
31
|
+
const declaredVariables = analyzeVariables(variableDefinitions);
|
|
32
|
+
|
|
33
|
+
const fields = analyzeSelections(
|
|
34
|
+
selectionSet.selections,
|
|
35
|
+
rootType,
|
|
36
|
+
entities,
|
|
37
|
+
gqlSchema,
|
|
38
|
+
declaredVariables,
|
|
39
|
+
generatedVariables,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const allVariables = [...declaredVariables, ...generatedVariables];
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
name: name ? name.value : null,
|
|
46
|
+
operation,
|
|
47
|
+
variables: allVariables,
|
|
48
|
+
fields,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { GraphQLObjectType, GraphQLSchema } from "graphql";
|
|
2
|
+
|
|
3
|
+
import type { FieldNode, SelectionNode } from "graphql";
|
|
4
|
+
import type { MergedEntities } from "../../configuration/getSchemas/mergeEntities";
|
|
5
|
+
import type { SelectionAnalysis, VariableDefinition } from "../types";
|
|
6
|
+
|
|
7
|
+
import { analyzeDirectives } from "../directiveUtils";
|
|
8
|
+
import { getFieldType, unwrapType } from "../typeUtils";
|
|
9
|
+
import { extractArgumentValue } from "../valueExtractors";
|
|
10
|
+
|
|
11
|
+
export const analyzeSelections = (
|
|
12
|
+
selections: readonly SelectionNode[],
|
|
13
|
+
parentType: GraphQLObjectType,
|
|
14
|
+
entities: MergedEntities,
|
|
15
|
+
gqlSchema: GraphQLSchema,
|
|
16
|
+
declaredVariables: VariableDefinition[],
|
|
17
|
+
generatedVariables: VariableDefinition[],
|
|
18
|
+
): SelectionAnalysis[] =>
|
|
19
|
+
selections
|
|
20
|
+
.map((selection) => {
|
|
21
|
+
if (selection.kind === "Field") {
|
|
22
|
+
const field = selection as FieldNode;
|
|
23
|
+
|
|
24
|
+
const isGqlQuery = entities.queriesMap[field.name.value] !== undefined;
|
|
25
|
+
|
|
26
|
+
let args = field.arguments
|
|
27
|
+
? Object.fromEntries(
|
|
28
|
+
field.arguments.map((arg) => [
|
|
29
|
+
arg.name.value,
|
|
30
|
+
extractArgumentValue(arg.value, isGqlQuery ? generatedVariables : undefined),
|
|
31
|
+
]),
|
|
32
|
+
)
|
|
33
|
+
: undefined;
|
|
34
|
+
|
|
35
|
+
const fieldName = field.name.value;
|
|
36
|
+
if (fieldName === "__typename") {
|
|
37
|
+
return {
|
|
38
|
+
name: fieldName,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const fieldType = getFieldType(parentType, fieldName);
|
|
42
|
+
let isArray = false;
|
|
43
|
+
let fieldObjType: GraphQLObjectType | null = null;
|
|
44
|
+
|
|
45
|
+
if (fieldType) {
|
|
46
|
+
const unwrapped = unwrapType(fieldType);
|
|
47
|
+
isArray = unwrapped.isArray;
|
|
48
|
+
if (unwrapped.type instanceof GraphQLObjectType) {
|
|
49
|
+
fieldObjType = unwrapped.type;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const hasDirectives = field.directives && field.directives.length > 0;
|
|
54
|
+
|
|
55
|
+
const directives = analyzeDirectives(field.directives || [], generatedVariables);
|
|
56
|
+
|
|
57
|
+
const isRequired =
|
|
58
|
+
directives.filter(
|
|
59
|
+
(dir) => dir.name === "include" || dir.name === "skip" || dir.name === "when",
|
|
60
|
+
).length === 0;
|
|
61
|
+
|
|
62
|
+
if (isArray && entities.queriesMap[fieldName]?.rolePermission?.filter) {
|
|
63
|
+
if (!args) {
|
|
64
|
+
args = {
|
|
65
|
+
where: entities.queriesMap[fieldName].rolePermission?.filter,
|
|
66
|
+
};
|
|
67
|
+
} else {
|
|
68
|
+
args = {
|
|
69
|
+
...args,
|
|
70
|
+
where: {
|
|
71
|
+
...(args.where || {}),
|
|
72
|
+
...entities.queriesMap[fieldName].rolePermission?.filter,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const selectionAnalysis: SelectionAnalysis = {
|
|
79
|
+
name: fieldName,
|
|
80
|
+
...(field.alias && { alias: field.alias.value }),
|
|
81
|
+
...(args && Object.keys(args).length && { arguments: args }),
|
|
82
|
+
...(isArray && { isArray }),
|
|
83
|
+
...(hasDirectives && { directives }),
|
|
84
|
+
...(field.selectionSet &&
|
|
85
|
+
fieldObjType && {
|
|
86
|
+
selections: analyzeSelections(
|
|
87
|
+
field.selectionSet.selections,
|
|
88
|
+
fieldObjType,
|
|
89
|
+
entities,
|
|
90
|
+
gqlSchema,
|
|
91
|
+
declaredVariables,
|
|
92
|
+
generatedVariables,
|
|
93
|
+
),
|
|
94
|
+
}),
|
|
95
|
+
...(isRequired && { isRequired }),
|
|
96
|
+
};
|
|
97
|
+
return selectionAnalysis;
|
|
98
|
+
} else if (selection.kind === "FragmentSpread") {
|
|
99
|
+
return {
|
|
100
|
+
name: `...${selection.name.value}`,
|
|
101
|
+
...(selection.directives &&
|
|
102
|
+
selection.directives.length > 0 && {
|
|
103
|
+
directives: analyzeDirectives(selection.directives, generatedVariables),
|
|
104
|
+
}),
|
|
105
|
+
};
|
|
106
|
+
} else if (selection.kind === "InlineFragment") {
|
|
107
|
+
const typeCondition =
|
|
108
|
+
selection.typeCondition &&
|
|
109
|
+
(gqlSchema.getType(selection.typeCondition.name.value) as GraphQLObjectType);
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
name: `... on ${selection.typeCondition?.name.value}`,
|
|
113
|
+
...(selection.directives &&
|
|
114
|
+
selection.directives.length > 0 && {
|
|
115
|
+
directives: analyzeDirectives(selection.directives, generatedVariables),
|
|
116
|
+
}),
|
|
117
|
+
selections:
|
|
118
|
+
selection.selectionSet && typeCondition
|
|
119
|
+
? analyzeSelections(
|
|
120
|
+
selection.selectionSet.selections,
|
|
121
|
+
typeCondition,
|
|
122
|
+
entities,
|
|
123
|
+
gqlSchema,
|
|
124
|
+
declaredVariables,
|
|
125
|
+
generatedVariables,
|
|
126
|
+
)
|
|
127
|
+
: undefined,
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
return {
|
|
131
|
+
name: "UnknownSelection",
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
.filter((sel) => sel.name !== "__typename");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { VariableDefinitionNode } from "graphql";
|
|
2
|
+
import type { VariableDefinition } from "../types";
|
|
3
|
+
|
|
4
|
+
import { processType } from "../typeUtils";
|
|
5
|
+
import { extractArgumentValue } from "../valueExtractors";
|
|
6
|
+
|
|
7
|
+
export const analyzeVariables = (
|
|
8
|
+
variableDefinitions: readonly VariableDefinitionNode[] = [],
|
|
9
|
+
): VariableDefinition[] =>
|
|
10
|
+
variableDefinitions.map((varDef) => ({
|
|
11
|
+
name: varDef.variable.name.value,
|
|
12
|
+
required: varDef.type.kind === "NonNullType",
|
|
13
|
+
type: processType(varDef.type),
|
|
14
|
+
...(varDef.defaultValue && {
|
|
15
|
+
defaultValue: extractArgumentValue(varDef.defaultValue),
|
|
16
|
+
}),
|
|
17
|
+
}));
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { GraphQLError, Kind } from "graphql";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ASTNode,
|
|
5
|
+
ASTVisitor,
|
|
6
|
+
DocumentNode,
|
|
7
|
+
FragmentDefinitionNode,
|
|
8
|
+
ValidationContext,
|
|
9
|
+
} from "graphql";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Compute the depth of a selection set, resolving fragment spreads.
|
|
13
|
+
* Introspection fields (__schema, __type, __typename) are excluded.
|
|
14
|
+
*/
|
|
15
|
+
function computeDepth(
|
|
16
|
+
node: { selectionSet?: { selections: readonly ASTNode[] } },
|
|
17
|
+
fragments: Map<string, FragmentDefinitionNode>,
|
|
18
|
+
depthSoFar: number,
|
|
19
|
+
maxDepth: number,
|
|
20
|
+
visited: Set<string>,
|
|
21
|
+
): number {
|
|
22
|
+
if (!node.selectionSet) return depthSoFar;
|
|
23
|
+
|
|
24
|
+
let max = depthSoFar;
|
|
25
|
+
|
|
26
|
+
for (const selection of node.selectionSet.selections) {
|
|
27
|
+
switch (selection.kind) {
|
|
28
|
+
case Kind.FIELD: {
|
|
29
|
+
// Skip introspection meta-fields
|
|
30
|
+
if (selection.name.value.startsWith("__")) continue;
|
|
31
|
+
|
|
32
|
+
const fieldDepth = computeDepth(selection, fragments, depthSoFar + 1, maxDepth, visited);
|
|
33
|
+
|
|
34
|
+
if (fieldDepth > max) max = fieldDepth;
|
|
35
|
+
|
|
36
|
+
// Early exit if already over the limit
|
|
37
|
+
if (max > maxDepth) return max;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
case Kind.FRAGMENT_SPREAD: {
|
|
42
|
+
const name = selection.name.value;
|
|
43
|
+
|
|
44
|
+
// Guard against circular fragments
|
|
45
|
+
if (visited.has(name)) continue;
|
|
46
|
+
visited.add(name);
|
|
47
|
+
|
|
48
|
+
const fragment = fragments.get(name);
|
|
49
|
+
if (!fragment) continue;
|
|
50
|
+
|
|
51
|
+
const fragmentDepth = computeDepth(fragment, fragments, depthSoFar, maxDepth, visited);
|
|
52
|
+
|
|
53
|
+
if (fragmentDepth > max) max = fragmentDepth;
|
|
54
|
+
if (max > maxDepth) return max;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case Kind.INLINE_FRAGMENT: {
|
|
59
|
+
const inlineDepth = computeDepth(selection, fragments, depthSoFar, maxDepth, visited);
|
|
60
|
+
|
|
61
|
+
if (inlineDepth > max) max = inlineDepth;
|
|
62
|
+
if (max > maxDepth) return max;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return max;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Collect all fragment definitions from a document.
|
|
73
|
+
*/
|
|
74
|
+
function collectFragments(document: DocumentNode): Map<string, FragmentDefinitionNode> {
|
|
75
|
+
const fragments = new Map<string, FragmentDefinitionNode>();
|
|
76
|
+
|
|
77
|
+
for (const def of document.definitions) {
|
|
78
|
+
if (def.kind === Kind.FRAGMENT_DEFINITION) {
|
|
79
|
+
fragments.set(def.name.value, def);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return fragments;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* GraphQL validation rule that rejects queries exceeding a maximum nesting depth.
|
|
88
|
+
*
|
|
89
|
+
* @param maxDepth - Maximum allowed depth (1 = only top-level fields)
|
|
90
|
+
* @returns A GraphQL ValidationRule
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { validate, parse } from "graphql";
|
|
95
|
+
*
|
|
96
|
+
* const errors = validate(schema, parse(query), [depthLimitRule(10)]);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export const depthLimitRule =
|
|
100
|
+
(maxDepth: number) =>
|
|
101
|
+
(context: ValidationContext): ASTVisitor => {
|
|
102
|
+
return {
|
|
103
|
+
Document(node) {
|
|
104
|
+
const fragments = collectFragments(node);
|
|
105
|
+
|
|
106
|
+
for (const def of node.definitions) {
|
|
107
|
+
if (def.kind !== Kind.OPERATION_DEFINITION) continue;
|
|
108
|
+
|
|
109
|
+
const depth = computeDepth(def, fragments, 0, maxDepth, new Set<string>());
|
|
110
|
+
|
|
111
|
+
if (depth > maxDepth) {
|
|
112
|
+
const operationName = def.name?.value ?? "anonymous";
|
|
113
|
+
|
|
114
|
+
context.reportError(
|
|
115
|
+
new GraphQLError(
|
|
116
|
+
`Query depth of ${depth} exceeds the maximum allowed depth of ${maxDepth} (operation: "${operationName}")`,
|
|
117
|
+
{ nodes: [def] },
|
|
118
|
+
),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { DirectiveNode } from "graphql";
|
|
2
|
+
import type { DirectiveAnalysis, VariableDefinition } from "./types";
|
|
3
|
+
|
|
4
|
+
import { extractArgumentValue } from "./valueExtractors";
|
|
5
|
+
|
|
6
|
+
// Directive argument specification — gates which args are parameterized vs enum-validated
|
|
7
|
+
interface DirectiveArgSpec {
|
|
8
|
+
type: "Int" | "Float" | "String" | "Boolean";
|
|
9
|
+
kind: "param" | "enum";
|
|
10
|
+
values?: string[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const DIRECTIVE_ARG_SPEC: Record<string, Record<string, DirectiveArgSpec>> = {
|
|
14
|
+
truncate: { length: { type: "Int", kind: "param" } },
|
|
15
|
+
default: { value: { type: "String", kind: "param" } },
|
|
16
|
+
substring: {
|
|
17
|
+
start: { type: "Int", kind: "param" },
|
|
18
|
+
length: { type: "Int", kind: "param" },
|
|
19
|
+
},
|
|
20
|
+
replace: {
|
|
21
|
+
find: { type: "String", kind: "param" },
|
|
22
|
+
replaceWith: { type: "String", kind: "param" },
|
|
23
|
+
},
|
|
24
|
+
concat: {
|
|
25
|
+
with: { type: "String", kind: "param" },
|
|
26
|
+
position: { type: "String", kind: "enum", values: ["before", "after"] },
|
|
27
|
+
},
|
|
28
|
+
pad: {
|
|
29
|
+
length: { type: "Int", kind: "param" },
|
|
30
|
+
char: { type: "String", kind: "param" },
|
|
31
|
+
side: { type: "String", kind: "enum", values: ["left", "right"] },
|
|
32
|
+
},
|
|
33
|
+
dateFormat: { format: { type: "String", kind: "param" } },
|
|
34
|
+
round: { decimals: { type: "Int", kind: "param" } },
|
|
35
|
+
multiply: { by: { type: "Float", kind: "param" } },
|
|
36
|
+
divide: { by: { type: "Float", kind: "param" } },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Control-flow directives — exempt from spec validation, keep raw extraction
|
|
40
|
+
const CONTROL_FLOW_DIRECTIVES = new Set(["skip", "include", "when"]);
|
|
41
|
+
|
|
42
|
+
export const analyzeDirectives = (
|
|
43
|
+
directives: readonly DirectiveNode[],
|
|
44
|
+
generatedVariables?: VariableDefinition[],
|
|
45
|
+
): DirectiveAnalysis[] =>
|
|
46
|
+
directives.map((directive) => {
|
|
47
|
+
const name = directive.name.value;
|
|
48
|
+
|
|
49
|
+
// Control-flow directives: extract raw (no parameterization, no validation)
|
|
50
|
+
if (CONTROL_FLOW_DIRECTIVES.has(name)) {
|
|
51
|
+
return {
|
|
52
|
+
name,
|
|
53
|
+
...(directive.arguments &&
|
|
54
|
+
directive.arguments.length > 0 && {
|
|
55
|
+
arguments: Object.fromEntries(
|
|
56
|
+
directive.arguments.map((arg) => [arg.name.value, extractArgumentValue(arg.value)]),
|
|
57
|
+
),
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Spec'd transform directives: validate arg types and parameterize param-kind args
|
|
63
|
+
const spec = DIRECTIVE_ARG_SPEC[name];
|
|
64
|
+
if (spec && directive.arguments) {
|
|
65
|
+
const args: Record<string, unknown> = {};
|
|
66
|
+
for (const arg of directive.arguments) {
|
|
67
|
+
const argName = arg.name.value;
|
|
68
|
+
const argSpec = spec[argName];
|
|
69
|
+
if (!argSpec) {
|
|
70
|
+
throw new Error(`Unknown argument "${argName}" for directive @${name}`);
|
|
71
|
+
}
|
|
72
|
+
if (argSpec.kind === "enum") {
|
|
73
|
+
const value = extractArgumentValue(arg.value);
|
|
74
|
+
if (argSpec.values && !argSpec.values.includes(value as string)) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`Invalid value "${value}" for @${name}(${argName}:). Expected one of: ${argSpec.values.join(", ")}`,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
args[argName] = value;
|
|
80
|
+
} else {
|
|
81
|
+
// param kind: parameterize through generatedVariables
|
|
82
|
+
args[argName] = extractArgumentValue(arg.value, generatedVariables);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return { name, arguments: args };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// No-arg transform directives (uppercase, trim, ceil, floor, abs, lowercase, ltrim, rtrim)
|
|
89
|
+
// or unknown directives: extract raw with no validation
|
|
90
|
+
if (directive.arguments && directive.arguments.length > 0) {
|
|
91
|
+
return {
|
|
92
|
+
name,
|
|
93
|
+
arguments: Object.fromEntries(
|
|
94
|
+
directive.arguments.map((arg) => [arg.name.value, extractArgumentValue(arg.value)]),
|
|
95
|
+
),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return { name };
|
|
99
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { parse } from "graphql";
|
|
2
|
+
|
|
3
|
+
import type { DocumentNode, GraphQLSchema } from "graphql";
|
|
4
|
+
import type { MergedEntities } from "../configuration/getSchemas/mergeEntities";
|
|
5
|
+
import type { AnalysisResult, SelectionAnalysis, VariableDefinition } from "./types";
|
|
6
|
+
|
|
7
|
+
import { analyzeFragment } from "./analyzers/fragmentAnalyzer";
|
|
8
|
+
import { analyzeOperation } from "./analyzers/operationAnalyzer";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Tag each top-level field with its source from the resolver registry
|
|
12
|
+
*/
|
|
13
|
+
const tagFieldsWithSource = (
|
|
14
|
+
fields: SelectionAnalysis[],
|
|
15
|
+
entities: MergedEntities,
|
|
16
|
+
): SelectionAnalysis[] => {
|
|
17
|
+
return fields.map((field) => ({
|
|
18
|
+
...field,
|
|
19
|
+
source: entities.getResolverSource(field.name),
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Function to analyze a GraphQL query
|
|
24
|
+
export function analyzeQuery(
|
|
25
|
+
query: string,
|
|
26
|
+
entities: MergedEntities,
|
|
27
|
+
gqlSchema: GraphQLSchema,
|
|
28
|
+
): AnalysisResult {
|
|
29
|
+
let ast: DocumentNode | null;
|
|
30
|
+
|
|
31
|
+
const generatedVariables: VariableDefinition[] = [];
|
|
32
|
+
|
|
33
|
+
const result: AnalysisResult & { errors?: { message: string }[] } = {
|
|
34
|
+
operations: [],
|
|
35
|
+
fragments: [],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
ast = parse(query);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
result.errors = [
|
|
42
|
+
{
|
|
43
|
+
message: `Error parsing query: ${error instanceof Error ? error.message : String(error)}`,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ast.definitions.forEach((def) => {
|
|
50
|
+
if (def.kind === "OperationDefinition") {
|
|
51
|
+
const operationAnalysis = analyzeOperation(def, entities, gqlSchema, generatedVariables);
|
|
52
|
+
|
|
53
|
+
if (operationAnalysis) {
|
|
54
|
+
// Tag top-level fields with their source
|
|
55
|
+
operationAnalysis.fields = tagFieldsWithSource(operationAnalysis.fields, entities);
|
|
56
|
+
result.operations.push(operationAnalysis);
|
|
57
|
+
}
|
|
58
|
+
} else if (def.kind === "FragmentDefinition") {
|
|
59
|
+
const fragmentAnalysis = analyzeFragment(def, entities, gqlSchema, generatedVariables);
|
|
60
|
+
|
|
61
|
+
result.fragments.push(fragmentAnalysis);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
}
|