@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.
Files changed (264) 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/common/search/search.facade.d.ts +1 -0
  6. package/dist/src/config/data-source-options.config.d.ts +4 -3
  7. package/dist/src/config/data-source-options.config.js +10 -3
  8. package/dist/src/config/plugin-collections-body-parser.config.js +3 -0
  9. package/dist/src/data-marts/credentials/credential.types.d.ts +26 -2
  10. package/dist/src/data-marts/credentials/credential.types.js +18 -6
  11. package/dist/src/data-marts/credentials/dto/credential-api.dto.d.ts +5 -1
  12. package/dist/src/data-marts/credentials/dto/credential-api.dto.js +21 -0
  13. package/dist/src/data-marts/credentials/dto/credential.dto.d.ts +2 -1
  14. package/dist/src/data-marts/credentials/entities/credential.entity.d.ts +2 -1
  15. package/dist/src/data-marts/credentials/entities/credential.entity.js +5 -0
  16. package/dist/src/data-marts/credentials/facades/credential-consumer-binding.facade.impl.js +6 -1
  17. package/dist/src/data-marts/credentials/mappers/credential.mapper.js +2 -0
  18. package/dist/src/data-marts/credentials/services/builtin-credential-definitions.js +8 -0
  19. package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.d.ts +4 -0
  20. package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.js +36 -17
  21. package/dist/src/data-marts/credentials/services/credential-fetch.service.d.ts +8 -0
  22. package/dist/src/data-marts/credentials/services/credential-fetch.service.js +115 -46
  23. package/dist/src/data-marts/credentials/services/credential-validation-probe.service.d.ts +3 -1
  24. package/dist/src/data-marts/credentials/services/credential-validation-probe.service.js +10 -2
  25. package/dist/src/data-marts/credentials/services/credential.service.d.ts +4 -0
  26. package/dist/src/data-marts/credentials/services/credential.service.js +36 -0
  27. package/dist/src/data-marts/credentials/services/google-service-account-key.d.ts +6 -0
  28. package/dist/src/data-marts/credentials/services/google-service-account-key.js +46 -0
  29. package/dist/src/data-marts/credentials/services/google-service-account-token.service.d.ts +25 -0
  30. package/dist/src/data-marts/credentials/services/google-service-account-token.service.js +177 -0
  31. package/dist/src/data-marts/credentials/use-cases/create-credential.service.d.ts +1 -0
  32. package/dist/src/data-marts/credentials/use-cases/create-credential.service.js +10 -2
  33. package/dist/src/data-marts/credentials/use-cases/update-credential.service.d.ts +1 -0
  34. package/dist/src/data-marts/credentials/use-cases/update-credential.service.js +28 -4
  35. package/dist/src/data-marts/credentials/use-cases/validate-credential.service.js +2 -5
  36. package/dist/src/data-marts/data-destination-types/ee/email/services/email-credentials-validator.js +1 -3
  37. package/dist/src/data-marts/data-destination-types/ee/google-chat/services/google-chat-credentials-validator.js +1 -3
  38. package/dist/src/data-marts/data-destination-types/google-sheets/services/google-sheets-credentials-validator.js +1 -3
  39. package/dist/src/data-marts/data-destination-types/google-sheets/services/google-sheets-report-writer.d.ts +1 -0
  40. package/dist/src/data-marts/data-destination-types/google-sheets/services/google-sheets-report-writer.js +13 -1
  41. package/dist/src/data-marts/data-destination-types/interfaces/data-destination-credentials-validator.interface.d.ts +2 -0
  42. package/dist/src/data-marts/data-destination-types/interfaces/data-destination-credentials-validator.interface.js +7 -0
  43. package/dist/src/data-marts/data-destination-types/looker-studio-connector/services/looker-studio-connector-credentials-validator.js +1 -3
  44. package/dist/src/data-marts/data-marts.module.js +8 -0
  45. package/dist/src/data-marts/data-storage-types/athena/adapters/athena-api.adapter.js +2 -1
  46. package/dist/src/data-marts/data-storage-types/athena/adapters/s3-api.adapter.js +5 -3
  47. package/dist/src/data-marts/data-storage-types/athena/services/athena-access.validator.js +2 -4
  48. package/dist/src/data-marts/data-storage-types/athena/utils/athena-output-location.util.d.ts +5 -0
  49. package/dist/src/data-marts/data-storage-types/athena/utils/athena-output-location.util.js +13 -0
  50. package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-access.validator.js +2 -4
  51. package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-resource-location.util.d.ts +3 -0
  52. package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-resource-location.util.js +18 -0
  53. package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-sharded-tables.util.d.ts +1 -0
  54. package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-sharded-tables.util.js +4 -1
  55. package/dist/src/data-marts/data-storage-types/bigquery/services/bigquery-storage-resource-browser.service.js +12 -5
  56. package/dist/src/data-marts/data-storage-types/databricks/services/databricks-access.validator.js +2 -4
  57. package/dist/src/data-marts/data-storage-types/interfaces/data-storage-access-validator.interface.d.ts +3 -0
  58. package/dist/src/data-marts/data-storage-types/interfaces/data-storage-access-validator.interface.js +7 -0
  59. package/dist/src/data-marts/data-storage-types/interfaces/storage-resource-browser.interface.d.ts +2 -0
  60. package/dist/src/data-marts/data-storage-types/redshift/services/redshift-access.validator.js +2 -6
  61. package/dist/src/data-marts/data-storage-types/snowflake/adapters/snowflake-api.adapter.js +1 -0
  62. package/dist/src/data-marts/data-storage-types/snowflake/services/snowflake-access.validator.js +2 -4
  63. package/dist/src/data-marts/dto/domain/list-data-marts.command.d.ts +2 -1
  64. package/dist/src/data-marts/dto/domain/list-data-marts.command.js +3 -1
  65. package/dist/src/data-marts/dto/presentation/run-data-mart-request-api.dto.js +4 -2
  66. package/dist/src/data-marts/dto/presentation/sql-dry-run-request-api.dto.js +3 -0
  67. package/dist/src/data-marts/dto/presentation/storage-resources/list-storage-resources-response.dto.d.ts +2 -0
  68. package/dist/src/data-marts/dto/presentation/storage-resources/list-storage-resources-response.dto.js +17 -0
  69. package/dist/src/data-marts/errors/google-sheets-api-call.error.d.ts +6 -0
  70. package/dist/src/data-marts/errors/google-sheets-api-call.error.js +34 -0
  71. package/dist/src/data-marts/facades/mcp-contexts.facade.d.ts +13 -0
  72. package/dist/src/data-marts/facades/mcp-contexts.facade.impl.d.ts +9 -0
  73. package/dist/src/data-marts/facades/mcp-contexts.facade.impl.js +35 -0
  74. package/dist/src/data-marts/facades/mcp-contexts.facade.js +5 -0
  75. package/dist/src/data-marts/facades/mcp-data-marts.facade.d.ts +9 -0
  76. package/dist/src/data-marts/facades/mcp-data-marts.facade.impl.js +4 -1
  77. package/dist/src/data-marts/mappers/context.mapper.d.ts +4 -0
  78. package/dist/src/data-marts/mappers/context.mapper.js +12 -0
  79. package/dist/src/data-marts/search/engine/advanced-search.service.js +1 -0
  80. package/dist/src/data-marts/search/engine/in-memory-paginated.search.js +17 -1
  81. package/dist/src/data-marts/search/engine/vector-search.port.d.ts +1 -0
  82. package/dist/src/data-marts/services/connector/backfill-segment.d.ts +22 -0
  83. package/dist/src/data-marts/services/connector/backfill-segment.js +91 -0
  84. package/dist/src/data-marts/services/connector/connector-execution.service.d.ts +1 -0
  85. package/dist/src/data-marts/services/connector/connector-execution.service.js +3 -0
  86. package/dist/src/data-marts/services/connector/connector-executor.service.d.ts +4 -1
  87. package/dist/src/data-marts/services/connector/connector-executor.service.js +107 -23
  88. package/dist/src/data-marts/services/connector/connector-run.service.d.ts +3 -0
  89. package/dist/src/data-marts/services/connector/connector-run.service.js +98 -4
  90. package/dist/src/data-marts/services/context/context.service.d.ts +2 -0
  91. package/dist/src/data-marts/services/context/context.service.js +21 -0
  92. package/dist/src/data-marts/services/data-mart-run.service.d.ts +1 -0
  93. package/dist/src/data-marts/services/data-mart-run.service.js +9 -0
  94. package/dist/src/data-marts/services/data-mart.service.d.ts +1 -0
  95. package/dist/src/data-marts/services/data-mart.service.js +3 -0
  96. package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.d.ts +14 -0
  97. package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.js +45 -0
  98. package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.d.ts +4 -0
  99. package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.js +46 -1
  100. package/dist/src/data-marts/use-cases/list-data-marts.service.js +1 -0
  101. package/dist/src/data-marts/use-cases/stream-http-data.service.d.ts +0 -1
  102. package/dist/src/data-marts/use-cases/stream-http-data.service.js +2 -6
  103. package/dist/src/data-marts/use-cases/update-data-storage.service.js +7 -7
  104. package/dist/src/data-marts/utils/field-errors.utils.d.ts +9 -0
  105. package/dist/src/data-marts/utils/field-errors.utils.js +51 -0
  106. package/dist/src/data-marts/utils/manual-backfill-range.d.ts +52 -0
  107. package/dist/src/data-marts/utils/manual-backfill-range.js +110 -8
  108. package/dist/src/ee/mcp/instructions/mcp-system-instructions.d.ts +1 -1
  109. package/dist/src/ee/mcp/instructions/mcp-system-instructions.js +4 -0
  110. package/dist/src/ee/mcp/sdk/mcp-output-schema.d.ts +3 -0
  111. package/dist/src/ee/mcp/sdk/mcp-output-schema.js +53 -0
  112. package/dist/src/ee/mcp/sdk/mcp-schema-refresh.d.ts +8 -0
  113. package/dist/src/ee/mcp/sdk/mcp-schema-refresh.js +44 -0
  114. package/dist/src/ee/mcp/sdk/mcp-sdk-server.factory.d.ts +8 -1
  115. package/dist/src/ee/mcp/sdk/mcp-sdk-server.factory.js +35 -4
  116. package/dist/src/ee/mcp/tools/context-input.d.ts +6 -0
  117. package/dist/src/ee/mcp/tools/context-input.js +13 -0
  118. package/dist/src/ee/mcp/tools/data-mart-catalog.tool.d.ts +10 -2
  119. package/dist/src/ee/mcp/tools/data-mart-catalog.tool.js +17 -5
  120. package/dist/src/ee/mcp/tools/data-mart-details.tool.d.ts +5 -1
  121. package/dist/src/ee/mcp/tools/data-mart-details.tool.js +4 -1
  122. package/dist/src/ee/mcp/tools/list-contexts.tool.d.ts +131 -0
  123. package/dist/src/ee/mcp/tools/list-contexts.tool.js +50 -0
  124. package/dist/src/ee/mcp/tools/mcp-tool.providers.js +2 -0
  125. package/dist/src/ee/mcp/tools/search-data-marts.tool.d.ts +10 -2
  126. package/dist/src/ee/mcp/tools/search-data-marts.tool.js +17 -3
  127. package/dist/src/ee/mcp/transport/mcp-http-entry.service.js +1 -1
  128. package/dist/src/idp/decorators/auth-context.decorator.js +1 -0
  129. package/dist/src/idp/guards/idp.guard.d.ts +3 -0
  130. package/dist/src/idp/guards/idp.guard.js +38 -8
  131. package/dist/src/idp/oauth/controllers/oauth-authorization.controller.js +8 -6
  132. package/dist/src/idp/oauth/mcp-client-integration.d.ts +1 -0
  133. package/dist/src/idp/oauth/mcp-client-integration.js +15 -0
  134. package/dist/src/idp/ports/plugin-runtime-authorizer.port.d.ts +6 -0
  135. package/dist/src/idp/types/auth.types.d.ts +1 -0
  136. package/dist/src/migrations/1790830000000-widen-sql-dry-run-trigger-sql-column.d.ts +6 -0
  137. package/dist/src/migrations/1790830000000-widen-sql-dry-run-trigger-sql-column.js +21 -0
  138. package/dist/src/migrations/1790900000000-add-plugin-version-backend.d.ts +6 -0
  139. package/dist/src/migrations/1790900000000-add-plugin-version-backend.js +21 -0
  140. package/dist/src/migrations/1790900000001-create-plugin-action-execution.d.ts +6 -0
  141. package/dist/src/migrations/1790900000001-create-plugin-action-execution.js +77 -0
  142. package/dist/src/migrations/1791000000000-add-credential-public-metadata.d.ts +6 -0
  143. package/dist/src/migrations/1791000000000-add-credential-public-metadata.js +23 -0
  144. package/dist/src/plugin-host/collections/dto/domain/plugin-collection.types.d.ts +1 -0
  145. package/dist/src/plugin-host/collections/errors/plugin-collection.errors.d.ts +6 -0
  146. package/dist/src/plugin-host/collections/errors/plugin-collection.errors.js +19 -1
  147. package/dist/src/plugin-host/collections/services/plugin-collection-declaration.service.js +3 -3
  148. package/dist/src/plugin-host/collections/use-cases/put-plugin-collection-document.service.js +7 -0
  149. package/dist/src/plugin-host/constants/plugin-action-limits.d.ts +34 -0
  150. package/dist/src/plugin-host/constants/plugin-action-limits.js +51 -0
  151. package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.d.ts +20 -0
  152. package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.js +123 -0
  153. package/dist/src/plugin-host/controllers/plugin-credential-runtime.controller.js +11 -19
  154. package/dist/src/plugin-host/controllers/plugin-gallery.controller.d.ts +5 -1
  155. package/dist/src/plugin-host/controllers/plugin-gallery.controller.js +25 -1
  156. package/dist/src/plugin-host/controllers/plugin-history.controller.d.ts +10 -0
  157. package/dist/src/plugin-host/controllers/plugin-history.controller.js +57 -0
  158. package/dist/src/plugin-host/controllers/plugin-release-check.controller.d.ts +10 -0
  159. package/dist/src/plugin-host/controllers/plugin-release-check.controller.js +58 -0
  160. package/dist/src/plugin-host/dto/domain/check-plugin-release.command.d.ts +22 -0
  161. package/dist/src/plugin-host/dto/domain/check-plugin-release.command.js +17 -0
  162. package/dist/src/plugin-host/dto/domain/find-plugin-by-repository.command.d.ts +6 -0
  163. package/dist/src/plugin-host/dto/domain/find-plugin-by-repository.command.js +13 -0
  164. package/dist/src/plugin-host/dto/domain/list-plugin-history.command.d.ts +10 -0
  165. package/dist/src/plugin-host/dto/domain/list-plugin-history.command.js +18 -0
  166. package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.d.ts +23 -0
  167. package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.js +44 -0
  168. package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.d.ts +36 -0
  169. package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.js +3 -0
  170. package/dist/src/plugin-host/dto/domain/plugin-history.dto.d.ts +29 -0
  171. package/dist/src/plugin-host/dto/domain/plugin-history.dto.js +3 -0
  172. package/dist/src/plugin-host/dto/domain/plugin-view.dto.d.ts +1 -0
  173. package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.d.ts +44 -0
  174. package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.js +208 -0
  175. package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.d.ts +2 -0
  176. package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.js +7 -0
  177. package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.d.ts +29 -0
  178. package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.js +148 -0
  179. package/dist/src/plugin-host/dto/presentation/plugin-lookup-api.dto.d.ts +3 -0
  180. package/dist/src/plugin-host/dto/presentation/plugin-lookup-api.dto.js +22 -0
  181. package/dist/src/plugin-host/dto/presentation/publication-api.dto.d.ts +17 -0
  182. package/dist/src/plugin-host/dto/presentation/publication-api.dto.js +95 -1
  183. package/dist/src/plugin-host/entities/plugin-action-execution.entity.d.ts +24 -0
  184. package/dist/src/plugin-host/entities/plugin-action-execution.entity.js +136 -0
  185. package/dist/src/plugin-host/entities/plugin-version.entity.d.ts +2 -1
  186. package/dist/src/plugin-host/entities/plugin-version.entity.js +5 -0
  187. package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.d.ts +9 -0
  188. package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.js +22 -0
  189. package/dist/src/plugin-host/enums/release-rejection-code.enum.d.ts +3 -0
  190. package/dist/src/plugin-host/enums/release-rejection-code.enum.js +6 -0
  191. package/dist/src/plugin-host/errors/plugin-action.errors.d.ts +45 -0
  192. package/dist/src/plugin-host/errors/plugin-action.errors.js +70 -0
  193. package/dist/src/plugin-host/errors/plugin-host.errors.d.ts +6 -0
  194. package/dist/src/plugin-host/errors/plugin-host.errors.js +10 -1
  195. package/dist/src/plugin-host/filters/plugin-host-exception.filter.js +2 -2
  196. package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.d.ts +3 -0
  197. package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.js +22 -0
  198. package/dist/src/plugin-host/mappers/plugin-presentation.mapper.d.ts +22 -1
  199. package/dist/src/plugin-host/mappers/plugin-presentation.mapper.js +87 -1
  200. package/dist/src/plugin-host/plugin-host.module.js +34 -0
  201. package/dist/src/plugin-host/services/action-input-validator.service.d.ts +23 -0
  202. package/dist/src/plugin-host/services/action-input-validator.service.js +277 -0
  203. package/dist/src/plugin-host/services/external-credential-definition-sync.service.d.ts +3 -0
  204. package/dist/src/plugin-host/services/external-credential-definition-sync.service.js +47 -15
  205. package/dist/src/plugin-host/services/plugin-action-dispatcher.service.d.ts +13 -0
  206. package/dist/src/plugin-host/services/plugin-action-dispatcher.service.js +140 -0
  207. package/dist/src/plugin-host/services/plugin-action-execution.service.d.ts +69 -0
  208. package/dist/src/plugin-host/services/plugin-action-execution.service.js +239 -0
  209. package/dist/src/plugin-host/services/plugin-action-starter.service.d.ts +22 -0
  210. package/dist/src/plugin-host/services/plugin-action-starter.service.js +81 -0
  211. package/dist/src/plugin-host/services/plugin-audit.service.d.ts +13 -0
  212. package/dist/src/plugin-host/services/plugin-audit.service.js +78 -0
  213. package/dist/src/plugin-host/services/plugin-publication.service.d.ts +4 -0
  214. package/dist/src/plugin-host/services/plugin-publication.service.js +51 -23
  215. package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.d.ts +5 -2
  216. package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.js +31 -3
  217. package/dist/src/plugin-host/services/plugin-version.service.d.ts +2 -1
  218. package/dist/src/plugin-host/services/release-candidate-rules.service.d.ts +51 -0
  219. package/dist/src/plugin-host/services/release-candidate-rules.service.js +198 -0
  220. package/dist/src/plugin-host/services/remote-url-validator.service.d.ts +7 -0
  221. package/dist/src/plugin-host/services/remote-url-validator.service.js +4 -0
  222. package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.d.ts +14 -0
  223. package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.js +50 -0
  224. package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.d.ts +8 -0
  225. package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.js +39 -0
  226. package/dist/src/plugin-host/use-cases/check-plugin-release.service.d.ts +22 -0
  227. package/dist/src/plugin-host/use-cases/check-plugin-release.service.js +152 -0
  228. package/dist/src/plugin-host/use-cases/find-plugin-by-repository.service.d.ts +9 -0
  229. package/dist/src/plugin-host/use-cases/find-plugin-by-repository.service.js +35 -0
  230. package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.d.ts +14 -0
  231. package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.js +85 -0
  232. package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.d.ts +9 -0
  233. package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.js +67 -0
  234. package/dist/src/plugin-host/use-cases/get-plugin-installation-entry.service.js +2 -7
  235. package/dist/src/plugin-host/use-cases/install-plugin.service.js +4 -0
  236. package/dist/src/plugin-host/use-cases/list-installations.service.d.ts +3 -1
  237. package/dist/src/plugin-host/use-cases/list-installations.service.js +14 -3
  238. package/dist/src/plugin-host/use-cases/list-plugin-history.service.d.ts +25 -0
  239. package/dist/src/plugin-host/use-cases/list-plugin-history.service.js +147 -0
  240. package/dist/src/plugin-host/use-cases/plugin-publisher-access.d.ts +5 -0
  241. package/dist/src/plugin-host/use-cases/plugin-publisher-access.js +28 -0
  242. package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.d.ts +12 -0
  243. package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.js +64 -0
  244. package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.d.ts +3 -5
  245. package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.js +15 -59
  246. package/dist/src/plugin-host/use-cases/uninstall-plugin.service.js +3 -1
  247. package/dist/src/plugin-host/use-cases/update-plugin.service.d.ts +0 -1
  248. package/dist/src/plugin-host/use-cases/update-plugin.service.js +3 -25
  249. package/dist/src/plugin-host/utils/action-input-schema.util.d.ts +14 -0
  250. package/dist/src/plugin-host/utils/action-input-schema.util.js +133 -0
  251. package/dist/src/plugin-host/utils/credential-handles.util.d.ts +3 -0
  252. package/dist/src/plugin-host/utils/credential-handles.util.js +13 -0
  253. package/dist/src/plugin-host/utils/execution-token.util.d.ts +5 -0
  254. package/dist/src/plugin-host/utils/execution-token.util.js +13 -0
  255. package/dist/src/plugin-host/utils/github-repo-locator.util.js +1 -1
  256. package/dist/src/plugin-host/utils/json-shape.util.d.ts +1 -0
  257. package/dist/src/plugin-host/utils/json-shape.util.js +21 -0
  258. package/dist/src/plugin-host/utils/plugin-action-outcome.util.d.ts +10 -0
  259. package/dist/src/plugin-host/utils/plugin-action-outcome.util.js +67 -0
  260. package/dist/src/plugin-host/utils/plugin-manifest.util.d.ts +121 -0
  261. package/dist/src/plugin-host/utils/plugin-manifest.util.js +111 -1
  262. package/dist/src/plugin-host/utils/request-abort-signal.util.d.ts +5 -0
  263. package/dist/src/plugin-host/utils/request-abort-signal.util.js +19 -0
  264. package/package.json +10 -8
