@aifabrix/builder 2.61.2 → 2.62.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 (81) hide show
  1. package/lib/api/applications.api.js +22 -2
  2. package/lib/api/bootstrap-snapshot.api.js +115 -0
  3. package/lib/app/deploy.js +14 -5
  4. package/lib/app/run-env-compose.js +5 -6
  5. package/lib/app/run.js +6 -4
  6. package/lib/build/standard-docker-build.js +4 -0
  7. package/lib/channels/channel-artifact-generator.js +13 -3
  8. package/lib/cli/infra-guided-footers.js +10 -8
  9. package/lib/cli/infra-guided.js +30 -10
  10. package/lib/cli/setup-infra-up-platform-action.js +14 -1
  11. package/lib/cli/setup-platform.js +2 -0
  12. package/lib/commands/auth-config.js +2 -0
  13. package/lib/commands/login.js +4 -0
  14. package/lib/commands/repair-datasource-apply.js +3 -1
  15. package/lib/commands/repair-datasource-legacy.js +94 -0
  16. package/lib/commands/setup-image-refresh.js +26 -0
  17. package/lib/commands/setup-modes.js +7 -1
  18. package/lib/commands/setup-prompts-platform-mode.js +34 -0
  19. package/lib/commands/setup.js +3 -0
  20. package/lib/commands/up-builder-api.js +24 -8
  21. package/lib/commands/up-common.js +16 -1
  22. package/lib/commands/up-dataplane-bootstrap.js +70 -14
  23. package/lib/commands/up-dataplane-credentials.js +21 -0
  24. package/lib/commands/up-dataplane.js +37 -18
  25. package/lib/commands/up-integration-server.js +112 -0
  26. package/lib/commands/wizard-config-normalizer.js +5 -1
  27. package/lib/core/admin-secrets-env-overlay.js +8 -3
  28. package/lib/core/environment-access-policy.js +121 -0
  29. package/lib/core/environment-mode-policy.js +177 -0
  30. package/lib/core/local-env-overrides.js +149 -0
  31. package/lib/core/secrets-ensure.js +4 -2
  32. package/lib/core/secrets-env-content.js +12 -9
  33. package/lib/core/secrets-env-write.js +1 -1
  34. package/lib/datasource/capability/capability-manifest.js +1 -0
  35. package/lib/deployment/installation/index.js +14 -1
  36. package/lib/deployment/installation/infra-catalog.js +3 -0
  37. package/lib/deployment/installation/local-environment-stage.js +285 -0
  38. package/lib/deployment/installation/local-installation.js +76 -0
  39. package/lib/deployment/installation/stage-input.js +5 -1
  40. package/lib/generator/builders.js +3 -1
  41. package/lib/generator/split-variables.js +2 -2
  42. package/lib/parameters/database-adoption.js +125 -0
  43. package/lib/parameters/physical-database-naming.js +136 -0
  44. package/lib/parameters/physical-secret-name.js +194 -0
  45. package/lib/parameters/rsa-secret-values.js +165 -0
  46. package/lib/programmatic/run-channel-install-artifacts.js +28 -2
  47. package/lib/programmatic/run-channel-package.js +3 -1
  48. package/lib/programmatic/workspace-context.js +37 -2
  49. package/lib/schema/infra.parameter.yaml +61 -27
  50. package/lib/schema/infrastructure-schema.json +213 -120
  51. package/lib/utils/compose-generate-docker-compose.js +2 -2
  52. package/lib/utils/compose-generator.js +4 -7
  53. package/lib/utils/compose-miso-env.js +2 -2
  54. package/lib/utils/compose-traefik-ingress-base.js +3 -4
  55. package/lib/utils/declarative-url-ports.js +3 -0
  56. package/lib/utils/env-environment-file-paths.js +105 -0
  57. package/lib/utils/environment-scoped-resources.js +48 -14
  58. package/lib/utils/paths-system-builder-keys.js +7 -1
  59. package/lib/utils/paths.js +7 -2
  60. package/lib/utils/postgres-platform-bootstrap.js +35 -1
  61. package/lib/utils/redis-env-scope.js +21 -1
  62. package/lib/utils/registry-auth-sources.js +154 -0
  63. package/lib/utils/registry-credentials.js +131 -14
  64. package/lib/utils/secrets-generator.js +30 -21
  65. package/lib/utils/secrets-helpers.js +5 -7
  66. package/lib/utils/secrets-kv-scope.js +127 -28
  67. package/lib/utils/secrets-materialize-local.js +9 -0
  68. package/lib/utils/secrets-missing-error.js +35 -1
  69. package/lib/utils/token-manager.js +14 -8
  70. package/lib/utils/url-public-path-prefix.js +6 -10
  71. package/package.json +3 -2
  72. package/templates/applications/builder-api/application.yaml +1 -1
  73. package/templates/applications/dataplane/application.yaml +2 -2
  74. package/templates/applications/dataplane/env.template +1 -1
  75. package/templates/applications/integration-server/application.yaml +91 -0
  76. package/templates/applications/integration-server/env.template +215 -0
  77. package/templates/applications/mirrored-templates.json +52 -0
  78. package/templates/applications/miso-controller/application.yaml +43 -1
  79. package/templates/applications/miso-controller/env.template +45 -39
  80. package/templates/marketplace/createUiDefinition.json +52 -4
  81. package/templates/marketplace/main.json +85 -7
