@owox/backend 0.38.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.
Files changed (179) hide show
  1. package/dist/src/common/helpers/read-bounded-body.helper.d.ts +1 -0
  2. package/dist/src/common/helpers/read-bounded-body.helper.js +28 -0
  3. package/dist/src/common/scheduler/system-tasks/system-trigger-type.d.ts +3 -1
  4. package/dist/src/common/scheduler/system-tasks/system-trigger-type.js +2 -0
  5. package/dist/src/config/data-source-options.config.d.ts +4 -3
  6. package/dist/src/config/data-source-options.config.js +10 -3
  7. package/dist/src/config/plugin-collections-body-parser.config.js +3 -0
  8. package/dist/src/data-marts/credentials/credential.types.d.ts +26 -2
  9. package/dist/src/data-marts/credentials/credential.types.js +18 -6
  10. package/dist/src/data-marts/credentials/dto/credential-api.dto.d.ts +5 -1
  11. package/dist/src/data-marts/credentials/dto/credential-api.dto.js +21 -0
  12. package/dist/src/data-marts/credentials/dto/credential.dto.d.ts +2 -1
  13. package/dist/src/data-marts/credentials/entities/credential.entity.d.ts +2 -1
  14. package/dist/src/data-marts/credentials/entities/credential.entity.js +5 -0
  15. package/dist/src/data-marts/credentials/facades/credential-consumer-binding.facade.impl.js +6 -1
  16. package/dist/src/data-marts/credentials/mappers/credential.mapper.js +2 -0
  17. package/dist/src/data-marts/credentials/services/builtin-credential-definitions.js +8 -0
  18. package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.d.ts +4 -0
  19. package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.js +36 -17
  20. package/dist/src/data-marts/credentials/services/credential-fetch.service.d.ts +8 -0
  21. package/dist/src/data-marts/credentials/services/credential-fetch.service.js +115 -46
  22. package/dist/src/data-marts/credentials/services/credential-validation-probe.service.d.ts +3 -1
  23. package/dist/src/data-marts/credentials/services/credential-validation-probe.service.js +10 -2
  24. package/dist/src/data-marts/credentials/services/credential.service.d.ts +4 -0
  25. package/dist/src/data-marts/credentials/services/credential.service.js +36 -0
  26. package/dist/src/data-marts/credentials/services/google-service-account-key.d.ts +6 -0
  27. package/dist/src/data-marts/credentials/services/google-service-account-key.js +46 -0
  28. package/dist/src/data-marts/credentials/services/google-service-account-token.service.d.ts +25 -0
  29. package/dist/src/data-marts/credentials/services/google-service-account-token.service.js +177 -0
  30. package/dist/src/data-marts/credentials/use-cases/create-credential.service.d.ts +1 -0
  31. package/dist/src/data-marts/credentials/use-cases/create-credential.service.js +10 -2
  32. package/dist/src/data-marts/credentials/use-cases/update-credential.service.d.ts +1 -0
  33. package/dist/src/data-marts/credentials/use-cases/update-credential.service.js +28 -4
  34. package/dist/src/data-marts/credentials/use-cases/validate-credential.service.js +2 -5
  35. package/dist/src/data-marts/data-marts.module.js +4 -0
  36. package/dist/src/data-marts/data-storage-types/snowflake/adapters/snowflake-api.adapter.js +1 -0
  37. package/dist/src/data-marts/dto/presentation/run-data-mart-request-api.dto.js +4 -2
  38. package/dist/src/data-marts/services/connector/backfill-segment.d.ts +22 -0
  39. package/dist/src/data-marts/services/connector/backfill-segment.js +91 -0
  40. package/dist/src/data-marts/services/connector/connector-execution.service.d.ts +1 -0
  41. package/dist/src/data-marts/services/connector/connector-execution.service.js +3 -0
  42. package/dist/src/data-marts/services/connector/connector-executor.service.d.ts +4 -1
  43. package/dist/src/data-marts/services/connector/connector-executor.service.js +107 -23
  44. package/dist/src/data-marts/services/connector/connector-run.service.d.ts +3 -0
  45. package/dist/src/data-marts/services/connector/connector-run.service.js +98 -4
  46. package/dist/src/data-marts/services/data-mart-run.service.d.ts +1 -0
  47. package/dist/src/data-marts/services/data-mart-run.service.js +9 -0
  48. package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.d.ts +14 -0
  49. package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.js +45 -0
  50. package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.d.ts +4 -0
  51. package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.js +46 -1
  52. package/dist/src/data-marts/utils/manual-backfill-range.d.ts +52 -0
  53. package/dist/src/data-marts/utils/manual-backfill-range.js +110 -8
  54. package/dist/src/ee/mcp/instructions/mcp-system-instructions.d.ts +1 -1
  55. package/dist/src/ee/mcp/instructions/mcp-system-instructions.js +1 -0
  56. package/dist/src/idp/decorators/auth-context.decorator.js +1 -0
  57. package/dist/src/idp/guards/idp.guard.d.ts +3 -0
  58. package/dist/src/idp/guards/idp.guard.js +38 -8
  59. package/dist/src/idp/oauth/controllers/oauth-authorization.controller.js +8 -6
  60. package/dist/src/idp/oauth/mcp-client-integration.d.ts +1 -0
  61. package/dist/src/idp/oauth/mcp-client-integration.js +15 -0
  62. package/dist/src/idp/ports/plugin-runtime-authorizer.port.d.ts +6 -0
  63. package/dist/src/idp/types/auth.types.d.ts +1 -0
  64. package/dist/src/migrations/1790900000000-add-plugin-version-backend.d.ts +6 -0
  65. package/dist/src/migrations/1790900000000-add-plugin-version-backend.js +21 -0
  66. package/dist/src/migrations/1790900000001-create-plugin-action-execution.d.ts +6 -0
  67. package/dist/src/migrations/1790900000001-create-plugin-action-execution.js +77 -0
  68. package/dist/src/migrations/1791000000000-add-credential-public-metadata.d.ts +6 -0
  69. package/dist/src/migrations/1791000000000-add-credential-public-metadata.js +23 -0
  70. package/dist/src/plugin-host/collections/dto/domain/plugin-collection.types.d.ts +1 -0
  71. package/dist/src/plugin-host/collections/errors/plugin-collection.errors.d.ts +6 -0
  72. package/dist/src/plugin-host/collections/errors/plugin-collection.errors.js +19 -1
  73. package/dist/src/plugin-host/collections/services/plugin-collection-declaration.service.js +3 -3
  74. package/dist/src/plugin-host/collections/use-cases/put-plugin-collection-document.service.js +7 -0
  75. package/dist/src/plugin-host/constants/plugin-action-limits.d.ts +34 -0
  76. package/dist/src/plugin-host/constants/plugin-action-limits.js +51 -0
  77. package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.d.ts +20 -0
  78. package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.js +123 -0
  79. package/dist/src/plugin-host/controllers/plugin-credential-runtime.controller.js +11 -19
  80. package/dist/src/plugin-host/controllers/plugin-history.controller.d.ts +10 -0
  81. package/dist/src/plugin-host/controllers/plugin-history.controller.js +57 -0
  82. package/dist/src/plugin-host/controllers/plugin-release-check.controller.d.ts +10 -0
  83. package/dist/src/plugin-host/controllers/plugin-release-check.controller.js +58 -0
  84. package/dist/src/plugin-host/dto/domain/check-plugin-release.command.d.ts +22 -0
  85. package/dist/src/plugin-host/dto/domain/check-plugin-release.command.js +17 -0
  86. package/dist/src/plugin-host/dto/domain/list-plugin-history.command.d.ts +10 -0
  87. package/dist/src/plugin-host/dto/domain/list-plugin-history.command.js +18 -0
  88. package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.d.ts +23 -0
  89. package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.js +44 -0
  90. package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.d.ts +36 -0
  91. package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.js +3 -0
  92. package/dist/src/plugin-host/dto/domain/plugin-history.dto.d.ts +29 -0
  93. package/dist/src/plugin-host/dto/domain/plugin-history.dto.js +3 -0
  94. package/dist/src/plugin-host/dto/domain/plugin-view.dto.d.ts +1 -0
  95. package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.d.ts +44 -0
  96. package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.js +208 -0
  97. package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.d.ts +2 -0
  98. package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.js +7 -0
  99. package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.d.ts +29 -0
  100. package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.js +148 -0
  101. package/dist/src/plugin-host/dto/presentation/publication-api.dto.d.ts +17 -0
  102. package/dist/src/plugin-host/dto/presentation/publication-api.dto.js +95 -1
  103. package/dist/src/plugin-host/entities/plugin-action-execution.entity.d.ts +24 -0
  104. package/dist/src/plugin-host/entities/plugin-action-execution.entity.js +136 -0
  105. package/dist/src/plugin-host/entities/plugin-version.entity.d.ts +2 -1
  106. package/dist/src/plugin-host/entities/plugin-version.entity.js +5 -0
  107. package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.d.ts +9 -0
  108. package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.js +22 -0
  109. package/dist/src/plugin-host/enums/release-rejection-code.enum.d.ts +3 -0
  110. package/dist/src/plugin-host/enums/release-rejection-code.enum.js +6 -0
  111. package/dist/src/plugin-host/errors/plugin-action.errors.d.ts +45 -0
  112. package/dist/src/plugin-host/errors/plugin-action.errors.js +70 -0
  113. package/dist/src/plugin-host/errors/plugin-host.errors.d.ts +6 -0
  114. package/dist/src/plugin-host/errors/plugin-host.errors.js +10 -1
  115. package/dist/src/plugin-host/filters/plugin-host-exception.filter.js +2 -2
  116. package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.d.ts +3 -0
  117. package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.js +22 -0
  118. package/dist/src/plugin-host/mappers/plugin-presentation.mapper.d.ts +16 -1
  119. package/dist/src/plugin-host/mappers/plugin-presentation.mapper.js +80 -1
  120. package/dist/src/plugin-host/plugin-host.module.js +32 -0
  121. package/dist/src/plugin-host/services/action-input-validator.service.d.ts +23 -0
  122. package/dist/src/plugin-host/services/action-input-validator.service.js +277 -0
  123. package/dist/src/plugin-host/services/external-credential-definition-sync.service.d.ts +3 -0
  124. package/dist/src/plugin-host/services/external-credential-definition-sync.service.js +47 -15
  125. package/dist/src/plugin-host/services/plugin-action-dispatcher.service.d.ts +13 -0
  126. package/dist/src/plugin-host/services/plugin-action-dispatcher.service.js +140 -0
  127. package/dist/src/plugin-host/services/plugin-action-execution.service.d.ts +69 -0
  128. package/dist/src/plugin-host/services/plugin-action-execution.service.js +239 -0
  129. package/dist/src/plugin-host/services/plugin-action-starter.service.d.ts +22 -0
  130. package/dist/src/plugin-host/services/plugin-action-starter.service.js +81 -0
  131. package/dist/src/plugin-host/services/plugin-audit.service.d.ts +13 -0
  132. package/dist/src/plugin-host/services/plugin-audit.service.js +78 -0
  133. package/dist/src/plugin-host/services/plugin-publication.service.d.ts +2 -0
  134. package/dist/src/plugin-host/services/plugin-publication.service.js +18 -10
  135. package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.d.ts +5 -2
  136. package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.js +31 -3
  137. package/dist/src/plugin-host/services/plugin-version.service.d.ts +2 -1
  138. package/dist/src/plugin-host/services/release-candidate-rules.service.d.ts +51 -0
  139. package/dist/src/plugin-host/services/release-candidate-rules.service.js +198 -0
  140. package/dist/src/plugin-host/services/remote-url-validator.service.d.ts +7 -0
  141. package/dist/src/plugin-host/services/remote-url-validator.service.js +4 -0
  142. package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.d.ts +14 -0
  143. package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.js +50 -0
  144. package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.d.ts +8 -0
  145. package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.js +39 -0
  146. package/dist/src/plugin-host/use-cases/check-plugin-release.service.d.ts +22 -0
  147. package/dist/src/plugin-host/use-cases/check-plugin-release.service.js +152 -0
  148. package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.d.ts +14 -0
  149. package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.js +85 -0
  150. package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.d.ts +9 -0
  151. package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.js +67 -0
  152. package/dist/src/plugin-host/use-cases/get-plugin-installation-entry.service.js +2 -7
  153. package/dist/src/plugin-host/use-cases/install-plugin.service.js +4 -0
  154. package/dist/src/plugin-host/use-cases/list-plugin-history.service.d.ts +25 -0
  155. package/dist/src/plugin-host/use-cases/list-plugin-history.service.js +147 -0
  156. package/dist/src/plugin-host/use-cases/plugin-publisher-access.d.ts +5 -0
  157. package/dist/src/plugin-host/use-cases/plugin-publisher-access.js +28 -0
  158. package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.d.ts +12 -0
  159. package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.js +64 -0
  160. package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.d.ts +3 -5
  161. package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.js +15 -59
  162. package/dist/src/plugin-host/use-cases/uninstall-plugin.service.js +3 -1
  163. package/dist/src/plugin-host/use-cases/update-plugin.service.d.ts +0 -1
  164. package/dist/src/plugin-host/use-cases/update-plugin.service.js +3 -25
  165. package/dist/src/plugin-host/utils/action-input-schema.util.d.ts +14 -0
  166. package/dist/src/plugin-host/utils/action-input-schema.util.js +133 -0
  167. package/dist/src/plugin-host/utils/credential-handles.util.d.ts +3 -0
  168. package/dist/src/plugin-host/utils/credential-handles.util.js +13 -0
  169. package/dist/src/plugin-host/utils/execution-token.util.d.ts +5 -0
  170. package/dist/src/plugin-host/utils/execution-token.util.js +13 -0
  171. package/dist/src/plugin-host/utils/json-shape.util.d.ts +1 -0
  172. package/dist/src/plugin-host/utils/json-shape.util.js +21 -0
  173. package/dist/src/plugin-host/utils/plugin-action-outcome.util.d.ts +10 -0
  174. package/dist/src/plugin-host/utils/plugin-action-outcome.util.js +67 -0
  175. package/dist/src/plugin-host/utils/plugin-manifest.util.d.ts +121 -0
  176. package/dist/src/plugin-host/utils/plugin-manifest.util.js +111 -1
  177. package/dist/src/plugin-host/utils/request-abort-signal.util.d.ts +5 -0
  178. package/dist/src/plugin-host/utils/request-abort-signal.util.js +19 -0
  179. package/package.json +10 -8
