@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
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PluginActionStarterService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const plugin_action_limits_1 = require("../constants/plugin-action-limits");
|
|
15
|
+
const plugin_action_execution_status_enum_1 = require("../enums/plugin-action-execution-status.enum");
|
|
16
|
+
const plugin_action_errors_1 = require("../errors/plugin-action.errors");
|
|
17
|
+
const execution_token_util_1 = require("../utils/execution-token.util");
|
|
18
|
+
const json_shape_util_1 = require("../utils/json-shape.util");
|
|
19
|
+
const plugin_manifest_util_1 = require("../utils/plugin-manifest.util");
|
|
20
|
+
const action_input_validator_service_1 = require("./action-input-validator.service");
|
|
21
|
+
const plugin_action_dispatcher_service_1 = require("./plugin-action-dispatcher.service");
|
|
22
|
+
const plugin_action_execution_service_1 = require("./plugin-action-execution.service");
|
|
23
|
+
let PluginActionStarterService = class PluginActionStarterService {
|
|
24
|
+
validator;
|
|
25
|
+
executions;
|
|
26
|
+
dispatcher;
|
|
27
|
+
constructor(validator, executions, dispatcher) {
|
|
28
|
+
this.validator = validator;
|
|
29
|
+
this.executions = executions;
|
|
30
|
+
this.dispatcher = dispatcher;
|
|
31
|
+
}
|
|
32
|
+
async start(request) {
|
|
33
|
+
const { installation, version, action } = request;
|
|
34
|
+
if (!version.backend || !Object.hasOwn(version.backend.actions, action)) {
|
|
35
|
+
throw new plugin_action_errors_1.ActionNotDeclaredError(action);
|
|
36
|
+
}
|
|
37
|
+
const declaration = version.backend.actions[action];
|
|
38
|
+
const input = request.input ?? null;
|
|
39
|
+
const shapeProblem = (0, json_shape_util_1.findJsonShapeProblem)(input);
|
|
40
|
+
if (shapeProblem) {
|
|
41
|
+
throw new plugin_action_errors_1.ActionInputInvalidError([{ instancePath: '', message: shapeProblem }]);
|
|
42
|
+
}
|
|
43
|
+
const inputBytes = input === null ? 0 : Buffer.byteLength(JSON.stringify(input));
|
|
44
|
+
if (inputBytes > plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxInputBytes) {
|
|
45
|
+
throw new plugin_action_errors_1.ActionInputTooLargeError();
|
|
46
|
+
}
|
|
47
|
+
await this.executions.assertWithinStartLimits(installation.id, Date.now());
|
|
48
|
+
if (declaration.input) {
|
|
49
|
+
const errors = await this.validator.validate(version.id, action, declaration.input, input);
|
|
50
|
+
if (errors.length > 0) {
|
|
51
|
+
throw new plugin_action_errors_1.ActionInputInvalidError(errors);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const backendUrl = (0, plugin_manifest_util_1.resolveBackendUrl)(version.backend, version.deliveryUrl);
|
|
55
|
+
const { token, tokenHash } = (0, execution_token_util_1.createExecutionToken)();
|
|
56
|
+
const execution = await this.executions.insertRunning({
|
|
57
|
+
pluginId: version.pluginId,
|
|
58
|
+
pluginVersionId: version.id,
|
|
59
|
+
installationId: installation.id,
|
|
60
|
+
projectId: installation.projectId,
|
|
61
|
+
userId: installation.userId,
|
|
62
|
+
action,
|
|
63
|
+
input,
|
|
64
|
+
inputBytes,
|
|
65
|
+
role: request.role,
|
|
66
|
+
timeoutSeconds: declaration.timeoutSeconds,
|
|
67
|
+
tokenHash,
|
|
68
|
+
trigger: request.trigger,
|
|
69
|
+
});
|
|
70
|
+
void this.dispatcher.dispatch(execution, backendUrl, token, declaration.timeoutSeconds);
|
|
71
|
+
return { id: execution.id, status: plugin_action_execution_status_enum_1.PluginActionExecutionStatus.RUNNING };
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
exports.PluginActionStarterService = PluginActionStarterService;
|
|
75
|
+
exports.PluginActionStarterService = PluginActionStarterService = __decorate([
|
|
76
|
+
(0, common_1.Injectable)(),
|
|
77
|
+
__metadata("design:paramtypes", [action_input_validator_service_1.ActionInputValidatorService,
|
|
78
|
+
plugin_action_execution_service_1.PluginActionExecutionService,
|
|
79
|
+
plugin_action_dispatcher_service_1.PluginActionDispatcherService])
|
|
80
|
+
], PluginActionStarterService);
|
|
81
|
+
//# sourceMappingURL=plugin-action-starter.service.js.map
|
|
@@ -3,6 +3,17 @@ import { OwoxEventDispatcher } from '../../common/event-dispatcher/owox-event-di
|
|
|
3
3
|
import { PluginAuditEvent } from '../entities/plugin-audit-event.entity';
|
|
4
4
|
import { PluginAuditAction } from '../enums/plugin-audit-action.enum';
|
|
5
5
|
import { PluginPublicationScope } from '../enums/plugin-publication-scope.enum';
|
|
6
|
+
export interface PluginHistoryQuery {
|
|
7
|
+
readonly projectId: string;
|
|
8
|
+
readonly userId: string;
|
|
9
|
+
readonly installations: boolean;
|
|
10
|
+
readonly publications: boolean;
|
|
11
|
+
readonly changes: boolean;
|
|
12
|
+
readonly deploymentPluginIds: readonly string[];
|
|
13
|
+
readonly relevantPluginIds: readonly string[];
|
|
14
|
+
readonly afterId: string | null;
|
|
15
|
+
readonly take: number;
|
|
16
|
+
}
|
|
6
17
|
export interface PluginAuditRecord {
|
|
7
18
|
readonly pluginId: string;
|
|
8
19
|
readonly action: PluginAuditAction;
|
|
@@ -19,4 +30,6 @@ export declare class PluginAuditService {
|
|
|
19
30
|
private readonly logger;
|
|
20
31
|
constructor(repository: Repository<PluginAuditEvent>, eventDispatcher: OwoxEventDispatcher);
|
|
21
32
|
record(entry: PluginAuditRecord): Promise<void>;
|
|
33
|
+
exists(id: string): Promise<boolean>;
|
|
34
|
+
findHistory(query: PluginHistoryQuery): Promise<PluginAuditEvent[]>;
|
|
22
35
|
}
|
|
@@ -19,7 +19,20 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
19
19
|
const typeorm_2 = require("typeorm");
|
|
20
20
|
const owox_event_dispatcher_1 = require("../../common/event-dispatcher/owox-event-dispatcher");
|
|
21
21
|
const plugin_audit_event_entity_1 = require("../entities/plugin-audit-event.entity");
|
|
22
|
+
const plugin_audit_action_enum_1 = require("../enums/plugin-audit-action.enum");
|
|
23
|
+
const plugin_publication_scope_enum_1 = require("../enums/plugin-publication-scope.enum");
|
|
22
24
|
const plugin_lifecycle_event_1 = require("../events/plugin-lifecycle.event");
|
|
25
|
+
const INSTALLATION_ACTIONS = [
|
|
26
|
+
plugin_audit_action_enum_1.PluginAuditAction.INSTALL,
|
|
27
|
+
plugin_audit_action_enum_1.PluginAuditAction.RESTORE,
|
|
28
|
+
plugin_audit_action_enum_1.PluginAuditAction.UNINSTALL,
|
|
29
|
+
];
|
|
30
|
+
const PUBLICATION_ACTIONS = [plugin_audit_action_enum_1.PluginAuditAction.PUBLISH, plugin_audit_action_enum_1.PluginAuditAction.UNPUBLISH];
|
|
31
|
+
const CHANGE_ACTIONS = [
|
|
32
|
+
plugin_audit_action_enum_1.PluginAuditAction.UPDATE,
|
|
33
|
+
plugin_audit_action_enum_1.PluginAuditAction.SUSPEND,
|
|
34
|
+
plugin_audit_action_enum_1.PluginAuditAction.RESUME,
|
|
35
|
+
];
|
|
23
36
|
let PluginAuditService = PluginAuditService_1 = class PluginAuditService {
|
|
24
37
|
repository;
|
|
25
38
|
eventDispatcher;
|
|
@@ -53,6 +66,71 @@ let PluginAuditService = PluginAuditService_1 = class PluginAuditService {
|
|
|
53
66
|
this.logger.warn(`Audit event for plugin ${entry.pluginId} was not published: ${error instanceof Error ? error.message : String(error)}`);
|
|
54
67
|
}
|
|
55
68
|
}
|
|
69
|
+
exists(id) {
|
|
70
|
+
return this.repository.existsBy({ id });
|
|
71
|
+
}
|
|
72
|
+
findHistory(query) {
|
|
73
|
+
const builder = this.repository
|
|
74
|
+
.createQueryBuilder('event')
|
|
75
|
+
.where(new typeorm_2.Brackets(visible => {
|
|
76
|
+
if (query.installations) {
|
|
77
|
+
visible.orWhere(new typeorm_2.Brackets(own => own
|
|
78
|
+
.where('event.action IN (:...installationActions)', {
|
|
79
|
+
installationActions: INSTALLATION_ACTIONS,
|
|
80
|
+
})
|
|
81
|
+
.andWhere('event.projectId = :projectId')
|
|
82
|
+
.andWhere('event.userId = :userId')));
|
|
83
|
+
}
|
|
84
|
+
if (query.publications) {
|
|
85
|
+
visible.orWhere(new typeorm_2.Brackets(project => project
|
|
86
|
+
.where('event.action IN (:...publicationActions)')
|
|
87
|
+
.andWhere('event.authorityScope = :projectScope', {
|
|
88
|
+
projectScope: plugin_publication_scope_enum_1.PluginPublicationScope.PROJECT,
|
|
89
|
+
})
|
|
90
|
+
.andWhere('event.projectId = :projectId')));
|
|
91
|
+
visible.orWhere(new typeorm_2.Brackets(member => member
|
|
92
|
+
.where('event.action IN (:...publicationActions)')
|
|
93
|
+
.andWhere('event.authorityScope = :memberScope', {
|
|
94
|
+
memberScope: plugin_publication_scope_enum_1.PluginPublicationScope.MEMBER,
|
|
95
|
+
})
|
|
96
|
+
.andWhere('event.projectId = :projectId')
|
|
97
|
+
.andWhere('event.userId = :userId')));
|
|
98
|
+
if (query.deploymentPluginIds.length > 0) {
|
|
99
|
+
visible.orWhere(new typeorm_2.Brackets(deployment => deployment
|
|
100
|
+
.where('event.action IN (:...publicationActions)')
|
|
101
|
+
.andWhere('event.authorityScope = :deploymentScope', {
|
|
102
|
+
deploymentScope: plugin_publication_scope_enum_1.PluginPublicationScope.DEPLOYMENT,
|
|
103
|
+
})
|
|
104
|
+
.andWhere('event.pluginId IN (:...deploymentPluginIds)', {
|
|
105
|
+
deploymentPluginIds: query.deploymentPluginIds,
|
|
106
|
+
})));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (query.changes && query.relevantPluginIds.length > 0) {
|
|
110
|
+
visible.orWhere(new typeorm_2.Brackets(change => change
|
|
111
|
+
.where('event.action IN (:...changeActions)', { changeActions: CHANGE_ACTIONS })
|
|
112
|
+
.andWhere('event.pluginId IN (:...relevantPluginIds)', {
|
|
113
|
+
relevantPluginIds: query.relevantPluginIds,
|
|
114
|
+
})));
|
|
115
|
+
}
|
|
116
|
+
}))
|
|
117
|
+
.setParameters({
|
|
118
|
+
projectId: query.projectId,
|
|
119
|
+
userId: query.userId,
|
|
120
|
+
publicationActions: PUBLICATION_ACTIONS,
|
|
121
|
+
});
|
|
122
|
+
if (query.afterId) {
|
|
123
|
+
const anchor = '(SELECT anchor.createdAt FROM plugin_audit_event anchor WHERE anchor.id = :afterId)';
|
|
124
|
+
builder.andWhere(new typeorm_2.Brackets(after => after
|
|
125
|
+
.where(`event.createdAt < ${anchor}`)
|
|
126
|
+
.orWhere(new typeorm_2.Brackets(tie => tie.where(`event.createdAt = ${anchor}`).andWhere('event.id < :afterId')))), { afterId: query.afterId });
|
|
127
|
+
}
|
|
128
|
+
return builder
|
|
129
|
+
.orderBy('event.createdAt', 'DESC')
|
|
130
|
+
.addOrderBy('event.id', 'DESC')
|
|
131
|
+
.limit(query.take)
|
|
132
|
+
.getMany();
|
|
133
|
+
}
|
|
56
134
|
};
|
|
57
135
|
exports.PluginAuditService = PluginAuditService;
|
|
58
136
|
exports.PluginAuditService = PluginAuditService = PluginAuditService_1 = __decorate([
|
|
@@ -22,8 +22,12 @@ export declare class PluginPublicationService {
|
|
|
22
22
|
addToAudience(publicationId: string, projectIds: string[]): Promise<void>;
|
|
23
23
|
removeFromAudience(publicationId: string, projectIds?: string[]): Promise<void>;
|
|
24
24
|
findVisibleTo(projectId: string, userId: string): Promise<PluginPublication[]>;
|
|
25
|
+
findEverVisibleTo(projectId: string, userId: string): Promise<PluginPublication[]>;
|
|
26
|
+
private visibleTo;
|
|
27
|
+
findDeploymentPluginIdByRepo(projectId: string, owner: string, name: string): Promise<string | null>;
|
|
25
28
|
listManageable(scope: PluginPublicationScope, filters: {
|
|
26
29
|
projectId?: string;
|
|
27
30
|
userId?: string;
|
|
28
31
|
}): Promise<PluginPublication[]>;
|
|
32
|
+
private deploymentVisibleToProject;
|
|
29
33
|
}
|
|
@@ -18,6 +18,7 @@ const typeorm_1 = require("@nestjs/typeorm");
|
|
|
18
18
|
const typeorm_2 = require("typeorm");
|
|
19
19
|
const plugin_publication_project_entity_1 = require("../entities/plugin-publication-project.entity");
|
|
20
20
|
const plugin_publication_entity_1 = require("../entities/plugin-publication.entity");
|
|
21
|
+
const plugin_entity_1 = require("../entities/plugin.entity");
|
|
21
22
|
const plugin_publication_scope_enum_1 = require("../enums/plugin-publication-scope.enum");
|
|
22
23
|
let PluginPublicationService = class PluginPublicationService {
|
|
23
24
|
publications;
|
|
@@ -64,27 +65,15 @@ let PluginPublicationService = class PluginPublicationService {
|
|
|
64
65
|
await this.audiences.update(projectIds ? { publicationId, projectId: (0, typeorm_2.In)(projectIds) } : { publicationId }, { isActive: false });
|
|
65
66
|
}
|
|
66
67
|
findVisibleTo(projectId, userId) {
|
|
67
|
-
return this.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
return this.visibleTo(projectId, userId, true).getMany();
|
|
69
|
+
}
|
|
70
|
+
findEverVisibleTo(projectId, userId) {
|
|
71
|
+
return this.visibleTo(projectId, userId, false).getMany();
|
|
72
|
+
}
|
|
73
|
+
visibleTo(projectId, userId, activeOnly) {
|
|
74
|
+
const query = this.publications.createQueryBuilder('publication').where(new typeorm_2.Brackets(scopes => {
|
|
71
75
|
scopes
|
|
72
|
-
.where(
|
|
73
|
-
deployment
|
|
74
|
-
.where('publication.scope = :deploymentScope', {
|
|
75
|
-
deploymentScope: plugin_publication_scope_enum_1.PluginPublicationScope.DEPLOYMENT,
|
|
76
|
-
})
|
|
77
|
-
.andWhere(new typeorm_2.Brackets(audience => {
|
|
78
|
-
audience
|
|
79
|
-
.where('publication.allProjects = :isActive', { isActive: true })
|
|
80
|
-
.orWhere(`EXISTS (
|
|
81
|
-
SELECT 1 FROM plugin_publication_project audience_row
|
|
82
|
-
WHERE audience_row.publicationId = publication.id
|
|
83
|
-
AND audience_row.projectId = :projectId
|
|
84
|
-
AND audience_row.isActive = :isActive
|
|
85
|
-
)`);
|
|
86
|
-
}));
|
|
87
|
-
}))
|
|
76
|
+
.where(this.deploymentVisibleToProject(projectId, activeOnly))
|
|
88
77
|
.orWhere(new typeorm_2.Brackets(project => {
|
|
89
78
|
project
|
|
90
79
|
.where('publication.scope = :projectScope', {
|
|
@@ -100,9 +89,25 @@ let PluginPublicationService = class PluginPublicationService {
|
|
|
100
89
|
.andWhere('publication.projectId = :projectId')
|
|
101
90
|
.andWhere('publication.userId = :userId');
|
|
102
91
|
}));
|
|
103
|
-
}))
|
|
104
|
-
|
|
105
|
-
.
|
|
92
|
+
}));
|
|
93
|
+
if (activeOnly) {
|
|
94
|
+
query.andWhere('publication.isActive = :isActive', { isActive: true });
|
|
95
|
+
}
|
|
96
|
+
return query.setParameters({ projectId, userId });
|
|
97
|
+
}
|
|
98
|
+
async findDeploymentPluginIdByRepo(projectId, owner, name) {
|
|
99
|
+
const publication = await this.publications
|
|
100
|
+
.createQueryBuilder('publication')
|
|
101
|
+
.innerJoin(plugin_entity_1.Plugin, 'plugin', 'plugin.id = publication.pluginId')
|
|
102
|
+
.where('publication.isActive = :isActive', { isActive: true })
|
|
103
|
+
.andWhere(this.deploymentVisibleToProject(projectId))
|
|
104
|
+
.andWhere('LOWER(plugin.repoOwner) = :owner', { owner: owner.toLowerCase() })
|
|
105
|
+
.andWhere('LOWER(plugin.repoName) = :name', { name: name.toLowerCase() })
|
|
106
|
+
.andWhere('plugin.isPrivateRepo = :isPrivate', { isPrivate: false })
|
|
107
|
+
.orderBy('plugin.modifiedAt', 'DESC')
|
|
108
|
+
.addOrderBy('plugin.id', 'ASC')
|
|
109
|
+
.getOne();
|
|
110
|
+
return publication?.pluginId ?? null;
|
|
106
111
|
}
|
|
107
112
|
listManageable(scope, filters) {
|
|
108
113
|
return this.publications.findBy({
|
|
@@ -111,6 +116,29 @@ let PluginPublicationService = class PluginPublicationService {
|
|
|
111
116
|
...(filters.userId ? { userId: filters.userId } : {}),
|
|
112
117
|
});
|
|
113
118
|
}
|
|
119
|
+
deploymentVisibleToProject(projectId, activeAudienceOnly = true) {
|
|
120
|
+
const activeAudience = activeAudienceOnly
|
|
121
|
+
? 'AND audience_row.isActive = :deploymentAudienceActive'
|
|
122
|
+
: '';
|
|
123
|
+
return new typeorm_2.Brackets(deployment => {
|
|
124
|
+
deployment
|
|
125
|
+
.where('publication.scope = :deploymentScope', {
|
|
126
|
+
deploymentScope: plugin_publication_scope_enum_1.PluginPublicationScope.DEPLOYMENT,
|
|
127
|
+
})
|
|
128
|
+
.andWhere(new typeorm_2.Brackets(audience => {
|
|
129
|
+
audience
|
|
130
|
+
.where('publication.allProjects = :deploymentAllProjects', {
|
|
131
|
+
deploymentAllProjects: true,
|
|
132
|
+
})
|
|
133
|
+
.orWhere(`EXISTS (
|
|
134
|
+
SELECT 1 FROM plugin_publication_project audience_row
|
|
135
|
+
WHERE audience_row.publicationId = publication.id
|
|
136
|
+
AND audience_row.projectId = :deploymentProjectId
|
|
137
|
+
${activeAudience}
|
|
138
|
+
)`, { deploymentProjectId: projectId, deploymentAudienceActive: true });
|
|
139
|
+
}));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
114
142
|
};
|
|
115
143
|
exports.PluginPublicationService = PluginPublicationService;
|
|
116
144
|
exports.PluginPublicationService = PluginPublicationService = __decorate([
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { PluginRuntimeAuthorizerPort, PluginRuntimeIdentity } from '../../idp/ports/plugin-runtime-authorizer.port';
|
|
1
|
+
import { PluginExecutionIdentity, PluginRuntimeAuthorizerPort, PluginRuntimeIdentity } from '../../idp/ports/plugin-runtime-authorizer.port';
|
|
2
2
|
import { PluginInstallationLookupPort } from '../facades/plugin-installation-lookup.facade';
|
|
3
|
+
import { PluginActionExecutionService } from './plugin-action-execution.service';
|
|
3
4
|
export declare class PluginRuntimeAuthorizerService implements PluginRuntimeAuthorizerPort {
|
|
4
5
|
private readonly installations;
|
|
5
|
-
|
|
6
|
+
private readonly executions;
|
|
7
|
+
constructor(installations: PluginInstallationLookupPort, executions: PluginActionExecutionService);
|
|
6
8
|
assertActiveInstallation(identity: PluginRuntimeIdentity): Promise<void>;
|
|
9
|
+
resolveExecutionToken(token: string): Promise<PluginExecutionIdentity | null>;
|
|
7
10
|
}
|
|
@@ -16,27 +16,55 @@ exports.PluginRuntimeAuthorizerService = void 0;
|
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const idp_protocol_1 = require("@owox/idp-protocol");
|
|
18
18
|
const plugin_installation_lookup_facade_1 = require("../facades/plugin-installation-lookup.facade");
|
|
19
|
+
const plugin_host_errors_1 = require("../errors/plugin-host.errors");
|
|
20
|
+
const execution_token_util_1 = require("../utils/execution-token.util");
|
|
21
|
+
const plugin_action_execution_service_1 = require("./plugin-action-execution.service");
|
|
19
22
|
let PluginRuntimeAuthorizerService = class PluginRuntimeAuthorizerService {
|
|
20
23
|
installations;
|
|
21
|
-
|
|
24
|
+
executions;
|
|
25
|
+
constructor(installations, executions) {
|
|
22
26
|
this.installations = installations;
|
|
27
|
+
this.executions = executions;
|
|
23
28
|
}
|
|
24
29
|
async assertActiveInstallation(identity) {
|
|
25
30
|
const installation = await this.installations.findSnapshot(identity.installationId);
|
|
26
31
|
if (!installation ||
|
|
27
32
|
!installation.isActive ||
|
|
28
|
-
installation.isSuspended ||
|
|
29
33
|
installation.pluginId !== identity.pluginId ||
|
|
30
34
|
installation.projectId !== identity.projectId ||
|
|
31
35
|
installation.userId !== identity.userId) {
|
|
32
36
|
throw new idp_protocol_1.AuthorizationError('Plugin runtime access denied');
|
|
33
37
|
}
|
|
38
|
+
if (installation.isSuspended) {
|
|
39
|
+
throw new plugin_host_errors_1.PluginSuspendedError(installation.pluginId);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async resolveExecutionToken(token) {
|
|
43
|
+
if (!token) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const execution = await this.executions.findRunningByTokenHash((0, execution_token_util_1.hashExecutionToken)(token), new Date());
|
|
47
|
+
if (!execution) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const role = idp_protocol_1.RoleEnum.safeParse(execution.role);
|
|
51
|
+
if (!role.success) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
executionId: execution.id,
|
|
56
|
+
pluginId: execution.pluginId,
|
|
57
|
+
installationId: execution.installationId,
|
|
58
|
+
projectId: execution.projectId,
|
|
59
|
+
userId: execution.userId,
|
|
60
|
+
role: role.data,
|
|
61
|
+
};
|
|
34
62
|
}
|
|
35
63
|
};
|
|
36
64
|
exports.PluginRuntimeAuthorizerService = PluginRuntimeAuthorizerService;
|
|
37
65
|
exports.PluginRuntimeAuthorizerService = PluginRuntimeAuthorizerService = __decorate([
|
|
38
66
|
(0, common_1.Injectable)(),
|
|
39
67
|
__param(0, (0, common_1.Inject)(plugin_installation_lookup_facade_1.PLUGIN_INSTALLATION_LOOKUP)),
|
|
40
|
-
__metadata("design:paramtypes", [Object])
|
|
68
|
+
__metadata("design:paramtypes", [Object, plugin_action_execution_service_1.PluginActionExecutionService])
|
|
41
69
|
], PluginRuntimeAuthorizerService);
|
|
42
70
|
//# sourceMappingURL=plugin-runtime-authorizer.service.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DataSource, Repository } from 'typeorm';
|
|
2
2
|
import { PluginVersion } from '../entities/plugin-version.entity';
|
|
3
3
|
import { Plugin } from '../entities/plugin.entity';
|
|
4
|
-
import type { PluginCollectionDeclaration } from '../utils/plugin-manifest.util';
|
|
4
|
+
import type { PluginBackendDeclaration, PluginCollectionDeclaration } from '../utils/plugin-manifest.util';
|
|
5
5
|
import type { StoredCredentialRequirement } from '../../data-marts/credentials/credential.types';
|
|
6
6
|
export interface InsertPluginVersionInput {
|
|
7
7
|
readonly pluginId: string;
|
|
@@ -14,6 +14,7 @@ export interface InsertPluginVersionInput {
|
|
|
14
14
|
readonly deliveryUrl: string;
|
|
15
15
|
readonly collections: readonly PluginCollectionDeclaration[];
|
|
16
16
|
readonly credentialRequirements: readonly StoredCredentialRequirement[];
|
|
17
|
+
readonly backend: PluginBackendDeclaration | null;
|
|
17
18
|
readonly releasePublishedAt: Date | null;
|
|
18
19
|
}
|
|
19
20
|
export declare class PluginVersionService {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { StoredCredentialRequirement } from '../../data-marts/credentials/credential.types';
|
|
2
|
+
import { ReleaseRejectionCode } from '../enums/release-rejection-code.enum';
|
|
3
|
+
import { GithubRepoRef } from '../utils/github-repo-locator.util';
|
|
4
|
+
import { PluginManifest } from '../utils/plugin-manifest.util';
|
|
5
|
+
import { ActionInputValidatorService } from './action-input-validator.service';
|
|
6
|
+
import { ExternalCredentialDefinitionSyncService } from './external-credential-definition-sync.service';
|
|
7
|
+
import { GithubApiService } from './github-api.service';
|
|
8
|
+
import { PluginVersionService } from './plugin-version.service';
|
|
9
|
+
import { RemoteUrlValidatorService } from './remote-url-validator.service';
|
|
10
|
+
export interface ReleaseCandidate {
|
|
11
|
+
readonly pluginId: string;
|
|
12
|
+
readonly ref: GithubRepoRef;
|
|
13
|
+
readonly commitSha: string;
|
|
14
|
+
readonly semver: string | null;
|
|
15
|
+
}
|
|
16
|
+
export interface ReleaseCandidateIssue {
|
|
17
|
+
readonly code: ReleaseRejectionCode;
|
|
18
|
+
readonly detail: string;
|
|
19
|
+
}
|
|
20
|
+
type Rejection = {
|
|
21
|
+
readonly ok: false;
|
|
22
|
+
} & ReleaseCandidateIssue;
|
|
23
|
+
export type ReleaseCandidateVerdict = {
|
|
24
|
+
readonly ok: true;
|
|
25
|
+
readonly manifest: PluginManifest;
|
|
26
|
+
readonly credentialRequirements: readonly StoredCredentialRequirement[];
|
|
27
|
+
} | Rejection;
|
|
28
|
+
export interface ReleaseCandidateReport {
|
|
29
|
+
readonly issues: readonly ReleaseCandidateIssue[];
|
|
30
|
+
readonly baselineSemver: string | null;
|
|
31
|
+
readonly collectionsEvaluated: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare class ReleaseCandidateRulesService {
|
|
34
|
+
private readonly githubApi;
|
|
35
|
+
private readonly remoteUrlValidator;
|
|
36
|
+
private readonly versionService;
|
|
37
|
+
private readonly inputValidator;
|
|
38
|
+
private readonly externalCredentialDefinitions?;
|
|
39
|
+
constructor(githubApi: GithubApiService, remoteUrlValidator: RemoteUrlValidatorService, versionService: PluginVersionService, inputValidator: ActionInputValidatorService, externalCredentialDefinitions?: ExternalCredentialDefinitionSyncService | undefined);
|
|
40
|
+
firstFailure(candidate: ReleaseCandidate): Promise<ReleaseCandidateVerdict>;
|
|
41
|
+
collectAll(candidate: ReleaseCandidate): Promise<ReleaseCandidateReport>;
|
|
42
|
+
private fetchManifest;
|
|
43
|
+
private findBaseline;
|
|
44
|
+
private checkCollections;
|
|
45
|
+
private checkActions;
|
|
46
|
+
private checkBackendOrigin;
|
|
47
|
+
private lineIssue;
|
|
48
|
+
private checkBackendUrl;
|
|
49
|
+
private resolveCredentialRequirements;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ReleaseCandidateRulesService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const internal_helpers_1 = require("@owox/internal-helpers");
|
|
18
|
+
const release_rejection_code_enum_1 = require("../enums/release-rejection-code.enum");
|
|
19
|
+
const plugin_manifest_util_1 = require("../utils/plugin-manifest.util");
|
|
20
|
+
const semver_util_1 = require("../utils/semver.util");
|
|
21
|
+
const action_input_validator_service_1 = require("./action-input-validator.service");
|
|
22
|
+
const external_credential_definition_sync_service_1 = require("./external-credential-definition-sync.service");
|
|
23
|
+
const github_api_service_1 = require("./github-api.service");
|
|
24
|
+
const plugin_version_service_1 = require("./plugin-version.service");
|
|
25
|
+
const remote_url_validator_service_1 = require("./remote-url-validator.service");
|
|
26
|
+
let ReleaseCandidateRulesService = class ReleaseCandidateRulesService {
|
|
27
|
+
githubApi;
|
|
28
|
+
remoteUrlValidator;
|
|
29
|
+
versionService;
|
|
30
|
+
inputValidator;
|
|
31
|
+
externalCredentialDefinitions;
|
|
32
|
+
constructor(githubApi, remoteUrlValidator, versionService, inputValidator, externalCredentialDefinitions) {
|
|
33
|
+
this.githubApi = githubApi;
|
|
34
|
+
this.remoteUrlValidator = remoteUrlValidator;
|
|
35
|
+
this.versionService = versionService;
|
|
36
|
+
this.inputValidator = inputValidator;
|
|
37
|
+
this.externalCredentialDefinitions = externalCredentialDefinitions;
|
|
38
|
+
}
|
|
39
|
+
async firstFailure(candidate) {
|
|
40
|
+
const parsed = await this.fetchManifest(candidate);
|
|
41
|
+
if (!parsed.ok)
|
|
42
|
+
return parsed;
|
|
43
|
+
const { manifest } = parsed;
|
|
44
|
+
const baseline = await this.findBaseline(candidate);
|
|
45
|
+
const collections = baseline && this.checkCollections(baseline, manifest);
|
|
46
|
+
if (collections)
|
|
47
|
+
return { ok: false, ...collections };
|
|
48
|
+
const actions = baseline && this.checkActions(baseline, manifest);
|
|
49
|
+
if (actions)
|
|
50
|
+
return { ok: false, ...actions };
|
|
51
|
+
const backendOrigin = baseline && this.checkBackendOrigin(baseline, manifest);
|
|
52
|
+
if (backendOrigin)
|
|
53
|
+
return { ok: false, ...backendOrigin };
|
|
54
|
+
const delivery = await this.remoteUrlValidator.validate(manifest.delivery.url);
|
|
55
|
+
if (!delivery.ok)
|
|
56
|
+
return delivery;
|
|
57
|
+
const backendUrl = await this.checkBackendUrl(manifest);
|
|
58
|
+
if (backendUrl)
|
|
59
|
+
return { ok: false, ...backendUrl };
|
|
60
|
+
const credentials = await this.resolveCredentialRequirements(manifest, 'resolve');
|
|
61
|
+
if (!credentials.ok)
|
|
62
|
+
return credentials;
|
|
63
|
+
return { ok: true, manifest, credentialRequirements: credentials.requirements };
|
|
64
|
+
}
|
|
65
|
+
async collectAll(candidate) {
|
|
66
|
+
const parsed = await this.fetchManifest(candidate);
|
|
67
|
+
const baseline = await this.findBaseline(candidate);
|
|
68
|
+
const baselineSemver = baseline?.semver ?? null;
|
|
69
|
+
if (!parsed.ok) {
|
|
70
|
+
return {
|
|
71
|
+
issues: [{ code: parsed.code, detail: parsed.detail }],
|
|
72
|
+
baselineSemver,
|
|
73
|
+
collectionsEvaluated: false,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
const { manifest } = parsed;
|
|
77
|
+
const issues = [];
|
|
78
|
+
const collections = baseline && this.checkCollections(baseline, manifest);
|
|
79
|
+
if (collections)
|
|
80
|
+
issues.push(collections);
|
|
81
|
+
const actions = baseline && this.checkActions(baseline, manifest);
|
|
82
|
+
if (actions)
|
|
83
|
+
issues.push(actions);
|
|
84
|
+
const backendOrigin = baseline && this.checkBackendOrigin(baseline, manifest);
|
|
85
|
+
if (backendOrigin)
|
|
86
|
+
issues.push(backendOrigin);
|
|
87
|
+
const delivery = await this.remoteUrlValidator.validate(manifest.delivery.url);
|
|
88
|
+
if (!delivery.ok)
|
|
89
|
+
issues.push({ code: delivery.code, detail: delivery.detail });
|
|
90
|
+
const backendUrl = await this.checkBackendUrl(manifest);
|
|
91
|
+
if (backendUrl)
|
|
92
|
+
issues.push(backendUrl);
|
|
93
|
+
const credentials = await this.resolveCredentialRequirements(manifest, 'preview');
|
|
94
|
+
if (!credentials.ok)
|
|
95
|
+
issues.push({ code: credentials.code, detail: credentials.detail });
|
|
96
|
+
return {
|
|
97
|
+
issues,
|
|
98
|
+
baselineSemver,
|
|
99
|
+
collectionsEvaluated: baseline !== undefined,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async fetchManifest({ ref, commitSha }) {
|
|
103
|
+
const parsed = (0, plugin_manifest_util_1.parsePluginManifest)(await this.githubApi.getFileAtCommit(ref, 'plugin.json', commitSha));
|
|
104
|
+
if (!parsed.ok)
|
|
105
|
+
return parsed;
|
|
106
|
+
const refusal = await this.inputValidator.compile((0, plugin_manifest_util_1.listActionInputSchemas)(parsed.manifest.backend));
|
|
107
|
+
return refusal
|
|
108
|
+
? { ok: false, code: release_rejection_code_enum_1.ReleaseRejectionCode.ACTION_INPUT_UNSUPPORTED, detail: refusal }
|
|
109
|
+
: parsed;
|
|
110
|
+
}
|
|
111
|
+
async findBaseline({ pluginId, semver, }) {
|
|
112
|
+
if (semver === null)
|
|
113
|
+
return undefined;
|
|
114
|
+
return (await this.versionService.findAllByPluginId(pluginId))
|
|
115
|
+
.filter(version => (0, semver_util_1.sameCompatibilityLine)(version.semver, semver))
|
|
116
|
+
.reduce((highest, version) => (!highest || (0, semver_util_1.compareSemver)(version.semver, highest.semver) > 0 ? version : highest), undefined);
|
|
117
|
+
}
|
|
118
|
+
checkCollections(baseline, manifest) {
|
|
119
|
+
const incompatibility = (0, plugin_manifest_util_1.findIncompatibleCollectionChange)(baseline.collections ?? [], manifest.collections);
|
|
120
|
+
return incompatibility
|
|
121
|
+
? this.lineIssue(release_rejection_code_enum_1.ReleaseRejectionCode.COLLECTIONS_INCOMPATIBLE, incompatibility, baseline)
|
|
122
|
+
: null;
|
|
123
|
+
}
|
|
124
|
+
checkActions(baseline, manifest) {
|
|
125
|
+
const incompatibility = (0, plugin_manifest_util_1.findIncompatibleActionChange)(baseline.backend, manifest.backend);
|
|
126
|
+
return incompatibility
|
|
127
|
+
? this.lineIssue(release_rejection_code_enum_1.ReleaseRejectionCode.ACTIONS_INCOMPATIBLE, incompatibility, baseline)
|
|
128
|
+
: null;
|
|
129
|
+
}
|
|
130
|
+
checkBackendOrigin(baseline, manifest) {
|
|
131
|
+
if (!manifest.backend)
|
|
132
|
+
return null;
|
|
133
|
+
const origin = new URL((0, plugin_manifest_util_1.resolveBackendUrl)(manifest.backend, manifest.delivery.url)).origin;
|
|
134
|
+
const baselineOrigin = baseline.backend && new URL((0, plugin_manifest_util_1.resolveBackendUrl)(baseline.backend, baseline.deliveryUrl)).origin;
|
|
135
|
+
if (origin === baselineOrigin)
|
|
136
|
+
return null;
|
|
137
|
+
const change = baselineOrigin
|
|
138
|
+
? `The backend cannot move from ${baselineOrigin} to ${origin}`
|
|
139
|
+
: `A backend on ${origin} cannot be added`;
|
|
140
|
+
return this.lineIssue(release_rejection_code_enum_1.ReleaseRejectionCode.BACKEND_ORIGIN_CHANGED, change, baseline);
|
|
141
|
+
}
|
|
142
|
+
lineIssue(code, incompatibility, baseline) {
|
|
143
|
+
const escape = (0, semver_util_1.majorOf)(baseline.semver) === 0
|
|
144
|
+
? 'bump the minor version to ship this breaking change while below 1.0.0'
|
|
145
|
+
: 'publish a new major version to ship this breaking change';
|
|
146
|
+
return {
|
|
147
|
+
code,
|
|
148
|
+
detail: `${incompatibility} within the ${baseline.semver} compatibility line; ${escape}`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async checkBackendUrl(manifest) {
|
|
152
|
+
if (!manifest.backend)
|
|
153
|
+
return null;
|
|
154
|
+
const checked = await this.remoteUrlValidator.checkPublicHttps((0, plugin_manifest_util_1.resolveBackendUrl)(manifest.backend, manifest.delivery.url));
|
|
155
|
+
return checked.ok ? null : { code: checked.code, detail: `backend.url: ${checked.detail}` };
|
|
156
|
+
}
|
|
157
|
+
async resolveCredentialRequirements(manifest, mode) {
|
|
158
|
+
if (!manifest.credentials.some(externalLocator)) {
|
|
159
|
+
return { ok: true, requirements: manifest.credentials };
|
|
160
|
+
}
|
|
161
|
+
if (!this.externalCredentialDefinitions) {
|
|
162
|
+
throw new Error('External Credential definitions are not available');
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
if (mode === 'preview') {
|
|
166
|
+
await this.externalCredentialDefinitions.previewRequirements(manifest.credentials);
|
|
167
|
+
return { ok: true, requirements: manifest.credentials };
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
ok: true,
|
|
171
|
+
requirements: await this.externalCredentialDefinitions.resolveRequirements(manifest.credentials),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (!(error instanceof external_credential_definition_sync_service_1.ExternalCredentialRequirementError))
|
|
176
|
+
throw error;
|
|
177
|
+
return {
|
|
178
|
+
ok: false,
|
|
179
|
+
code: release_rejection_code_enum_1.ReleaseRejectionCode.MANIFEST_SCHEMA,
|
|
180
|
+
detail: (0, internal_helpers_1.castError)(error).message,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
exports.ReleaseCandidateRulesService = ReleaseCandidateRulesService;
|
|
186
|
+
exports.ReleaseCandidateRulesService = ReleaseCandidateRulesService = __decorate([
|
|
187
|
+
(0, common_1.Injectable)(),
|
|
188
|
+
__param(4, (0, common_1.Optional)()),
|
|
189
|
+
__metadata("design:paramtypes", [github_api_service_1.GithubApiService,
|
|
190
|
+
remote_url_validator_service_1.RemoteUrlValidatorService,
|
|
191
|
+
plugin_version_service_1.PluginVersionService,
|
|
192
|
+
action_input_validator_service_1.ActionInputValidatorService,
|
|
193
|
+
external_credential_definition_sync_service_1.ExternalCredentialDefinitionSyncService])
|
|
194
|
+
], ReleaseCandidateRulesService);
|
|
195
|
+
function externalLocator(requirement) {
|
|
196
|
+
return (typeof requirement === 'string' ? requirement : requirement.id).startsWith('@');
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=release-candidate-rules.service.js.map
|