@@ -13,6 +13,13 @@ export declare class RemoteUrlValidatorService {
13
13
  private readonly logger;
14
14
  constructor(config: PluginHostConfigService);
15
15
  validate(rawUrl: string): Promise<RemoteUrlCheckResult>;
16
+ checkPublicHttps(rawUrl: string): Promise<{
17
+ readonly ok: true;
18
+ } | {
19
+ readonly ok: false;
20
+ readonly code: ReleaseRejectionCode;
21
+ readonly detail: string;
22
+ }>;
16
23
  private run;
17
24
  private walk;
18
25
  private guard;
@@ -34,6 +34,10 @@ let RemoteUrlValidatorService = RemoteUrlValidatorService_1 = class RemoteUrlVal
34
34
  return this.reject(release_rejection_code_enum_1.ReleaseRejectionCode.URL_UNREACHABLE, 'The delivery URL could not be read');
35
35
  }
36
36
  }
37
+ async checkPublicHttps(rawUrl) {
38
+ const guarded = await this.guard(rawUrl);
39
+ return guarded.ok ? { ok: true } : guarded;
40
+ }
37
41
  async run(rawUrl) {
38
42
  const walked = await this.walk(rawUrl, release_rejection_code_enum_1.ReleaseRejectionCode.URL_UNREACHABLE);
39
43
  if (!walked.ok) {
@@ -0,0 +1,14 @@
1
+ import { SystemTrigger } from '../../common/scheduler/shared/entities/system-trigger.entity';
2
+ import { BaseSystemTaskProcessor } from '../../common/scheduler/system-tasks/base-system-task.processor';
3
+ import { SystemTriggerType } from '../../common/scheduler/system-tasks/system-trigger-type';
4
+ import { PluginActionExecutionService } from '../services/plugin-action-execution.service';
5
+ export declare class PluginActionExecutionSweepProcessor extends BaseSystemTaskProcessor {
6
+ private readonly executions;
7
+ private readonly logger;
8
+ constructor(executions: PluginActionExecutionService);
9
+ getType(): SystemTriggerType;
10
+ getDefaultCron(): string;
11
+ process(_trigger: SystemTrigger, options?: {
12
+ signal?: AbortSignal;
13
+ }): Promise<void>;
14
+ }
@@ -0,0 +1,50 @@
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 PluginActionExecutionSweepProcessor_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.PluginActionExecutionSweepProcessor = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const base_system_task_processor_1 = require("../../common/scheduler/system-tasks/base-system-task.processor");
16
+ const system_trigger_type_1 = require("../../common/scheduler/system-tasks/system-trigger-type");
17
+ const plugin_action_limits_1 = require("../constants/plugin-action-limits");
18
+ const plugin_action_execution_service_1 = require("../services/plugin-action-execution.service");
19
+ const CRON = '* * * * *';
20
+ const HOUR_MS = 60 * 60 * 1000;
21
+ const DAY_MS = 24 * HOUR_MS;
22
+ let PluginActionExecutionSweepProcessor = PluginActionExecutionSweepProcessor_1 = class PluginActionExecutionSweepProcessor extends base_system_task_processor_1.BaseSystemTaskProcessor {
23
+ executions;
24
+ logger = new common_1.Logger(PluginActionExecutionSweepProcessor_1.name);
25
+ constructor(executions) {
26
+ super();
27
+ this.executions = executions;
28
+ }
29
+ getType() {
30
+ return system_trigger_type_1.SystemTriggerType.PLUGIN_ACTION_EXECUTION_SWEEP;
31
+ }
32
+ getDefaultCron() {
33
+ return CRON;
34
+ }
35
+ async process(_trigger, options) {
36
+ const now = Date.now();
37
+ const timedOut = await this.executions.timeOutOrphans(new Date(now - plugin_action_limits_1.PLUGIN_ACTION_LIMITS.orphanGraceMs));
38
+ await this.executions.clearPayloads(new Date(now - plugin_action_limits_1.PLUGIN_ACTION_LIMITS.payloadRetentionHours * HOUR_MS), options?.signal);
39
+ await this.executions.deleteFinished(new Date(now - plugin_action_limits_1.PLUGIN_ACTION_LIMITS.rowRetentionDays * DAY_MS), options?.signal);
40
+ if (timedOut > 0) {
41
+ this.logger.warn(`${timedOut} plugin action executions outlived the replica that dispatched them and were marked TIMED_OUT`);
42
+ }
43
+ }
44
+ };
45
+ exports.PluginActionExecutionSweepProcessor = PluginActionExecutionSweepProcessor;
46
+ exports.PluginActionExecutionSweepProcessor = PluginActionExecutionSweepProcessor = PluginActionExecutionSweepProcessor_1 = __decorate([
47
+ (0, common_1.Injectable)(),
48
+ __metadata("design:paramtypes", [plugin_action_execution_service_1.PluginActionExecutionService])
49
+ ], PluginActionExecutionSweepProcessor);
50
+ //# sourceMappingURL=plugin-action-execution-sweep.processor.js.map
@@ -0,0 +1,8 @@
1
+ import { CancelPluginActionExecutionCommand } from '../dto/domain/plugin-action-execution.command';
2
+ import type { PluginActionExecutionView } from '../dto/domain/plugin-action-execution.dto';
3
+ import { PluginActionExecutionService } from '../services/plugin-action-execution.service';
4
+ export declare class CancelPluginActionExecutionService {
5
+ private readonly executions;
6
+ constructor(executions: PluginActionExecutionService);
7
+ run(command: CancelPluginActionExecutionCommand): Promise<PluginActionExecutionView>;
8
+ }
@@ -0,0 +1,39 @@
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.CancelPluginActionExecutionService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const plugin_action_errors_1 = require("../errors/plugin-action.errors");
15
+ const plugin_action_execution_mapper_1 = require("../mappers/plugin-action-execution.mapper");
16
+ const plugin_action_execution_service_1 = require("../services/plugin-action-execution.service");
17
+ let CancelPluginActionExecutionService = class CancelPluginActionExecutionService {
18
+ executions;
19
+ constructor(executions) {
20
+ this.executions = executions;
21
+ }
22
+ async run(command) {
23
+ const installationId = command.context.installationId;
24
+ if (installationId) {
25
+ await this.executions.cancel(command.id, installationId);
26
+ }
27
+ const execution = await this.executions.findById(command.id);
28
+ if (!execution || execution.installationId !== installationId) {
29
+ throw new plugin_action_errors_1.ExecutionNotFoundError();
30
+ }
31
+ return (0, plugin_action_execution_mapper_1.toPluginActionExecutionView)(execution);
32
+ }
33
+ };
34
+ exports.CancelPluginActionExecutionService = CancelPluginActionExecutionService;
35
+ exports.CancelPluginActionExecutionService = CancelPluginActionExecutionService = __decorate([
36
+ (0, common_1.Injectable)(),
37
+ __metadata("design:paramtypes", [plugin_action_execution_service_1.PluginActionExecutionService])
38
+ ], CancelPluginActionExecutionService);
39
+ //# sourceMappingURL=cancel-plugin-action-execution.service.js.map
@@ -0,0 +1,22 @@
1
+ import { PluginHostConfigService } from '../config/plugin-host.config';
2
+ import { CheckPluginReleaseCommand, PluginReleaseCheckResultDto } from '../dto/domain/check-plugin-release.command';
3
+ import { GithubApiService } from '../services/github-api.service';
4
+ import { PluginPublicationService } from '../services/plugin-publication.service';
5
+ import { PluginVersionService } from '../services/plugin-version.service';
6
+ import { PluginService } from '../services/plugin.service';
7
+ import { PublicationAuthorizationService } from '../services/publication-authorization.service';
8
+ import { ReleaseCandidateRulesService } from '../services/release-candidate-rules.service';
9
+ export declare class CheckPluginReleaseService {
10
+ private readonly pluginService;
11
+ private readonly authorization;
12
+ private readonly publications;
13
+ private readonly versionService;
14
+ private readonly githubApi;
15
+ private readonly candidateRules;
16
+ private readonly config;
17
+ private readonly lastCheckAt;
18
+ constructor(pluginService: PluginService, authorization: PublicationAuthorizationService, publications: PluginPublicationService, versionService: PluginVersionService, githubApi: GithubApiService, candidateRules: ReleaseCandidateRulesService, config: PluginHostConfigService);
19
+ run(command: CheckPluginReleaseCommand): Promise<PluginReleaseCheckResultDto>;
20
+ private versionConflict;
21
+ private claimSlot;
22
+ }
@@ -0,0 +1,152 @@
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.CheckPluginReleaseService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const plugin_host_config_1 = require("../config/plugin-host.config");
15
+ const github_access_mode_enum_1 = require("../enums/github-access-mode.enum");
16
+ const release_rejection_code_enum_1 = require("../enums/release-rejection-code.enum");
17
+ const plugin_host_errors_1 = require("../errors/plugin-host.errors");
18
+ const github_api_service_1 = require("../services/github-api.service");
19
+ const plugin_publication_service_1 = require("../services/plugin-publication.service");
20
+ const plugin_version_service_1 = require("../services/plugin-version.service");
21
+ const plugin_service_1 = require("../services/plugin.service");
22
+ const publication_authorization_service_1 = require("../services/publication-authorization.service");
23
+ const release_candidate_rules_service_1 = require("../services/release-candidate-rules.service");
24
+ const github_repo_locator_util_1 = require("../utils/github-repo-locator.util");
25
+ const semver_util_1 = require("../utils/semver.util");
26
+ const plugin_publisher_access_1 = require("./plugin-publisher-access");
27
+ let CheckPluginReleaseService = class CheckPluginReleaseService {
28
+ pluginService;
29
+ authorization;
30
+ publications;
31
+ versionService;
32
+ githubApi;
33
+ candidateRules;
34
+ config;
35
+ lastCheckAt = new Map();
36
+ constructor(pluginService, authorization, publications, versionService, githubApi, candidateRules, config) {
37
+ this.pluginService = pluginService;
38
+ this.authorization = authorization;
39
+ this.publications = publications;
40
+ this.versionService = versionService;
41
+ this.githubApi = githubApi;
42
+ this.candidateRules = candidateRules;
43
+ this.config = config;
44
+ }
45
+ async run(command) {
46
+ const namedSemver = command.version === undefined ? null : eligibleSemver(command.version);
47
+ const locator = (0, github_repo_locator_util_1.parseGithubRepoLocator)(command.repoLocator);
48
+ const plugin = await this.pluginService.findByRepoName(locator.owner, locator.name);
49
+ const isPublisher = this.authorization.isDeploymentPublisher(command.context);
50
+ const notFound = () => new common_1.NotFoundException(`Plugin ${locator.owner}/${locator.name} was not found on this deployment`);
51
+ if (!plugin ||
52
+ !(isPublisher || (await (0, plugin_publisher_access_1.managesPublicationOf)(this.publications, plugin.id, command.context)))) {
53
+ throw notFound();
54
+ }
55
+ this.claimSlot(`${plugin.id}:${command.context.userId || command.context.apiKeyId}`);
56
+ const ref = { owner: plugin.repoOwner, name: plugin.repoName };
57
+ if ((await this.githubApi.getRepo(ref)).githubRepoId !== plugin.githubRepoId) {
58
+ throw notFound();
59
+ }
60
+ const current = plugin.currentVersionId
61
+ ? await this.versionService.findById(plugin.currentVersionId)
62
+ : null;
63
+ const semver = namedSemver ?? (current ? nextVersionOf(current.semver) : null);
64
+ const identity = {
65
+ pluginId: plugin.id,
66
+ repository: `${ref.owner}/${ref.name}`,
67
+ candidateVersion: semver,
68
+ };
69
+ const commitSha = await this.githubApi.resolveCommitSha(ref, command.ref);
70
+ if (!commitSha) {
71
+ return {
72
+ ...identity,
73
+ commitSha: null,
74
+ baselineVersion: null,
75
+ collectionsEvaluated: false,
76
+ issues: [
77
+ {
78
+ code: release_rejection_code_enum_1.ReleaseRejectionCode.COMMIT_UNRESOLVABLE,
79
+ detail: `Ref ${command.ref} does not resolve to a commit`,
80
+ },
81
+ ],
82
+ };
83
+ }
84
+ const versionIssue = semver ? await this.versionConflict(plugin.id, semver, current) : null;
85
+ const report = await this.candidateRules.collectAll({
86
+ pluginId: plugin.id,
87
+ ref,
88
+ commitSha,
89
+ semver,
90
+ });
91
+ return {
92
+ ...identity,
93
+ commitSha,
94
+ baselineVersion: report.baselineSemver,
95
+ collectionsEvaluated: report.collectionsEvaluated,
96
+ issues: [...(versionIssue ? [versionIssue] : []), ...report.issues],
97
+ };
98
+ }
99
+ async versionConflict(pluginId, semver, current) {
100
+ const recorded = await this.versionService.findBySemver(pluginId, semver);
101
+ if (recorded) {
102
+ return {
103
+ code: release_rejection_code_enum_1.ReleaseRejectionCode.VERSION_CONFLICT,
104
+ detail: `Version ${semver} is already recorded from commit ${recorded.commitSha}`,
105
+ };
106
+ }
107
+ if (current && (0, semver_util_1.compareSemver)(semver, current.semver) < 0) {
108
+ return {
109
+ code: release_rejection_code_enum_1.ReleaseRejectionCode.VERSION_CONFLICT,
110
+ detail: `Version ${semver} is lower than the current version ${current.semver}; release sync stops at the current version, so it would never become current`,
111
+ };
112
+ }
113
+ return null;
114
+ }
115
+ claimSlot(key) {
116
+ const mode = this.config.isAppModeConfigured
117
+ ? github_access_mode_enum_1.GithubAccessMode.APP
118
+ : this.config.githubToken
119
+ ? github_access_mode_enum_1.GithubAccessMode.SERVER_TOKEN
120
+ : github_access_mode_enum_1.GithubAccessMode.ANONYMOUS;
121
+ const intervalMs = this.config.getSyncMinIntervalMs(mode);
122
+ const now = Date.now();
123
+ const last = this.lastCheckAt.get(key);
124
+ if (last !== undefined && now - last < intervalMs) {
125
+ throw new plugin_host_errors_1.PluginCheckRateLimitedError(Math.ceil((last + intervalMs - now) / 1000));
126
+ }
127
+ this.lastCheckAt.set(key, now);
128
+ }
129
+ };
130
+ exports.CheckPluginReleaseService = CheckPluginReleaseService;
131
+ exports.CheckPluginReleaseService = CheckPluginReleaseService = __decorate([
132
+ (0, common_1.Injectable)(),
133
+ __metadata("design:paramtypes", [plugin_service_1.PluginService,
134
+ publication_authorization_service_1.PublicationAuthorizationService,
135
+ plugin_publication_service_1.PluginPublicationService,
136
+ plugin_version_service_1.PluginVersionService,
137
+ github_api_service_1.GithubApiService,
138
+ release_candidate_rules_service_1.ReleaseCandidateRulesService,
139
+ plugin_host_config_1.PluginHostConfigService])
140
+ ], CheckPluginReleaseService);
141
+ function nextVersionOf(current) {
142
+ const [major, minor, patch] = current.split('.').map(Number);
143
+ return major === 0 ? `0.${minor}.${patch + 1}` : `${major}.${minor + 1}.0`;
144
+ }
145
+ function eligibleSemver(version) {
146
+ const parsed = (0, semver_util_1.parseReleaseTag)(version);
147
+ if (!parsed.ok) {
148
+ throw new common_1.BadRequestException(`Version ${version} is not eligible: use X.Y.Z, optionally prefixed with v, without prerelease or build metadata`);
149
+ }
150
+ return (0, semver_util_1.formatSemver)(parsed.parts);
151
+ }
152
+ //# sourceMappingURL=check-plugin-release.service.js.map
@@ -0,0 +1,9 @@
1
+ import { FindPluginByRepositoryCommand } from '../dto/domain/find-plugin-by-repository.command';
2
+ import { PluginPublicationService } from '../services/plugin-publication.service';
3
+ export declare class FindPluginByRepositoryService {
4
+ private readonly publications;
5
+ constructor(publications: PluginPublicationService);
6
+ run(command: FindPluginByRepositoryCommand): Promise<{
7
+ pluginId: string;
8
+ }>;
9
+ }
@@ -0,0 +1,35 @@
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.FindPluginByRepositoryService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const plugin_publication_service_1 = require("../services/plugin-publication.service");
15
+ const github_repo_locator_util_1 = require("../utils/github-repo-locator.util");
16
+ let FindPluginByRepositoryService = class FindPluginByRepositoryService {
17
+ publications;
18
+ constructor(publications) {
19
+ this.publications = publications;
20
+ }
21
+ async run(command) {
22
+ const { owner, name } = (0, github_repo_locator_util_1.parseGithubRepoLocator)(command.repository);
23
+ const pluginId = await this.publications.findDeploymentPluginIdByRepo(command.context.projectId, owner, name);
24
+ if (!pluginId) {
25
+ throw new common_1.NotFoundException('No public plugin is published from this repository');
26
+ }
27
+ return { pluginId };
28
+ }
29
+ };
30
+ exports.FindPluginByRepositoryService = FindPluginByRepositoryService;
31
+ exports.FindPluginByRepositoryService = FindPluginByRepositoryService = __decorate([
32
+ (0, common_1.Injectable)(),
33
+ __metadata("design:paramtypes", [plugin_publication_service_1.PluginPublicationService])
34
+ ], FindPluginByRepositoryService);
35
+ //# sourceMappingURL=find-plugin-by-repository.service.js.map
@@ -0,0 +1,14 @@
1
+ import { type CredentialConsumerBindingFacade } from '../../data-marts/credentials/facades/credential-consumer-binding.facade';
2
+ import { GetCurrentPluginActionExecutionCommand } from '../dto/domain/plugin-action-execution.command';
3
+ import type { PluginActionWorkerContext } from '../dto/domain/plugin-action-execution.dto';
4
+ import { PluginActionExecutionService } from '../services/plugin-action-execution.service';
5
+ import { PluginVersionService } from '../services/plugin-version.service';
6
+ import { PluginService } from '../services/plugin.service';
7
+ export declare class GetCurrentPluginActionExecutionService {
8
+ private readonly executions;
9
+ private readonly plugins;
10
+ private readonly versions;
11
+ private readonly credentialBindings;
12
+ constructor(executions: PluginActionExecutionService, plugins: PluginService, versions: PluginVersionService, credentialBindings: CredentialConsumerBindingFacade);
13
+ run(command: GetCurrentPluginActionExecutionCommand): Promise<PluginActionWorkerContext>;
14
+ }
@@ -0,0 +1,85 @@
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.GetCurrentPluginActionExecutionService = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const credential_consumer_binding_facade_1 = require("../../data-marts/credentials/facades/credential-consumer-binding.facade");
18
+ const credential_types_1 = require("../../data-marts/credentials/credential.types");
19
+ const plugin_action_errors_1 = require("../errors/plugin-action.errors");
20
+ const plugin_action_execution_service_1 = require("../services/plugin-action-execution.service");
21
+ const plugin_version_service_1 = require("../services/plugin-version.service");
22
+ const plugin_service_1 = require("../services/plugin.service");
23
+ const credential_handles_util_1 = require("../utils/credential-handles.util");
24
+ let GetCurrentPluginActionExecutionService = class GetCurrentPluginActionExecutionService {
25
+ executions;
26
+ plugins;
27
+ versions;
28
+ credentialBindings;
29
+ constructor(executions, plugins, versions, credentialBindings) {
30
+ this.executions = executions;
31
+ this.plugins = plugins;
32
+ this.versions = versions;
33
+ this.credentialBindings = credentialBindings;
34
+ }
35
+ async run(command) {
36
+ const { context } = command;
37
+ if (!context.executionId) {
38
+ throw new plugin_action_errors_1.ExecutionTokenRequiredError();
39
+ }
40
+ const execution = await this.executions.findWithInput(context.executionId);
41
+ if (!execution?.deadlineAt || execution.installationId !== context.installationId) {
42
+ throw new plugin_action_errors_1.ExecutionNotFoundError();
43
+ }
44
+ const plugin = await this.plugins.findById(execution.pluginId);
45
+ const current = plugin?.currentVersionId
46
+ ? await this.versions.findById(plugin.currentVersionId)
47
+ : null;
48
+ const started = current?.id === execution.pluginVersionId
49
+ ? current
50
+ : await this.versions.findById(execution.pluginVersionId);
51
+ if (!plugin || !current || !started) {
52
+ throw new plugin_action_errors_1.ExecutionNotFoundError();
53
+ }
54
+ const ready = await this.credentialBindings.assertConsumerReady({
55
+ projectId: context.projectId,
56
+ userId: context.userId,
57
+ roles: context.roles ?? [],
58
+ consumerType: 'plugin-installation',
59
+ consumerId: execution.installationId,
60
+ requirements: (current.credentialRequirements ?? []).filter(requirement => (0, credential_types_1.normalizeCredentialRequirement)(requirement).definitionId !== null),
61
+ });
62
+ return {
63
+ executionId: execution.id,
64
+ action: execution.action,
65
+ input: execution.input,
66
+ trigger: execution.trigger,
67
+ deadlineAt: execution.deadlineAt,
68
+ plugin: { id: plugin.id, repositoryId: plugin.githubRepoId },
69
+ pluginVersion: started.semver,
70
+ installationId: execution.installationId,
71
+ projectId: execution.projectId,
72
+ userId: execution.userId,
73
+ credentialHandles: (0, credential_handles_util_1.toCredentialHandles)(ready),
74
+ };
75
+ }
76
+ };
77
+ exports.GetCurrentPluginActionExecutionService = GetCurrentPluginActionExecutionService;
78
+ exports.GetCurrentPluginActionExecutionService = GetCurrentPluginActionExecutionService = __decorate([
79
+ (0, common_1.Injectable)(),
80
+ __param(3, (0, common_1.Inject)(credential_consumer_binding_facade_1.CREDENTIAL_CONSUMER_BINDING_FACADE)),
81
+ __metadata("design:paramtypes", [plugin_action_execution_service_1.PluginActionExecutionService,
82
+ plugin_service_1.PluginService,
83
+ plugin_version_service_1.PluginVersionService, Object])
84
+ ], GetCurrentPluginActionExecutionService);
85
+ //# sourceMappingURL=get-current-plugin-action-execution.service.js.map
@@ -0,0 +1,9 @@
1
+ import { GetPluginActionExecutionCommand } from '../dto/domain/plugin-action-execution.command';
2
+ import type { PluginActionExecutionView } from '../dto/domain/plugin-action-execution.dto';
3
+ import { PluginActionExecutionService } from '../services/plugin-action-execution.service';
4
+ export declare class GetPluginActionExecutionService {
5
+ private readonly executions;
6
+ constructor(executions: PluginActionExecutionService);
7
+ run(command: GetPluginActionExecutionCommand): Promise<PluginActionExecutionView>;
8
+ private find;
9
+ }
@@ -0,0 +1,67 @@
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.GetPluginActionExecutionService = 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 plugin_action_execution_mapper_1 = require("../mappers/plugin-action-execution.mapper");
18
+ const plugin_action_execution_service_1 = require("../services/plugin-action-execution.service");
19
+ let GetPluginActionExecutionService = class GetPluginActionExecutionService {
20
+ executions;
21
+ constructor(executions) {
22
+ this.executions = executions;
23
+ }
24
+ async run(command) {
25
+ const waitUntil = Date.now() + command.waitSeconds * 1000;
26
+ const execution = await this.find(command);
27
+ let status = execution.status;
28
+ let polled = false;
29
+ while (status !== null && !(0, plugin_action_execution_status_enum_1.isFinalPluginActionStatus)(status)) {
30
+ const remaining = waitUntil - Date.now();
31
+ if (remaining <= 0 || command.signal.aborted)
32
+ break;
33
+ await pause(Math.min(plugin_action_limits_1.PLUGIN_ACTION_LIMITS.waitPollMs, remaining), command.signal);
34
+ if (command.signal.aborted)
35
+ break;
36
+ status = await this.executions.findStatus(command.id);
37
+ polled = true;
38
+ }
39
+ return (0, plugin_action_execution_mapper_1.toPluginActionExecutionView)(polled ? await this.find(command) : execution);
40
+ }
41
+ async find(command) {
42
+ const execution = await this.executions.findById(command.id);
43
+ if (!execution || execution.installationId !== command.context.installationId) {
44
+ throw new plugin_action_errors_1.ExecutionNotFoundError();
45
+ }
46
+ return execution;
47
+ }
48
+ };
49
+ exports.GetPluginActionExecutionService = GetPluginActionExecutionService;
50
+ exports.GetPluginActionExecutionService = GetPluginActionExecutionService = __decorate([
51
+ (0, common_1.Injectable)(),
52
+ __metadata("design:paramtypes", [plugin_action_execution_service_1.PluginActionExecutionService])
53
+ ], GetPluginActionExecutionService);
54
+ function pause(ms, signal) {
55
+ return new Promise(resolve => {
56
+ const elapsed = new AbortController();
57
+ const timer = setTimeout(() => {
58
+ elapsed.abort();
59
+ resolve();
60
+ }, ms);
61
+ signal.addEventListener('abort', () => {
62
+ clearTimeout(timer);
63
+ resolve();
64
+ }, { once: true, signal: elapsed.signal });
65
+ });
66
+ }
67
+ //# sourceMappingURL=get-plugin-action-execution.service.js.map
@@ -18,6 +18,7 @@ const plugin_host_errors_1 = require("../errors/plugin-host.errors");
18
18
  const plugin_installation_service_1 = require("../services/plugin-installation.service");
19
19
  const plugin_version_service_1 = require("../services/plugin-version.service");
20
20
  const plugin_service_1 = require("../services/plugin.service");
21
+ const credential_handles_util_1 = require("../utils/credential-handles.util");
21
22
  const credential_consumer_binding_facade_1 = require("../../data-marts/credentials/facades/credential-consumer-binding.facade");
22
23
  let GetPluginInstallationEntryService = class GetPluginInstallationEntryService {
23
24
  installations;
@@ -62,13 +63,7 @@ let GetPluginInstallationEntryService = class GetPluginInstallationEntryService
62
63
  displayName: version.displayName,
63
64
  pluginId: plugin.id,
64
65
  versionId: version.id,
65
- credentialHandles: readyRequirements.map(requirement => requirement.definitionId === null
66
- ? {
67
- name: requirement.key,
68
- kind: 'ai',
69
- models: requirement.models,
70
- }
71
- : { name: requirement.key, kind: 'exact' }),
66
+ credentialHandles: (0, credential_handles_util_1.toCredentialHandles)(readyRequirements),
72
67
  };
73
68
  }
74
69
  };