@@ -15,6 +15,7 @@ const data_marts_module_1 = require("../data-marts/data-marts.module");
15
15
  const plugin_collections_data_source_options_config_1 = require("../config/plugin-collections-data-source-options.config");
16
16
  const plugin_runtime_authorizer_port_1 = require("../idp/ports/plugin-runtime-authorizer.port");
17
17
  const plugin_host_config_1 = require("./config/plugin-host.config");
18
+ const plugin_action_execution_entity_1 = require("./entities/plugin-action-execution.entity");
18
19
  const plugin_audit_event_entity_1 = require("./entities/plugin-audit-event.entity");
19
20
  const plugin_installation_entity_1 = require("./entities/plugin-installation.entity");
20
21
  const plugin_publication_project_entity_1 = require("./entities/plugin-publication-project.entity");
@@ -23,15 +24,22 @@ const plugin_version_entity_1 = require("./entities/plugin-version.entity");
23
24
  const plugin_entity_1 = require("./entities/plugin.entity");
24
25
  const plugin_admin_controller_1 = require("./controllers/plugin-admin.controller");
25
26
  const plugin_gallery_controller_1 = require("./controllers/plugin-gallery.controller");
27
+ const plugin_history_controller_1 = require("./controllers/plugin-history.controller");
26
28
  const plugin_installations_controller_1 = require("./controllers/plugin-installations.controller");
