@owox/backend 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/src/common/helpers/read-bounded-body.helper.d.ts +1 -0
  2. package/dist/src/common/helpers/read-bounded-body.helper.js +28 -0
  3. package/dist/src/common/scheduler/system-tasks/system-trigger-type.d.ts +3 -1
  4. package/dist/src/common/scheduler/system-tasks/system-trigger-type.js +2 -0
  5. package/dist/src/config/data-source-options.config.d.ts +4 -3
  6. package/dist/src/config/data-source-options.config.js +10 -3
  7. package/dist/src/config/plugin-collections-body-parser.config.js +3 -0
  8. package/dist/src/data-marts/credentials/credential.types.d.ts +26 -2
  9. package/dist/src/data-marts/credentials/credential.types.js +18 -6
  10. package/dist/src/data-marts/credentials/dto/credential-api.dto.d.ts +5 -1
  11. package/dist/src/data-marts/credentials/dto/credential-api.dto.js +21 -0
  12. package/dist/src/data-marts/credentials/dto/credential.dto.d.ts +2 -1
  13. package/dist/src/data-marts/credentials/entities/credential.entity.d.ts +2 -1
  14. package/dist/src/data-marts/credentials/entities/credential.entity.js +5 -0
  15. package/dist/src/data-marts/credentials/facades/credential-consumer-binding.facade.impl.js +6 -1
  16. package/dist/src/data-marts/credentials/mappers/credential.mapper.js +2 -0
  17. package/dist/src/data-marts/credentials/services/builtin-credential-definitions.js +8 -0
  18. package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.d.ts +4 -0
  19. package/dist/src/data-marts/credentials/services/credential-external-definition-registry.service.js +36 -17
  20. package/dist/src/data-marts/credentials/services/credential-fetch.service.d.ts +8 -0
  21. package/dist/src/data-marts/credentials/services/credential-fetch.service.js +115 -46
  22. package/dist/src/data-marts/credentials/services/credential-validation-probe.service.d.ts +3 -1
  23. package/dist/src/data-marts/credentials/services/credential-validation-probe.service.js +10 -2
  24. package/dist/src/data-marts/credentials/services/credential.service.d.ts +4 -0
  25. package/dist/src/data-marts/credentials/services/credential.service.js +36 -0
  26. package/dist/src/data-marts/credentials/services/google-service-account-key.d.ts +6 -0
  27. package/dist/src/data-marts/credentials/services/google-service-account-key.js +46 -0
  28. package/dist/src/data-marts/credentials/services/google-service-account-token.service.d.ts +25 -0
  29. package/dist/src/data-marts/credentials/services/google-service-account-token.service.js +177 -0
  30. package/dist/src/data-marts/credentials/use-cases/create-credential.service.d.ts +1 -0
  31. package/dist/src/data-marts/credentials/use-cases/create-credential.service.js +10 -2
  32. package/dist/src/data-marts/credentials/use-cases/update-credential.service.d.ts +1 -0
  33. package/dist/src/data-marts/credentials/use-cases/update-credential.service.js +28 -4
  34. package/dist/src/data-marts/credentials/use-cases/validate-credential.service.js +2 -5
  35. package/dist/src/data-marts/data-marts.module.js +4 -0
  36. package/dist/src/data-marts/data-storage-types/snowflake/adapters/snowflake-api.adapter.js +1 -0
  37. package/dist/src/data-marts/dto/presentation/run-data-mart-request-api.dto.js +4 -2
  38. package/dist/src/data-marts/services/connector/backfill-segment.d.ts +22 -0
  39. package/dist/src/data-marts/services/connector/backfill-segment.js +91 -0
  40. package/dist/src/data-marts/services/connector/connector-execution.service.d.ts +1 -0
  41. package/dist/src/data-marts/services/connector/connector-execution.service.js +3 -0
  42. package/dist/src/data-marts/services/connector/connector-executor.service.d.ts +4 -1
  43. package/dist/src/data-marts/services/connector/connector-executor.service.js +107 -23
  44. package/dist/src/data-marts/services/connector/connector-run.service.d.ts +3 -0
  45. package/dist/src/data-marts/services/connector/connector-run.service.js +98 -4
  46. package/dist/src/data-marts/services/data-mart-run.service.d.ts +1 -0
  47. package/dist/src/data-marts/services/data-mart-run.service.js +9 -0
  48. package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.d.ts +14 -0
  49. package/dist/src/data-marts/system-triggers/processors/repair-backfill-chains-processor.js +45 -0
  50. package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.d.ts +4 -0
  51. package/dist/src/data-marts/use-cases/cancel-data-mart-run.service.js +46 -1
  52. package/dist/src/data-marts/utils/manual-backfill-range.d.ts +52 -0
  53. package/dist/src/data-marts/utils/manual-backfill-range.js +110 -8
  54. package/dist/src/ee/mcp/instructions/mcp-system-instructions.d.ts +1 -1
  55. package/dist/src/ee/mcp/instructions/mcp-system-instructions.js +1 -0
  56. package/dist/src/idp/decorators/auth-context.decorator.js +1 -0
  57. package/dist/src/idp/guards/idp.guard.d.ts +3 -0
  58. package/dist/src/idp/guards/idp.guard.js +38 -8
  59. package/dist/src/idp/oauth/controllers/oauth-authorization.controller.js +8 -6
  60. package/dist/src/idp/oauth/mcp-client-integration.d.ts +1 -0
  61. package/dist/src/idp/oauth/mcp-client-integration.js +15 -0
  62. package/dist/src/idp/ports/plugin-runtime-authorizer.port.d.ts +6 -0
  63. package/dist/src/idp/types/auth.types.d.ts +1 -0
  64. package/dist/src/migrations/1790900000000-add-plugin-version-backend.d.ts +6 -0
  65. package/dist/src/migrations/1790900000000-add-plugin-version-backend.js +21 -0
  66. package/dist/src/migrations/1790900000001-create-plugin-action-execution.d.ts +6 -0
  67. package/dist/src/migrations/1790900000001-create-plugin-action-execution.js +77 -0
  68. package/dist/src/migrations/1791000000000-add-credential-public-metadata.d.ts +6 -0
  69. package/dist/src/migrations/1791000000000-add-credential-public-metadata.js +23 -0
  70. package/dist/src/plugin-host/collections/dto/domain/plugin-collection.types.d.ts +1 -0
  71. package/dist/src/plugin-host/collections/errors/plugin-collection.errors.d.ts +6 -0
  72. package/dist/src/plugin-host/collections/errors/plugin-collection.errors.js +19 -1
  73. package/dist/src/plugin-host/collections/services/plugin-collection-declaration.service.js +3 -3
  74. package/dist/src/plugin-host/collections/use-cases/put-plugin-collection-document.service.js +7 -0
  75. package/dist/src/plugin-host/constants/plugin-action-limits.d.ts +34 -0
  76. package/dist/src/plugin-host/constants/plugin-action-limits.js +51 -0
  77. package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.d.ts +20 -0
  78. package/dist/src/plugin-host/controllers/plugin-action-runtime.controller.js +123 -0
  79. package/dist/src/plugin-host/controllers/plugin-credential-runtime.controller.js +11 -19
  80. package/dist/src/plugin-host/controllers/plugin-history.controller.d.ts +10 -0
  81. package/dist/src/plugin-host/controllers/plugin-history.controller.js +57 -0
  82. package/dist/src/plugin-host/controllers/plugin-release-check.controller.d.ts +10 -0
  83. package/dist/src/plugin-host/controllers/plugin-release-check.controller.js +58 -0
  84. package/dist/src/plugin-host/dto/domain/check-plugin-release.command.d.ts +22 -0
  85. package/dist/src/plugin-host/dto/domain/check-plugin-release.command.js +17 -0
  86. package/dist/src/plugin-host/dto/domain/list-plugin-history.command.d.ts +10 -0
  87. package/dist/src/plugin-host/dto/domain/list-plugin-history.command.js +18 -0
  88. package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.d.ts +23 -0
  89. package/dist/src/plugin-host/dto/domain/plugin-action-execution.command.js +44 -0
  90. package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.d.ts +36 -0
  91. package/dist/src/plugin-host/dto/domain/plugin-action-execution.dto.js +3 -0
  92. package/dist/src/plugin-host/dto/domain/plugin-history.dto.d.ts +29 -0
  93. package/dist/src/plugin-host/dto/domain/plugin-history.dto.js +3 -0
  94. package/dist/src/plugin-host/dto/domain/plugin-view.dto.d.ts +1 -0
  95. package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.d.ts +44 -0
  96. package/dist/src/plugin-host/dto/presentation/plugin-action-api.dto.js +208 -0
  97. package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.d.ts +2 -0
  98. package/dist/src/plugin-host/dto/presentation/plugin-gallery-api.dto.js +7 -0
  99. package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.d.ts +29 -0
  100. package/dist/src/plugin-host/dto/presentation/plugin-history-api.dto.js +148 -0
  101. package/dist/src/plugin-host/dto/presentation/publication-api.dto.d.ts +17 -0
  102. package/dist/src/plugin-host/dto/presentation/publication-api.dto.js +95 -1
  103. package/dist/src/plugin-host/entities/plugin-action-execution.entity.d.ts +24 -0
  104. package/dist/src/plugin-host/entities/plugin-action-execution.entity.js +136 -0
  105. package/dist/src/plugin-host/entities/plugin-version.entity.d.ts +2 -1
  106. package/dist/src/plugin-host/entities/plugin-version.entity.js +5 -0
  107. package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.d.ts +9 -0
  108. package/dist/src/plugin-host/enums/plugin-action-execution-status.enum.js +22 -0
  109. package/dist/src/plugin-host/enums/release-rejection-code.enum.d.ts +3 -0
  110. package/dist/src/plugin-host/enums/release-rejection-code.enum.js +6 -0
  111. package/dist/src/plugin-host/errors/plugin-action.errors.d.ts +45 -0
  112. package/dist/src/plugin-host/errors/plugin-action.errors.js +70 -0
  113. package/dist/src/plugin-host/errors/plugin-host.errors.d.ts +6 -0
  114. package/dist/src/plugin-host/errors/plugin-host.errors.js +10 -1
  115. package/dist/src/plugin-host/filters/plugin-host-exception.filter.js +2 -2
  116. package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.d.ts +3 -0
  117. package/dist/src/plugin-host/mappers/plugin-action-execution.mapper.js +22 -0
  118. package/dist/src/plugin-host/mappers/plugin-presentation.mapper.d.ts +16 -1
  119. package/dist/src/plugin-host/mappers/plugin-presentation.mapper.js +80 -1
  120. package/dist/src/plugin-host/plugin-host.module.js +32 -0
  121. package/dist/src/plugin-host/services/action-input-validator.service.d.ts +23 -0
  122. package/dist/src/plugin-host/services/action-input-validator.service.js +277 -0
  123. package/dist/src/plugin-host/services/external-credential-definition-sync.service.d.ts +3 -0
  124. package/dist/src/plugin-host/services/external-credential-definition-sync.service.js +47 -15
  125. package/dist/src/plugin-host/services/plugin-action-dispatcher.service.d.ts +13 -0
  126. package/dist/src/plugin-host/services/plugin-action-dispatcher.service.js +140 -0
  127. package/dist/src/plugin-host/services/plugin-action-execution.service.d.ts +69 -0
  128. package/dist/src/plugin-host/services/plugin-action-execution.service.js +239 -0
  129. package/dist/src/plugin-host/services/plugin-action-starter.service.d.ts +22 -0
  130. package/dist/src/plugin-host/services/plugin-action-starter.service.js +81 -0
  131. package/dist/src/plugin-host/services/plugin-audit.service.d.ts +13 -0
  132. package/dist/src/plugin-host/services/plugin-audit.service.js +78 -0
  133. package/dist/src/plugin-host/services/plugin-publication.service.d.ts +2 -0
  134. package/dist/src/plugin-host/services/plugin-publication.service.js +18 -10
  135. package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.d.ts +5 -2
  136. package/dist/src/plugin-host/services/plugin-runtime-authorizer.service.js +31 -3
  137. package/dist/src/plugin-host/services/plugin-version.service.d.ts +2 -1
  138. package/dist/src/plugin-host/services/release-candidate-rules.service.d.ts +51 -0
  139. package/dist/src/plugin-host/services/release-candidate-rules.service.js +198 -0
  140. package/dist/src/plugin-host/services/remote-url-validator.service.d.ts +7 -0
  141. package/dist/src/plugin-host/services/remote-url-validator.service.js +4 -0
  142. package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.d.ts +14 -0
  143. package/dist/src/plugin-host/system-triggers/plugin-action-execution-sweep.processor.js +50 -0
  144. package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.d.ts +8 -0
  145. package/dist/src/plugin-host/use-cases/cancel-plugin-action-execution.service.js +39 -0
  146. package/dist/src/plugin-host/use-cases/check-plugin-release.service.d.ts +22 -0
  147. package/dist/src/plugin-host/use-cases/check-plugin-release.service.js +152 -0
  148. package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.d.ts +14 -0
  149. package/dist/src/plugin-host/use-cases/get-current-plugin-action-execution.service.js +85 -0
  150. package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.d.ts +9 -0
  151. package/dist/src/plugin-host/use-cases/get-plugin-action-execution.service.js +67 -0
  152. package/dist/src/plugin-host/use-cases/get-plugin-installation-entry.service.js +2 -7
  153. package/dist/src/plugin-host/use-cases/install-plugin.service.js +4 -0
  154. package/dist/src/plugin-host/use-cases/list-plugin-history.service.d.ts +25 -0
  155. package/dist/src/plugin-host/use-cases/list-plugin-history.service.js +147 -0
  156. package/dist/src/plugin-host/use-cases/plugin-publisher-access.d.ts +5 -0
  157. package/dist/src/plugin-host/use-cases/plugin-publisher-access.js +28 -0
  158. package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.d.ts +12 -0
  159. package/dist/src/plugin-host/use-cases/start-plugin-action-execution.service.js +64 -0
  160. package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.d.ts +3 -5
  161. package/dist/src/plugin-host/use-cases/sync-plugin-releases.service.js +15 -59
  162. package/dist/src/plugin-host/use-cases/uninstall-plugin.service.js +3 -1
  163. package/dist/src/plugin-host/use-cases/update-plugin.service.d.ts +0 -1
  164. package/dist/src/plugin-host/use-cases/update-plugin.service.js +3 -25
  165. package/dist/src/plugin-host/utils/action-input-schema.util.d.ts +14 -0
  166. package/dist/src/plugin-host/utils/action-input-schema.util.js +133 -0
  167. package/dist/src/plugin-host/utils/credential-handles.util.d.ts +3 -0
  168. package/dist/src/plugin-host/utils/credential-handles.util.js +13 -0
  169. package/dist/src/plugin-host/utils/execution-token.util.d.ts +5 -0
  170. package/dist/src/plugin-host/utils/execution-token.util.js +13 -0
  171. package/dist/src/plugin-host/utils/json-shape.util.d.ts +1 -0
  172. package/dist/src/plugin-host/utils/json-shape.util.js +21 -0
  173. package/dist/src/plugin-host/utils/plugin-action-outcome.util.d.ts +10 -0
  174. package/dist/src/plugin-host/utils/plugin-action-outcome.util.js +67 -0
  175. package/dist/src/plugin-host/utils/plugin-manifest.util.d.ts +121 -0
  176. package/dist/src/plugin-host/utils/plugin-manifest.util.js +111 -1
  177. package/dist/src/plugin-host/utils/request-abort-signal.util.d.ts +5 -0
  178. package/dist/src/plugin-host/utils/request-abort-signal.util.js +19 -0
  179. package/package.json +10 -8
