@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,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.SearchDataMartsTool = void 0;
16
+ const context_input_1 = require("./context-input");
17
+ const mcp_contexts_facade_1 = require("../../../data-marts/facades/mcp-contexts.facade");
16
18
  const common_1 = require("@nestjs/common");
17
19
  const zod_v4_1 = require("zod-v4");
18
20
  const search_facade_1 = require("../../../common/search/search.facade");
@@ -28,6 +30,7 @@ const DEFAULT_LIMIT = 10;
28
30
  const MAX_LIMIT = 25;
29
31
  const inputSchema = zod_v4_1.z
30
32
  .object({
33
+ context_ids: context_input_1.contextIdsSchema,
31
34
  prompt: zod_v4_1.z.string().trim().min(2).max(256),
32
35
  limit: zod_v4_1.z.number().int().min(1).max(MAX_LIMIT).optional(),
33
36
  })
@@ -37,8 +40,9 @@ let SearchDataMartsTool = class SearchDataMartsTool {
37
40
  publicOriginService;
38
41
  projectContext;
39
42
  dataMarts;
43
+ contexts;
40
44
  name = 'get_relevant_data_marts_by_prompt';
41
- description = 'Find relevant non-draft data marts in the current OWOX project from a natural-language prompt, limited to data marts visible to the current MCP user. This is the default discovery step for a concrete analytical question when the data mart has not already been confirmed. Use it when the user asks to find, discover, or search published data marts by title, description, business meaning, schema fields, or metrics. This tool returns only data marts, not data storages or destinations, and it intentionally excludes draft data marts.';
45
+ description = 'Find relevant non-draft data marts in the current OWOX project from a natural-language prompt, limited to data marts visible to the current MCP user. This is the default discovery step for a concrete analytical question when the data mart has not already been confirmed. Use it when the user asks to find, discover, or search published data marts by title, description, business meaning, schema fields, or metrics. This tool returns only data marts, not data storages or destinations, and it intentionally excludes draft data marts. Use get_project_context → list_contexts to discover business goals, then pass context_ids to restrict discovery to any selected context; omission preserves project-wide discovery within your existing access. Responses include all attached context IDs and names.';
42
46
  zodSchema = inputSchema.shape;
43
47
  outputSchema = {
44
48
  project: zod_v4_1.z.object({ id: zod_v4_1.z.string(), title: zod_v4_1.z.string() }).optional(),
@@ -46,6 +50,7 @@ let SearchDataMartsTool = class SearchDataMartsTool {
46
50
  id: zod_v4_1.z.string(),
47
51
  title: zod_v4_1.z.string(),
48
52
  description: zod_v4_1.z.string(),
53
+ contexts: (0, context_input_1.makeContextSummariesSchema)(),
49
54
  url: zod_v4_1.z.string(),
50
55
  relevance_score: zod_v4_1.z.number(),
51
56
  })),
@@ -60,22 +65,26 @@ let SearchDataMartsTool = class SearchDataMartsTool {
60
65
  openWorldHint: false,
61
66
  };
62
67
  requiredScopes = ['mcp:read'];