29
+ const plugin_release_check_controller_1 = require("./controllers/plugin-release-check.controller");
27
30
  const plugin_publications_controller_1 = require("./controllers/plugin-publications.controller");
28
31
  const plugin_credential_runtime_controller_1 = require("./controllers/plugin-credential-runtime.controller");
32
+ const plugin_action_runtime_controller_1 = require("./controllers/plugin-action-runtime.controller");
29
33
  const credential_definitions_github_controller_1 = require("./controllers/credential-definitions-github.controller");
30
34
  const github_api_service_1 = require("./services/github-api.service");
31
35
  const external_credential_definition_sync_service_1 = require("./services/external-credential-definition-sync.service");
32
36
  const github_auth_service_1 = require("./services/github-auth.service");
33
37
  const plugin_installation_lookup_facade_1 = require("./facades/plugin-installation-lookup.facade");
34
38
  const plugin_installation_lookup_facade_impl_1 = require("./facades/plugin-installation-lookup.facade.impl");
39
+ const action_input_validator_service_1 = require("./services/action-input-validator.service");
40
+ const plugin_action_dispatcher_service_1 = require("./services/plugin-action-dispatcher.service");
41
+ const plugin_action_execution_service_1 = require("./services/plugin-action-execution.service");
42
+ const plugin_action_starter_service_1 = require("./services/plugin-action-starter.service");
35
43
  const plugin_audit_service_1 = require("./services/plugin-audit.service");