@@ -0,0 +1,64 @@
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.StartPluginActionExecutionService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const plugin_action_errors_1 = require("../errors/plugin-action.errors");
15
+ const plugin_action_starter_service_1 = require("../services/plugin-action-starter.service");
16
+ const plugin_version_service_1 = require("../services/plugin-version.service");
17
+ const plugin_service_1 = require("../services/plugin.service");
18
+ let StartPluginActionExecutionService = class StartPluginActionExecutionService {
19
+ plugins;
20
+ versions;
21
+ starter;
22
+ constructor(plugins, versions, starter) {
23
+ this.plugins = plugins;
24
+ this.versions = versions;
25
+ this.starter = starter;
26
+ }
27
+ async run(command) {
28
+ const { context, action } = command;
29
+ if (context.executionId) {
30
+ throw new plugin_action_errors_1.ExecutionTokenNotAllowedError();
31
+ }
32
+ const role = context.roles?.[0];
33
+ if (!context.pluginId || !context.installationId || !role) {
34
+ throw new common_1.ForbiddenException('Plugin runtime authentication is required');
35
+ }
36
+ const plugin = await this.plugins.findById(context.pluginId);
37
+ const version = plugin?.currentVersionId
38
+ ? await this.versions.findById(plugin.currentVersionId)
39
+ : null;
40
+ if (!version) {
41
+ throw new plugin_action_errors_1.ActionNotDeclaredError(action);
42
+ }
43
+ return this.starter.start({
44
+ installation: {
45
+ id: context.installationId,
46
+ projectId: context.projectId,
47
+ userId: context.userId,
48
+ },
49
+ version,
50
+ action,
51
+ input: command.input,
52
+ role,
53
+ trigger: 'frontend',
54
+ });
55
+ }
56
+ };
57
+ exports.StartPluginActionExecutionService = StartPluginActionExecutionService;
58
+ exports.StartPluginActionExecutionService = StartPluginActionExecutionService = __decorate([
59
+ (0, common_1.Injectable)(),
60
+ __metadata("design:paramtypes", [plugin_service_1.PluginService,
61
+ plugin_version_service_1.PluginVersionService,
62
+ plugin_action_starter_service_1.PluginActionStarterService])
63
+ ], StartPluginActionExecutionService);
64
+ //# sourceMappingURL=start-plugin-action-execution.service.js.map
@@ -1,21 +1,19 @@
1
1
  import { PluginHostConfigService } from '../config/plugin-host.config';