63
- constructor(searchFacade, publicOriginService, projectContext, dataMarts) {
68
+ constructor(searchFacade, publicOriginService, projectContext, dataMarts, contexts) {
64
69
  this.searchFacade = searchFacade;
65
70
  this.publicOriginService = publicOriginService;
66
71
  this.projectContext = projectContext;
67
72
  this.dataMarts = dataMarts;
73
+ this.contexts = contexts;
68
74
  }
69
75
  parseInput(input) {
70
76
  return inputSchema.parse(input);
71
77
  }
72
78
  async handler(input, context) {
73
79
  const parsed = this.parseInput(input);
80
+ if (parsed.context_ids)
81
+ await this.contexts.validateContextIds(context.projectId, parsed.context_ids);
74
82
  const [results, projectContext] = await Promise.all([
75
83
  this.searchFacade.search(context.projectId, parsed.prompt, {
76
84
  topK: parsed.limit ?? DEFAULT_LIMIT,
77
85
  entityTypes: [search_facade_1.SearchableEntityType.DATA_MART],
78
86
  excludeDrafts: true,
87
+ ...(parsed.context_ids ? { contextIds: parsed.context_ids } : {}),
79
88
  accessScope: {
80
89
  userId: context.userId,
81
90
  roles: context.roles,
@@ -83,6 +92,9 @@ let SearchDataMartsTool = class SearchDataMartsTool {
83
92
  }),
84
93
  (0, mcp_project_summary_util_1.tryGetMcpProjectSummary)(this.projectContext, context),
85
94
  ]);
95
+ const attachedContexts = await this.contexts.getDataMartContexts(context.projectId, results
96
+ .filter(result => result.entityType === search_facade_1.SearchableEntityType.DATA_MART)
97
+ .map(result => result.entityId));
86
98
  const publicOrigin = this.publicOriginService.getPublicOrigin();
87
99
  const dataMarts = results
88
100
  .filter(result => result.entityType === search_facade_1.SearchableEntityType.DATA_MART)
@@ -91,6 +103,7 @@ let SearchDataMartsTool = class SearchDataMartsTool {
91
103
  title: result.title,
92
104
  description: result.description ?? '',
93
105
  url: (0, mcp_public_url_util_1.joinPublicOrigin)(publicOrigin, (0, data_mart_ui_path_1.buildDataMartUiPath)(context.projectId, result.entityId)),
106
+ contexts: attachedContexts[result.entityId] ?? [],
94
107
  relevance_score: result.finalScore,
95
108
  }));
96
109
  const gettingStarted = dataMarts.length === 0
@@ -110,6 +123,7 @@ exports.SearchDataMartsTool = SearchDataMartsTool = __decorate([
110
123
  __param(0, (0, common_1.Inject)(search_facade_1.SEARCH_FACADE)),
111
124
  __param(2, (0, common_1.Inject)(mcp_project_context_facade_1.MCP_PROJECT_CONTEXT_FACADE)),
112
125
  __param(3, (0, common_1.Inject)(mcp_data_marts_facade_1.MCP_DATA_MARTS_FACADE)),
113
- __metadata("design:paramtypes", [Object, public_origin_service_1.PublicOriginService, Object, Object])
126
+ __param(4, (0, common_1.Inject)(mcp_contexts_facade_1.MCP_CONTEXTS_FACADE)),
127
+ __metadata("design:paramtypes", [Object, public_origin_service_1.PublicOriginService, Object, Object, Object])
114
128
  ], SearchDataMartsTool);
115
129
  //# sourceMappingURL=search-data-marts.tool.js.map
@@ -49,7 +49,7 @@ let McpHttpEntryService = McpHttpEntryService_1 = class McpHttpEntryService {
49
49
  return;
50
50
  }
51
51
  const express = this.adapterHost.httpAdapter.getInstance();
52
- this.handler = (0, server_1.createMcpHandler)(({ authInfo }) => this.serverFactory.create((0, mcp_auth_middleware_1.toMcpAuthContext)(authInfo), this.instructionsService.getInstructions()), { onerror: error => this.onTransportError(error) });
52
+ this.handler = (0, server_1.createMcpHandler)(({ authInfo, era }) => this.serverFactory.create((0, mcp_auth_middleware_1.toMcpAuthContext)(authInfo), this.instructionsService.getInstructions(), { era, notifyToolsChanged: () => this.handler?.notify.toolsChanged() }), { onerror: error => this.onTransportError(error) });
53
53
  const nodeHandler = (0, node_1.toNodeHandler)(this.handler, {
54
54
  onerror: error => this.onTransportError(error),
55
55
  });
@@ -22,6 +22,7 @@ function getAuthorizationContext(request) {
22
22
  pluginId: request.idpContext.pluginId,
23
23
  installationId: request.idpContext.installationId,
24
24
  viewOnly: request.idpContext.viewOnly,
25
+ executionId: request.idpContext.executionId,
25
26
  };
26
27
  }
27
28
  throw new common_1.BadRequestException('Invalid authentication context');
@@ -19,6 +19,7 @@ export interface AuthenticatedRequest extends Request {
19
19
  pluginId?: string;
20
20
  installationId?: string;
21
21
  viewOnly?: boolean;
22
+ executionId?: string;
22
23
  };
23
24
  }
24
25
  export declare const AUTH_CONTEXT = "AuthContext";