36
44
  const plugin_installation_service_1 = require("./services/plugin-installation.service");
37
45
  const plugin_credential_binding_reconciliation_service_1 = require("./services/plugin-credential-binding-reconciliation.service");
@@ -42,15 +50,22 @@ const plugin_service_1 = require("./services/plugin.service");
42
50
  const publication_authorization_service_1 = require("./services/publication-authorization.service");
43
51
  const plugin_runtime_authorizer_service_1 = require("./services/plugin-runtime-authorizer.service");
44
52
  const remote_url_validator_service_1 = require("./services/remote-url-validator.service");
53
+ const release_candidate_rules_service_1 = require("./services/release-candidate-rules.service");
45
54
  const plugin_presentation_mapper_1 = require("./mappers/plugin-presentation.mapper");
46
55
  const find_plugin_by_repository_service_1 = require("./use-cases/find-plugin-by-repository.service");
47
56
  const get_plugin_details_service_1 = require("./use-cases/get-plugin-details.service");
48
57
  const get_plugin_installation_entry_service_1 = require("./use-cases/get-plugin-installation-entry.service");
49
58
  const install_plugin_service_1 = require("./use-cases/install-plugin.service");
50
59
  const list_installations_service_1 = require("./use-cases/list-installations.service");
60
+ const list_plugin_history_service_1 = require("./use-cases/list-plugin-history.service");
51
61
  const uninstall_plugin_service_1 = require("./use-cases/uninstall-plugin.service");
52
62
  const update_plugin_service_1 = require("./use-cases/update-plugin.service");
63
+ const check_plugin_release_service_1 = require("./use-cases/check-plugin-release.service");
53
64
  const issue_plugin_runtime_token_service_1 = require("./use-cases/issue-plugin-runtime-token.service");
65
+ const start_plugin_action_execution_service_1 = require("./use-cases/start-plugin-action-execution.service");
66
+ const cancel_plugin_action_execution_service_1 = require("./use-cases/cancel-plugin-action-execution.service");
67
+ const get_current_plugin_action_execution_service_1 = require("./use-cases/get-current-plugin-action-execution.service");
68
+ const get_plugin_action_execution_service_1 = require("./use-cases/get-plugin-action-execution.service");
54
69
  const get_plugin_gallery_service_1 = require("./use-cases/get-plugin-gallery.service");
55
70
  const list_publications_service_1 = require("./use-cases/list-publications.service");
56
71
  const publish_plugin_service_1 = require("./use-cases/publish-plugin.service");
@@ -58,6 +73,7 @@ const resume_plugin_service_1 = require("./use-cases/resume-plugin.service");
58
73
  const run_plugin_update_check_service_1 = require("./use-cases/run-plugin-update-check.service");
59
74
  const plugin_update_check_processor_1 = require("./system-triggers/plugin-update-check.processor");
60
75
  const credential_definition_update_check_processor_1 = require("./system-triggers/credential-definition-update-check.processor");
76
+ const plugin_action_execution_sweep_processor_1 = require("./system-triggers/plugin-action-execution-sweep.processor");
61
77
  const suspend_plugin_service_1 = require("./use-cases/suspend-plugin.service");
62
78
  const sync_plugin_releases_service_1 = require("./use-cases/sync-plugin-releases.service");
63
79
  const unpublish_plugin_service_1 = require("./use-cases/unpublish-plugin.service");
@@ -89,6 +105,7 @@ exports.PluginHostModule = PluginHostModule = __decorate([
89
105
  plugin_publication_project_entity_1.PluginPublicationProject,
90
106
  plugin_installation_entity_1.PluginInstallation,
91
107
  plugin_audit_event_entity_1.PluginAuditEvent,
108
+ plugin_action_execution_entity_1.PluginActionExecution,
92
109
  ]),
93
110
  typeorm_1.TypeOrmModule.forFeature([plugin_collection_document_collection_entity_1.PluginCollectionDocument, plugin_collection_usage_collection_entity_1.PluginCollectionUsage, plugin_collection_audit_event_collection_entity_1.PluginCollectionAuditEvent], plugin_collections_data_source_options_config_1.PLUGIN_COLLECTIONS_DATA_SOURCE),
94
111
  idp_module_1.IdpModule,