@@ -58,7 +58,13 @@ const {
58
58
  } = require('../utils/infra-optional-service-flags');
59
59
 
60
60
  /** Builder app keys touched by `up-platform --force`. */
61
- const PLATFORM_APPS = ['keycloak', 'miso-controller', 'dataplane', 'builder-api'];
61
+ const PLATFORM_APPS = [
62
+ 'keycloak',
63
+ 'miso-controller',
64
+ 'dataplane',
65
+ 'builder-api',
66
+ 'integration-server'
67
+ ];
62
68
 
63
69
  function formatBackupSuffix() {
64
70
  const d = new Date();
@@ -73,8 +73,42 @@ async function promptSetupPlatformMode(options = {}) {
73
73
  return normalizeSetupPlatformMode(mode);
74
74
  }
75
75
 
76
+ /**
77
+ * Whether this installation carries the integration server.
78
+ *
79
+ * It runs once per stack in the `miso` environment and most installations do not need it,
80
+ * so it is opt-in rather than something every install acquires by default. The answer is
81
+ * persisted, so it is asked once rather than on every run.
82
+ *
83
+ * `--integration-server` and `--no-integration-server` answer it non-interactively; a
84
+ * non-TTY run without either defaults to not installing it, because acquiring an extra
85
+ * application by silence is the wrong default.
86
+ *
87
+ * @async
88
+ * @param {Object} [options] - CLI options
89
+ * @returns {Promise<boolean>}
90
+ */
91
+ async function promptIntegrationServer(options = {}) {
92
+ if (options.integrationServer === true || options.integrationServer === false) {
93
+ return options.integrationServer;
94
+ }
95
+ if (!process.stdin.isTTY || options.yes === true) {
96
+ return false;
97
+ }
98
+ const { integrationServer } = await inquirer.prompt([
99
+ {
100
+ type: 'confirm',
101
+ name: 'integrationServer',
102
+ message: 'Install the integration server (runs once in the miso environment)?',
103
+ default: false
104
+ }
105
+ ]);
106
+ return Boolean(integrationServer);
107
+ }
108
+
76
109
  module.exports = {
77
110
  resolvePlatformModeFromOptions,
78
111
  promptSetupPlatformMode,
112
+ promptIntegrationServer,
79
113
  getSetupPlatformModePromptChoices
80
114
  };
@@ -110,8 +110,11 @@ async function runSetupWithCliMode(options, cliMode) {
110
110
 
111
111
  async function applySetupPlatformMode(options) {
112
112
  const mode = await setupPlatformModePrompts.promptSetupPlatformMode(options);
113
+ const integrationServer = await setupPlatformModePrompts.promptIntegrationServer(options);
113
114
  const cfg = await config.getConfig();
114
115
  applyPlatformTopologyFlagsToConfig(cfg, mode);
116
+ const { onboardingAppsForIntegrationServer } = require('../core/local-env-overrides');
117
+ cfg.onboardingApps = onboardingAppsForIntegrationServer(integrationServer);
115
118
  await config.saveConfig(cfg);
116
119
  await syncPlatformControllerUrlsInConfig();
117
120
  return mode;
@@ -23,10 +23,28 @@ const {
23
23
  resolveUpBuilderApiControllerContext,
24
24
  provisionAndDeployBuilderApi,
25
25
  refreshBuilderApiEnvAfterProvision,
26
- computeBuilderApiRunOverrides,
27
- resolveEnvironment
26
+ computeBuilderApiRunOverrides
28
27
  } = require('./up-builder-api-provision');
29
28
 
29
+ const BUILDER_API_ENVIRONMENT_KEY = 'miso';
30
+
31
+ /**
32
+ * Builder API is a platform application and is installed once in miso.
33
+ * The selected workload environment only controls which workloads it manages.
34
+ *
35
+ * @param {Object} options
36
+ * @returns {string}
37
+ */
38
+ function resolveBuilderApiEnvironmentKey(options) {
39
+ const requested = options && options.envKey
40
+ ? String(options.envKey).trim().toLowerCase()
41
+ : BUILDER_API_ENVIRONMENT_KEY;
42
+ if (requested !== BUILDER_API_ENVIRONMENT_KEY) {
43
+ throw new Error('Builder-api can only be installed in environment \'miso\'.');
44
+ }
45
+ return BUILDER_API_ENVIRONMENT_KEY;
46
+ }
47
+
30
48
  /**
31
49
  * @async
32
50
  * @param {Object} [options]
@@ -39,10 +57,7 @@ async function handleUpBuilderApi(options = {}) {
39
57
  );
40
58
  }
41
59
 
42
- const environmentKey =
43
- options && options.envKey
44
- ? String(options.envKey).trim().toLowerCase()
45
- : await resolveEnvironment();
60
+ const environmentKey = resolveBuilderApiEnvironmentKey(options);
46
61
 
47
62
  const { controllerUrl, authConfig, useBootstrap } = await resolveUpBuilderApiControllerContext(
48
63
  options,
@@ -63,6 +78,7 @@ async function handleUpBuilderApi(options = {}) {
63
78
  const { portOverride } = await computeBuilderApiRunOverrides(options);
64
79
 
65
80
  const runOpts = {
81
+ env: environmentKey,
66
82
  registry: options.registry,
67
83
  registryMode: options.registryMode,
68
84
  skipEnvOutputPath: true,
@@ -79,10 +95,10 @@ async function handleUpBuilderApi(options = {}) {
79
95
  if (options.platformInstall !== true) {
80
96
  logger.log(
81
97
  formatSuccessParagraph(
82
- 'up-builder-api complete. Builder-api is registered, deployed in dev, and running locally.'
98
+ 'up-builder-api complete. Builder-api is registered in miso and running locally.'
83
99
  )
84
100
  );
85
101
  }
86
102
  }
87
103
 
88
- module.exports = { handleUpBuilderApi };
104
+ module.exports = { handleUpBuilderApi, resolveBuilderApiEnvironmentKey };
@@ -331,12 +331,16 @@ const DATAPLANE_BUILDER_APP_KEYS = Object.freeze(['dataplane']);
331
331
  /** Builder API platform app key (154.2). */
332
332
  const BUILDER_API_APP_KEYS = Object.freeze(['builder-api']);
333
333
 
334
+ /** Optional integration server platform app key. */
335
+ const INTEGRATION_SERVER_APP_KEYS = Object.freeze(['integration-server']);
336
+
334
337
  /** Builder dirs removed on up-platform / setup force (includes Celery companions). */
335
338
  const PLATFORM_BUILDER_CLEAN_APP_KEYS = Object.freeze([
336
339
  'keycloak',
337
340
  'miso-controller',
338
341
  ...DATAPLANE_BUILDER_APP_KEYS,
339
- ...BUILDER_API_APP_KEYS
342
+ ...BUILDER_API_APP_KEYS,
343
+ ...INTEGRATION_SERVER_APP_KEYS
340
344
  ]);
341
345
 
342
346
  /**
@@ -375,6 +379,15 @@ async function ensureBuilderApiAppsFromTemplate(opts = {}) {
375
379
  return anyCopied;
376
380
  }
377
381
 
382
+ /**
383
+ * Ensure the optional integration server manifest exists under the system builder root.
384
+ * @param {object} [opts]
385
+ * @returns {Promise<boolean>}
386
+ */
387
+ async function ensureIntegrationServerAppsFromTemplate(opts = {}) {
388
+ return ensureAppFromTemplate(INTEGRATION_SERVER_APP_KEYS[0], opts);
389
+ }
390
+
378
391
  /**
379
392
  * Merge builder/packages `application.yaml` into `~/.aifabrix/urls.local.yaml`.
380
393
  * Same scan as the end of {@link prepareUrlsLocalRegistryForUpPlatform}; call after platform app
@@ -410,10 +423,12 @@ module.exports = {
410
423
  applyUpPlatformForceConfig,
411
424
  cleanBuilderAppDirs,
412
425
  BUILDER_API_APP_KEYS,
426
+ INTEGRATION_SERVER_APP_KEYS,
413
427
  DATAPLANE_BUILDER_APP_KEYS,
414
428
  PLATFORM_BUILDER_CLEAN_APP_KEYS,
415
429
  ensureAppFromTemplate,
416
430
  ensureBuilderApiAppsFromTemplate,
431
+ ensureIntegrationServerAppsFromTemplate,
417
432
  ensureDataplaneAppsFromTemplate,
418
433
  patchEnvOutputPathForDeployOnly,
419
434
  validateEnvOutputPathFolderOrNull,
@@ -19,8 +19,12 @@ const {
19
19
  extractAppConfiguration
20
20
  } = require('../utils/app-register-config');
21
21
  const { buildRegistrationData, saveLocalCredentials, applyLocalhostPortAdjustment } = require('../app/register');
22
- const { loadDataplanePipelineCredentialsFromSecretsFile } = require('./up-dataplane-credentials');
23
22
  const { formatSuccessLine } = require('../utils/cli-test-layout-chalk');
23
+ const { getToken } = require('../api/auth.api');
24
+ const { updateApplicationSelfStatus } = require('../api/applications.api');
25
+ const { tokenFrom } = require('../app/run-parameter-sync');
26
+ const { resolveDeclarativeShowUrlsForApp } = require('../core/secrets-env-declarative-expand');
27
+ const pathsUtil = require('../utils/paths');
24
28
 
25
29
  const ENCRYPTION_VAULT_KEYS = [
26
30
  'miso-controller-secrets-encryptionKeyVault',
@@ -87,6 +91,68 @@ async function canUseBootstrapProvision(options = {}) {
87
91
  return Boolean(encryptionKey);
88
92
  }
89
93
 
94
+ /**
95
+ * Persist canonical declarative URLs before Dataplane takes its bootstrap snapshot.
96
+ * @param {string} controllerUrl
97
+ * @param {string} environmentKey
98
+ * @param {{clientId: string, clientSecret: string}} credentials
99
+ * @param {number} containerPort
100
+ * @returns {Promise<void>}
101
+ */
102
+ async function syncDataplaneApplicationUrls(controllerUrl, environmentKey, credentials, containerPort) {
103
+ const appPath = pathsUtil.getBuilderPath('dataplane');
104
+ const variablesPath = pathsUtil.resolveApplicationConfigPath(appPath);
105
+ const urls = await resolveDeclarativeShowUrlsForApp('dataplane', appPath, variablesPath, 'docker');
106
+ if (!urls) {
107
+ throw new Error('Could not resolve canonical Dataplane public and internal URLs');
108
+ }
109
+ const tokenResponse = await getToken(credentials.clientId, credentials.clientSecret, controllerUrl);
110
+ const response = await updateApplicationSelfStatus(
111
+ controllerUrl,
112
+ environmentKey,
113
+ { type: 'client-token', token: tokenFrom(tokenResponse) },
114
+ { status: 'deploying', url: urls.publicUrl, internalUrl: urls.internalUrl, port: containerPort }
115
+ );
116
+ if (!response?.success) {
117
+ throw new Error('Controller rejected canonical Dataplane public and internal URLs');
118
+ }
119
+ }
120
+
121
+ async function handleBootstrapResponse(responseData, controllerUrl, environmentKey, containerPort) {
122
+ if (responseData.credentials && responseData.credentials.clientSecret) {
123
+ await saveLocalCredentials(responseData, controllerUrl);
124
+ await syncDataplaneApplicationUrls(
125
+ controllerUrl,
126
+ environmentKey,
127
+ responseData.credentials,
128
+ containerPort
129
+ );
130
+ logger.log(formatSuccessLine('Dataplane bootstrap credentials saved locally'));
131
+ const { waitForDataplaneCredentials } = require('./up-dataplane-credentials');
132
+ if (!(await waitForDataplaneCredentials(controllerUrl))) {
133
+ throw new Error(
134
+ 'Dataplane bootstrap credentials were issued but the controller did not accept them in time. ' +
135
+ 'The deploy that follows gets one attempt, so it would fail with a less specific error. ' +
136
+ 'Retry the command; if it persists, check the controller is serving /api/v1/auth/token.'
137
+ );
138
+ }
139
+ return;
140
+ }
141
+ if (responseData.status === 'already_provisioned') {
142
+ logger.log(formatSuccessLine('Dataplane already provisioned (bootstrap idempotent)'));
143
+ const { credentialsAcceptToken } = require('./up-dataplane-credentials');
144
+ if (await credentialsAcceptToken(controllerUrl)) return;
145
+ throw new Error(
146
+ 'Dataplane is registered on the controller but local pipeline credentials are missing or ' +
147
+ 'not accepted by it. Run: aifabrix login && aifabrix app rotate-secret dataplane'
148
+ );
149
+ }
150
+ throw new Error(
151
+ 'Dataplane bootstrap returned no credentials and no "already_provisioned" status ' +
152
+ `(status: ${responseData.status || 'none'}). The controller may be a version this CLI does not support.`
153
+ );
154
+ }
155
+
90
156
  /**
91
157
  * Register dataplane via bootstrap endpoint (idempotent).
92
158
  * @async
@@ -107,6 +173,7 @@ async function bootstrapDataplaneApplication(options, controllerUrl, environment
107
173
 
108
174
  const { variables } = await loadVariablesYaml('dataplane');
109
175
  const appConfig = await extractAppConfiguration(variables, 'dataplane', options);
176
+ const containerPort = appConfig.port;
110
177
  await applyLocalhostPortAdjustment(appConfig, controllerUrl, options);
111
178
 
112
179
  const imageOverride = options.image || buildDataplaneImageRefFn(options);
@@ -126,24 +193,13 @@ async function bootstrapDataplaneApplication(options, controllerUrl, environment
126
193
  registrationData
127
194
  );
128
195
 
129
- if (responseData.credentials && responseData.credentials.clientSecret) {
130
- await saveLocalCredentials(responseData, controllerUrl);
131
- logger.log(formatSuccessLine('Dataplane bootstrap credentials saved locally'));
132
- } else if (responseData.status === 'already_provisioned') {
133
- logger.log(formatSuccessLine('Dataplane already provisioned (bootstrap idempotent)'));
134
- const localCredentials = await loadDataplanePipelineCredentialsFromSecretsFile();
135
- if (!localCredentials) {
136
- throw new Error(
137
- 'Dataplane is registered on the controller but pipeline credentials are missing locally. ' +
138
- 'Run fresh setup with volume wipe, or: aifabrix login && aifabrix app rotate-secret dataplane'
139
- );
140
- }
141
- }
196
+ await handleBootstrapResponse(responseData, controllerUrl, environmentKey, containerPort);
142
197
  }
143
198
 
144
199
  module.exports = {
145
200
  canUseBootstrapProvision,
146
201
  resolveBootstrapEncryptionKey,
147
202
  bootstrapDataplaneApplication,
203
+ syncDataplaneApplicationUrls,
148
204
  pickBootstrapEncryptionKeyFromSecrets
149
205
  };
@@ -193,8 +193,29 @@ async function alignDataplaneCredentialsAfterDeploy(options, controllerUrl) {
193
193
  }
194
194
  }
195
195
 
196
+ /**
197
+ * Wait until a freshly bootstrapped pair is accepted, before anything depends on it.
198
+ *
199
+ * The Controller can answer the bootstrap call before the pipeline client is usable, and
200
+ * the deploy that follows gets one attempt against one URL: validateDeployment retries only
201
+ * on a 5xx, so a 401 from a client that is not published yet ends the install. The align
202
+ * step already tolerates this, with 15 attempts across three bases, but it runs after the
203
+ * deploy — the forgiving check after the unforgiving one.
204
+ *
205
+ * @async
206
+ * @param {string} controllerUrl
207
+ * @param {Object} [retry] - Overrides for the bootstrap probe budget
208
+ * @returns {Promise<boolean>} True once the pair is accepted
209
+ */
210
+ async function waitForDataplaneCredentials(controllerUrl, retry = {}) {
211
+ const { maxAttempts, delayMs } = resolveCredentialProbeRetry({ useBootstrap: true, credentialProbeRetry: retry });
212
+ return credentialsAcceptTokenWithRetry(controllerUrl, maxAttempts, delayMs);
213
+ }
214
+
196
215
  module.exports = {
197
216
  alignDataplaneCredentialsAfterDeploy,
217
+ waitForDataplaneCredentials,
218
+ credentialsAcceptTokenWithRetry,
198
219
  probeDataplaneClientToken,
199
220
  credentialsAcceptToken,
200
221
  loadDataplanePipelineCredentialsFromSecretsFile,
@@ -227,6 +227,9 @@ async function deployDataplaneToController(options) {
227
227
  image: imageOverride,
228
228
  registryMode: options.registryMode,
229
229
  envKey: options.envKey ? String(options.envKey).trim().toLowerCase() : undefined,
230
+ // The bootstrap path has no device login, so it sets client-credentials explicitly.
231
+ // Dropping it here left the deploy in 'auto' mode.
232
+ deploymentAuth: options.deploymentAuth,
230
233
  // Guided up-platform already shows a top-level spinner for the dataplane step.
231
234
  // Avoid nested deploy polling spinners/logs.
232
235
  silentPoll: options.platformInstall === true
@@ -266,7 +269,8 @@ function emitDataplaneManifestLineFromBuilder() {
266
269
  }
267
270
 
268
271
  function computeDataplanePortOverride(runEnvKey, developerIdNum) {
269
- if (runEnvKey !== 'dev' && runEnvKey !== 'tst') {
272
+ const { isScopedRunEnvironmentKey } = require('../utils/environment-scoped-resources');
273
+ if (!isScopedRunEnvironmentKey(runEnvKey)) {
270
274
  return undefined;
271
275
  }
272
276
  return dataplaneDockerHostPort(3001, developerIdNum, runEnvKey);
@@ -355,6 +359,37 @@ async function provisionAndDeployDataplane(options, environmentKey, controllerUr
355
359
  * @returns {Promise<void>}
356
360
  * @throws {Error} If infra not up, controller unavailable, not logged in, environment not dev, or any step fails
357
361
  */
362
+ /**
363
+ * Run options for the local dataplane container.
364
+ *
365
+ * A guided platform install already shows one spinner for the whole dataplane step, so it
366
+ * either forwards its own progress callback or asks for silence; a standalone run prints
367
+ * normally.
368
+ *
369
+ * @param {Object} options - Command options
370
+ * @param {string} runEnvKey - Resolved run environment
371
+ * @param {number|undefined} portOverride - Resolved port override
372
+ * @returns {Object} Options for app.runApp
373
+ */
374
+ function buildDataplaneRunOptions(options, runEnvKey, portOverride) {
375
+ const runAppOpts = {
376
+ skipEnvOutputPath: true,
377
+ env: runEnvKey,
378
+ port: portOverride,
379
+ registry: options.registry || undefined,
380
+ base: options.base !== false,
381
+ skipManifestMetadataLine: true
382
+ };
383
+ if (options.platformInstall === true) {
384
+ if (typeof options.onPollText === 'function') {
385
+ runAppOpts.onPollText = options.onPollText;
386
+ } else {
387
+ runAppOpts.silentPoll = true;
388
+ }
389
+ }
390
+ return runAppOpts;
391
+ }
392
+
358
393
  async function handleUpDataplane(options = {}) {
359
394
  if (options.platformInstall !== true) {
360
395
  logger.log(chalk.blue('Starting up-dataplane (register/rotate, deploy, then run dataplane locally)...\n'));
@@ -386,23 +421,7 @@ async function handleUpDataplane(options = {}) {
386
421
  );
387
422
 
388
423
  const { runEnvKey, portOverride } = await computeDataplaneRunOverrides(options);
389
-
390
- const runAppOpts = {
391
- skipEnvOutputPath: true,
392
- env: runEnvKey,
393
- port: portOverride,
394
- registry: options.registry || undefined,
395
- base: options.base !== false,
396
- skipManifestMetadataLine: true
397
- };
398
- if (options.platformInstall === true) {
399
- if (typeof options.onPollText === 'function') {
400
- runAppOpts.onPollText = options.onPollText;
401
- } else {
402
- runAppOpts.silentPoll = true;
403
- }
404
- }
405
- await app.runApp('dataplane', runAppOpts);
424
+ await app.runApp('dataplane', buildDataplaneRunOptions(options, runEnvKey, portOverride));
406
425
 
407
426
  if (options.platformInstall !== true) {
408
427
  logger.log(formatSuccessParagraph('up-dataplane complete. Dataplane is registered, deployed in dev, and running locally.'));
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Install the optional Integration Server as a miso-only platform application.
3
+ *
4
+ * @fileoverview Integration Server setup phase
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ const app = require('../app');
10
+ const config = require('../core/config');
11
+ const { generateEnvFile } = require('../core/secrets');
12
+ const pathsUtil = require('../utils/paths');
13
+ const { loadConfigFile } = require('../utils/config-format');
14
+ const { resolveDockerImageRef } = require('../utils/resolve-docker-image-ref');
15
+ const { callBootstrapApi } = require('../utils/app-bootstrap-api');
16
+ const { loadVariablesYaml, extractAppConfiguration } = require('../utils/app-register-config');
17
+ const { buildRegistrationData, saveLocalCredentials, applyLocalhostPortAdjustment } = require('../app/register');
18
+ const { publishedHostPort, parseDeveloperIdNum } = require('../utils/declarative-url-ports');
19
+ const { resolveBootstrapEncryptionKey } = require('./up-dataplane-bootstrap');
20
+ const { resolveUpBuilderApiControllerContext } = require('./up-builder-api-provision');
21
+ const {
22
+ ensureIntegrationServerAppsFromTemplate,
23
+ refreshUrlsLocalRegistryForCurrentProject
24
+ } = require('./up-common');
25
+ const { resolveLocalOnboardingApps } = require('../core/local-env-overrides');
26
+
27
+ const APP_KEY = 'integration-server';
28
+ const ENVIRONMENT_KEY = 'miso';
29
+
30
+ async function isIntegrationServerSelected() {
31
+ const cfg = await config.getConfig();
32
+ return resolveLocalOnboardingApps(cfg).includes(APP_KEY);
33
+ }
34
+
35
+ function resolveIntegrationServerImageRef(options = {}) {
36
+ const appPath = pathsUtil.getBuilderPath(APP_KEY);
37
+ const manifestPath = pathsUtil.resolveApplicationConfigPath(appPath);
38
+ const variables = loadConfigFile(manifestPath) || {};
39
+ const { imageName, imageTag } = resolveDockerImageRef(APP_KEY, variables, {
40
+ registry: options.registry
41
+ });
42
+ return `${imageName}:${imageTag}`;
43
+ }
44
+
45
+ async function bootstrapIntegrationServer(options, controllerUrl) {
46
+ const encryptionKey = await resolveBootstrapEncryptionKey();
47
+ if (!encryptionKey) {
48
+ throw new Error('Bootstrap encryption key is unavailable for Integration Server installation.');
49
+ }
50
+ const { variables } = await loadVariablesYaml(APP_KEY);
51
+ const appConfig = await extractAppConfiguration(variables, APP_KEY, options);
52
+ await applyLocalhostPortAdjustment(appConfig, controllerUrl, options);
53
+ const image = options.image || resolveIntegrationServerImageRef(options);
54
+ const registrationData = buildRegistrationData(appConfig, {
55
+ image,
56
+ imageOverride: image,
57
+ registryMode: options.registryMode,
58
+ envKey: ENVIRONMENT_KEY
59
+ });
60
+ const response = await callBootstrapApi(
61
+ controllerUrl,
62
+ encryptionKey,
63
+ ENVIRONMENT_KEY,
64
+ registrationData
65
+ );
66
+ if (!response.credentials || !response.credentials.clientSecret) {
67
+ throw new Error('Integration Server bootstrap did not return its existing credentials.');
68
+ }
69
+ await saveLocalCredentials(response, controllerUrl);
70
+ }
71
+
72
+ async function runIntegrationServer(options) {
73
+ await generateEnvFile(APP_KEY, null, 'local', true);
74
+ const developerId = parseDeveloperIdNum(await config.getDeveloperId());
75
+ await app.runApp(APP_KEY, {
76
+ env: ENVIRONMENT_KEY,
77
+ registry: options.registry,
78
+ registryMode: options.registryMode,
79
+ image: options.image,
80
+ port: publishedHostPort(3006, developerId),
81
+ skipEnvOutputPath: true,
82
+ skipInfraCheck: true,
83
+ skipManifestMetadataLine: true,
84
+ silentPoll: true
85
+ });
86
+ }
87
+
88
+ async function handleUpIntegrationServer(options = {}) {
89
+ await ensureIntegrationServerAppsFromTemplate({ silent: true });
90
+ refreshUrlsLocalRegistryForCurrentProject();
91
+ const context = await resolveUpBuilderApiControllerContext(options, ENVIRONMENT_KEY);
92
+ if (!context.useBootstrap) {
93
+ throw new Error('Integration Server installation requires local bootstrap provisioning.');
94
+ }
95
+ await bootstrapIntegrationServer(options, context.controllerUrl);
96
+ const image = options.image || resolveIntegrationServerImageRef(options);
97
+ await app.deployApp(APP_KEY, {
98
+ image,
99
+ imageOverride: image,
100
+ registryMode: options.registryMode,
101
+ envKey: ENVIRONMENT_KEY,
102
+ deploymentAuth: 'client-credentials',
103
+ silentPoll: true
104
+ });
105
+ await runIntegrationServer({ ...options, image });
106
+ }
107
+
108
+ module.exports = {
109
+ handleUpIntegrationServer,
110
+ isIntegrationServerSelected,
111
+ resolveIntegrationServerImageRef
112
+ };
@@ -6,7 +6,9 @@
6
6
 
7
7
  const { repairKeyedDocument } = require('./repair-datasource-keyed-document');
8
8
 
9
- const ENTITY_TYPE_FALLBACK = 'record-storage';
9
+ const { repairLegacyDatasource } = require('./repair-datasource-legacy');
10
+
11
+ const ENTITY_TYPE_FALLBACK = 'recordStorage';
10
12
  const VALID_ENTITY_TYPES = new Set([
11
13
  'document-storage',
12
14
  'documentStorage',
@@ -16,6 +18,7 @@ const VALID_ENTITY_TYPES = new Set([
16
18
  'recordStorage',
17
19
  'message-service',
18
20
  'messageService',
21
+ 'serviceContract',
19
22
  'none'
20
23
  ]);
21
24
  const VALID_PORTAL_FIELDS = new Set(['text', 'textarea', 'select', 'json', 'boolean', 'number']);
@@ -89,6 +92,7 @@ function normalizeDatasourceConfig(datasourceConfig, openapiSpec) {
89
92
  if (datasourceConfig.entityType && !VALID_ENTITY_TYPES.has(datasourceConfig.entityType)) {
90
93
  datasourceConfig.entityType = ENTITY_TYPE_FALLBACK;
91
94
  }
95
+ repairLegacyDatasource(datasourceConfig);
92
96
  normalizePortalInput(datasourceConfig);
93
97
  normalizeCipOutputModes(datasourceConfig);
94
98
  repairKeyedDocument(datasourceConfig, { openapiSpec });
@@ -10,9 +10,10 @@
10
10
 
11
11
  /**
12
12
  * @param {Object.<string, string>} adminObj
13
+ * @param {string} [appName]
13
14
  * @returns {Object.<string, string>}
14
15
  */
15
- function buildPlatformEnvOverlayFromAdminSecrets(adminObj) {
16
+ function buildPlatformEnvOverlayFromAdminSecrets(adminObj, appName) {
16
17
  if (!adminObj || typeof adminObj !== 'object') return {};
17
18
  const platformPwd =
18
19
  adminObj.PLATFORM_ADMIN_PASSWORD ||
@@ -39,6 +40,9 @@ function buildPlatformEnvOverlayFromAdminSecrets(adminObj) {
39
40
  if (email) {
40
41
  overlay.ONBOARDING_ADMIN_EMAIL = email;
41
42
  }
43
+ if (appName === 'miso-controller' && adminObj.POSTGRES_PASSWORD) {
44
+ overlay.POSTGRES_ADMIN_PASSWORD = adminObj.POSTGRES_PASSWORD;
45
+ }
42
46
  return overlay;
43
47
  }
44
48
 
@@ -46,9 +50,10 @@ function buildPlatformEnvOverlayFromAdminSecrets(adminObj) {
46
50
  * Apply admin-secrets values over resolved app env (admin-secrets wins for platform keys).
47
51
  * @param {Object.<string, string>} envMap
48
52
  * @param {Object.<string, string>} adminObj
53
+ * @param {string} [appName]
49
54
  */
50
- function applyAdminSecretsPlatformOverlay(envMap, adminObj) {
51
- const overlay = buildPlatformEnvOverlayFromAdminSecrets(adminObj);
55
+ function applyAdminSecretsPlatformOverlay(envMap, adminObj, appName) {
56
+ const overlay = buildPlatformEnvOverlayFromAdminSecrets(adminObj, appName);
52
57
  for (const [key, value] of Object.entries(overlay)) {
53
58
  if (value !== undefined && value !== null && String(value).trim() !== '') {
54
59
  envMap[key] = String(value);