2
2
  import { PluginSyncResultDto, SyncPluginReleasesCommand } from '../dto/domain/plugin-sync.dto';
3
3
  import { GithubApiService } from '../services/github-api.service';
4
- import { ExternalCredentialDefinitionSyncService } from '../services/external-credential-definition-sync.service';
5
4
  import { PluginService } from '../services/plugin.service';
6
5
  import { PluginVersionService } from '../services/plugin-version.service';
7
6
  import { PluginCredentialBindingReconciliationService } from '../services/plugin-credential-binding-reconciliation.service';
8
- import { RemoteUrlValidatorService } from '../services/remote-url-validator.service';
7
+ import { ReleaseCandidateRulesService } from '../services/release-candidate-rules.service';
9
8
  export declare class SyncPluginReleasesService {
10
9
  private readonly githubApi;
11
- private readonly remoteUrlValidator;
10
+ private readonly candidateRules;
12
11
  private readonly pluginService;
13
12
  private readonly versionService;
14
13
  private readonly config;
15
14
  private readonly credentialBindingReconciliation;
16
- private readonly externalCredentialDefinitions?;
17
15
  private readonly logger;
18
- constructor(githubApi: GithubApiService, remoteUrlValidator: RemoteUrlValidatorService, pluginService: PluginService, versionService: PluginVersionService, config: PluginHostConfigService, credentialBindingReconciliation: PluginCredentialBindingReconciliationService, externalCredentialDefinitions?: ExternalCredentialDefinitionSyncService | undefined);
16
+ constructor(githubApi: GithubApiService, candidateRules: ReleaseCandidateRulesService, pluginService: PluginService, versionService: PluginVersionService, config: PluginHostConfigService, credentialBindingReconciliation: PluginCredentialBindingReconciliationService);
19
17
  run(command: SyncPluginReleasesCommand): Promise<PluginSyncResultDto>;
20
18
  private findOrCreatePlugin;
21
19
  private selectCandidates;
@@ -8,9 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
11
  var SyncPluginReleasesService_1;
15
12
  Object.defineProperty(exports, "__esModule", { value: true });
16
13
  exports.SyncPluginReleasesService = void 0;
@@ -20,31 +17,27 @@ const plugin_host_config_1 = require("../config/plugin-host.config");
20
17
  const release_rejection_code_enum_1 = require("../enums/release-rejection-code.enum");
21
18
  const plugin_host_errors_1 = require("../errors/plugin-host.errors");
22
19
  const github_api_service_1 = require("../services/github-api.service");
23
- const external_credential_definition_sync_service_1 = require("../services/external-credential-definition-sync.service");
24
20
  const plugin_service_1 = require("../services/plugin.service");
25
21
  const plugin_version_service_1 = require("../services/plugin-version.service");
26
22
  const plugin_credential_binding_reconciliation_service_1 = require("../services/plugin-credential-binding-reconciliation.service");
27
- const remote_url_validator_service_1 = require("../services/remote-url-validator.service");
23
+ const release_candidate_rules_service_1 = require("../services/release-candidate-rules.service");
28
24
  const github_repo_locator_util_1 = require("../utils/github-repo-locator.util");
29
- const plugin_manifest_util_1 = require("../utils/plugin-manifest.util");
30
25
  const semver_util_1 = require("../utils/semver.util");
31
26
  let SyncPluginReleasesService = SyncPluginReleasesService_1 = class SyncPluginReleasesService {
32
27
  githubApi;
33
- remoteUrlValidator;
28
+ candidateRules;
34
29
  pluginService;
35
30
  versionService;
36
31
  config;
37
32
  credentialBindingReconciliation;
38
- externalCredentialDefinitions;
39
33
  logger = new common_1.Logger(SyncPluginReleasesService_1.name);
40
- constructor(githubApi, remoteUrlValidator, pluginService, versionService, config, credentialBindingReconciliation, externalCredentialDefinitions) {
34
+ constructor(githubApi, candidateRules, pluginService, versionService, config, credentialBindingReconciliation) {
41
35
  this.githubApi = githubApi;
42
- this.remoteUrlValidator = remoteUrlValidator;
36
+ this.candidateRules = candidateRules;
43
37
  this.pluginService = pluginService;
44
38
  this.versionService = versionService;
45
39
  this.config = config;
46
40
  this.credentialBindingReconciliation = credentialBindingReconciliation;
47
- this.externalCredentialDefinitions = externalCredentialDefinitions;
48
41
  }
49
42
  async run(command) {
50
43
  const ref = (0, github_repo_locator_util_1.parseGithubRepoLocator)(command.repoLocator);
@@ -126,45 +119,12 @@ let SyncPluginReleasesService = SyncPluginReleasesService_1 = class SyncPluginRe
126
119
  into.rejections.push(this.rejection(release, release_rejection_code_enum_1.ReleaseRejectionCode.VERSION_CONFLICT, `Version ${semver} is already recorded from commit ${recorded.commitSha} (release ${recorded.githubReleaseId}); refusing to replace it with commit ${commitSha} (release ${release.githubReleaseId})`));
127
120
  return false;
128
121
  }
129
- const manifestSource = await this.githubApi.getFileAtCommit(ref, 'plugin.json', commitSha);
130
- const manifest = (0, plugin_manifest_util_1.parsePluginManifest)(manifestSource);
131
- if (!manifest.ok) {
132
- into.rejections.push(this.rejection(release, manifest.code, manifest.detail));
133
- return false;
134
- }
135
- const baseline = (await this.versionService.findAllByPluginId(pluginId))
136
- .filter(version => (0, semver_util_1.sameCompatibilityLine)(version.semver, semver))
137
- .reduce((highest, version) => (!highest || (0, semver_util_1.compareSemver)(version.semver, highest.semver) > 0 ? { semver: version.semver, collections: version.collections ?? [] } : highest), undefined);
138
- if (baseline) {
139
- const incompatibility = (0, plugin_manifest_util_1.findIncompatibleCollectionChange)(baseline.collections ?? [], manifest.manifest.collections);
140
- if (incompatibility) {
141
- const escape = (0, semver_util_1.majorOf)(semver) === 0
142
- ? 'bump the minor version to ship this breaking change while below 1.0.0'
143
- : 'publish a new major version to ship this breaking change';
144
- into.rejections.push(this.rejection(release, release_rejection_code_enum_1.ReleaseRejectionCode.COLLECTIONS_INCOMPATIBLE, `${incompatibility} within the ${baseline.semver} compatibility line; ${escape}`));
145
- return false;
146
- }
147
- }
148
- const delivery = await this.remoteUrlValidator.validate(manifest.manifest.delivery.url);
149
- if (!delivery.ok) {
150
- into.rejections.push(this.rejection(release, delivery.code, delivery.detail));
151
- return false;
152
- }
153
- let credentialRequirements = manifest.manifest.credentials;
154
- try {
155
- if (manifest.manifest.credentials.some(requirement => externalLocator(requirement))) {
156
- if (!this.externalCredentialDefinitions) {
157
- throw new Error('External Credential definitions are not available');
158
- }
159
- credentialRequirements = await this.externalCredentialDefinitions.resolveRequirements(manifest.manifest.credentials);
160
- }
161
- }
162
- catch (error) {
163
- if (!(error instanceof external_credential_definition_sync_service_1.ExternalCredentialRequirementError))
164
- throw error;
165
- into.rejections.push(this.rejection(release, release_rejection_code_enum_1.ReleaseRejectionCode.MANIFEST_SCHEMA, (0, internal_helpers_1.castError)(error).message));
122
+ const verdict = await this.candidateRules.firstFailure({ pluginId, ref, commitSha, semver });
123
+ if (!verdict.ok) {
124
+ into.rejections.push(this.rejection(release, verdict.code, verdict.detail));
166
125
  return false;
167
126
  }
127
+ const { manifest, credentialRequirements } = verdict;
168
128
  try {
169
129
  const inserted = await this.versionService.insertVersionForLease({
170
130
  pluginId,
@@ -172,11 +132,12 @@ let SyncPluginReleasesService = SyncPluginReleasesService_1 = class SyncPluginRe
172
132
  commitSha,
173
133
  githubReleaseId: release.githubReleaseId,
174
134
  tagName: release.tagName,
175
- displayName: manifest.manifest.name,
176
- description: manifest.manifest.description,
177
- deliveryUrl: manifest.manifest.delivery.url,
178
- collections: manifest.manifest.collections,
135
+ displayName: manifest.name,
136
+ description: manifest.description,
137
+ deliveryUrl: manifest.delivery.url,
138
+ collections: manifest.collections,
179
139
  credentialRequirements,
140
+ backend: manifest.backend ?? null,
180
141
  releasePublishedAt: release.publishedAt,
181
142
  }, syncLeaseId);
182
143
  if (!inserted)
@@ -266,16 +227,11 @@ let SyncPluginReleasesService = SyncPluginReleasesService_1 = class SyncPluginRe
266
227
  exports.SyncPluginReleasesService = SyncPluginReleasesService;
267
228
  exports.SyncPluginReleasesService = SyncPluginReleasesService = SyncPluginReleasesService_1 = __decorate([
268
229
  (0, common_1.Injectable)(),
269
- __param(6, (0, common_1.Optional)()),
270
230
  __metadata("design:paramtypes", [github_api_service_1.GithubApiService,
271
- remote_url_validator_service_1.RemoteUrlValidatorService,
231
+ release_candidate_rules_service_1.ReleaseCandidateRulesService,
272
232
  plugin_service_1.PluginService,
273
233
  plugin_version_service_1.PluginVersionService,
274
234
  plugin_host_config_1.PluginHostConfigService,
275
- plugin_credential_binding_reconciliation_service_1.PluginCredentialBindingReconciliationService,
276
- external_credential_definition_sync_service_1.ExternalCredentialDefinitionSyncService])
235
+ plugin_credential_binding_reconciliation_service_1.PluginCredentialBindingReconciliationService])
277
236
  ], SyncPluginReleasesService);
278
- function externalLocator(requirement) {
279
- return (typeof requirement === 'string' ? requirement : requirement.id).startsWith('@');
280
- }
281
237
  //# sourceMappingURL=sync-plugin-releases.service.js.map
@@ -35,7 +35,8 @@ let UninstallPluginService = class UninstallPluginService {
35
35
  if (!installation) {
36
36
  throw new common_1.NotFoundException('You do not have this plugin installed');
37
37
  }
38
- if (installation.uninstalledAt === null) {
38
+ const wasUninstalled = installation.uninstalledAt !== null;
39
+ if (!wasUninstalled) {
39
40
  await this.installations.uninstall(installation.id);
40
41
  }
41
42
  await this.credentialBindings.deactivateConsumer('plugin-installation', installation.id, command.context.projectId);
@@ -45,6 +46,7 @@ let UninstallPluginService = class UninstallPluginService {
45
46
  authorityScope: plugin_publication_scope_enum_1.PluginPublicationScope.MEMBER,
46
47
  projectId: command.context.projectId,
47
48
  userId: command.context.userId,
49
+ beforeState: { uninstalled: wasUninstalled },
48
50
  });
49
51
  }
50
52
  };
@@ -17,6 +17,5 @@ export declare class UpdatePluginService {
17
17
  constructor(pluginService: PluginService, authorization: PublicationAuthorizationService, schedule: PluginUpdateScheduleService, check: RunPluginUpdateCheckService, versionService: PluginVersionService, publications: PluginPublicationService, installations: PluginInstallationService);
18
18
  run(command: UpdatePluginCommand): Promise<PluginUpdateResultDto>;
19
19
  private resolvePlugin;
20
- private managesPublicationOf;
21
20
  private mayReach;
22
21
  }
@@ -11,7 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UpdatePluginService = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
- const plugin_publication_scope_enum_1 = require("../enums/plugin-publication-scope.enum");
15
14
  const plugin_service_1 = require("../services/plugin.service");
16
15
  const plugin_installation_service_1 = require("../services/plugin-installation.service");
17
16
  const plugin_publication_service_1 = require("../services/plugin-publication.service");
@@ -20,6 +19,7 @@ const plugin_version_service_1 = require("../services/plugin-version.service");
20
19
  const publication_authorization_service_1 = require("../services/publication-authorization.service");
21
20
  const github_repo_locator_util_1 = require("../utils/github-repo-locator.util");
22
21
  const plugin_publisher_diagnostics_1 = require("./plugin-publisher-diagnostics");
22
+ const plugin_publisher_access_1 = require("./plugin-publisher-access");
23
23
  const run_plugin_update_check_service_1 = require("./run-plugin-update-check.service");
24
24
  let UpdatePluginService = class UpdatePluginService {
25
25
  pluginService;
@@ -47,7 +47,7 @@ let UpdatePluginService = class UpdatePluginService {
47
47
  apiKeyId: command.context.apiKeyId ?? null,
48
48
  });
49
49
  const isPublisher = this.authorization.isDeploymentPublisher(command.context);
50
- const managesPublication = isPublisher || (await this.managesPublicationOf(plugin.id, command.context));
50
+ const managesPublication = isPublisher || (await (0, plugin_publisher_access_1.managesPublicationOf)(this.publications, plugin.id, command.context));
51
51
  let diagnostics = null;
52
52
  if (managesPublication) {
53
53
  const version = result.currentVersionId
@@ -59,7 +59,7 @@ let UpdatePluginService = class UpdatePluginService {
59
59
  const scheduled = await this.pluginService.findById(plugin.id);
60
60
  return {
61
61
  pluginId: result.pluginId,
62
- repository: visibleRepository(scheduled ?? plugin, result.repository, isPublisher),
62
+ repository: (0, plugin_publisher_access_1.visibleRepository)(scheduled ?? plugin, result.repository, isPublisher),
63
63
  currentVersionId: result.currentVersionId,
64
64
  currentSemver: result.currentSemver,
65
65
  outcome: result.outcome,
@@ -86,25 +86,6 @@ let UpdatePluginService = class UpdatePluginService {
86
86
  }
87
87
  throw new common_1.NotFoundException('A plugin id or repository is required');
88
88
  }
89
- async managesPublicationOf(pluginId, context) {
90
- const scopes = [];
91
- if (context.roles?.includes('admin')) {
92
- scopes.push(plugin_publication_scope_enum_1.PluginPublicationScope.PROJECT);
93
- }
94
- if (context.userId) {
95
- scopes.push(plugin_publication_scope_enum_1.PluginPublicationScope.MEMBER);
96
- }
97
- for (const scope of scopes) {
98
- const rows = await this.publications.listManageable(scope, {
99
- projectId: context.projectId,
100
- userId: scope === plugin_publication_scope_enum_1.PluginPublicationScope.MEMBER ? (context.userId ?? undefined) : undefined,
101
- });
102
- if (rows.some(row => row.pluginId === pluginId)) {
103
- return true;
104
- }
105
- }
106
- return false;
107
- }
108
89
  async mayReach(pluginId, context) {
109
90
  if (this.authorization.isDeploymentPublisher(context)) {
110
91
  return true;
@@ -128,7 +109,4 @@ exports.UpdatePluginService = UpdatePluginService = __decorate([
128
109
  plugin_publication_service_1.PluginPublicationService,
129
110
  plugin_installation_service_1.PluginInstallationService])
130
111
  ], UpdatePluginService);
131
- function visibleRepository(plugin, repository, isPublisher) {
132
- return plugin.isPrivateRepo && !isPublisher ? `${plugin.repoOwner}/***` : repository;
133
- }
134
112
  //# sourceMappingURL=update-plugin.service.js.map
@@ -0,0 +1,14 @@
1
+ export declare const ACTION_INPUT_AJV: {
2
+ readonly options: {
3
+ readonly strict: true;
4
+ readonly allErrors: true;
5
+ readonly logger: false;
6
+ readonly inlineRefs: false;
7
+ readonly ownProperties: true;
8
+ };
9
+ readonly metaSchema: "https://json-schema.org/draft/2020-12/schema";
10
+ readonly refusedKeywords: readonly ["pattern", "patternProperties", "format", "uniqueItems"];
11
+ };
12
+ type JsonObject = Record<string, unknown>;
13
+ export declare function assertBoundedSchema(root: JsonObject): void;
14
+ export {};
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ACTION_INPUT_AJV = void 0;
4
+ exports.assertBoundedSchema = assertBoundedSchema;
5
+ const plugin_action_limits_1 = require("../constants/plugin-action-limits");
6
+ const DRAFT_2020_12 = 'https://json-schema.org/draft/2020-12/schema';
7
+ const REFUSED_KEYWORDS = ['pattern', 'patternProperties', 'format', 'uniqueItems'];
8
+ const UNSUPPORTED_KEYWORDS = ['$async', '$dynamicRef', '$recursiveRef'];
9
+ const SUBSCHEMA_KEYWORDS = [
10
+ 'additionalProperties',
11
+ 'contains',
12
+ 'else',
13
+ 'if',
14
+ 'items',
15
+ 'not',
16
+ 'propertyNames',
17
+ 'then',
18
+ 'unevaluatedItems',
19
+ 'unevaluatedProperties',
20
+ ];
21
+ const SUBSCHEMA_LIST_KEYWORDS = ['allOf', 'anyOf', 'oneOf', 'prefixItems'];
22
+ const SUBSCHEMA_MAP_KEYWORDS = [
23
+ 'dependencies',
24
+ 'dependentSchemas',
25
+ 'patternProperties',
26
+ 'properties',
27
+ ];
28
+ const PREVENT_SCOPE_CHANGE = new Set([
29
+ 'properties',
30
+ 'patternProperties',
31
+ 'enum',
32
+ 'dependencies',
33
+ 'definitions',
34
+ ]);
35
+ exports.ACTION_INPUT_AJV = {
36
+ options: { strict: true, allErrors: true, logger: false, inlineRefs: false, ownProperties: true },
37
+ metaSchema: DRAFT_2020_12,
38
+ refusedKeywords: REFUSED_KEYWORDS,
39
+ };
40
+ function isObject(value) {
41
+ return typeof value === 'object' && value !== null;
42
+ }
43
+ function resolveLocalRef(root, ref) {
44
+ if (!ref.startsWith('#')) {
45
+ throw new Error(`$ref "${ref}" is not local`);
46
+ }
47
+ if (ref.includes('#', 1)) {
48
+ throw new Error(`$ref "${ref}" has "#" after its first character`);
49
+ }
50
+ if (ref === '#')
51
+ return root;
52
+ const unresolved = new Error(`$ref "${ref}" does not resolve`);
53
+ if (!ref.startsWith('#/'))
54
+ throw unresolved;
55
+ let node = root;
56
+ for (const part of ref.slice(2).split('/')) {
57
+ let key;
58
+ try {
59
+ key = decodeURIComponent(part).replace(/~1/g, '/').replace(/~0/g, '~');
60
+ }
61
+ catch {
62
+ throw unresolved;
63
+ }
64
+ if (!isObject(node) || !Object.hasOwn(node, key))
65
+ throw unresolved;
66
+ node = node[key];
67
+ if (!PREVENT_SCOPE_CHANGE.has(part) && isObject(node) && Object.hasOwn(node, '$id')) {
68
+ throw new Error('$id is supported only at the root');
69
+ }
70
+ }
71
+ return node;
72
+ }
73
+ function countPayload(schema) {
74
+ let entries = Array.isArray(schema.enum) ? schema.enum.length : 0;
75
+ for (const keyword of ['dependentRequired', 'dependencies']) {
76
+ const map = schema[keyword];
77
+ if (!isObject(map))
78
+ continue;
79
+ for (const names of Object.values(map)) {
80
+ if (Array.isArray(names))
81
+ entries += names.length;
82
+ }
83
+ }
84
+ return entries;
85
+ }
86
+ function assertBoundedSchema(root) {
87
+ const limit = plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxInputSchemaNodes;
88
+ const expanding = new Set();
89
+ let nodes = 0;
90
+ const count = (cost) => {
91
+ nodes += cost;
92
+ if (nodes > limit) {
93
+ throw new Error(`exceeds ${limit} subschemas, enum entries and dependency names with every $ref inlined`);
94
+ }
95
+ };
96
+ const visit = (schema) => {
97
+ count(1);
98
+ if (!isObject(schema))
99
+ return;
100
+ count(countPayload(schema));
101
+ const unsupported = UNSUPPORTED_KEYWORDS.find(keyword => Object.hasOwn(schema, keyword));
102
+ if (unsupported)
103
+ throw new Error(`unsupported keyword: "${unsupported}"`);
104
+ if (schema !== root && Object.hasOwn(schema, '$id')) {
105
+ throw new Error('$id is supported only at the root');
106
+ }
107
+ expanding.add(schema);
108
+ if (typeof schema.$ref === 'string') {
109
+ const target = resolveLocalRef(root, schema.$ref);
110
+ if (isObject(target) && expanding.has(target)) {
111
+ throw new Error(`$ref "${schema.$ref}" is recursive`);
112
+ }
113
+ visit(target);
114
+ }
115
+ for (const keyword of SUBSCHEMA_KEYWORDS) {
116
+ if (Object.hasOwn(schema, keyword))
117
+ visit(schema[keyword]);
118
+ }
119
+ for (const keyword of SUBSCHEMA_LIST_KEYWORDS) {
120
+ const list = schema[keyword];
121
+ if (Array.isArray(list))
122
+ list.forEach(visit);
123
+ }
124
+ for (const keyword of SUBSCHEMA_MAP_KEYWORDS) {
125
+ const map = schema[keyword];
126
+ if (isObject(map))
127
+ Object.values(map).forEach(visit);
128
+ }
129
+ expanding.delete(schema);
130
+ };
131
+ visit(root);
132
+ }
133
+ //# sourceMappingURL=action-input-schema.util.js.map
@@ -0,0 +1,3 @@
1
+ import type { NormalizedCredentialRequirement } from '../../data-marts/credentials/credential.types';
2
+ import type { PluginCredentialHandleDto } from '../dto/domain/plugin-installation.dto';
3
+ export declare function toCredentialHandles(ready: readonly NormalizedCredentialRequirement[]): PluginCredentialHandleDto[];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toCredentialHandles = toCredentialHandles;
4
+ function toCredentialHandles(ready) {
5
+ return ready.map(requirement => requirement.definitionId === null
6
+ ? {
7
+ name: requirement.key,
8
+ kind: 'ai',
9
+ models: requirement.models,
10
+ }
11
+ : { name: requirement.key, kind: 'exact' });
12
+ }
13
+ //# sourceMappingURL=credential-handles.util.js.map
@@ -0,0 +1,5 @@
1
+ export declare function createExecutionToken(): {
2
+ token: string;
3
+ tokenHash: string;
4
+ };
5
+ export declare function hashExecutionToken(token: string): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createExecutionToken = createExecutionToken;
4
+ exports.hashExecutionToken = hashExecutionToken;
5
+ const node_crypto_1 = require("node:crypto");
6
+ function createExecutionToken() {
7
+ const token = (0, node_crypto_1.randomBytes)(32).toString('base64url');
8
+ return { token, tokenHash: hashExecutionToken(token) };
9
+ }
10
+ function hashExecutionToken(token) {
11
+ return (0, node_crypto_1.createHash)('sha256').update(token).digest('hex');
12
+ }
13
+ //# sourceMappingURL=execution-token.util.js.map
@@ -0,0 +1 @@
1
+ export declare function findJsonShapeProblem(value: unknown): string | null;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findJsonShapeProblem = findJsonShapeProblem;
4
+ const plugin_action_limits_1 = require("../constants/plugin-action-limits");
5
+ function findJsonShapeProblem(value) {
6
+ const maxDepth = plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxJsonDepth;
7
+ const visit = (node, depth) => {
8
+ if (typeof node !== 'object' || node === null)
9
+ return null;
10
+ if (depth > maxDepth)
11
+ return `is nested deeper than ${maxDepth} levels`;
12
+ for (const child of Object.values(node)) {
13
+ const problem = visit(child, depth + 1);
14
+ if (problem)
15
+ return problem;
16
+ }
17
+ return null;
18
+ };
19
+ return visit(value, 1);
20
+ }
21
+ //# sourceMappingURL=json-shape.util.js.map
@@ -0,0 +1,10 @@
1
+ import { PluginActionExecutionStatus } from '../enums/plugin-action-execution-status.enum';
2
+ export type PluginActionOutcome = {
3
+ status: PluginActionExecutionStatus.SUCCEEDED;
4
+ result: unknown;
5
+ } | {
6
+ status: PluginActionExecutionStatus.FAILED;
7
+ errorCode: string;
8
+ errorMessage: string;
9
+ };
10
+ export declare function classifyBackendResponse(status: number, body: string | null): PluginActionOutcome;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classifyBackendResponse = classifyBackendResponse;
4
+ const plugin_action_limits_1 = require("../constants/plugin-action-limits");
5
+ const plugin_action_execution_status_enum_1 = require("../enums/plugin-action-execution-status.enum");
6
+ const json_shape_util_1 = require("./json-shape.util");
7
+ function classifyBackendResponse(status, body) {
8
+ try {
9
+ return classify(status, body);
10
+ }
11
+ catch {
12
+ return invalid('The backend answer could not be read');
13
+ }
14
+ }
15
+ function classify(status, body) {
16
+ if (body === null) {
17
+ return invalid('The backend answer is larger than allowed');
18
+ }
19
+ if (status >= 300 && status < 400) {
20
+ return invalid(`The backend answered ${status}`);
21
+ }
22
+ const parsed = parseJson(body);
23
+ if (status === 200) {
24
+ if (!isRecord(parsed) || !Object.hasOwn(parsed, 'result')) {
25
+ return invalid('The backend answered 200 without a result');
26
+ }
27
+ const problem = (0, json_shape_util_1.findJsonShapeProblem)(parsed.result);
28
+ if (problem) {
29
+ return invalid(`The result ${problem}`);
30
+ }
31
+ if (Buffer.byteLength(JSON.stringify(parsed.result)) > plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxResultBytes) {
32
+ return invalid('The result is larger than 1 MiB');
33
+ }
34
+ return { status: plugin_action_execution_status_enum_1.PluginActionExecutionStatus.SUCCEEDED, result: parsed.result };
35
+ }
36
+ if (status < 300) {
37
+ return invalid(`The backend answered ${status}`);
38
+ }
39
+ const error = isRecord(parsed) ? parsed.error : undefined;
40
+ if (isRecord(error) && (0, plugin_action_limits_1.isPluginOwnedErrorCode)(error.code)) {
41
+ return {
42
+ status: plugin_action_execution_status_enum_1.PluginActionExecutionStatus.FAILED,
43
+ errorCode: error.code,
44
+ errorMessage: String(error.message ?? '').slice(0, plugin_action_limits_1.PLUGIN_ACTION_LIMITS.maxErrorMessageChars),
45
+ };
46
+ }
47
+ return invalid(`The backend answered ${status} without a usable error code`);
48
+ }
49
+ function invalid(errorMessage) {
50
+ return {
51
+ status: plugin_action_execution_status_enum_1.PluginActionExecutionStatus.FAILED,
52
+ errorCode: 'BACKEND_INVALID_RESPONSE',
53
+ errorMessage,
54
+ };
55
+ }
56
+ function parseJson(body) {
57
+ try {
58
+ return JSON.parse(body);
59
+ }
60
+ catch {
61
+ return undefined;
62
+ }
63
+ }
64
+ function isRecord(value) {
65
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
66
+ }
67
+ //# sourceMappingURL=plugin-action-outcome.util.js.map