@@ -99,9 +116,12 @@ exports.PluginHostModule = PluginHostModule = __decorate([
99
116
  plugin_collections_controller_1.PluginCollectionsController,
100
117
  credential_definitions_github_controller_1.CredentialDefinitionsGithubController,
101
118
  plugin_credential_runtime_controller_1.PluginCredentialRuntimeController,
119
+ plugin_action_runtime_controller_1.PluginActionRuntimeController,
102
120
  plugin_publications_controller_1.PluginPublicationsController,
103
121
  plugin_admin_controller_1.PluginAdminController,
122
+ plugin_release_check_controller_1.PluginReleaseCheckController,
104
123
  plugin_installations_controller_1.PluginInstallationsController,
124
+ plugin_history_controller_1.PluginHistoryController,
105
125
  plugin_gallery_controller_1.PluginGalleryController,
106
126
  ],
107
127
  providers: [
@@ -121,6 +141,7 @@ exports.PluginHostModule = PluginHostModule = __decorate([
121
141
  external_credential_definition_sync_service_1.ExternalCredentialDefinitionSyncService,
122
142
  add_github_credential_definition_service_1.AddGithubCredentialDefinitionService,
123
143
  remote_url_validator_service_1.RemoteUrlValidatorService,
144
+ release_candidate_rules_service_1.ReleaseCandidateRulesService,
124
145
  plugin_service_1.PluginService,
125
146
  plugin_version_service_1.PluginVersionService,
126
147
  plugin_audit_service_1.PluginAuditService,
@@ -137,16 +158,27 @@ exports.PluginHostModule = PluginHostModule = __decorate([
137
158
  suspend_plugin_service_1.SuspendPluginService,
138
159
  resume_plugin_service_1.ResumePluginService,
139
160
  plugin_installation_service_1.PluginInstallationService,
161
+ plugin_action_execution_service_1.PluginActionExecutionService,
162
+ plugin_action_dispatcher_service_1.PluginActionDispatcherService,
163
+ action_input_validator_service_1.ActionInputValidatorService,
164
+ plugin_action_starter_service_1.PluginActionStarterService,
165
+ start_plugin_action_execution_service_1.StartPluginActionExecutionService,
166
+ get_plugin_action_execution_service_1.GetPluginActionExecutionService,
167
+ cancel_plugin_action_execution_service_1.CancelPluginActionExecutionService,
168
+ get_current_plugin_action_execution_service_1.GetCurrentPluginActionExecutionService,
140
169
  plugin_credential_binding_reconciliation_service_1.PluginCredentialBindingReconciliationService,
141
170
  plugin_update_schedule_service_1.PluginUpdateScheduleService,
142
171
  run_plugin_update_check_service_1.RunPluginUpdateCheckService,
143
172
  plugin_update_check_processor_1.PluginUpdateCheckProcessor,
144
173
  credential_definition_update_check_processor_1.CredentialDefinitionUpdateCheckProcessor,
174
+ plugin_action_execution_sweep_processor_1.PluginActionExecutionSweepProcessor,
145
175
  install_plugin_service_1.InstallPluginService,
146
176
  uninstall_plugin_service_1.UninstallPluginService,
147
177
  list_installations_service_1.ListInstallationsService,
178
+ list_plugin_history_service_1.ListPluginHistoryService,
148
179
  get_plugin_installation_entry_service_1.GetPluginInstallationEntryService,
149
180
  update_plugin_service_1.UpdatePluginService,
181
+ check_plugin_release_service_1.CheckPluginReleaseService,
150
182
  issue_plugin_runtime_token_service_1.IssuePluginRuntimeTokenService,
151
183
  plugin_installation_lookup_facade_impl_1.PluginInstallationLookupFacade,
152
184
  { provide: plugin_installation_lookup_facade_1.PLUGIN_INSTALLATION_LOOKUP, useExisting: plugin_installation_lookup_facade_impl_1.PluginInstallationLookupFacade },
@@ -0,0 +1,23 @@
1
+ import { OnModuleDestroy } from '@nestjs/common';
2
+ import { type ActionInputError } from '../errors/plugin-action.errors';
3
+ export interface ActionInputSchema {
4
+ readonly path: string;
5
+ readonly schema: Record<string, unknown>;
6
+ }
7
+ export declare class ActionInputValidatorService implements OnModuleDestroy {
8
+ private readonly logger;
9
+ private readonly slots;
10
+ private readonly queue;
11
+ private readonly pendingByVersion;
12
+ private stopped;
13
+ validate(pluginVersionId: string, action: string, schema: Record<string, unknown>, input: unknown): Promise<readonly ActionInputError[]>;
14
+ compile(schemas: readonly ActionInputSchema[]): Promise<string | null>;
15
+ onModuleDestroy(): Promise<void>;
16
+ private refuseToQueue;
17
+ private drain;
18
+ private run;
19
+ private startBudget;
20
+ private spawn;
21
+ private replace;
22
+ private release;
23
+ }
@@ -0,0 +1,277 @@
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 ActionInputValidatorService_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ActionInputValidatorService = void 0;
11
+ const common_1 = require("@nestjs/common");
12
+ const internal_helpers_1 = require("@owox/internal-helpers");
13
+ const node_worker_threads_1 = require("node:worker_threads");
14
+ const plugin_action_limits_1 = require("../constants/plugin-action-limits");
15
+ const plugin_action_errors_1 = require("../errors/plugin-action.errors");
16
+ const action_input_schema_util_1 = require("../utils/action-input-schema.util");
17
+ const AJV_PATH = require.resolve('ajv/dist/2020');
18
+ const WORKER_SOURCE = `
19
+ const { parentPort, workerData } = require('node:worker_threads');
20
+ const Ajv2020 = require(workerData.ajvPath).default;
21
+ const { ajv: setup, cacheSize, maxErrors } = workerData;
22
+ const compiled = new Map();
23
+
24
+ const reason = error => String((error && error.message) || error);
25
+
26
+ function build(schema) {
27
+ const ajv = new Ajv2020(setup.options);
28
+ ajv.getSchema(setup.metaSchema);
29
+ for (const keyword of setup.refusedKeywords) ajv.removeKeyword(keyword);
30
+ return ajv.compile(schema);
31
+ }
32
+
33
+ function compile(key, schema) {
34
+ const cached = compiled.get(key);
35
+ if (cached) {
36
+ compiled.delete(key);
37
+ compiled.set(key, cached);
38
+ return cached;
39
+ }
40
+ const validate = build(schema);
41
+ if (compiled.size >= cacheSize) compiled.delete(compiled.keys().next().value);
42
+ compiled.set(key, validate);
43
+ return validate;
44
+ }
45
+
46
+ // A release's schemas, as JSON text: the first one ajv refuses, or none. Not cached, it is no version yet.
47
+ function compileAll(schemas) {
48
+ for (let index = 0; index < schemas.length; index += 1) {
49
+ try {
50
+ build(JSON.parse(schemas[index]));
51
+ } catch (error) {
52
+ return parentPort.postMessage({ schemaError: reason(error), index });
53
+ }
54
+ }
55
+ parentPort.postMessage({ schemaError: null });
56
+ }
57
+
58
+ parentPort.on('message', message => {
59
+ if (message.schemas) return compileAll(message.schemas);
60
+ const { key, schema, input } = message;
61
+ let validate;
62
+ try {
63
+ validate = compile(key, schema);
64
+ } catch (error) {
65
+ parentPort.postMessage({ schemaError: reason(error) });
66
+ return;
67
+ }
68
+ parentPort.postMessage({ compiled: true });
69
+ // A throw from here ends the worker, which the pool reads as an exceeded budget.
70
+ const valid = validate(input);
71
+ if (typeof valid !== 'boolean') {
72
+ // An async schema answers a Promise: no verdict in time. It answers once settled, so its work stays
73
+ // inside its own budget, and its rejection must not end the worker.
74
+ return Promise.resolve(valid).catch(() => {}).then(() => parentPort.postMessage({ overBudget: true }));
75
+ }
76
+ if (valid) return parentPort.postMessage({ errors: [] });
77
+ const errors = (validate.errors || []).slice(0, maxErrors).map(error => ({
78
+ instancePath: error.instancePath,
79
+ message: error.message || 'is invalid',
80
+ }));
81
+ parentPort.postMessage({
82
+ errors: errors.length > 0 ? errors : [{ instancePath: '', message: 'is invalid' }],
83
+ });
84
+ });
85
+
86
+ parentPort.postMessage({ ready: true });
87
+ `;
88
+ const OVER_BUDGET = [
89
+ { instancePath: '', message: 'Input validation exceeded its budget' },
90
+ ];
91
+ const COMPILE_OVER_BUDGET = 'Input schema compilation exceeded its budget';
92
+ function stoppedError() {
93
+ return new Error('Input validation stopped');
94
+ }
95
+ let ActionInputValidatorService = ActionInputValidatorService_1 = class ActionInputValidatorService {
96
+ logger = new common_1.Logger(ActionInputValidatorService_1.name);
97
+ slots = new Set();
98
+ queue = [];
99
+ pendingByVersion = new Map();
100
+ stopped = false;
101
+ validate(pluginVersionId, action, schema, input) {
102
+ return new Promise((resolve, reject) => {
103
+ const pending = this.pendingByVersion.get(pluginVersionId) ?? 0;
104
+ if (pending >= plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxValidationsPerVersion) {
105
+ this.logger.warn(`TOO_MANY_EXECUTIONS: ${plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxValidationsPerVersion} validations per version reached, pluginVersionId=${pluginVersionId}`);
106
+ reject(new plugin_action_errors_1.TooManyExecutionsError('Too many inputs of this plugin are being validated. Try again shortly.'));
107
+ return;
108
+ }
109
+ const refusal = this.refuseToQueue(`pluginVersionId=${pluginVersionId}`);
110
+ if (refusal) {
111
+ reject(refusal);
112
+ return;
113
+ }
114
+ this.pendingByVersion.set(pluginVersionId, pending + 1);
115
+ const release = () => this.release(pluginVersionId);
116
+ this.queue.push({
117
+ message: { key: `${pluginVersionId}:${action}`, schema, input },
118
+ budgetMs: plugin_action_limits_1.PLUGIN_ACTION_LIMITS.validationBootMs,
119
+ resolve: verdict => {
120
+ release();
121
+ if ('errors' in verdict)
122
+ resolve(verdict.errors);
123
+ else if ('overBudget' in verdict)
124
+ resolve(OVER_BUDGET);
125
+ else
126
+ reject(new Error(String(verdict.schemaError)));
127
+ },
128
+ reject: error => {
129
+ release();
130
+ reject(error);
131
+ },
132
+ });
133
+ this.drain();
134
+ });
135
+ }
136
+ async compile(schemas) {
137
+ if (schemas.length === 0)
138
+ return null;
139
+ const texts = [];
140
+ for (const { path, schema } of schemas) {
141
+ try {
142
+ texts.push(JSON.stringify(schema));
143
+ }
144
+ catch (error) {
145
+ return `${path}: ${(0, internal_helpers_1.castError)(error).message}`;
146
+ }
147
+ }
148
+ return new Promise((resolve, reject) => {
149
+ const refusal = this.refuseToQueue('release compile');
150
+ if (refusal) {
151
+ reject(refusal);
152
+ return;
153
+ }
154
+ this.queue.push({
155
+ message: { schemas: texts },
156
+ budgetMs: plugin_action_limits_1.PLUGIN_ACTION_LIMITS.inputSchemaCompileBudgetMs,
157
+ resolve: verdict => {
158
+ if ('overBudget' in verdict)
159
+ resolve(COMPILE_OVER_BUDGET);
160
+ else if ('schemaError' in verdict && verdict.schemaError !== null) {
161
+ resolve(`${schemas[verdict.index ?? 0].path}: ${verdict.schemaError}`);
162
+ }
163
+ else
164
+ resolve(null);
165
+ },
166
+ reject,
167
+ });
168
+ this.drain();
169
+ });
170
+ }
171
+ async onModuleDestroy() {
172
+ this.stopped = true;
173
+ const slots = [...this.slots];
174
+ this.slots.clear();
175
+ for (const job of this.queue.splice(0))
176
+ job.reject(stoppedError());
177
+ for (const slot of slots) {
178
+ clearTimeout(slot.timer);
179
+ slot.job?.reject(stoppedError());
180
+ }
181
+ await Promise.all(slots.map(slot => slot.worker.terminate()));
182
+ }
183
+ refuseToQueue(subject) {
184
+ if (this.queue.length >= plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxQueuedValidations) {
185
+ this.logger.warn(`TOO_MANY_EXECUTIONS: ${plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxQueuedValidations} queued validations reached, ${subject}`);
186
+ return new plugin_action_errors_1.TooManyExecutionsError('Input validation is busy. Try again shortly.');
187
+ }
188
+ return this.stopped ? stoppedError() : null;
189
+ }
190
+ drain() {
191
+ for (const slot of this.slots) {
192
+ const next = slot.job ? undefined : this.queue.shift();
193
+ if (next)
194
+ this.run(slot, next);
195
+ }
196
+ while (this.queue.length > 0 && this.slots.size < plugin_action_limits_1.PLUGIN_ACTION_LIMITS.validationWorkers) {
197
+ this.run(this.spawn(), this.queue.shift());
198
+ }
199
+ }
200
+ run(slot, job) {
201
+ slot.job = job;
202
+ slot.worker.ref();
203
+ slot.worker.postMessage(job.message);
204
+ if (slot.ready)
205
+ this.startBudget(slot);
206
+ }
207
+ startBudget(slot, budgetMs = slot.job?.budgetMs) {
208
+ slot.timer = setTimeout(() => this.replace(slot), budgetMs);
209
+ }
210
+ spawn() {
211
+ const worker = new node_worker_threads_1.Worker(WORKER_SOURCE, {
212
+ eval: true,
213
+ workerData: {
214
+ ajvPath: AJV_PATH,
215
+ ajv: action_input_schema_util_1.ACTION_INPUT_AJV,
216
+ cacheSize: plugin_action_limits_1.PLUGIN_ACTION_LIMITS.validationWorkerCacheSize,
217
+ maxErrors: plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxReportedInputErrors,
218
+ },
219
+ resourceLimits: { maxOldGenerationSizeMb: plugin_action_limits_1.PLUGIN_ACTION_LIMITS.validationWorkerHeapMb },
220
+ });
221
+ const slot = { worker, ready: false };
222
+ slot.timer = setTimeout(() => setImmediate(() => {
223
+ if (!slot.ready)
224
+ this.replace(slot);
225
+ }), plugin_action_limits_1.PLUGIN_ACTION_LIMITS.validationBootMs);
226
+ worker.on('message', (reply) => {
227
+ if (!this.slots.has(slot))
228
+ return;
229
+ clearTimeout(slot.timer);
230
+ if ('ready' in reply) {
231
+ slot.ready = true;
232
+ if (slot.job)
233
+ this.startBudget(slot);
234
+ return;
235
+ }
236
+ if ('compiled' in reply) {
237
+ this.startBudget(slot, plugin_action_limits_1.PLUGIN_ACTION_LIMITS.validationBudgetMs);
238
+ return;
239
+ }
240
+ const { job } = slot;
241
+ slot.job = undefined;
242
+ worker.unref();
243
+ job?.resolve(reply);
244
+ this.drain();
245
+ });
246
+ worker.on('error', error => this.replace(slot, error));
247
+ worker.on('exit', () => this.replace(slot));
248
+ worker.unref();
249
+ this.slots.add(slot);
250
+ return slot;
251
+ }
252
+ replace(slot, error) {
253
+ if (!this.slots.delete(slot))
254
+ return;
255
+ clearTimeout(slot.timer);
256
+ const { job } = slot;
257
+ slot.job = undefined;
258
+ if (slot.ready)
259
+ job?.resolve({ overBudget: true });
260
+ else
261
+ job?.reject(error ?? new Error('The input validation worker did not start'));
262
+ void slot.worker.terminate();
263
+ this.drain();
264
+ }
265
+ release(pluginVersionId) {
266
+ const pending = (this.pendingByVersion.get(pluginVersionId) ?? 1) - 1;
267
+ if (pending > 0)
268
+ this.pendingByVersion.set(pluginVersionId, pending);
269
+ else
270
+ this.pendingByVersion.delete(pluginVersionId);
271
+ }
272
+ };
273
+ exports.ActionInputValidatorService = ActionInputValidatorService;
274
+ exports.ActionInputValidatorService = ActionInputValidatorService = ActionInputValidatorService_1 = __decorate([
275
+ (0, common_1.Injectable)()
276
+ ], ActionInputValidatorService);
277
+ //# sourceMappingURL=action-input-validator.service.js.map
@@ -11,5 +11,8 @@ export declare class ExternalCredentialDefinitionSyncService {
11
11
  private readonly registry;
12
12
  constructor(github: GithubApiService, registry: CredentialExternalDefinitionRegistryService);
13
13
  syncLocator(locator: string): Promise<ResolvedCredentialDefinition>;
14
+ private settleLocator;
14
15
  resolveRequirements(requirements: readonly PluginCredentialRequirement[]): Promise<StoredCredentialRequirement[]>;
16
+ previewRequirements(requirements: readonly PluginCredentialRequirement[]): Promise<void>;
17
+ private settleRequirements;
15
18
  }
@@ -17,6 +17,7 @@ const credential_external_definition_registry_service_1 = require("../../data-ma
17
17
  const external_credential_manifest_1 = require("../../data-marts/credentials/services/external-credential-manifest");
18
18
  const credential_types_1 = require("../../data-marts/credentials/credential.types");
19
19
  const github_read_policy_enum_1 = require("../enums/github-read-policy.enum");
20
+ const plugin_host_errors_1 = require("../errors/plugin-host.errors");
20
21
  const github_repo_locator_util_1 = require("../utils/github-repo-locator.util");
21
22
  const semver_util_1 = require("../utils/semver.util");
22
23
  const github_api_service_1 = require("./github-api.service");
@@ -30,7 +31,10 @@ let ExternalCredentialDefinitionSyncService = class ExternalCredentialDefinition
30
31
  this.github = github;
31
32
  this.registry = registry;
32
33
  }
33
- async syncLocator(locator) {
34
+ syncLocator(locator) {
35
+ return this.settleLocator(locator, input => this.registry.register(input));
36
+ }
37
+ async settleLocator(locator, settle) {
34
38
  const ref = parseExternalLocator(locator);
35
39
  const repo = await this.github.getRepo(ref, github_read_policy_enum_1.GithubReadPolicy.CONFIGURED);
36
40
  const releases = (await this.github.listReleases(ref, github_read_policy_enum_1.GithubReadPolicy.CONFIGURED))
@@ -54,7 +58,7 @@ let ExternalCredentialDefinitionSyncService = class ExternalCredentialDefinition
54
58
  continue;
55
59
  }
56
60
  try {
57
- return await this.registry.register({
61
+ return await settle({
58
62
  githubRepoId: repo.githubRepoId,
59
63
  repoOwner: repo.owner,
60
64
  repoName: repo.name,
@@ -77,19 +81,51 @@ let ExternalCredentialDefinitionSyncService = class ExternalCredentialDefinition
77
81
  throw new ExternalCredentialRequirementError('No eligible Credential definition release was found');
78
82
  }
79
83
  async resolveRequirements(requirements) {
80
- const resolved = [];
84
+ const settled = await this.settleRequirements(requirements, locator => this.syncLocator(locator));
85
+ return settled.map(({ requirement, definition }) => {
86
+ if (!definition)
87
+ return requirement;
88
+ const external = {
89
+ id: definition.contract.id,
90
+ definitionId: definition.definitionId,
91
+ optional: typeof requirement === 'string' ? false : requirement.optional,
92
+ models: typeof requirement === 'string' ? undefined : requirement.models,
93
+ };
94
+ return external;
95
+ });
96
+ }
97
+ async previewRequirements(requirements) {
98
+ await this.settleRequirements(requirements, async (locator) => {
99
+ try {
100
+ return await this.settleLocator(locator, input => this.registry.preview(input));
101
+ }
102
+ catch (error) {
103
+ if (error instanceof plugin_host_errors_1.InvalidRepoLocatorError ||
104
+ error instanceof plugin_host_errors_1.GithubRepoNotFoundError ||
105
+ error instanceof plugin_host_errors_1.GithubRepoNotAccessibleError) {
106
+ const installationUrl = error instanceof plugin_host_errors_1.GithubRepoNotAccessibleError
107
+ ? error.errorDetails?.installationUrl
108
+ : undefined;
109
+ throw new ExternalCredentialRequirementError(`${locator}: ${error.message}${installationUrl ? ` ${installationUrl}` : ''}`);
110
+ }
111
+ throw error;
112
+ }
113
+ });
114
+ }
115
+ async settleRequirements(requirements, settle) {
116
+ const settled = [];
81
117
  for (const requirement of requirements) {
82
118
  const locator = typeof requirement === 'string' ? requirement : requirement.id;
83
119
  if (!locator.startsWith('@')) {
84
120
  if (locator !== 'ai' && !builtin_credential_definitions_1.BUILTIN_CREDENTIAL_DEFINITION_IDS.has(locator)) {
85
121
  throw new ExternalCredentialRequirementError(`Unknown Credential requirement "${locator}"; use ai, a built-in definition, or @owner/repository`);
86
122
  }
87
- resolved.push(requirement);
123
+ settled.push({ requirement, definition: null });
88
124
  continue;
89
125
  }
90
126
  let definition;
91
127
  try {
92
- definition = await this.syncLocator(locator);
128
+ definition = await settle(locator);
93
129
  }
94
130
  catch (error) {
95
131
  if (error instanceof ExternalCredentialRequirementError)
@@ -99,23 +135,19 @@ let ExternalCredentialDefinitionSyncService = class ExternalCredentialDefinition
99
135
  }
100
136
  throw error;
101
137
  }
102
- const external = {
103
- id: definition.contract.id,
104
- definitionId: definition.definitionId,
105
- optional: typeof requirement === 'string' ? false : requirement.optional,
106
- models: typeof requirement === 'string' ? undefined : requirement.models,
107
- };
108
- resolved.push(external);
138
+ settled.push({ requirement, definition });
109
139
  }
110
140
  const keys = new Set();
111
- for (const requirement of resolved) {
112
- const key = (0, credential_types_1.normalizeCredentialRequirement)(requirement).key;
141
+ for (const { requirement, definition } of settled) {
142
+ const key = definition
143
+ ? definition.contract.id
144
+ : (0, credential_types_1.normalizeCredentialRequirement)(requirement).key;
113
145
  if (keys.has(key)) {
114
146
  throw new ExternalCredentialRequirementError(`Duplicate resolved Credential handle ${key}`);
115
147
  }
116
148
  keys.add(key);
117
149
  }
118
- return resolved;
150
+ return settled;
119
151
  }
120
152
  };
121
153
  exports.ExternalCredentialDefinitionSyncService = ExternalCredentialDefinitionSyncService;
@@ -0,0 +1,13 @@
1
+ import { GracefulShutdownService } from '../../common/scheduler/services/graceful-shutdown.service';
2
+ import { PluginHostConfigService } from '../config/plugin-host.config';
3
+ import type { PluginActionExecution } from '../entities/plugin-action-execution.entity';
4
+ import { PluginActionExecutionService } from './plugin-action-execution.service';
5
+ export declare class PluginActionDispatcherService {
6
+ private readonly executions;
7
+ private readonly shutdown;
8
+ private readonly config;
9
+ private readonly logger;
10
+ constructor(executions: PluginActionExecutionService, shutdown: GracefulShutdownService, config: PluginHostConfigService);
11
+ dispatch(execution: PluginActionExecution, backendUrl: string, token: string, timeoutSeconds: number): Promise<void>;
12
+ private call;
13
+ }