@@ -69,13 +69,16 @@ let InstallPluginService = class InstallPluginService {
69
69
  }
70
70
  const existing = await this.installations.findOne(plugin.id, command.context.projectId, command.context.userId);
71
71
  let firstInstall = false;
72
+ let wasUninstalled = false;
72
73
  let installation;
73
74
  if (existing) {
75
+ wasUninstalled = existing.uninstalledAt !== null;
74
76
  installation = await this.restore(existing);
75
77
  }
76
78
  else {
77
79
  const claimed = await this.installations.installOrFind(plugin.id, command.context.projectId, command.context.userId);
78
80
  firstInstall = claimed.wonRace;
81
+ wasUninstalled = claimed.installation.uninstalledAt !== null;
79
82
  installation = claimed.wonRace
80
83
  ? claimed.installation
81
84
  : await this.restore(claimed.installation);
@@ -99,6 +102,7 @@ let InstallPluginService = class InstallPluginService {
99
102
  authorityScope: plugin_publication_scope_enum_1.PluginPublicationScope.MEMBER,
100
103
  projectId: command.context.projectId,
101
104
  userId: command.context.userId,
105
+ ...(firstInstall ? {} : { beforeState: { uninstalled: wasUninstalled } }),
102
106
  afterState: { versionId: plugin.currentVersionId },
103
107
  });
