@owox/backend 0.37.0 → 0.39.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/dist/src/common/helpers/read-bounded-body.helper.d.ts +1 -0
- package/dist/src/common/helpers/read-bounded-body.helper.js +28 -0
- package/dist/src/common/scheduler/system-tasks/system-trigger-type.d.ts +3 -1
- package/dist/src/common/scheduler/system-tasks/system-trigger-type.js +2 -0
- package/dist/src/common/search/search.facade.d.ts +1 -0
- package/dist/src/config/data-source-options.config.d.ts +4 -3
- package/dist/src/config/data-source-options.config.js +10 -3
- package/dist/src/config/plugin-collections-body-parser.config.js +3 -0
- package/dist/src/data-marts/credentials/credential.types.d.ts +26 -2
- package/dist/src/data-marts/credentials/credential.types.js +18 -6
- package/dist/src/data-marts/credentials/dto/credential-api.dto.d.ts +5 -1
- package/dist/src/data-marts/credentials/dto/credential-api.dto.js +21 -0
- package/dist/src/data-marts/credentials/dto/credential.dto.d.ts +2 -1
- package/dist/src/data-marts/credentials/entities/credential.entity.d.ts +2 -1
- package/dist/src/data-marts/credentials/entities/credential.entity.js +5 -0
- package/dist/src/data-marts/credentials/facades/credential-consumer-binding.facade.impl.js +6 -1
- package/dist/src/data-marts/credentials/mappers/credential.mapper.js +2 -0
- package/dist/src/data-marts/credentials/services/builtin-credential-definitions.js +8 -0
- package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.d.ts +4 -0
- package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.js +36 -17
- package/dist/src/data-marts/credentials/services/credential-fetch.service.d.ts +8 -0
- package/dist/src/data-marts/credentials/services/credential-fetch.service.js +115 -46
- package/dist/src/data-marts/credentials/services/credential-validation-probe.service.d.ts +3 -1
- package/dist/src/data-marts/credentials/services/credential-validation-probe.service.js +10 -2
- package/dist/src/data-marts/credentials/services/credential.service.d.ts +4 -0
- package/dist/src/data-marts/credentials/services/credential.service.js +36 -0
- package/dist/src/data-marts/credentials/services/google-service-account-key.d.ts +6 -0
- package/dist/src/data-marts/credentials/services/google-service-account-key.js +46 -0
- package/dist/src/data-marts/credentials/services/google-service-account-token.service.d.ts +25 -0
- package/dist/src/data-marts/credentials/services/google-service-account-token.service.js +177 -0
- package/dist/src/data-marts/credentials/use-cases/create-credential.service.d.ts +1 -0
- package/dist/src/data-marts/credentials/use-cases/create-credential.service.js +10 -2
- package/dist/src/data-marts/credentials/use-cases/update-credential.service.d.ts +1 -0
- package/dist/src/data-marts/credentials/use-cases/update-credential.service.js +28 -4
- package/dist/src/data-marts/credentials/use-cases/validate-credential.service.js +2 -5
- package/dist/src/data-marts/data-destination-types/ee/email/services/email-credentials-validator.js +1 -3
- package/dist/src/data-marts/data-destination-types/ee/google-chat/services/google-chat-credentials-validator.js +1 -3
- package/dist/src/data-marts/data-destination-types/google-sheets/services/google-sheets-credentials-validator.js +1 -3
- package/dist/src/data-marts/data-destination-types/google-sheets/services/google-sheets-report-writer.d.ts +1 -0
- package/dist/src/data-marts/data-destination-types/google-sheets/services/google-sheets-report-writer.js +13 -1
- package/dist/src/data-marts/data-destination-types/interfaces/data-destination-credentials-validator.interface.d.ts +2 -0
- package/dist/src/data-marts/data-destination-types/interfaces/data-destination-credentials-validator.interface.js +7 -0
- package/dist/src/data-marts/data-destination-types/looker-studio-connector/services/looker-studio-connector-credentials-validator.js +1 -3
- package/dist/src/data-marts/data-marts.module.js +8 -0
- package/dist/src/data-marts/data-storage-types/athena/adapters/athena-api.adapter.js +2 -1
- package/dist/src/data-marts/data-storage-types/athena/adapters/s3-api.adapter.js +5 -3
- package/dist/src/data-marts/data-storage-types/athena/services/athena-access.validator.js +2 -4
- package/dist/src/data-marts/data-storage-types/athena/utils/athena-output-location.util.d.ts +5 -0
- package/dist/src/data-marts/data-storage-types/athena/utils/athena-output-location.util.js +13 -0
- package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-access.validator.js +2 -4
- package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-resource-location.util.d.ts +3 -0
- package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-resource-location.util.js +18 -0
- package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-sharded-tables.util.d.ts +1 -0
- package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-sharded-tables.util.js +4 -1
- package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-storage-resource-browser.service.js +12 -5
- package/dist/src/data-marts/data-storage-types/databricks/services/databricks-access.validator.js +2 -4
- package/dist/src/data-marts/data-storage-types/interfaces/data-storage-access-validator.interface.d.ts +3 -0
- package/dist/src/data-marts/data-storage-types/interfaces/data-storage-access-validator.interface.js +7 -0
- package/dist/src/data-marts/data-storage-types/interfaces/storage-resource-browser.interface.d.ts +2 -0
- package/dist/src/data-marts/data-storage-types/redshift/services/redshift-access.validator.js +2 -6
- package/dist/src/data-marts/data-storage-types/snowflake/adapters/snowflake-api.adapter.js +1 -0
- package/dist/src/data-marts/data-storage-types/snowflake/services/snowflake-access.validator.js +2 -4
- package/dist/src/data-marts/dto/domain/list-data-marts.command.d.ts +2 -1
- package/dist/src/data-marts/dto/domain/list-data-marts.command.js +3 -1
- package/dist/src/data-marts/dto/presentation/run-data-mart-request-api.dto.js +4 -2
- package/dist/src/data-marts/dto/presentation/sql-dry-run-request-api.dto.js +3 -0
- package/dist/src/data-marts/dto/presentation/storage-resources/list-storage-resources-response.dto.d.ts +2 -0
- package/dist/src/data-marts/dto/presentation/storage-resources/list-storage-resources-response.dto.js +17 -0
- package/dist/src/data-marts/errors/google-sheets-api-call.error.d.ts +6 -0
- package/dist/src/data-marts/errors/google-sheets-api-call.error.js +34 -0
- package/dist/src/data-marts/facades/mcp-contexts.facade.d.ts +13 -0
- package/dist/src/data-marts/facades/mcp-contexts.facade.impl.d.ts +9 -0
- package/dist/src/data-marts/facades/mcp-contexts.facade.impl.js +35 -0
- package/dist/src/data-marts/facades/mcp-contexts.facade.js +5 -0
- package/dist/src/data-marts/facades/mcp-data-marts.facade.d.ts +9 -0
- package/dist/src/data-marts/facades/mcp-data-marts.facade.impl.js +4 -1
- package/dist/src/data-marts/mappers/context.mapper.d.ts +4 -0
- package/dist/src/data-marts/mappers/context.mapper.js +12 -0
- package/dist/src/data-marts/search/engine/advanced-search.service.js +1 -0
- package/dist/src/data-marts/search/engine/in-memory-paginated.search.js +17 -1
- package/dist/src/data-marts/search/engine/vector-search.port.d.ts +1 -0
- package/dist/src/data-marts/services/connector/backfill-segment.d.ts +22 -0
- package/dist/src/data-marts/services/connector/backfill-segment.js +91 -0
- package/dist/src/data-marts/services/connector/connector-execution.service.d.ts +1 -0
- package/dist/src/data-marts/services/connector/connector-execution.service.js +3 -0
- package/dist/src/data-marts/services/connector/connector-executor.service.d.ts +4 -1
- package/dist/src/data-marts/services/connector/connector-executor.service.js +107 -23
- package/dist/src/data-marts/services/connector/connector-run.service.d.ts +3 -0
- package/dist/src/data-marts/services/connector/connector-run.service.js +98 -4
- package/dist/src/data-marts/services/context/context.service.d.ts +2 -0
- package/dist/src/data-marts/services/context/context.service.js +21 -0
- package/dist/src/data-marts/services/data-mart-run.service.d.ts +1 -0
- package/dist/src/data-marts/services/data-mart-run.service.js +9 -0
- package/dist/src/data-marts/services/data-mart.service.d.ts +1 -0
- package/dist/src/data-marts/services/data-mart.service.js +3 -0
- package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.d.ts +14 -0
- package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.js +45 -0
- package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.d.ts +4 -0
- package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.js +46 -1
- package/dist/src/data-marts/use-cases/list-data-marts.service.js +1 -0
- package/dist/src/data-marts/use-cases/stream-http-data.service.d.ts +0 -1
- package/dist/src/data-marts/use-cases/stream-http-data.service.js +2 -6
- package/dist/src/data-marts/use-cases/update-data-storage.service.js +7 -7
- package/dist/src/data-marts/utils/field-errors.utils.d.ts +9 -0
- package/dist/src/data-marts/utils/field-errors.utils.js +51 -0
- package/dist/src/data-marts/utils/manual-backfill-range.d.ts +52 -0
- package/dist/src/data-marts/utils/manual-backfill-range.js +110 -8
- package/dist/src/ee/mcp/instructions/mcp-system-instructions.d.ts +1 -1
- package/dist/src/ee/mcp/instructions/mcp-system-instructions.js +4 -0
- package/dist/src/ee/mcp/sdk/mcp-output-schema.d.ts +3 -0
- package/dist/src/ee/mcp/sdk/mcp-output-schema.js +53 -0
- package/dist/src/ee/mcp/sdk/mcp-schema-refresh.d.ts +8 -0
- package/dist/src/ee/mcp/sdk/mcp-schema-refresh.js +44 -0
- package/dist/src/ee/mcp/sdk/mcp-sdk-server.factory.d.ts +8 -1
- package/dist/src/ee/mcp/sdk/mcp-sdk-server.factory.js +35 -4
- package/dist/src/ee/mcp/tools/context-input.d.ts +6 -0
- package/dist/src/ee/mcp/tools/context-input.js +13 -0
- package/dist/src/ee/mcp/tools/data-mart-catalog.tool.d.ts +10 -2
- package/dist/src/ee/mcp/tools/data-mart-catalog.tool.js +17 -5
- package/dist/src/ee/mcp/tools/data-mart-details.tool.d.ts +5 -1
- package/dist/src/ee/mcp/tools/data-mart-details.tool.js +4 -1
- package/dist/src/ee/mcp/tools/list-contexts.tool.d.ts +131 -0
- package/dist/src/ee/mcp/tools/list-contexts.tool.js +50 -0
- package/dist/src/ee/mcp/tools/mcp-tool.providers.js +2 -0
- package/dist/src/ee/mcp/tools/search-data-marts.tool.d.ts +10 -2
- package/dist/src/ee/mcp/tools/search-data-marts.tool.js +17 -3
- package/dist/src/ee/mcp/transport/mcp-http-entry.service.js +1 -1
- package/dist/src/idp/decorators/auth-context.decorator.js +1 -0
- package/dist/src/idp/guards/idp.guard.d.ts +3 -0
- package/dist/src/idp/guards/idp.guard.js +38 -8
- package/dist/src/idp/oauth/controllers/oauth-authorization.controller.js +8 -6
- package/dist/src/idp/oauth/mcp-client-integration.d.ts +1 -0
- package/dist/src/idp/oauth/mcp-client-integration.js +15 -0
- package/dist/src/idp/ports/plugin-runtime-authorizer.port.d.ts +6 -0
- package/dist/src/idp/types/auth.types.d.ts +1 -0
- package/dist/src/migrations/1790830000000-widen-sql-dry-run-trigger-sql-column.d.ts +6 -0
- package/dist/src/migrations/1790830000000-widen-sql-dry-run-trigger-sql-column.js +21 -0
- package/dist/src/migrations/1790900000000-add-plugin-version-backend.d.ts +6 -0
- package/dist/src/migrations/1790900000000-add-plugin-version-backend.js +21 -0
- package/dist/src/migrations/1790900000001-create-plugin-action-execution.d.ts +6 -0
- package/dist/src/migrations/1790900000001-create-plugin-action-execution.js +77 -0
- package/dist/src/migrations/1791000000000-add-credential-public-metadata.d.ts +6 -0
- package/dist/src/migrations/1791000000000-add-credential-public-metadata.js +23 -0
- package/dist/src/plugin-host/collections/dto/domain/plugin-collection.types.d.ts +1 -0
- package/dist/src/plugin-host/collections/errors/plugin-collection.errors.d.ts +6 -0
- package/dist/src/plugin-host/collections/errors/plugin-collection.errors.js +19 -1
- package/dist/src/plugin-host/collections/services/plugin-collection-declaration.service.js +3 -3
- package/dist/src/plugin-host/collections/use-cases/put-plugin-collection-document.service.js +7 -0
- package/dist/src/plugin-host/constants/plugin-action-limits.d.ts +34 -0
- package/dist/src/plugin-host/constants/plugin-action-limits.js +51 -0
- package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.d.ts +20 -0
- package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.js +123 -0
- package/dist/src/plugin-host/controllers/plugin-credential-runtime.controller.js +11 -19
- package/dist/src/plugin-host/controllers/plugin-gallery.controller.d.ts +5 -1
- package/dist/src/plugin-host/controllers/plugin-gallery.controller.js +25 -1
- package/dist/src/plugin-host/controllers/plugin-history.controller.d.ts +10 -0
- package/dist/src/plugin-host/controllers/plugin-history.controller.js +57 -0
- package/dist/src/plugin-host/controllers/plugin-release-check.controller.d.ts +10 -0
- package/dist/src/plugin-host/controllers/plugin-release-check.controller.js +58 -0
- package/dist/src/plugin-host/dto/domain/check-plugin-release.command.d.ts +22 -0
- package/dist/src/plugin-host/dto/domain/check-plugin-release.command.js +17 -0
- package/dist/src/plugin-host/dto/domain/find-plugin-by-repository.command.d.ts +6 -0
- package/dist/src/plugin-host/dto/domain/find-plugin-by-repository.command.js +13 -0
- package/dist/src/plugin-host/dto/domain/list-plugin-history.command.d.ts +10 -0
- package/dist/src/plugin-host/dto/domain/list-plugin-history.command.js +18 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.d.ts +23 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.js +44 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.d.ts +36 -0
- package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.js +3 -0
- package/dist/src/plugin-host/dto/domain/plugin-history.dto.d.ts +29 -0
- package/dist/src/plugin-host/dto/domain/plugin-history.dto.js +3 -0
- package/dist/src/plugin-host/dto/domain/plugin-view.dto.d.ts +1 -0
- package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.d.ts +44 -0
- package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.js +208 -0
- package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.d.ts +2 -0
- package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.js +7 -0
- package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.d.ts +29 -0
- package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.js +148 -0
- package/dist/src/plugin-host/dto/presentation/plugin-lookup-api.dto.d.ts +3 -0
- package/dist/src/plugin-host/dto/presentation/plugin-lookup-api.dto.js +22 -0
- package/dist/src/plugin-host/dto/presentation/publication-api.dto.d.ts +17 -0
- package/dist/src/plugin-host/dto/presentation/publication-api.dto.js +95 -1
- package/dist/src/plugin-host/entities/plugin-action-execution.entity.d.ts +24 -0
- package/dist/src/plugin-host/entities/plugin-action-execution.entity.js +136 -0
- package/dist/src/plugin-host/entities/plugin-version.entity.d.ts +2 -1
- package/dist/src/plugin-host/entities/plugin-version.entity.js +5 -0
- package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.d.ts +9 -0
- package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.js +22 -0
- package/dist/src/plugin-host/enums/release-rejection-code.enum.d.ts +3 -0
- package/dist/src/plugin-host/enums/release-rejection-code.enum.js +6 -0
- package/dist/src/plugin-host/errors/plugin-action.errors.d.ts +45 -0
- package/dist/src/plugin-host/errors/plugin-action.errors.js +70 -0
- package/dist/src/plugin-host/errors/plugin-host.errors.d.ts +6 -0
- package/dist/src/plugin-host/errors/plugin-host.errors.js +10 -1
- package/dist/src/plugin-host/filters/plugin-host-exception.filter.js +2 -2
- package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.d.ts +3 -0
- package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.js +22 -0
- package/dist/src/plugin-host/mappers/plugin-presentation.mapper.d.ts +22 -1
- package/dist/src/plugin-host/mappers/plugin-presentation.mapper.js +87 -1
- package/dist/src/plugin-host/plugin-host.module.js +34 -0
- package/dist/src/plugin-host/services/action-input-validator.service.d.ts +23 -0
- package/dist/src/plugin-host/services/action-input-validator.service.js +277 -0
- package/dist/src/plugin-host/services/external-credential-definition-sync.service.d.ts +3 -0
- package/dist/src/plugin-host/services/external-credential-definition-sync.service.js +47 -15
- package/dist/src/plugin-host/services/plugin-action-dispatcher.service.d.ts +13 -0
- package/dist/src/plugin-host/services/plugin-action-dispatcher.service.js +140 -0
- package/dist/src/plugin-host/services/plugin-action-execution.service.d.ts +69 -0
- package/dist/src/plugin-host/services/plugin-action-execution.service.js +239 -0
- package/dist/src/plugin-host/services/plugin-action-starter.service.d.ts +22 -0
- package/dist/src/plugin-host/services/plugin-action-starter.service.js +81 -0
- package/dist/src/plugin-host/services/plugin-audit.service.d.ts +13 -0
- package/dist/src/plugin-host/services/plugin-audit.service.js +78 -0
- package/dist/src/plugin-host/services/plugin-publication.service.d.ts +4 -0
- package/dist/src/plugin-host/services/plugin-publication.service.js +51 -23
- package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.d.ts +5 -2
- package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.js +31 -3
- package/dist/src/plugin-host/services/plugin-version.service.d.ts +2 -1
- package/dist/src/plugin-host/services/release-candidate-rules.service.d.ts +51 -0
- package/dist/src/plugin-host/services/release-candidate-rules.service.js +198 -0
- package/dist/src/plugin-host/services/remote-url-validator.service.d.ts +7 -0
- package/dist/src/plugin-host/services/remote-url-validator.service.js +4 -0
- package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.d.ts +14 -0
- package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.js +50 -0
- package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.d.ts +8 -0
- package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.js +39 -0
- package/dist/src/plugin-host/use-cases/check-plugin-release.service.d.ts +22 -0
- package/dist/src/plugin-host/use-cases/check-plugin-release.service.js +152 -0
- package/dist/src/plugin-host/use-cases/find-plugin-by-repository.service.d.ts +9 -0
- package/dist/src/plugin-host/use-cases/find-plugin-by-repository.service.js +35 -0
- package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.d.ts +14 -0
- package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.js +85 -0
- package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.d.ts +9 -0
- package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.js +67 -0
- package/dist/src/plugin-host/use-cases/get-plugin-installation-entry.service.js +2 -7
- package/dist/src/plugin-host/use-cases/install-plugin.service.js +4 -0
- package/dist/src/plugin-host/use-cases/list-installations.service.d.ts +3 -1
- package/dist/src/plugin-host/use-cases/list-installations.service.js +14 -3
- package/dist/src/plugin-host/use-cases/list-plugin-history.service.d.ts +25 -0
- package/dist/src/plugin-host/use-cases/list-plugin-history.service.js +147 -0
- package/dist/src/plugin-host/use-cases/plugin-publisher-access.d.ts +5 -0
- package/dist/src/plugin-host/use-cases/plugin-publisher-access.js +28 -0
- package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.d.ts +12 -0
- package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.js +64 -0
- package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.d.ts +3 -5
- package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.js +15 -59
- package/dist/src/plugin-host/use-cases/uninstall-plugin.service.js +3 -1
- package/dist/src/plugin-host/use-cases/update-plugin.service.d.ts +0 -1
- package/dist/src/plugin-host/use-cases/update-plugin.service.js +3 -25
- package/dist/src/plugin-host/utils/action-input-schema.util.d.ts +14 -0
- package/dist/src/plugin-host/utils/action-input-schema.util.js +133 -0
- package/dist/src/plugin-host/utils/credential-handles.util.d.ts +3 -0
- package/dist/src/plugin-host/utils/credential-handles.util.js +13 -0
- package/dist/src/plugin-host/utils/execution-token.util.d.ts +5 -0
- package/dist/src/plugin-host/utils/execution-token.util.js +13 -0
- package/dist/src/plugin-host/utils/github-repo-locator.util.js +1 -1
- package/dist/src/plugin-host/utils/json-shape.util.d.ts +1 -0
- package/dist/src/plugin-host/utils/json-shape.util.js +21 -0
- package/dist/src/plugin-host/utils/plugin-action-outcome.util.d.ts +10 -0
- package/dist/src/plugin-host/utils/plugin-action-outcome.util.js +67 -0
- package/dist/src/plugin-host/utils/plugin-manifest.util.d.ts +121 -0
- package/dist/src/plugin-host/utils/plugin-manifest.util.js +111 -1
- package/dist/src/plugin-host/utils/request-abort-signal.util.d.ts +5 -0
- package/dist/src/plugin-host/utils/request-abort-signal.util.js +19 -0
- package/package.json +10 -8
|
@@ -18,13 +18,14 @@ const common_1 = require("@nestjs/common");
|
|
|
18
18
|
const config_1 = require("@nestjs/config");
|
|
19
19
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
20
20
|
const typeorm_2 = require("typeorm");
|
|
21
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
21
22
|
const connectors_1 = require("@owox/connectors");
|
|
22
23
|
const internal_helpers_1 = require("@owox/internal-helpers");
|
|
23
24
|
const { ConfigDto, GENERATED_REFRESH_TOKEN_CREDENTIAL_FIELD } = connectors_1.Core;
|
|
24
25
|
const GENERATED_REFRESH_TOKEN_MAX_LENGTH = 4096;
|
|
25
26
|
exports.MAX_MERGED_RUN_OUTPUT_ENTRIES = 10000;
|
|
26
27
|
const MAX_MERGED_RUN_OUTPUT_BYTES = 6 * 1024 * 1024;
|
|
27
|
-
const MAX_RUN_BUFFER_ENTRIES = exports.MAX_MERGED_RUN_OUTPUT_ENTRIES -
|
|
28
|
+
const MAX_RUN_BUFFER_ENTRIES = exports.MAX_MERGED_RUN_OUTPUT_ENTRIES - 2;
|
|
28
29
|
const MAX_TRACE_ENTRIES = 1000;
|
|
29
30
|
const data_mart_run_entity_1 = require("../../entities/data-mart-run.entity");
|
|
30
31
|
const data_mart_run_status_enum_1 = require("../../enums/data-mart-run-status.enum");
|
|
@@ -42,6 +43,8 @@ const owox_event_dispatcher_1 = require("../../../common/event-dispatcher/owox-e
|
|
|
42
43
|
const connector_run_event_1 = require("../../events/connector-run.event");
|
|
43
44
|
const project_billing_service_1 = require("../project-billing/project-billing.service");
|
|
44
45
|
const connector_definition_service_1 = require("./connector-definition.service");
|
|
46
|
+
const connector_run_trigger_service_1 = require("./connector-run-trigger.service");
|
|
47
|
+
const backfill_segment_1 = require("./backfill-segment");
|
|
45
48
|
const connector_process_spawner_service_1 = require("./connector-process-spawner.service");
|
|
46
49
|
const connector_storage_config_service_1 = require("./connector-storage-config.service");
|
|
47
50
|
const connector_source_config_service_1 = require("./connector-source-config.service");
|
|
@@ -69,8 +72,9 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
69
72
|
connectorDefinitionService;
|
|
70
73
|
connectorSourceCredentialsService;
|
|
71
74
|
configService;
|
|
75
|
+
connectorRunTriggerService;
|
|
72
76
|
logger = new common_1.Logger(ConnectorExecutorService_1.name);
|
|
73
|
-
constructor(dataMartRunRepository, processSpawner, storageConfigService, sourceConfigService, credentialInjector, connectorOutputCaptureService, connectorStateService, gracefulShutdownService, systemTimeService, eventDispatcher, projectBillingService, dataMartService, connectorDefinitionService, connectorSourceCredentialsService, configService) {
|
|
77
|
+
constructor(dataMartRunRepository, processSpawner, storageConfigService, sourceConfigService, credentialInjector, connectorOutputCaptureService, connectorStateService, gracefulShutdownService, systemTimeService, eventDispatcher, projectBillingService, dataMartService, connectorDefinitionService, connectorSourceCredentialsService, configService, connectorRunTriggerService) {
|
|
74
78
|
this.dataMartRunRepository = dataMartRunRepository;
|
|
75
79
|
this.processSpawner = processSpawner;
|
|
76
80
|
this.storageConfigService = storageConfigService;
|
|
@@ -86,6 +90,7 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
86
90
|
this.connectorDefinitionService = connectorDefinitionService;
|
|
87
91
|
this.connectorSourceCredentialsService = connectorSourceCredentialsService;
|
|
88
92
|
this.configService = configService;
|
|
93
|
+
this.connectorRunTriggerService = connectorRunTriggerService;
|
|
89
94
|
}
|
|
90
95
|
async executeInBackground(dataMart, run, payload, signal) {
|
|
91
96
|
const runId = run.id;
|
|
@@ -102,6 +107,8 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
102
107
|
let hasAnySuccessfulConfiguration = false;
|
|
103
108
|
let wasCancelled = false;
|
|
104
109
|
let operationBlockedException;
|
|
110
|
+
const chainMeta = (0, manual_backfill_range_1.readBackfillChainMeta)(run.additionalParams);
|
|
111
|
+
const segmentWindow = chainMeta ? (0, manual_backfill_range_1.readBackfillRange)((0, manual_backfill_range_1.unwrapRunPayload)(payload)) : undefined;
|
|
105
112
|
try {
|
|
106
113
|
if (this.gracefulShutdownService.isInShutdownMode()) {
|
|
107
114
|
throw new connector_execution_error_1.ConnectorExecutionError('Skipping connector execution. Application is shutting down.', undefined, { dataMartId: dataMart.id, projectId: dataMart.projectId, runId });
|
|
@@ -119,7 +126,12 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
119
126
|
}
|
|
120
127
|
logFlusher = this.createRunLogFlusher(runId, liveLogs, liveErrors, hasOutputFromEarlierAttempt);
|
|
121
128
|
logFlusher?.start();
|
|
122
|
-
|
|
129
|
+
if (chainMeta && segmentWindow) {
|
|
130
|
+
const startedMarker = (0, backfill_segment_1.buildSegmentMarker)(chainMeta, segmentWindow, 'started', this.systemTimeService.now().toISOString());
|
|
131
|
+
addBoundedMessage(capturedLogs, startedMarker);
|
|
132
|
+
addBoundedMessage(liveLogs, startedMarker);
|
|
133
|
+
}
|
|
134
|
+
configurationResults = await this.runConnectorConfigurations(run, processId, dataMart, payload, signal, liveLogs, liveErrors, chainMeta !== undefined);
|
|
123
135
|
configurationResults.forEach(result => {
|
|
124
136
|
result.logs.forEach(log => addBoundedMessage(capturedLogs, log));
|
|
125
137
|
result.errors.forEach(error => addBoundedMessage(capturedErrors, error));
|
|
@@ -155,6 +167,37 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
155
167
|
}
|
|
156
168
|
}
|
|
157
169
|
finally {
|
|
170
|
+
const isShuttingDown = this.gracefulShutdownService.isInShutdownMode();
|
|
171
|
+
const willBeInterrupted = isShuttingDown && !wasCancelled && !allConfigurationsSucceeded;
|
|
172
|
+
const anyDateProgress = configurationResults.some(result => result.backfillLoadedThrough !== undefined);
|
|
173
|
+
const chainStep = chainMeta &&
|
|
174
|
+
!wasCancelled &&
|
|
175
|
+
signal?.aborted !== true &&
|
|
176
|
+
!operationBlockedException &&
|
|
177
|
+
!willBeInterrupted
|
|
178
|
+
? (0, manual_backfill_range_1.nextBackfillChainStep)(chainMeta, {
|
|
179
|
+
segmentSucceeded: allConfigurationsSucceeded,
|
|
180
|
+
anyProgressAdvanced: anyDateProgress,
|
|
181
|
+
}, (0, manual_backfill_range_1.getMaxManualBackfillDays)())
|
|
182
|
+
: undefined;
|
|
183
|
+
const chainContinues = chainStep?.action === 'continue';
|
|
184
|
+
if (chainMeta && segmentWindow && !wasCancelled && !willBeInterrupted) {
|
|
185
|
+
const reportedDays = configurationResults.flatMap(result => result.backfillLoadedThrough ? [result.backfillLoadedThrough] : []);
|
|
186
|
+
const loadedThrough = reportedDays.length > 0 ? reportedDays.reduce((a, b) => (a < b ? a : b)) : undefined;
|
|
187
|
+
const chainEnd = operationBlockedException
|
|
188
|
+
? 'stopped'
|
|
189
|
+
: chainStep?.action === 'end'
|
|
190
|
+
? chainStep.chainEnd
|
|
191
|
+
: undefined;
|
|
192
|
+
(0, connector_message_utils_1.addMessageToArray)(capturedLogs, (0, backfill_segment_1.buildSegmentMarker)(chainMeta, segmentWindow, allConfigurationsSucceeded ? 'completed' : 'failed', this.systemTimeService.now().toISOString(), {
|
|
193
|
+
loadedThrough,
|
|
194
|
+
configurationsLoaded: reportedDays.length,
|
|
195
|
+
configurationsTotal: configurationResults.length,
|
|
196
|
+
counted: hasAnySuccessfulConfiguration,
|
|
197
|
+
chainContinues,
|
|
198
|
+
...(chainEnd ? { chainEnd } : {}),
|
|
199
|
+
}));
|
|
200
|
+
}
|
|
158
201
|
const hasSuccessfulFieldsUpdate = configurationResults.some(result => result.success && result.fieldsUpdate);
|
|
159
202
|
try {
|
|
160
203
|
await this.persistSuccessfulFieldsUpdate(dataMart, configurationResults, runId);
|
|
@@ -180,21 +223,21 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
180
223
|
}
|
|
181
224
|
await logFlusher?.stop();
|
|
182
225
|
const flushedSnapshot = logFlusher?.persistedSnapshot() ?? null;
|
|
183
|
-
const persistedStatus = await this.updateRunStatus(runId, allConfigurationsSucceeded, capturedLogs, capturedErrors, operationBlockedException, wasCancelled, flushedSnapshot
|
|
226
|
+
const persistedStatus = await this.updateRunStatus(runId, allConfigurationsSucceeded, capturedLogs, capturedErrors, operationBlockedException, wasCancelled, willBeInterrupted, flushedSnapshot, chainStep?.action === 'continue'
|
|
227
|
+
? { run, dataMart, meta: chainStep.meta, window: chainStep.window }
|
|
228
|
+
: undefined);
|
|
184
229
|
if (hasAnySuccessfulConfiguration &&
|
|
185
230
|
persistedStatus !== null &&
|
|
186
231
|
persistedStatus !== data_mart_run_status_enum_1.DataMartRunStatus.INTERRUPTED) {
|
|
187
232
|
await this.projectBillingService.registerConnectorRunConsumption(dataMart, runId);
|
|
188
233
|
}
|
|
189
|
-
if (
|
|
234
|
+
if (persistedStatus === data_mart_run_status_enum_1.DataMartRunStatus.SUCCESS) {
|
|
190
235
|
await this.eventDispatcher.publishExternal(new connector_run_event_1.ConnectorRunEvent(dataMart.id, runId, dataMart.projectId, run.createdById ?? 'system', run.runType, 'successfully'));
|
|
191
236
|
}
|
|
192
|
-
else if (persistedStatus !== null &&
|
|
193
|
-
!wasCancelled &&
|
|
194
|
-
!this.gracefulShutdownService.isInShutdownMode()) {
|
|
237
|
+
else if (persistedStatus !== null && !wasCancelled && !willBeInterrupted) {
|
|
195
238
|
await this.eventDispatcher.publishExternal(new connector_run_event_1.ConnectorRunEvent(dataMart.id, runId, dataMart.projectId, run.createdById ?? 'system', run.runType, 'unsuccessfully'));
|
|
196
239
|
}
|
|
197
|
-
if (!hasSuccessfulFieldsUpdate) {
|
|
240
|
+
if (!hasSuccessfulFieldsUpdate && !chainContinues) {
|
|
198
241
|
await this.actualizeSchemaAfterConnectorExecution(dataMart, runId);
|
|
199
242
|
}
|
|
200
243
|
this.gracefulShutdownService.unregisterActiveProcess(processId);
|
|
@@ -225,7 +268,7 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
225
268
|
}
|
|
226
269
|
}
|
|
227
270
|
}
|
|
228
|
-
async runConnectorConfigurations(run, processId, dataMart, payload, signal, liveLogs = [], liveErrors = []) {
|
|
271
|
+
async runConnectorConfigurations(run, processId, dataMart, payload, signal, liveLogs = [], liveErrors = [], isChainSegment = false) {
|
|
229
272
|
const runId = run.id;
|
|
230
273
|
const definition = dataMart.definition;
|
|
231
274
|
const { connector } = definition;
|
|
@@ -549,6 +592,9 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
549
592
|
logs: configLogs,
|
|
550
593
|
errors: configErrors,
|
|
551
594
|
fieldsUpdate,
|
|
595
|
+
...(isChainSegment && backfillProgress[configId] !== undefined
|
|
596
|
+
? { backfillLoadedThrough: backfillProgress[configId] }
|
|
597
|
+
: {}),
|
|
552
598
|
});
|
|
553
599
|
}
|
|
554
600
|
}
|
|
@@ -742,7 +788,7 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
742
788
|
});
|
|
743
789
|
}, error => this.logger.warn(`Incremental log flush failed for run ${runId}: ${(0, internal_helpers_1.castError)(error).message}`));
|
|
744
790
|
}
|
|
745
|
-
async updateRunStatus(runId, allConfigurationsSucceeded, capturedLogs, capturedErrors, operationBlockedException, wasCancelled = false, flushedSnapshot = null) {
|
|
791
|
+
async updateRunStatus(runId, allConfigurationsSucceeded, capturedLogs, capturedErrors, operationBlockedException, wasCancelled = false, willBeInterrupted = false, flushedSnapshot = null, nextSegment) {
|
|
746
792
|
let status = wasCancelled
|
|
747
793
|
? data_mart_run_status_enum_1.DataMartRunStatus.CANCELLED
|
|
748
794
|
: allConfigurationsSucceeded
|
|
@@ -750,21 +796,37 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
750
796
|
: operationBlockedException
|
|
751
797
|
? data_mart_run_status_enum_1.DataMartRunStatus.RESTRICTED
|
|
752
798
|
: data_mart_run_status_enum_1.DataMartRunStatus.FAILED;
|
|
753
|
-
if (
|
|
754
|
-
!allConfigurationsSucceeded &&
|
|
755
|
-
this.gracefulShutdownService.isInShutdownMode()) {
|
|
799
|
+
if (willBeInterrupted) {
|
|
756
800
|
status = data_mart_run_status_enum_1.DataMartRunStatus.INTERRUPTED;
|
|
757
801
|
}
|
|
758
802
|
const newLogStrings = capturedLogs.map(log => JSON.stringify(log));
|
|
759
803
|
const newErrorStrings = capturedErrors.map(error => JSON.stringify(error));
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
|
|
804
|
+
const merged = await this.mergeWithPersistedOutput(runId, newLogStrings, newErrorStrings, flushedSnapshot);
|
|
805
|
+
let logsToSave = merged.logs;
|
|
806
|
+
const errorsToSave = merged.errors;
|
|
807
|
+
let landed;
|
|
808
|
+
try {
|
|
809
|
+
landed = await this.writeRunOutcome(runId, status, logsToSave, errorsToSave, nextSegment);
|
|
810
|
+
}
|
|
811
|
+
catch (error) {
|
|
812
|
+
if (!nextSegment)
|
|
813
|
+
throw error;
|
|
814
|
+
const failure = (0, internal_helpers_1.castError)(error);
|
|
815
|
+
this.logger.error(`Failed to queue the next backfill segment: ${failure.message}`, failure.stack, {
|
|
816
|
+
runId,
|
|
817
|
+
});
|
|
818
|
+
const queueWarning = 'Could not queue the next backfill segment. The backfill continues automatically within 15 minutes.';
|
|
819
|
+
logsToSave = this.capMergedEntries([
|
|
820
|
+
...(logsToSave ?? []),
|
|
821
|
+
JSON.stringify({
|
|
822
|
+
type: connector_message_type_enum_1.ConnectorMessageType.WARNING,
|
|
823
|
+
at: this.systemTimeService.now().toISOString(),
|
|
824
|
+
warning: queueWarning,
|
|
825
|
+
}),
|
|
826
|
+
]);
|
|
827
|
+
landed = await this.writeRunOutcome(runId, status, logsToSave, errorsToSave);
|
|
828
|
+
}
|
|
829
|
+
if (landed) {
|
|
768
830
|
return status;
|
|
769
831
|
}
|
|
770
832
|
this.logger.log(`Skipped final status update for run ${runId}: run already reached a terminal status`);
|
|
@@ -773,6 +835,21 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
773
835
|
}
|
|
774
836
|
return null;
|
|
775
837
|
}
|
|
838
|
+
async writeRunOutcome(runId, status, logs, errors, nextSegment) {
|
|
839
|
+
const result = await this.dataMartRunRepository.update({ id: runId, status: (0, typeorm_2.In)(data_mart_run_cancellation_1.NON_TERMINAL_DATA_MART_RUN_STATUSES) }, { status, finishedAt: this.systemTimeService.now(), logs, errors });
|
|
840
|
+
if (!result.affected)
|
|
841
|
+
return false;
|
|
842
|
+
if (!nextSegment)
|
|
843
|
+
return true;
|
|
844
|
+
const { run, dataMart, meta, window } = nextSegment;
|
|
845
|
+
if (status !== data_mart_run_status_enum_1.DataMartRunStatus.SUCCESS && status !== data_mart_run_status_enum_1.DataMartRunStatus.FAILED) {
|
|
846
|
+
this.logger.warn(`Not queueing backfill segment ${meta.segmentIndex} of ${meta.segmentsTotal}: run ended ${status}`, { dataMartId: run.dataMartId, projectId: dataMart.projectId, runId });
|
|
847
|
+
return true;
|
|
848
|
+
}
|
|
849
|
+
const nextRun = await (0, backfill_segment_1.createNextSegmentRun)(this.dataMartRunRepository, this.connectorRunTriggerService, run, dataMart, meta, window);
|
|
850
|
+
this.logger.log(`Queued backfill segment ${meta.segmentIndex} of ${meta.segmentsTotal} as run ${nextRun.id}`, { dataMartId: run.dataMartId, projectId: dataMart.projectId, runId, nextRunId: nextRun.id });
|
|
851
|
+
return true;
|
|
852
|
+
}
|
|
776
853
|
async mergeWithPersistedOutput(runId, newLogStrings, newErrorStrings, flushedSnapshot = null) {
|
|
777
854
|
const existing = await this.dataMartRunRepository.findOne({ where: { id: runId } });
|
|
778
855
|
const existingLogs = this.discountFlushedEntries(existing?.logs ?? [], flushedSnapshot?.logs, newLogStrings);
|
|
@@ -824,6 +901,12 @@ let ConnectorExecutorService = ConnectorExecutorService_1 = class ConnectorExecu
|
|
|
824
901
|
}
|
|
825
902
|
};
|
|
826
903
|
exports.ConnectorExecutorService = ConnectorExecutorService;
|
|
904
|
+
__decorate([
|
|
905
|
+
(0, typeorm_transactional_1.Transactional)(),
|
|
906
|
+
__metadata("design:type", Function),
|
|
907
|
+
__metadata("design:paramtypes", [String, String, Object, Object, Object]),
|
|
908
|
+
__metadata("design:returntype", Promise)
|
|
909
|
+
], ConnectorExecutorService.prototype, "writeRunOutcome", null);
|
|
827
910
|
exports.ConnectorExecutorService = ConnectorExecutorService = ConnectorExecutorService_1 = __decorate([
|
|
828
911
|
(0, common_1.Injectable)(),
|
|
829
912
|
__param(0, (0, typeorm_1.InjectRepository)(data_mart_run_entity_1.DataMartRun)),
|
|
@@ -841,6 +924,7 @@ exports.ConnectorExecutorService = ConnectorExecutorService = ConnectorExecutorS
|
|
|
841
924
|
data_mart_service_1.DataMartService,
|
|
842
925
|
connector_definition_service_1.ConnectorDefinitionService,
|
|
843
926
|
connector_source_credentials_service_1.ConnectorSourceCredentialsService,
|
|
844
|
-
config_1.ConfigService
|
|
927
|
+
config_1.ConfigService,
|
|
928
|
+
connector_run_trigger_service_1.ConnectorRunTriggerService])
|
|
845
929
|
], ConnectorExecutorService);
|
|
846
930
|
//# sourceMappingURL=connector-executor.service.js.map
|
|
@@ -17,6 +17,9 @@ export declare class ConnectorRunService {
|
|
|
17
17
|
executeExistingRun(dataMart: DataMart, run: DataMartRun, payload?: Record<string, unknown> | null, signal?: AbortSignal): Promise<void>;
|
|
18
18
|
getDataMartConnectorRunsByStatus(status: DataMartRunStatus): Promise<DataMartRun[]>;
|
|
19
19
|
executeInterruptedRuns(): Promise<void>;
|
|
20
|
+
repairBackfillChains(): Promise<void>;
|
|
21
|
+
private hasLaterRun;
|
|
22
|
+
private queueChainSegment;
|
|
20
23
|
private validateDataMartForConnector;
|
|
21
24
|
private checkDataMartIsRunning;
|
|
22
25
|
private createDataMartRun;
|
|
@@ -14,10 +14,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
var ConnectorRunService_1;
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.ConnectorRunService = void 0;
|
|
17
|
+
const node_crypto_1 = require("node:crypto");
|
|
17
18
|
const common_1 = require("@nestjs/common");
|
|
18
19
|
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
19
20
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
20
21
|
const typeorm_2 = require("typeorm");
|
|
22
|
+
const internal_helpers_1 = require("@owox/internal-helpers");
|
|
21
23
|
const business_violation_exception_1 = require("../../../common/exceptions/business-violation.exception");
|
|
22
24
|
const data_mart_entity_1 = require("../../entities/data-mart.entity");
|
|
23
25
|
const data_mart_run_entity_1 = require("../../entities/data-mart-run.entity");
|
|
@@ -29,8 +31,11 @@ const connector_execution_error_1 = require("../../errors/connector-execution.er
|
|
|
29
31
|
const types_1 = require("../../../common/scheduler/shared/types");
|
|
30
32
|
const connector_run_trigger_service_1 = require("./connector-run-trigger.service");
|
|
31
33
|
const connector_executor_service_1 = require("./connector-executor.service");
|
|
34
|
+
const backfill_segment_1 = require("./backfill-segment");
|
|
32
35
|
const system_time_service_1 = require("../../../common/scheduler/services/system-time.service");
|
|
33
36
|
const manual_backfill_range_1 = require("../../utils/manual-backfill-range");
|
|
37
|
+
const CHAIN_REPAIR_LOOKBACK_MS = 24 * 60 * 60 * 1000;
|
|
38
|
+
const CHAIN_SUCCESSOR_CLOCK_SLACK_MS = 60 * 1000;
|
|
34
39
|
let ConnectorRunService = ConnectorRunService_1 = class ConnectorRunService {
|
|
35
40
|
dataMartRunRepository;
|
|
36
41
|
connectorRunTriggerService;
|
|
@@ -50,14 +55,16 @@ let ConnectorRunService = ConnectorRunService_1 = class ConnectorRunService {
|
|
|
50
55
|
throw new business_violation_exception_1.BusinessViolationException('Connector is already running. Please wait until it finishes');
|
|
51
56
|
}
|
|
52
57
|
const preparedPayload = (0, manual_backfill_range_1.prepareManualBackfillPayload)(payload, this.systemTimeService.now());
|
|
53
|
-
const
|
|
58
|
+
const chainPlan = (0, manual_backfill_range_1.planBackfillChain)(preparedPayload, (0, node_crypto_1.randomUUID)());
|
|
59
|
+
const runPayload = chainPlan?.payload ?? preparedPayload;
|
|
60
|
+
const dataMartRun = await this.createDataMartRun(dataMart, createdById, runType, runPayload, chainPlan?.meta);
|
|
54
61
|
await this.connectorRunTriggerService.createTrigger({
|
|
55
62
|
dataMartId: dataMart.id,
|
|
56
63
|
projectId: dataMart.projectId,
|
|
57
64
|
createdById,
|
|
58
65
|
dataMartRunId: dataMartRun.id,
|
|
59
66
|
runType,
|
|
60
|
-
payload:
|
|
67
|
+
payload: dataMartRun.additionalParams ?? undefined,
|
|
61
68
|
});
|
|
62
69
|
return dataMartRun.id;
|
|
63
70
|
}
|
|
@@ -107,6 +114,85 @@ let ConnectorRunService = ConnectorRunService_1 = class ConnectorRunService {
|
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
116
|
}
|
|
117
|
+
async repairBackfillChains() {
|
|
118
|
+
const cutoff = new Date(this.systemTimeService.now().getTime() - CHAIN_REPAIR_LOOKBACK_MS);
|
|
119
|
+
const recent = await this.dataMartRunRepository.find({
|
|
120
|
+
where: {
|
|
121
|
+
type: data_mart_run_type_enum_1.DataMartRunType.CONNECTOR,
|
|
122
|
+
status: (0, typeorm_2.In)([data_mart_run_status_enum_1.DataMartRunStatus.SUCCESS, data_mart_run_status_enum_1.DataMartRunStatus.FAILED]),
|
|
123
|
+
runType: types_1.RunType.manual,
|
|
124
|
+
finishedAt: (0, typeorm_2.MoreThanOrEqual)(cutoff),
|
|
125
|
+
},
|
|
126
|
+
select: [
|
|
127
|
+
'id',
|
|
128
|
+
'dataMartId',
|
|
129
|
+
'status',
|
|
130
|
+
'runType',
|
|
131
|
+
'createdById',
|
|
132
|
+
'finishedAt',
|
|
133
|
+
'additionalParams',
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
const latestByChain = new Map();
|
|
137
|
+
for (const run of recent) {
|
|
138
|
+
const meta = (0, manual_backfill_range_1.readBackfillChainMeta)(run.additionalParams);
|
|
139
|
+
if (!meta)
|
|
140
|
+
continue;
|
|
141
|
+
const current = latestByChain.get(meta.id);
|
|
142
|
+
if (!current || meta.segmentIndex > current.meta.segmentIndex) {
|
|
143
|
+
latestByChain.set(meta.id, { run, meta });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const { run, meta } of latestByChain.values()) {
|
|
147
|
+
try {
|
|
148
|
+
const step = (0, manual_backfill_range_1.nextBackfillChainStep)(meta, {
|
|
149
|
+
segmentSucceeded: run.status === data_mart_run_status_enum_1.DataMartRunStatus.SUCCESS,
|
|
150
|
+
anyProgressAdvanced: Object.keys((0, manual_backfill_range_1.readBackfillProgress)(run.additionalParams)).length > 0,
|
|
151
|
+
}, (0, manual_backfill_range_1.getMaxManualBackfillDays)());
|
|
152
|
+
if (step.action !== 'continue')
|
|
153
|
+
continue;
|
|
154
|
+
if (await this.hasLaterRun(run, meta))
|
|
155
|
+
continue;
|
|
156
|
+
const withDataMart = await this.dataMartRunRepository.findOne({
|
|
157
|
+
where: { id: run.id },
|
|
158
|
+
relations: ['dataMart'],
|
|
159
|
+
});
|
|
160
|
+
if (!withDataMart?.dataMart || (await this.checkDataMartIsRunning(withDataMart.dataMart))) {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const nextRunId = await this.queueChainSegment(withDataMart, step.meta, step.window);
|
|
164
|
+
this.logger.log(`Repaired backfill chain ${meta.id}: queued segment ${step.meta.segmentIndex} of ${step.meta.segmentsTotal} as run ${nextRunId}`, { dataMartId: run.dataMartId, runId: run.id, nextRunId });
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
const failure = (0, internal_helpers_1.castError)(error);
|
|
168
|
+
this.logger.error(`Failed to repair backfill chain ${meta.id}: ${failure.message}`, failure.stack, { dataMartId: run.dataMartId, runId: run.id });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async hasLaterRun(run, meta) {
|
|
173
|
+
if (!run.finishedAt)
|
|
174
|
+
return true;
|
|
175
|
+
const since = new Date(run.finishedAt.getTime() - CHAIN_SUCCESSOR_CLOCK_SLACK_MS);
|
|
176
|
+
const candidates = await this.dataMartRunRepository.find({
|
|
177
|
+
where: {
|
|
178
|
+
dataMartId: run.dataMartId,
|
|
179
|
+
type: data_mart_run_type_enum_1.DataMartRunType.CONNECTOR,
|
|
180
|
+
id: (0, typeorm_2.Not)(run.id),
|
|
181
|
+
createdAt: (0, typeorm_2.MoreThanOrEqual)(since),
|
|
182
|
+
},
|
|
183
|
+
select: ['id', 'additionalParams'],
|
|
184
|
+
});
|
|
185
|
+
return candidates.some(candidate => {
|
|
186
|
+
const candidateMeta = (0, manual_backfill_range_1.readBackfillChainMeta)(candidate.additionalParams);
|
|
187
|
+
if (candidateMeta?.id === meta.id)
|
|
188
|
+
return candidateMeta.segmentIndex > meta.segmentIndex;
|
|
189
|
+
return (0, manual_backfill_range_1.isManualBackfillPayload)((0, manual_backfill_range_1.unwrapRunPayload)(candidate.additionalParams));
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async queueChainSegment(run, meta, window) {
|
|
193
|
+
const nextRun = await (0, backfill_segment_1.createNextSegmentRun)(this.dataMartRunRepository, this.connectorRunTriggerService, run, run.dataMart, meta, window);
|
|
194
|
+
return nextRun.id;
|
|
195
|
+
}
|
|
110
196
|
validateDataMartForConnector(dataMart) {
|
|
111
197
|
if (dataMart.definitionType !== data_mart_definition_type_enum_1.DataMartDefinitionType.CONNECTOR) {
|
|
112
198
|
throw new connector_execution_error_1.ConnectorExecutionError('DataMart is not a connector type', undefined, {
|
|
@@ -131,7 +217,7 @@ let ConnectorRunService = ConnectorRunService_1 = class ConnectorRunService {
|
|
|
131
217
|
});
|
|
132
218
|
return !!dataMartRun;
|
|
133
219
|
}
|
|
134
|
-
async createDataMartRun(dataMart, createdById, runType, payload) {
|
|
220
|
+
async createDataMartRun(dataMart, createdById, runType, payload, chainMeta) {
|
|
135
221
|
const dataMartRun = this.dataMartRunRepository.create({
|
|
136
222
|
dataMartId: dataMart.id,
|
|
137
223
|
type: data_mart_run_type_enum_1.DataMartRunType.CONNECTOR,
|
|
@@ -141,7 +227,9 @@ let ConnectorRunService = ConnectorRunService_1 = class ConnectorRunService {
|
|
|
141
227
|
runType,
|
|
142
228
|
logs: [],
|
|
143
229
|
errors: [],
|
|
144
|
-
additionalParams: payload
|
|
230
|
+
additionalParams: payload
|
|
231
|
+
? { payload, ...(chainMeta ? { [manual_backfill_range_1.BACKFILL_CHAIN_KEY]: chainMeta } : {}) }
|
|
232
|
+
: undefined,
|
|
145
233
|
});
|
|
146
234
|
return this.dataMartRunRepository.save(dataMartRun);
|
|
147
235
|
}
|
|
@@ -153,6 +241,12 @@ __decorate([
|
|
|
153
241
|
__metadata("design:paramtypes", [data_mart_entity_1.DataMart, String, String, Object]),
|
|
154
242
|
__metadata("design:returntype", Promise)
|
|
155
243
|
], ConnectorRunService.prototype, "run", null);
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, typeorm_transactional_1.Transactional)(),
|
|
246
|
+
__metadata("design:type", Function),
|
|
247
|
+
__metadata("design:paramtypes", [data_mart_run_entity_1.DataMartRun, Object, Object]),
|
|
248
|
+
__metadata("design:returntype", Promise)
|
|
249
|
+
], ConnectorRunService.prototype, "queueChainSegment", null);
|
|
156
250
|
exports.ConnectorRunService = ConnectorRunService = ConnectorRunService_1 = __decorate([
|
|
157
251
|
(0, common_1.Injectable)(),
|
|
158
252
|
__param(0, (0, typeorm_1.InjectRepository)(data_mart_run_entity_1.DataMartRun)),
|
|
@@ -21,6 +21,8 @@ export declare class ContextService {
|
|
|
21
21
|
private readonly userProjectionsFetcherService;
|
|
22
22
|
constructor(contextRepository: Repository<Context>, dataMartContextRepository: Repository<DataMartContext>, storageContextRepository: Repository<StorageContext>, destinationContextRepository: Repository<DestinationContext>, memberRoleContextRepository: Repository<MemberRoleContext>, memberRoleScopeRepository: Repository<MemberRoleScope>, userProvisioningContextSettingsContextRepository: Repository<UserProvisioningContextSettingsContext>, contextMapper: ContextMapper, userProjectionsFetcherService: UserProjectionsFetcherService);
|
|
23
23
|
create(projectId: string, createdById: string, name: string, description?: string): Promise<ContextDto>;
|
|
24
|
+
listForMcp(projectId: string): Promise<import("../../facades/mcp-contexts.facade").McpContext[]>;
|
|
25
|
+
getDataMartContextSummaries(projectId: string, dataMartIds: string[]): Promise<Record<string, import("../../facades/mcp-contexts.facade").McpContextSummary[]>>;
|
|
24
26
|
list(projectId: string): Promise<ContextDto[]>;
|
|
25
27
|
update(contextId: string, projectId: string, name: string, description?: string): Promise<ContextDto>;
|
|
26
28
|
getImpact(contextId: string, projectId: string): Promise<ContextImpactDto>;
|
|
@@ -85,6 +85,27 @@ let ContextService = class ContextService {
|
|
|
85
85
|
const userProjections = await this.userProjectionsFetcherService.fetchUserProjectionsList(saved.createdById ? [saved.createdById] : []);
|
|
86
86
|
return this.contextMapper.toDomainDto(saved, userProjections);
|
|
87
87
|
}
|
|
88
|
+
async listForMcp(projectId) {
|
|
89
|
+
const entities = await this.contextRepository.find({
|
|
90
|
+
where: { projectId },
|
|
91
|
+
order: { name: 'ASC' },
|
|
92
|
+
});
|
|
93
|
+
return entities.map(entity => this.contextMapper.toMcpContext(entity));
|
|
94
|
+
}
|
|
95
|
+
async getDataMartContextSummaries(projectId, dataMartIds) {
|
|
96
|
+
if (dataMartIds.length === 0)
|
|
97
|
+
return {};
|
|
98
|
+
const rows = await this.dataMartContextRepository.find({
|
|
99
|
+
where: {
|
|
100
|
+
dataMartId: (0, typeorm_2.In)([...new Set(dataMartIds)]),
|
|
101
|
+
context: { projectId },
|
|
102
|
+
dataMart: { projectId },
|
|
103
|
+
},
|
|
104
|
+
relations: ['context'],
|
|
105
|
+
order: { context: { name: 'ASC' } },
|
|
106
|
+
});
|
|
107
|
+
return this.contextMapper.toDataMartContextSummaries(rows);
|
|
108
|
+
}
|
|
88
109
|
async list(projectId) {
|
|
89
110
|
const entities = await this.contextRepository.find({
|
|
90
111
|
where: { projectId },
|
|
@@ -86,6 +86,7 @@ export declare class DataMartRunService {
|
|
|
86
86
|
findById(runId: string): Promise<DataMartRun | null>;
|
|
87
87
|
getByIdAndDataMartId(runId: string, dataMartId: string): Promise<DataMartRun | null>;
|
|
88
88
|
getDataQualityDetailsByIdAndDataMartId(runId: string, dataMartId: string): Promise<DataMartRun | null>;
|
|
89
|
+
findActiveConnectorRun(dataMartId: string): Promise<DataMartRun | null>;
|
|
89
90
|
markAsCancelled(dataMartRun: DataMartRun): Promise<boolean>;
|
|
90
91
|
createAndMarkReportRunAsPending(report: Report, context: ReportRunContext): Promise<DataMartRun>;
|
|
91
92
|
createAndMarkReportRunAsStarted(report: Report, context: ReportRunContext): Promise<DataMartRun>;
|
|
@@ -129,6 +129,15 @@ let DataMartRunService = DataMartRunService_1 = class DataMartRunService {
|
|
|
129
129
|
.andWhere('run.dataMartId = :dataMartId', { dataMartId })
|
|
130
130
|
.getOne();
|
|
131
131
|
}
|
|
132
|
+
async findActiveConnectorRun(dataMartId) {
|
|
133
|
+
return this.dataMartRunRepository.findOne({
|
|
134
|
+
where: {
|
|
135
|
+
dataMartId,
|
|
136
|
+
type: data_mart_run_type_enum_1.DataMartRunType.CONNECTOR,
|
|
137
|
+
status: (0, typeorm_2.In)([data_mart_run_status_enum_1.DataMartRunStatus.PENDING, data_mart_run_status_enum_1.DataMartRunStatus.RUNNING]),
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
132
141
|
async markAsCancelled(dataMartRun) {
|
|
133
142
|
const result = await this.dataMartRunRepository.update({
|
|
134
143
|
id: dataMartRun.id,
|
|
@@ -112,6 +112,9 @@ let DataMartService = DataMartService_1 = class DataMartService {
|
|
|
112
112
|
if (options?.status) {
|
|
113
113
|
qb.andWhere('dm.status = :status', { status: options.status });
|
|
114
114
|
}
|
|
115
|
+
if (options?.contextIds?.length) {
|
|
116
|
+
qb.andWhere('EXISTS (SELECT 1 FROM data_mart_contexts filteredContext WHERE filteredContext.data_mart_id = dm.id AND filteredContext.context_id IN (:...filterContextIds))', { filterContextIds: options.contextIds });
|
|
117
|
+
}
|
|
115
118
|
this.applyNonAdminVisibilityGate(qb, projectId, options);
|
|
116
119
|
if (options?.ownerFilter === owner_filter_enum_1.OwnerFilter.HAS_OWNERS) {
|
|
117
120
|
qb.andWhere(`(EXISTS (SELECT 1 FROM data_mart_technical_owners t WHERE t.data_mart_id = dm.id)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SystemTrigger } from '../../../common/scheduler/shared/entities/system-trigger.entity';
|
|
2
|
+
import { BaseSystemTaskProcessor } from '../../../common/scheduler/system-tasks/base-system-task.processor';
|
|
3
|
+
import { SystemTriggerType } from '../../../common/scheduler/system-tasks/system-trigger-type';
|
|
4
|
+
import { ConnectorExecutionService } from '../../services/connector/connector-execution.service';
|
|
5
|
+
export declare class RepairBackfillChainsProcessor extends BaseSystemTaskProcessor {
|
|
6
|
+
private readonly connectorExecutionService;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
constructor(connectorExecutionService: ConnectorExecutionService);
|
|
9
|
+
getType(): SystemTriggerType;
|
|
10
|
+
getDefaultCron(): string;
|
|
11
|
+
process(_trigger: SystemTrigger, options?: {
|
|
12
|
+
signal?: AbortSignal;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var RepairBackfillChainsProcessor_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.RepairBackfillChainsProcessor = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const base_system_task_processor_1 = require("../../../common/scheduler/system-tasks/base-system-task.processor");
|
|
16
|
+
const system_trigger_type_1 = require("../../../common/scheduler/system-tasks/system-trigger-type");
|
|
17
|
+
const connector_execution_service_1 = require("../../services/connector/connector-execution.service");
|
|
18
|
+
let RepairBackfillChainsProcessor = RepairBackfillChainsProcessor_1 = class RepairBackfillChainsProcessor extends base_system_task_processor_1.BaseSystemTaskProcessor {
|
|
19
|
+
connectorExecutionService;
|
|
20
|
+
logger = new common_1.Logger(RepairBackfillChainsProcessor_1.name);
|
|
21
|
+
constructor(connectorExecutionService) {
|
|
22
|
+
super();
|
|
23
|
+
this.connectorExecutionService = connectorExecutionService;
|
|
24
|
+
}
|
|
25
|
+
getType() {
|
|
26
|
+
return system_trigger_type_1.SystemTriggerType.REPAIR_BACKFILL_CHAINS;
|
|
27
|
+
}
|
|
28
|
+
getDefaultCron() {
|
|
29
|
+
return '0 */15 * * * *';
|
|
30
|
+
}
|
|
31
|
+
async process(_trigger, options) {
|
|
32
|
+
if (options?.signal?.aborted) {
|
|
33
|
+
this.logger.debug('Backfill chain repair aborted before start');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.logger.debug('Executing backfill chain repair');
|
|
37
|
+
await this.connectorExecutionService.repairBackfillChains();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.RepairBackfillChainsProcessor = RepairBackfillChainsProcessor;
|
|
41
|
+
exports.RepairBackfillChainsProcessor = RepairBackfillChainsProcessor = RepairBackfillChainsProcessor_1 = __decorate([
|
|
42
|
+
(0, common_1.Injectable)(),
|
|
43
|
+
__metadata("design:paramtypes", [connector_execution_service_1.ConnectorExecutionService])
|
|
44
|
+
], RepairBackfillChainsProcessor);
|
|
45
|
+
//# sourceMappingURL=repair-backfill-chains-processor.js.map
|
|
@@ -16,9 +16,13 @@ export declare class CancelDataMartRunService {
|
|
|
16
16
|
private readonly accessDecisionService;
|
|
17
17
|
constructor(dataMartService: DataMartService, dataMartRunService: DataMartRunService, connectorRunTriggerService: ConnectorRunTriggerService, reportRunTriggerService: ReportRunTriggerService, dataQualityRunService: DataQualityRunService, reportService: ReportService, accessDecisionService: AccessDecisionService);
|
|
18
18
|
run(command: CancelDataMartRunCommand): Promise<void>;
|
|
19
|
+
private findChainMeta;
|
|
19
20
|
private cancelRunState;
|
|
20
21
|
private isSupportedRunType;
|
|
21
22
|
private isStandardReportRun;
|
|
22
23
|
private markActiveRunAsCancelled;
|
|
24
|
+
private cancelChainRun;
|
|
25
|
+
private resolveChainTarget;
|
|
26
|
+
private cancelChainRunState;
|
|
23
27
|
private getStandardReportRunReportId;
|
|
24
28
|
}
|