@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,81 @@
|
|
|
1
|
+
import type { CacheStore } from "./types";
|
|
2
|
+
|
|
3
|
+
import { getCacheRedisClient } from "./redisClient";
|
|
4
|
+
import { logger } from "../../logging";
|
|
5
|
+
|
|
6
|
+
export class RedisCacheStore implements CacheStore {
|
|
7
|
+
private prefix: string;
|
|
8
|
+
private trackingKey: string;
|
|
9
|
+
private ttlSeconds: number | undefined;
|
|
10
|
+
private client: ReturnType<typeof getCacheRedisClient>;
|
|
11
|
+
private log = logger("redis-cache");
|
|
12
|
+
|
|
13
|
+
constructor(operationName: string, ttlMs?: number) {
|
|
14
|
+
this.prefix = `cache:${operationName}:`;
|
|
15
|
+
this.trackingKey = `${this.prefix}__keys`;
|
|
16
|
+
this.ttlSeconds = ttlMs ? Math.ceil(ttlMs / 1000) : undefined;
|
|
17
|
+
this.client = getCacheRedisClient();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private fullKey(key: string): string {
|
|
21
|
+
const hash = Bun.hash(key).toString(36);
|
|
22
|
+
return `${this.prefix}${hash}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async get(key: string): Promise<unknown | undefined> {
|
|
26
|
+
try {
|
|
27
|
+
const raw = await this.client.get(this.fullKey(key));
|
|
28
|
+
if (raw === null) return undefined;
|
|
29
|
+
return JSON.parse(raw);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
this.log.error({ err: error, operation: "get" }, "cache get failed");
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async set(key: string, value: unknown): Promise<void> {
|
|
37
|
+
try {
|
|
38
|
+
const redisKey = this.fullKey(key);
|
|
39
|
+
await this.client.set(redisKey, JSON.stringify(value));
|
|
40
|
+
if (this.ttlSeconds) {
|
|
41
|
+
await this.client.expire(redisKey, this.ttlSeconds);
|
|
42
|
+
}
|
|
43
|
+
await this.client.sadd(this.trackingKey, key);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this.log.error({ err: error, operation: "set" }, "cache set failed");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async delete(key: string): Promise<void> {
|
|
50
|
+
try {
|
|
51
|
+
await this.client.del(this.fullKey(key));
|
|
52
|
+
await this.client.srem(this.trackingKey, key);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
this.log.error({ err: error, operation: "delete" }, "cache delete failed");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async clear(): Promise<void> {
|
|
59
|
+
try {
|
|
60
|
+
const originalKeys = await this.client.smembers(this.trackingKey);
|
|
61
|
+
if (originalKeys.length > 0) {
|
|
62
|
+
const redisKeys = originalKeys.map((k: string) => this.fullKey(k));
|
|
63
|
+
for (const redisKey of redisKeys) {
|
|
64
|
+
await this.client.del(redisKey);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
await this.client.del(this.trackingKey);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
this.log.error({ err: error, operation: "clear" }, "cache clear failed");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async keys(): Promise<string[]> {
|
|
74
|
+
try {
|
|
75
|
+
return await this.client.smembers(this.trackingKey);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
this.log.error({ err: error, operation: "keys" }, "cache keys failed");
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RedisClient as ValkeyClient } from "bun";
|
|
2
|
+
|
|
3
|
+
import { env } from "../env";
|
|
4
|
+
|
|
5
|
+
let client: InstanceType<typeof ValkeyClient> | null = null;
|
|
6
|
+
|
|
7
|
+
export const getCacheRedisClient = (): InstanceType<typeof ValkeyClient> => {
|
|
8
|
+
if (!client) {
|
|
9
|
+
client = new ValkeyClient(env.cache.redisUrl);
|
|
10
|
+
}
|
|
11
|
+
return client;
|
|
12
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CacheStore } from "./types";
|
|
2
|
+
|
|
3
|
+
const cacheRegistry = new Map<string, CacheStore>();
|
|
4
|
+
|
|
5
|
+
export const registerCache = (name: string, cache: CacheStore) => {
|
|
6
|
+
cacheRegistry.set(name, cache);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const getCache = (name: string): CacheStore | undefined => {
|
|
10
|
+
return cacheRegistry.get(name);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const InvalidationHelper = {
|
|
14
|
+
invalidate: async (
|
|
15
|
+
operationName: string,
|
|
16
|
+
pattern?: Record<string, unknown>,
|
|
17
|
+
): Promise<boolean> => {
|
|
18
|
+
const cache = cacheRegistry.get(operationName);
|
|
19
|
+
if (!cache) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!pattern || Object.keys(pattern).length === 0) {
|
|
24
|
+
await cache.clear();
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const allKeys = await cache.keys();
|
|
29
|
+
for (const key of allKeys) {
|
|
30
|
+
try {
|
|
31
|
+
const parsedKey = JSON.parse(key);
|
|
32
|
+
const cachedVariables = parsedKey.variables;
|
|
33
|
+
|
|
34
|
+
let match = true;
|
|
35
|
+
for (const [k, v] of Object.entries(pattern)) {
|
|
36
|
+
if (cachedVariables[k] !== v) {
|
|
37
|
+
match = false;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (match) {
|
|
43
|
+
await cache.delete(key);
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
// Ignore parse errors
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StartCronJobsReturn } from "../cron";
|
|
2
|
+
import type { GqlQueryFn } from "../types/common";
|
|
3
|
+
import type { CronJob } from "../types/configuration";
|
|
4
|
+
|
|
5
|
+
import { startCronJobs } from "../cron";
|
|
6
|
+
|
|
7
|
+
let cronJobs: StartCronJobsReturn | null = null;
|
|
8
|
+
|
|
9
|
+
export const instantiateCronJobs = async (jobs: CronJob[], gqlQuery: GqlQueryFn<true>) => {
|
|
10
|
+
if (!cronJobs) {
|
|
11
|
+
cronJobs = await startCronJobs(jobs, gqlQuery);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return cronJobs;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getCronJobs = () => cronJobs;
|
|
18
|
+
|
|
19
|
+
export const setCronJobs = (jobs: StartCronJobsReturn | null) => {
|
|
20
|
+
cronJobs = jobs;
|
|
21
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { SQL } from "bun";
|
|
2
|
+
|
|
3
|
+
import type { ConnectionPool } from "mssql";
|
|
4
|
+
import type { Database } from "../types/configuration.ts";
|
|
5
|
+
|
|
6
|
+
import { getPool as getPoolMSSQL } from "../databases/engines/mssql/connection.ts";
|
|
7
|
+
import { getPool as getPoolMySQL } from "../databases/engines/mysql/connection.ts";
|
|
8
|
+
import { getPool as getPoolPostgreSQL } from "../databases/engines/postgresql/connection.ts";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Type for database connections mapping
|
|
12
|
+
* Keys are database names from configuration, values are connection pools
|
|
13
|
+
*/
|
|
14
|
+
export type DatabasesConnections = Record<string, SQL | ConnectionPool>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Type for custom repository mapping
|
|
18
|
+
* Keys are database names from configuration, values are the result of repository factory
|
|
19
|
+
*/
|
|
20
|
+
export type RepositoryMap<TRepository = unknown> = Record<string, TRepository>;
|
|
21
|
+
|
|
22
|
+
export const databasesConnections: DatabasesConnections = {};
|
|
23
|
+
export const repositoryMap: RepositoryMap = {};
|
|
24
|
+
|
|
25
|
+
export const instantiateDatabasesConnections = async (databases: Database[]) => {
|
|
26
|
+
for await (const db of databases) {
|
|
27
|
+
let connection: SQL | ConnectionPool | undefined;
|
|
28
|
+
|
|
29
|
+
if (db.type === "pg") {
|
|
30
|
+
connection = await getPoolPostgreSQL(db);
|
|
31
|
+
databasesConnections[db.name] = connection;
|
|
32
|
+
} else if (db.type === "mssql") {
|
|
33
|
+
connection = await getPoolMSSQL(db);
|
|
34
|
+
databasesConnections[db.name] = connection;
|
|
35
|
+
} else if (db.type === "mysql") {
|
|
36
|
+
connection = await getPoolMySQL(db);
|
|
37
|
+
databasesConnections[db.name] = connection;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (connection && db.onConnect) {
|
|
41
|
+
await db.onConnect(connection, db);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Initialize custom repository if factory is provided
|
|
45
|
+
if (connection && db.repository) {
|
|
46
|
+
repositoryMap[db.name] = db.repository(connection);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return { databasesConnections, repositoryMap };
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Close every open database connection and clear the singleton maps. Bun's `SQL`
|
|
55
|
+
* and mssql's `ConnectionPool` both expose `close()`. Used by
|
|
56
|
+
* `createGraphQLEngine`'s `close()` so an in-process consumer can release
|
|
57
|
+
* connections without a running server.
|
|
58
|
+
*/
|
|
59
|
+
export const disconnectDatabases = async () => {
|
|
60
|
+
await Promise.all(Object.values(databasesConnections).map((connection) => connection.close()));
|
|
61
|
+
|
|
62
|
+
for (const name of Object.keys(databasesConnections)) {
|
|
63
|
+
delete databasesConnections[name];
|
|
64
|
+
}
|
|
65
|
+
for (const name of Object.keys(repositoryMap)) {
|
|
66
|
+
delete repositoryMap[name];
|
|
67
|
+
}
|
|
68
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { KafkaPublisher } from "../queues/kafka";
|
|
2
|
+
import type { RabbitMQPublisher } from "../queues/rabbitmq";
|
|
3
|
+
import type { QueueConfig } from "../types/zod/queue";
|
|
4
|
+
|
|
5
|
+
import { startKafkaConnections } from "../queues/kafka";
|
|
6
|
+
import { startRabbitMQConnections } from "../queues/rabbitmq";
|
|
7
|
+
import { logger } from "../logging";
|
|
8
|
+
|
|
9
|
+
export type QueueConnectionStatus = { type: "rabbitmq" | "kafka"; connected: boolean };
|
|
10
|
+
|
|
11
|
+
export type QueueManager = {
|
|
12
|
+
publisherMap: () => Record<string, RabbitMQPublisher | KafkaPublisher>;
|
|
13
|
+
sendMessage: (
|
|
14
|
+
publisherName: string,
|
|
15
|
+
message: string | object,
|
|
16
|
+
key?: string,
|
|
17
|
+
) => Promise<boolean> | boolean;
|
|
18
|
+
connections: () => QueueConnectionStatus[];
|
|
19
|
+
cleanup?: () => Promise<void>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export let queueManager: QueueManager | undefined;
|
|
23
|
+
|
|
24
|
+
export const setQueueManager = (manager: QueueManager | undefined) => {
|
|
25
|
+
queueManager = manager;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const instantiateQueues = async (queues: QueueConfig[]) => {
|
|
29
|
+
// Separate RabbitMQ and Kafka queues
|
|
30
|
+
const rabbitMQQueues = queues.filter((queue) => queue.type === "rabbitmq");
|
|
31
|
+
const kafkaQueues = queues.filter((queue) => queue.type === "kafka");
|
|
32
|
+
|
|
33
|
+
const managers: QueueManager[] = [];
|
|
34
|
+
|
|
35
|
+
// Initialize RabbitMQ connections
|
|
36
|
+
if (rabbitMQQueues.length > 0) {
|
|
37
|
+
const rabbitMQManager = await startRabbitMQConnections(rabbitMQQueues);
|
|
38
|
+
|
|
39
|
+
managers.push({
|
|
40
|
+
publisherMap: rabbitMQManager.publisherMap,
|
|
41
|
+
sendMessage: rabbitMQManager.sendMessage,
|
|
42
|
+
connections: () =>
|
|
43
|
+
rabbitMQManager.managers.map((manager) => ({
|
|
44
|
+
type: "rabbitmq" as const,
|
|
45
|
+
connected: manager.isConnected(),
|
|
46
|
+
})),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Initialize Kafka connections
|
|
51
|
+
if (kafkaQueues.length > 0) {
|
|
52
|
+
const kafkaManager = await startKafkaConnections(kafkaQueues);
|
|
53
|
+
|
|
54
|
+
managers.push({
|
|
55
|
+
publisherMap: kafkaManager.publisherMap,
|
|
56
|
+
sendMessage: kafkaManager.sendMessage,
|
|
57
|
+
connections: () =>
|
|
58
|
+
kafkaManager.managers.map((manager) => ({
|
|
59
|
+
type: "kafka" as const,
|
|
60
|
+
connected: manager.isConnected(),
|
|
61
|
+
})),
|
|
62
|
+
cleanup: kafkaManager.cleanup,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Merge all publisher maps and create unified send function
|
|
67
|
+
const combinedPublisherMap = () =>
|
|
68
|
+
managers.reduce((acc, manager) => ({ ...acc, ...manager.publisherMap() }), {});
|
|
69
|
+
|
|
70
|
+
const combinedSendMessage = async (
|
|
71
|
+
publisherName: string,
|
|
72
|
+
message: string | object,
|
|
73
|
+
key?: string,
|
|
74
|
+
) => {
|
|
75
|
+
// Find which manager has this publisher
|
|
76
|
+
for (const manager of managers) {
|
|
77
|
+
if (manager.publisherMap()[publisherName]) {
|
|
78
|
+
return await manager.sendMessage(publisherName, message, key);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
logger("queues").error(
|
|
83
|
+
{ publisher: publisherName },
|
|
84
|
+
"publisher not found in any queue manager",
|
|
85
|
+
);
|
|
86
|
+
return false;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const combinedCleanup = async () => {
|
|
90
|
+
await Promise.all(
|
|
91
|
+
managers.filter((manager) => manager.cleanup).map((manager) => manager.cleanup!()),
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
queueManager = {
|
|
96
|
+
publisherMap: combinedPublisherMap,
|
|
97
|
+
sendMessage: combinedSendMessage,
|
|
98
|
+
connections: () => managers.flatMap((manager) => manager.connections()),
|
|
99
|
+
cleanup: combinedCleanup,
|
|
100
|
+
};
|
|
101
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export type {
|
|
3
|
+
SubscriptionContext,
|
|
4
|
+
SubscriptionResult,
|
|
5
|
+
SubscriptionStrategy,
|
|
6
|
+
SubscriptionStrategyRegistry,
|
|
7
|
+
QueryEventEmitter,
|
|
8
|
+
DatabasePoller,
|
|
9
|
+
} from "./types";
|
|
10
|
+
|
|
11
|
+
// Strategy registry
|
|
12
|
+
export {
|
|
13
|
+
createSubscriptionStrategyRegistry,
|
|
14
|
+
getStrategyForSource,
|
|
15
|
+
createDatabaseSubscriptionStrategy,
|
|
16
|
+
createQueueSubscriptionStrategy,
|
|
17
|
+
} from "./strategies";
|
|
18
|
+
|
|
19
|
+
// Polling utilities
|
|
20
|
+
export { createDatabasePoller, type DatabasePollerConfig } from "./utils/polling";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { SubscriptionContext, SubscriptionResult, SubscriptionStrategy } from "../types";
|
|
2
|
+
import { EntitySource } from "../../types/resolver";
|
|
3
|
+
import { createDatabasePoller } from "../utils/polling";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Database subscription strategy - polls database for changes using hash comparison
|
|
7
|
+
*
|
|
8
|
+
* This strategy:
|
|
9
|
+
* 1. Manages connection registration with the event emitter
|
|
10
|
+
* 2. Creates a poller that executes the query periodically
|
|
11
|
+
* 3. Uses hash comparison to detect data changes
|
|
12
|
+
* 4. Only broadcasts updates when data has actually changed
|
|
13
|
+
*/
|
|
14
|
+
export const createDatabaseSubscriptionStrategy = (): SubscriptionStrategy => ({
|
|
15
|
+
source: EntitySource.TABLE,
|
|
16
|
+
|
|
17
|
+
getSubscriptionKey(context) {
|
|
18
|
+
const { analysis } = context;
|
|
19
|
+
const operation = analysis.operations[0];
|
|
20
|
+
// Use operation name as the base key (existing behavior)
|
|
21
|
+
return operation.name ?? operation.fields[0]?.name ?? "unknown";
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
async subscribe(context: SubscriptionContext): Promise<SubscriptionResult> {
|
|
25
|
+
const {
|
|
26
|
+
ws,
|
|
27
|
+
subscriptionId,
|
|
28
|
+
analysis,
|
|
29
|
+
variableDefinitions,
|
|
30
|
+
variables,
|
|
31
|
+
schemaEntity,
|
|
32
|
+
eventEmitter,
|
|
33
|
+
} = context;
|
|
34
|
+
|
|
35
|
+
const subscriptionKey = this.getSubscriptionKey(context);
|
|
36
|
+
|
|
37
|
+
// Check if connection already exists - join existing subscription
|
|
38
|
+
if (eventEmitter.hasConnection(subscriptionKey)) {
|
|
39
|
+
eventEmitter.sendDataByQueryNameToSingleClient(subscriptionKey, ws, subscriptionId);
|
|
40
|
+
eventEmitter.addConnection(subscriptionKey, subscriptionId, ws);
|
|
41
|
+
return { alreadyExists: true };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Register new connection
|
|
45
|
+
eventEmitter.addConnection(subscriptionKey, subscriptionId, ws);
|
|
46
|
+
|
|
47
|
+
// Create and start the poller
|
|
48
|
+
const poller = await createDatabasePoller({
|
|
49
|
+
analysis,
|
|
50
|
+
variableDefinitions,
|
|
51
|
+
variables,
|
|
52
|
+
schemaEntity,
|
|
53
|
+
subscriptionKey,
|
|
54
|
+
eventEmitter,
|
|
55
|
+
pollIntervalMs: 1000,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Store poll reference for cleanup by event emitter
|
|
59
|
+
eventEmitter.setPoll(subscriptionKey, poller);
|
|
60
|
+
|
|
61
|
+
// Start polling
|
|
62
|
+
poller.start();
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
cleanup: () => poller.stop(),
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SubscriptionStrategy, SubscriptionStrategyRegistry } from "../types";
|
|
2
|
+
import { EntitySource } from "../../types/resolver";
|
|
3
|
+
import { createDatabaseSubscriptionStrategy } from "./database";
|
|
4
|
+
import { createQueueSubscriptionStrategy } from "./queue";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Create and populate the subscription strategy registry
|
|
8
|
+
*/
|
|
9
|
+
export const createSubscriptionStrategyRegistry = (): SubscriptionStrategyRegistry => {
|
|
10
|
+
const registry: SubscriptionStrategyRegistry = new Map();
|
|
11
|
+
|
|
12
|
+
// Register built-in strategies
|
|
13
|
+
const databaseStrategy = createDatabaseSubscriptionStrategy();
|
|
14
|
+
const queueStrategy = createQueueSubscriptionStrategy();
|
|
15
|
+
|
|
16
|
+
registry.set(EntitySource.TABLE, databaseStrategy);
|
|
17
|
+
registry.set(EntitySource.QUEUE_PUBLISHER, queueStrategy);
|
|
18
|
+
|
|
19
|
+
return registry;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Helper to get strategy by source, with fallback to database strategy
|
|
24
|
+
*/
|
|
25
|
+
export const getStrategyForSource = (
|
|
26
|
+
registry: SubscriptionStrategyRegistry,
|
|
27
|
+
source: string | undefined,
|
|
28
|
+
): SubscriptionStrategy | undefined => {
|
|
29
|
+
if (!source) {
|
|
30
|
+
// Default to database strategy for backward compatibility
|
|
31
|
+
return registry.get(EntitySource.TABLE);
|
|
32
|
+
}
|
|
33
|
+
return registry.get(source);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Re-export individual strategies for testing or custom registration
|
|
37
|
+
export { createDatabaseSubscriptionStrategy } from "./database";
|
|
38
|
+
export { createQueueSubscriptionStrategy } from "./queue";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { SubscriptionContext, SubscriptionResult, SubscriptionStrategy } from "../types";
|
|
2
|
+
import { EntitySource } from "../../types/resolver";
|
|
3
|
+
import { filterResultBySelection } from "../../utils/selection";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Builds a composite subscription key from the field name, alias, and
|
|
7
|
+
* selections. Clients with the exact same query (including alias and
|
|
8
|
+
* requested fields) share a single connection group; any difference
|
|
9
|
+
* produces a distinct key and therefore its own group with its own
|
|
10
|
+
* responseKey and dataTransform.
|
|
11
|
+
*/
|
|
12
|
+
const buildCompositeKey = (context: SubscriptionContext): string => {
|
|
13
|
+
const { field } = context;
|
|
14
|
+
return `${field.name}:${field.alias ?? ""}:${JSON.stringify(field.selections)}`;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Queue subscription strategy - leverages existing queue consumer infrastructure
|
|
19
|
+
*
|
|
20
|
+
* Queue subscriptions are push-based, unlike database subscriptions:
|
|
21
|
+
* - No polling needed - messages are pushed via the queue consumer
|
|
22
|
+
* - The queue consumer (kafka.ts/rabbitmq.ts) already calls queryEventEmitter.sendDataUpdate()
|
|
23
|
+
* - This strategy manages connection registration with the event emitter
|
|
24
|
+
*/
|
|
25
|
+
export const createQueueSubscriptionStrategy = (): SubscriptionStrategy => ({
|
|
26
|
+
source: EntitySource.QUEUE_PUBLISHER,
|
|
27
|
+
|
|
28
|
+
getSubscriptionKey(context) {
|
|
29
|
+
return buildCompositeKey(context);
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
async subscribe(context: SubscriptionContext): Promise<SubscriptionResult> {
|
|
33
|
+
const { ws, subscriptionId, eventEmitter, field } = context;
|
|
34
|
+
const subscriptionKey = this.getSubscriptionKey(context);
|
|
35
|
+
// The field key is what queue consumers broadcast on (e.g. "conn_queueName")
|
|
36
|
+
const fieldKey = field.name;
|
|
37
|
+
|
|
38
|
+
// Check if connection already exists - join existing subscription group
|
|
39
|
+
if (eventEmitter.hasConnection(subscriptionKey)) {
|
|
40
|
+
eventEmitter.sendDataByQueryNameToSingleClient(subscriptionKey, ws, subscriptionId);
|
|
41
|
+
eventEmitter.addConnection(subscriptionKey, subscriptionId, ws);
|
|
42
|
+
return { alreadyExists: true };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Register new connection group
|
|
46
|
+
eventEmitter.addConnection(subscriptionKey, subscriptionId, ws);
|
|
47
|
+
// Tie the composite key to the field key so sendDataUpdate fan-out works
|
|
48
|
+
eventEmitter.registerFieldMapping(fieldKey, subscriptionKey);
|
|
49
|
+
// Top-level response key (handles field alias)
|
|
50
|
+
eventEmitter.setResponseKey(subscriptionKey, field.alias || field.name);
|
|
51
|
+
// Apply selection filtering and nested alias mapping to each message
|
|
52
|
+
eventEmitter.setDataTransform(subscriptionKey, (data) =>
|
|
53
|
+
filterResultBySelection(data, field.selections),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
// No cleanup needed - queue consumers manage their own lifecycle
|
|
58
|
+
cleanup: undefined,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ServerWebSocket } from "bun";
|
|
2
|
+
import type { AnalysisResult, SelectionAnalysis, VariableDefinition } from "../analyzeQuery/types";
|
|
3
|
+
import type { GetSchemaReturn } from "../configuration/getSchemas";
|
|
4
|
+
import type { createQueryEventEmitter } from "../utils/event-emitter";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Type for the query event emitter instance
|
|
8
|
+
*/
|
|
9
|
+
export type QueryEventEmitter = ReturnType<typeof createQueryEventEmitter>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Database poller interface - controls polling lifecycle
|
|
13
|
+
*/
|
|
14
|
+
export interface DatabasePoller {
|
|
15
|
+
start(): Timer | undefined;
|
|
16
|
+
stop(): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Context provided to subscription strategy handlers
|
|
21
|
+
*/
|
|
22
|
+
export interface SubscriptionContext {
|
|
23
|
+
/** The WebSocket connection */
|
|
24
|
+
ws: ServerWebSocket<unknown>;
|
|
25
|
+
/** Unique subscription ID from the client */
|
|
26
|
+
subscriptionId: string;
|
|
27
|
+
/** Analyzed GraphQL query */
|
|
28
|
+
analysis: AnalysisResult;
|
|
29
|
+
/** The first field being subscribed to */
|
|
30
|
+
field: SelectionAnalysis;
|
|
31
|
+
/** Variable definitions from the query */
|
|
32
|
+
variableDefinitions: VariableDefinition[];
|
|
33
|
+
/** Resolved variable values (after object flattening and $session.* replacement) */
|
|
34
|
+
variables: Record<string, unknown>;
|
|
35
|
+
/** Schema and entity information for the current role */
|
|
36
|
+
schemaEntity: GetSchemaReturn;
|
|
37
|
+
/** Shared event emitter for broadcasting updates */
|
|
38
|
+
eventEmitter: QueryEventEmitter;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Result of starting a subscription
|
|
43
|
+
*/
|
|
44
|
+
export interface SubscriptionResult {
|
|
45
|
+
/** Cleanup function called when subscription ends */
|
|
46
|
+
cleanup?: () => void | Promise<void>;
|
|
47
|
+
/** True if subscription was joined to an existing connection (no new poll/consumer needed) */
|
|
48
|
+
alreadyExists?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Strategy interface for handling different subscription sources
|
|
53
|
+
*/
|
|
54
|
+
export interface SubscriptionStrategy {
|
|
55
|
+
/**
|
|
56
|
+
* Unique identifier for this strategy (matches EntitySource enum value)
|
|
57
|
+
*/
|
|
58
|
+
readonly source: string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Start the subscription and return a cleanup function
|
|
62
|
+
*/
|
|
63
|
+
subscribe(context: SubscriptionContext): Promise<SubscriptionResult>;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Generate the unique subscription key for this subscription
|
|
67
|
+
*/
|
|
68
|
+
getSubscriptionKey(context: SubscriptionContext): string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Registry type for subscription strategies
|
|
73
|
+
*/
|
|
74
|
+
export type SubscriptionStrategyRegistry = Map<string, SubscriptionStrategy>;
|