@@ -31,10 +32,12 @@ export declare class IdpGuard implements CanActivate {
31
32
  constructor(reflector: Reflector, idpProviderService: IdpProviderService, cls: ClsService, idpProjectionsService: IdpProjectionsService, moduleRef: ModuleRef);
32
33
  canActivate(context: ExecutionContext): Promise<boolean>;
33
34
  private authenticateUser;
35
+ private authenticateExecution;
34
36
  private checkViewOnlyRestrictions;
35
37
  private checkApiKeyHeaderBinding;
36
38
  private checkApiKeyUsageRestrictions;
37
39
  private checkPluginRuntimeAuthorization;
40
+ private runtimeAuthorizer;
38
41
  private isNonEmptyString;
39
42
  private static readonly ROLE_DISPLAY_NAMES;
40
43
  private checkRoleAuthorization;
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.IdpGuard = exports.AUTH_CONTEXT = void 0;
14
14
  const common_1 = require("@nestjs/common");
15
15
  const idp_protocol_1 = require("@owox/idp-protocol");
16
+ const business_violation_exception_1 = require("../../common/exceptions/business-violation.exception");
16
17
  const idp_projections_service_1 = require("../services/idp-projections.service");
17
18
  const types_1 = require("../types");
18
19
  const core_1 = require("@nestjs/core");
@@ -78,6 +79,7 @@ let IdpGuard = class IdpGuard {
78
79
  pluginId: tokenPayload.pluginId,
79
80
  installationId: tokenPayload.installationId,
80
81
  viewOnly,
82
+ executionId: tokenPayload.executionId,
81
83
  };
82
84
  this.cls.set(exports.AUTH_CONTEXT, {
83
85
  userId: tokenPayload.userId,
@@ -88,13 +90,16 @@ let IdpGuard = class IdpGuard {
88
90
  pluginId: tokenPayload.pluginId,
89
91
  installationId: tokenPayload.installationId,
90
92
  viewOnly,
93
+ executionId: tokenPayload.executionId,
91
94
  });
92
95
  if (request && STATE_CHANGING_METHODS.includes(request.method)) {
93
96
  void this.idpProjectionsService.updateProjectionsFromIdpPayload(tokenPayload);
94
97
  }
95
98
  }
96
99
  catch (error) {
97
- if (error instanceof common_1.UnauthorizedException || error instanceof idp_protocol_1.AuthorizationError) {
100
+ if (error instanceof common_1.UnauthorizedException ||
101
+ error instanceof idp_protocol_1.AuthorizationError ||
102
+ (error instanceof business_violation_exception_1.BusinessViolationException && error.code === 'PLUGIN_SUSPENDED')) {
98
103
  throw error;
99
104
  }
100
105
  throw new idp_protocol_1.AuthenticationError('Authentication failed');
@@ -105,6 +110,10 @@ let IdpGuard = class IdpGuard {
105
110
  return true;
106
111
  }
107
112
  async authenticateUser(request, strategy) {
113
+ const executionToken = request.headers['x-owox-execution-token'];
114
+ if (executionToken !== undefined) {
115
+ return this.authenticateExecution(request, executionToken);
116
+ }
108
117
  const idpProvider = this.idpProviderService.getProvider(request);
109
118
  const token = request.headers['x-owox-authorization'] ?? '';
110
119
  const tokenPayload = strategy === types_1.Strategy.PARSE
@@ -113,7 +122,25 @@ let IdpGuard = class IdpGuard {
113
122
  if (!tokenPayload) {
114
123
  throw new idp_protocol_1.AuthenticationError('Invalid authorization');
115
124
  }
116
- return tokenPayload;
125
+ return { ...tokenPayload, executionId: undefined };
126
+ }
127
+ async authenticateExecution(request, executionToken) {
128
+ if (Array.isArray(executionToken) || request.headers['x-owox-authorization'] !== undefined) {
129
+ throw new idp_protocol_1.AuthenticationError('Send one authorization header');
130
+ }
131
+ const identity = await this.runtimeAuthorizer().resolveExecutionToken(executionToken);
132
+ if (!identity) {
133
+ throw new idp_protocol_1.AuthenticationError('Invalid execution token');
134
+ }
135
+ return {
136
+ userId: identity.userId,
137
+ projectId: identity.projectId,
138
+ roles: [identity.role],
139
+ authFlow: 'plugin',
140
+ pluginId: identity.pluginId,
141
+ installationId: identity.installationId,
142
+ executionId: identity.executionId,
143
+ };
117
144
  }
118
145
  checkViewOnlyRestrictions(request, tokenPayload, viewOnlySafe) {
119
146
  if (!(0, idp_protocol_1.isViewOnlyPayload)(tokenPayload)) {
@@ -161,6 +188,14 @@ let IdpGuard = class IdpGuard {
161
188
  !this.isNonEmptyString(tokenPayload.userId)) {
162
189
  throw new idp_protocol_1.AuthorizationError('Invalid plugin runtime identity');
163
190
  }
191
+ await this.runtimeAuthorizer().assertActiveInstallation({
192
+ pluginId: tokenPayload.pluginId,
193
+ installationId: tokenPayload.installationId,
194
+ projectId: tokenPayload.projectId,
195
+ userId: tokenPayload.userId,
196
+ });
197
+ }
198
+ runtimeAuthorizer() {
164
199
  let authorizer;
165
200
  try {
166
201
  authorizer = this.moduleRef.get(plugin_runtime_authorizer_port_1.PLUGIN_RUNTIME_AUTHORIZER, {
@@ -173,12 +208,7 @@ let IdpGuard = class IdpGuard {
173
208
  if (!authorizer) {
174
209
  throw new idp_protocol_1.AuthorizationError('Plugin runtime authorization is unavailable');
175
210
  }
176
- await authorizer.assertActiveInstallation({
177
- pluginId: tokenPayload.pluginId,
178
- installationId: tokenPayload.installationId,
179
- projectId: tokenPayload.projectId,
180
- userId: tokenPayload.userId,
181
- });
211
+ return authorizer;
182
212
  }
183
213
  isNonEmptyString(value) {
184
214
  return typeof value === 'string' && value.trim().length > 0;
@@ -19,6 +19,7 @@ const internal_helpers_1 = require("@owox/internal-helpers");
19
19
  const idp_protocol_1 = require("@owox/idp-protocol");
20
20
  const idp_provider_service_1 = require("../../services/idp-provider.service");
21
21
  const oauth_client_registry_1 = require("../oauth-client.registry");
22
+ const mcp_client_integration_1 = require("../mcp-client-integration");
22
23
  const oauth_idp_port_1 = require("../oauth-idp.port");
23
24
  const oauth_project_selection_service_1 = require("../oauth-project-selection.service");
24
25
  const oauth_project_member_resolver_1 = require("../oauth-project-member.resolver");
@@ -66,7 +67,7 @@ let OAuthAuthorizationController = OAuthAuthorizationController_1 = class OAuthA
66
67
  const authorizationRequest = validated.request;
67
68
  const resourceContext = validated.resourceContext;
68
69
  const provider = this.idpProviderService.getProvider(request);
69
- const authorization = await this.resolveAuthorizationContext(provider, request, response);
70
+ const authorization = await this.resolveAuthorizationContext(provider, request, response, (0, mcp_client_integration_1.getMcpClientIntegration)(authorizationRequest.redirectUri));
70
71
  if (!authorization) {
71
72
  return;
72
73
  }
@@ -160,7 +161,7 @@ let OAuthAuthorizationController = OAuthAuthorizationController_1 = class OAuthA
160
161
  ? this.projectSelectionService.resolveSelectedProjectMember(provider, context, projects, selectedProjectId)
161
162
  : this.projectMemberResolver.resolve(context);
162
163
  }
163
- async resolveAuthorizationContext(provider, request, response) {
164
+ async resolveAuthorizationContext(provider, request, response, integration) {
164
165
  const accessToken = this.getHeaderValue(request, 'x-owox-authorization');
165
166
  if (accessToken) {
166
167
  const payload = await provider.parseToken(accessToken);
@@ -170,7 +171,7 @@ let OAuthAuthorizationController = OAuthAuthorizationController_1 = class OAuthA
170
171
  }
171
172
  const refreshToken = this.getCookieValue(request, 'refreshToken');
172
173
  if (!refreshToken) {
173
- this.redirectToSignIn(request, response);
174
+ this.redirectToSignIn(request, response, integration);
174
175
  return null;
175
176
  }
176
177
  try {
@@ -178,13 +179,13 @@ let OAuthAuthorizationController = OAuthAuthorizationController_1 = class OAuthA
178
179
  this.persistRefreshTokenIfReturned(request, response, auth);
179
180
  const payload = await provider.parseToken(auth.accessToken);
180
181
  if (!payload) {
181
- this.redirectToSignIn(request, response);
182
+ this.redirectToSignIn(request, response, integration);
182
183
  return null;
183
184
  }
184
185
  return { context: this.toAuthorizationContext(payload), accessToken: auth.accessToken };
185
186
  }
186
187
  catch {
187
- this.redirectToSignIn(request, response);
188
+ this.redirectToSignIn(request, response, integration);
188
189
  return null;
189
190
  }
190
191
  }
@@ -221,13 +222,14 @@ let OAuthAuthorizationController = OAuthAuthorizationController_1 = class OAuthA
221
222
  maxAge: auth.refreshTokenExpiresIn * 1000,
222
223
  });
223
224
  }
224
- redirectToSignIn(request, response) {
225
+ redirectToSignIn(request, response, integration) {
225
226
  const currentUrl = request.originalUrl || request.url;
226
227
  const host = request.get('host') ?? 'localhost';
227
228
  const signInUrl = new URL('/auth/sign-in', `${request.protocol}://${host}`);
228
229
  signInUrl.searchParams.set('redirect', currentUrl);
229
230
  signInUrl.searchParams.set('redirect-to', currentUrl);
230
231
  signInUrl.searchParams.set('app-redirect-to', currentUrl);
232
+ signInUrl.searchParams.set('integration', integration);
231
233
  this.logger.log('Redirecting OAuth authorize request to sign-in', {
232
234
  clientId: this.extractClientId(currentUrl, request, host),
233
235
  host,
@@ -0,0 +1 @@
1
+ export declare function getMcpClientIntegration(redirectUri: string): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMcpClientIntegration = getMcpClientIntegration;
4
+ function getMcpClientIntegration(redirectUri) {
5
+ const origin = new URL(redirectUri).origin;
6
+ switch (origin) {
7
+ case 'https://claude.ai':
8
+ return 'claude';
9
+ case 'https://chatgpt.com':
10
+ return 'chatgpt';
11
+ default:
12
+ return 'owox-data-marts';
13
+ }
14
+ }
15
+ //# sourceMappingURL=mcp-client-integration.js.map
@@ -1,10 +1,16 @@
1
+ import type { Role } from '@owox/idp-protocol';
1
2
  export interface PluginRuntimeIdentity {
2
3
  readonly pluginId: string;
3
4
  readonly installationId: string;
4
5
  readonly projectId: string;
5
6
  readonly userId: string;
6
7
  }
8
+ export interface PluginExecutionIdentity extends PluginRuntimeIdentity {
9
+ readonly executionId: string;
10
+ readonly role: Role;
11
+ }
7
12
  export declare const PLUGIN_RUNTIME_AUTHORIZER: unique symbol;
8
13
  export interface PluginRuntimeAuthorizerPort {
9
14
  assertActiveInstallation(identity: PluginRuntimeIdentity): Promise<void>;
15
+ resolveExecutionToken(token: string): Promise<PluginExecutionIdentity | null>;
10
16
  }
@@ -12,4 +12,5 @@ export interface AuthorizationContext {
12
12
  pluginId?: string;
13
13
  installationId?: string;
14
14
  viewOnly?: boolean;
15
+ executionId?: string;
15
16
  }
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class WidenSqlDryRunTriggerSqlColumn1790830000000 implements MigrationInterface {
3
+ readonly name = "WidenSqlDryRunTriggerSqlColumn1790830000000";
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WidenSqlDryRunTriggerSqlColumn1790830000000 = void 0;
4
+ class WidenSqlDryRunTriggerSqlColumn1790830000000 {
5
+ name = 'WidenSqlDryRunTriggerSqlColumn1790830000000';
6
+ async up(queryRunner) {
7
+ if (queryRunner.connection.options.type !== 'mysql') {
8
+ return;
9
+ }
10
+ await queryRunner.query('ALTER TABLE `sql_dry_run_triggers` MODIFY `sql` MEDIUMTEXT NOT NULL');
11
+ }
12
+ async down(queryRunner) {
13
+ if (queryRunner.connection.options.type !== 'mysql') {
14
+ return;
15
+ }
16
+ await queryRunner.query('DELETE FROM `sql_dry_run_triggers` WHERE LENGTH(`sql`) > 65535');
17
+ await queryRunner.query('ALTER TABLE `sql_dry_run_triggers` MODIFY `sql` TEXT NOT NULL');
18
+ }
19
+ }
20
+ exports.WidenSqlDryRunTriggerSqlColumn1790830000000 = WidenSqlDryRunTriggerSqlColumn1790830000000;
21
+ //# sourceMappingURL=1790830000000-widen-sql-dry-run-trigger-sql-column.js.map
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddPluginVersionBackend1790900000000 implements MigrationInterface {
3
+ readonly name = "AddPluginVersionBackend1790900000000";
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddPluginVersionBackend1790900000000 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const TABLE = 'plugin_version';
6
+ const COLUMN = 'backend';
7
+ class AddPluginVersionBackend1790900000000 {
8
+ name = 'AddPluginVersionBackend1790900000000';
9
+ async up(queryRunner) {
10
+ if (!(await queryRunner.hasColumn(TABLE, COLUMN))) {
11
+ await queryRunner.addColumn(TABLE, new typeorm_1.TableColumn({ name: COLUMN, type: 'json', isNullable: true }));
12
+ }
13
+ }
14
+ async down(queryRunner) {
15
+ if (await queryRunner.hasColumn(TABLE, COLUMN)) {
16
+ await queryRunner.dropColumn(TABLE, COLUMN);
17
+ }
18
+ }
19
+ }
20
+ exports.AddPluginVersionBackend1790900000000 = AddPluginVersionBackend1790900000000;
21
+ //# sourceMappingURL=1790900000000-add-plugin-version-backend.js.map
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreatePluginActionExecution1790900000001 implements MigrationInterface {
3
+ readonly name = "CreatePluginActionExecution1790900000001";
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreatePluginActionExecution1790900000001 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const migration_utils_1 = require("./migration-utils");
6
+ const TABLE = 'plugin_action_execution';
7
+ class CreatePluginActionExecution1790900000001 {
8
+ name = 'CreatePluginActionExecution1790900000001';
9
+ async up(queryRunner) {
10
+ if (await queryRunner.hasTable(TABLE)) {
11
+ return;
12
+ }
13
+ const payloadType = queryRunner.connection.options.type === 'mysql' ? 'mediumtext' : 'text';
14
+ await queryRunner.createTable(new typeorm_1.Table({
15
+ name: TABLE,
16
+ columns: [
17
+ { name: 'id', type: 'varchar', length: '36', isPrimary: true },
18
+ { name: 'pluginId', type: 'varchar', length: '36', isNullable: false },
19
+ { name: 'pluginVersionId', type: 'varchar', length: '36', isNullable: false },
20
+ { name: 'installationId', type: 'varchar', length: '36', isNullable: false },
21
+ { name: 'projectId', type: 'varchar', length: '255', isNullable: false },
22
+ { name: 'userId', type: 'varchar', length: '255', isNullable: false },
23
+ { name: 'action', type: 'varchar', length: '64', isNullable: false },
24
+ { name: 'input', type: payloadType, isNullable: true },
25
+ { name: 'trigger', type: 'varchar', length: '16', isNullable: false },
26
+ { name: 'status', type: 'varchar', length: '16', isNullable: false },
27
+ { name: 'role', type: 'varchar', length: '16', isNullable: false },
28
+ { name: 'tokenHash', type: 'varchar', length: '64', isNullable: true },
29
+ { name: 'deadlineAt', type: 'datetime', isNullable: true, default: null },
30
+ { name: 'createdAt', type: 'datetime', default: 'CURRENT_TIMESTAMP' },
31
+ { name: 'startedAt', type: 'datetime', isNullable: true, default: null },
32
+ { name: 'finishedAt', type: 'datetime', isNullable: true, default: null },
33
+ { name: 'errorCode', type: 'varchar', length: '64', isNullable: true },
34
+ { name: 'errorMessage', type: 'varchar', length: '1000', isNullable: true },
35
+ { name: 'result', type: payloadType, isNullable: true },
36
+ { name: 'payloadsClearedAt', type: 'datetime', isNullable: true, default: null },
37
+ { name: 'payloadBytes', type: 'int', isNullable: false, default: 0 },
38
+ ],
39
+ }));
40
+ for (const index of [
41
+ new typeorm_1.TableIndex({
42
+ name: 'UQ_plugin_action_execution_token',
43
+ columnNames: ['tokenHash'],
44
+ isUnique: true,
45
+ }),
46
+ new typeorm_1.TableIndex({
47
+ name: 'idx_plugin_action_execution_running',
48
+ columnNames: ['installationId', 'status'],
49
+ }),
50
+ new typeorm_1.TableIndex({
51
+ name: 'idx_plugin_action_execution_deadline',
52
+ columnNames: ['status', 'deadlineAt'],
53
+ }),
54
+ new typeorm_1.TableIndex({
55
+ name: 'idx_plugin_action_execution_starts',
56
+ columnNames: ['installationId', 'startedAt', 'payloadBytes'],
57
+ }),
58
+ new typeorm_1.TableIndex({
59
+ name: 'idx_plugin_action_execution_finished',
60
+ columnNames: ['finishedAt'],
61
+ }),
62
+ new typeorm_1.TableIndex({
63
+ name: 'idx_plugin_action_execution_payloads',
64
+ columnNames: ['payloadsClearedAt', 'finishedAt'],
65
+ }),
66
+ ]) {
67
+ await queryRunner.createIndex(TABLE, index);
68
+ }
69
+ }
70
+ async down(queryRunner) {
71
+ if (await queryRunner.hasTable(TABLE)) {
72
+ await (0, migration_utils_1.softDropTable)(queryRunner, TABLE);
73
+ }
74
+ }
75
+ }
76
+ exports.CreatePluginActionExecution1790900000001 = CreatePluginActionExecution1790900000001;
77
+ //# sourceMappingURL=1790900000001-create-plugin-action-execution.js.map
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddCredentialPublicMetadata1791000000000 implements MigrationInterface {
3
+ readonly name = "AddCredentialPublicMetadata1791000000000";
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddCredentialPublicMetadata1791000000000 = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const CREDENTIAL = 'credential';
6
+ const COLUMN = 'publicMetadata';
7
+ class AddCredentialPublicMetadata1791000000000 {
8
+ name = 'AddCredentialPublicMetadata1791000000000';
9
+ async up(queryRunner) {
10
+ if ((await queryRunner.hasTable(CREDENTIAL)) &&
11
+ !(await queryRunner.hasColumn(CREDENTIAL, COLUMN))) {
12
+ await queryRunner.addColumn(CREDENTIAL, new typeorm_1.TableColumn({ name: COLUMN, type: 'json', isNullable: true }));
13
+ }
14
+ }
15
+ async down(queryRunner) {
16
+ if ((await queryRunner.hasTable(CREDENTIAL)) &&
17
+ (await queryRunner.hasColumn(CREDENTIAL, COLUMN))) {
18
+ await queryRunner.dropColumn(CREDENTIAL, COLUMN);
19
+ }
20
+ }
21
+ }
22
+ exports.AddCredentialPublicMetadata1791000000000 = AddCredentialPublicMetadata1791000000000;
23
+ //# sourceMappingURL=1791000000000-add-credential-public-metadata.js.map
@@ -20,6 +20,7 @@ export interface PluginCollectionPageDto {
20
20
  }
21
21
  export interface ResolvedPluginCollection {
22
22
  readonly declaration: PluginCollectionDeclaration;
23
+ readonly semver: string;
23
24
  readonly namespaceKey: string;
24
25
  readonly memberId: string | null;
25
26
  }
@@ -7,6 +7,12 @@ export declare class PluginCollectionAuthorizationDeniedError extends ForbiddenE
7
7
  }
8
8
  export declare class PluginCollectionValidationError extends BadRequestException {
9
9
  }
10
+ export declare class PluginCollectionNotEntityBoundError extends PluginCollectionValidationError {
11
+ constructor(collectionName: string, semver: string);
12
+ }
13
+ export declare class PluginCollectionParentIdRequiredError extends PluginCollectionValidationError {
14
+ constructor(collectionName: string, entityType: string, semver: string);
15
+ }
10
16
  export declare class PluginCollectionQuotaExceededError extends PayloadTooLargeException {
11
17
  constructor(limit: string);
12
18
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PluginCollectionQuotaExceededError = exports.PluginCollectionValidationError = exports.PluginCollectionAuthorizationDeniedError = exports.PluginCollectionNotFoundError = void 0;
3
+ exports.PluginCollectionQuotaExceededError = exports.PluginCollectionParentIdRequiredError = exports.PluginCollectionNotEntityBoundError = exports.PluginCollectionValidationError = exports.PluginCollectionAuthorizationDeniedError = exports.PluginCollectionNotFoundError = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  class PluginCollectionNotFoundError extends common_1.NotFoundException {
6
6
  constructor() {
@@ -17,6 +17,24 @@ exports.PluginCollectionAuthorizationDeniedError = PluginCollectionAuthorization
17
17
  class PluginCollectionValidationError extends common_1.BadRequestException {
18
18
  }
19
19
  exports.PluginCollectionValidationError = PluginCollectionValidationError;
20
+ class PluginCollectionNotEntityBoundError extends PluginCollectionValidationError {
21
+ constructor(collectionName, semver) {
22
+ super({
23
+ code: 'PLUGIN_COLLECTION_NOT_ENTITY_BOUND',
24
+ message: `Collection "${collectionName}" has no entityBinding in plugin.json of the current version ${semver}, so put does not accept parentId`,
25
+ });
26
+ }
27
+ }
28
+ exports.PluginCollectionNotEntityBoundError = PluginCollectionNotEntityBoundError;
29
+ class PluginCollectionParentIdRequiredError extends PluginCollectionValidationError {
30
+ constructor(collectionName, entityType, semver) {
31
+ super({
32
+ code: 'PLUGIN_COLLECTION_PARENT_ID_REQUIRED',
33
+ message: `Collection "${collectionName}" has an entityBinding to ${entityType} in plugin.json of the current version ${semver}, so put requires parentId`,
34
+ });
35
+ }
36
+ }
37
+ exports.PluginCollectionParentIdRequiredError = PluginCollectionParentIdRequiredError;
20
38
  class PluginCollectionQuotaExceededError extends common_1.PayloadTooLargeException {
21
39
  constructor(limit) {
22
40
  super(`Plugin collection limit exceeded: ${limit}`);
@@ -27,8 +27,8 @@ let PluginCollectionDeclarationService = class PluginCollectionDeclarationServic
27
27
  if (!plugin?.currentVersionId)
28
28
  throw new plugin_collection_errors_1.PluginCollectionNotFoundError();
29
29
  const version = await this.versions.findById(plugin.currentVersionId);
30
- const declaration = (version?.collections ?? []).find(item => item.name === collectionName);
31
- if (!declaration)
30
+ const declaration = version?.collections?.find(item => item.name === collectionName);
31
+ if (!version || !declaration)
32
32
  throw new plugin_collection_errors_1.PluginCollectionNotFoundError();
33
33
  const memberId = declaration.scope === 'member' ? context.userId : null;
34
34
  const namespaceKey = (0, node_crypto_1.createHash)('sha256')
@@ -40,7 +40,7 @@ let PluginCollectionDeclarationService = class PluginCollectionDeclarationServic
40
40
  collectionName,
41
41
  ]))
42
42
  .digest('hex');
43
- return { declaration, namespaceKey, memberId };
43
+ return { declaration, semver: version.semver, namespaceKey, memberId };
44
44
  }
45
45
  };
46
46
  exports.PluginCollectionDeclarationService = PluginCollectionDeclarationService;
@@ -27,6 +27,13 @@ let PutPluginCollectionDocumentService = class PutPluginCollectionDocumentServic
27
27
  async run(command) {
28
28
  const resolved = await this.declarations.resolve(command.collectionName, command.context);
29
29
  try {
30
+ const { entityBinding } = resolved.declaration;
31
+ if (command.parentId !== null && !entityBinding) {
32
+ throw new plugin_collection_errors_1.PluginCollectionNotEntityBoundError(command.collectionName, resolved.semver);
33
+ }
34
+ if (command.parentId === null && entityBinding) {
35
+ throw new plugin_collection_errors_1.PluginCollectionParentIdRequiredError(command.collectionName, entityBinding.type, resolved.semver);
36
+ }
30
37
  return await this.persistence.put(resolved, command);
31
38
  }
32
39
  catch (error) {