104
108
  return {
@@ -2,6 +2,7 @@ import { ListInstallationsCommand } from '../dto/domain/list-installations.comma
2
2
  import { InstalledPluginDto } from '../dto/domain/plugin-installation.dto';
3
3
  import { PluginPresentationMapper } from '../mappers/plugin-presentation.mapper';
4
4
  import { PluginInstallationService } from '../services/plugin-installation.service';
5
+ import { PluginPublicationService } from '../services/plugin-publication.service';
5
6
  import { PluginVersionService } from '../services/plugin-version.service';
6
7
  import { PluginService } from '../services/plugin.service';
7
8
  export declare class ListInstallationsService {
@@ -9,6 +10,7 @@ export declare class ListInstallationsService {
9
10
  private readonly pluginService;
10
11
  private readonly versionService;
11
12
  private readonly mapper;
12
- constructor(installations: PluginInstallationService, pluginService: PluginService, versionService: PluginVersionService, mapper: PluginPresentationMapper);
13
+ private readonly publications;
14
+ constructor(installations: PluginInstallationService, pluginService: PluginService, versionService: PluginVersionService, mapper: PluginPresentationMapper, publications: PluginPublicationService);
13
15
  run(command: ListInstallationsCommand): Promise<InstalledPluginDto[]>;
14
16
  }