@aifabrix/builder 2.60.0 → 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.
- package/README.md +14 -11
- package/docs/README.md +80 -0
- package/docs/builder-help/evidence-patterns.json +155 -0
- package/docs/builder-help/golden-examples/crm-company.json +30 -0
- package/docs/builder-help/golden-examples/crm-deal.json +29 -0
- package/docs/builder-help/golden-examples/document-storage-keyed-get.json +85 -0
- package/docs/builder-help/golden-examples/document-storage.json +30 -0
- package/docs/builder-help/golden-examples/meeting-transcript.json +29 -0
- package/docs/builder-help/golden-examples/repository-template.json +29 -0
- package/docs/builder-help/golden-examples/service-ticket.json +29 -0
- package/docs/builder-help/platform-roles.json +98 -0
- package/docs/builder-help/resource-type-catalog.json +402 -0
- package/lib/api/applications.api.js +22 -2
- package/lib/api/bootstrap-snapshot.api.js +115 -0
- package/lib/api/configuration.api.js +131 -0
- package/lib/api/system-secrets.api.js +72 -0
- package/lib/app/deploy.js +14 -5
- package/lib/app/run-docker-fallback.js +6 -1
- package/lib/app/run-env-compose.js +5 -6
- package/lib/app/run-helpers.js +2 -1
- package/lib/app/run-parameter-sync.js +142 -0
- package/lib/app/run.js +6 -4
- package/lib/build/docker-build-args.js +5 -2
- package/lib/build/index.js +3 -2
- package/lib/build/standard-docker-build.js +6 -2
- package/lib/channels/channel-artifact-generator.js +13 -3
- package/lib/cli/infra-guided-footers.js +10 -8
- package/lib/cli/infra-guided.js +30 -10
- package/lib/cli/setup-app.js +5 -0
- package/lib/cli/setup-environment.js +156 -0
- package/lib/cli/setup-infra-up-platform-action.js +14 -1
- package/lib/cli/setup-platform.js +2 -0
- package/lib/commands/auth-config.js +2 -0
- package/lib/commands/datasource-capability-upsert-cli.js +112 -0
- package/lib/commands/datasource-capability.js +4 -2
- package/lib/commands/env-secret-context.js +113 -0
- package/lib/commands/env-secret-list.js +200 -0
- package/lib/commands/env-secret-push-confirm.js +54 -0
- package/lib/commands/env-secret-push-run.js +227 -0
- package/lib/commands/env-secret-push.js +168 -0
- package/lib/commands/login.js +4 -0
- package/lib/commands/repair-datasource-apply.js +5 -1
- package/lib/commands/repair-datasource-keyed-document.js +122 -0
- package/lib/commands/repair-datasource-legacy.js +94 -0
- package/lib/commands/repair-datasource-run.js +1 -0
- package/lib/commands/setup-image-refresh.js +26 -0
- package/lib/commands/setup-modes.js +8 -9
- package/lib/commands/setup-prompts-platform-mode.js +34 -0
- package/lib/commands/setup-prompts.js +2 -180
- package/lib/commands/setup.js +3 -0
- package/lib/commands/up-builder-api.js +24 -8
- package/lib/commands/up-common.js +16 -1
- package/lib/commands/up-dataplane-bootstrap.js +70 -14
- package/lib/commands/up-dataplane-credentials.js +21 -0
- package/lib/commands/up-dataplane.js +37 -18
- package/lib/commands/up-integration-server.js +112 -0
- package/lib/commands/verify-operations-skip-e2e.js +25 -1
- package/lib/commands/verify-operations-steps.js +13 -1
- package/lib/commands/wizard-config-normalizer.js +12 -5
- package/lib/commands/wizard-core.js +5 -157
- package/lib/commands/wizard-file-saving.js +163 -0
- package/lib/core/admin-secrets-env-overlay.js +8 -3
- package/lib/core/env-platform-expand.js +5 -1
- package/lib/core/environment-access-policy.js +121 -0
- package/lib/core/environment-mode-policy.js +177 -0
- package/lib/core/local-env-overrides.js +149 -0
- package/lib/core/secrets-ensure.js +4 -2
- package/lib/core/secrets-env-content.js +17 -10
- package/lib/core/secrets-env-write.js +11 -4
- package/lib/core/secrets-load.js +4 -2
- package/lib/datasource/binary-documents-validator.js +190 -0
- package/lib/datasource/capability/capability-manifest.js +1 -0
- package/lib/datasource/capability/run-capability-upsert.js +202 -0
- package/lib/datasource/capability/upsert-ingredients.js +291 -0
- package/lib/datasource/capability/upsert-operations.js +138 -0
- package/lib/datasource/capability/upsert-test-scaffold.js +189 -0
- package/lib/datasource/validate.js +12 -5
- package/lib/deployment/installation/index.js +14 -1
- package/lib/deployment/installation/infra-catalog.js +3 -0
- package/lib/deployment/installation/local-environment-stage.js +285 -0
- package/lib/deployment/installation/local-installation.js +76 -0
- package/lib/deployment/installation/stage-input.js +5 -1
- package/lib/generator/builders.js +3 -1
- package/lib/generator/index.js +3 -0
- package/lib/generator/split-variables.js +2 -2
- package/lib/lifecycle/product-model.js +4 -3
- package/lib/lifecycle/report-display.js +3 -2
- package/lib/parameters/database-adoption.js +125 -0
- package/lib/parameters/infra-parameter-catalog.js +1 -1
- package/lib/parameters/physical-database-naming.js +136 -0
- package/lib/parameters/physical-secret-name.js +194 -0
- package/lib/parameters/rsa-secret-values.js +165 -0
- package/lib/programmatic/builder-help-enterprise-sync-fabrix.js +1 -1
- package/lib/programmatic/builder-help-governance.js +1 -1
- package/lib/programmatic/builder-help.js +1 -1
- package/lib/programmatic/run-channel-install-artifacts.js +28 -2
- package/lib/programmatic/run-channel-package.js +3 -1
- package/lib/programmatic/workspace-context.js +37 -2
- package/lib/role-assistant/test-runner-workhub-answers.js +4 -1
- package/lib/role-assistant/test-runner-workhub-missing-fields.js +42 -0
- package/lib/role-assistant/test-runner-workhub-wait-stop.js +94 -0
- package/lib/role-assistant/test-runner-workhub.js +28 -19
- package/lib/schema/application-schema.json +14 -2
- package/lib/schema/external-datasource.schema.json +23 -3
- package/lib/schema/infra.parameter.yaml +440 -56
- package/lib/schema/infrastructure-schema.json +213 -120
- package/lib/utils/compose-generate-docker-compose.js +9 -14
- package/lib/utils/compose-generator.js +4 -7
- package/lib/utils/compose-miso-env.js +2 -2
- package/lib/utils/compose-traefik-ingress-base.js +3 -4
- package/lib/utils/datasource-binary-evidence.js +92 -0
- package/lib/utils/datasource-test-run-capability-scope.js +44 -1
- package/lib/utils/datasource-test-run-debug-display.js +2 -0
- package/lib/utils/datasource-test-run-display.js +8 -2
- package/lib/utils/datasource-test-run-issue-guidance.js +176 -0
- package/lib/utils/datasource-test-run-tty-log.js +2 -0
- package/lib/utils/declarative-url-ports.js +3 -0
- package/lib/utils/env-copy.js +11 -10
- package/lib/utils/env-environment-file-paths.js +105 -0
- package/lib/utils/environment-scoped-resources.js +48 -14
- package/lib/utils/external-system-system-test-tty.js +3 -2
- package/lib/utils/image-tags.js +2 -2
- package/lib/utils/paths-system-builder-keys.js +7 -1
- package/lib/utils/paths.js +7 -2
- package/lib/utils/platform-kv-ref.js +1 -1
- package/lib/utils/postgres-platform-bootstrap.js +35 -1
- package/lib/utils/prepare-local-data-mount.js +58 -0
- package/lib/utils/redis-env-scope.js +21 -1
- package/lib/utils/registry-auth-sources.js +154 -0
- package/lib/utils/registry-credentials.js +131 -14
- package/lib/utils/secrets-generator.js +30 -21
- package/lib/utils/secrets-helpers.js +5 -8
- package/lib/utils/secrets-kv-scope.js +127 -28
- package/lib/utils/secrets-materialize-local.js +9 -0
- package/lib/utils/secrets-missing-error.js +35 -1
- package/lib/utils/system-secret-mapping.js +125 -0
- package/lib/utils/test-log-writer.js +2 -1
- package/lib/utils/token-manager.js +14 -8
- package/lib/utils/url-public-path-prefix.js +6 -10
- package/lib/validation/external-manifest-validator.js +5 -0
- package/lib/validation/openapi-contract-surface-validator.js +3 -1
- package/lib/validation/validate-external-file.js +5 -1
- package/package.json +6 -4
- package/templates/agent-kit/agent-kit.yaml +1 -1
- package/templates/agent-kit/skills/aifabrix-connected-system/SKILL.md +2 -1
- package/templates/agent-kit/skills/aifabrix-connected-system/references/delivery-gates.md +15 -0
- package/templates/agent-kit/skills/aifabrix-plan/SKILL.md +3 -2
- package/templates/agent-kit/skills/aifabrix-prove/SKILL.md +6 -2
- package/templates/agent-kit/skills/aifabrix-prove/references/evidence-lifecycle.md +22 -0
- package/templates/agent-kit/skills/aifabrix-role-assistant/SKILL.md +7 -1
- package/templates/agent-kit/skills/aifabrix-role-assistant/references/testing-playbook.md +117 -0
- package/templates/agent-kit/skills/shared/interaction.md +83 -0
- package/templates/agent-kit/skills/shared/status.md +3 -12
- package/templates/applications/builder-api/application.yaml +1 -1
- package/templates/applications/builder-api/env.template +5 -1
- package/templates/applications/dataplane/application.yaml +2 -2
- package/templates/applications/dataplane/env.template +10 -12
- package/templates/applications/integration-server/application.yaml +91 -0
- package/templates/applications/integration-server/env.template +215 -0
- package/templates/applications/keycloak/application.yaml +6 -1
- package/templates/applications/mirrored-templates.json +52 -0
- package/templates/applications/miso-controller/application.yaml +116 -2
- package/templates/applications/miso-controller/env.template +62 -17
- package/templates/applications/miso-controller/rbac.yaml +17 -0
- package/templates/external-system/external-datasource.yaml.hbs +7 -1
- package/templates/marketplace/createUiDefinition.json +52 -4
- package/templates/marketplace/main.json +88 -10
- package/templates/python/docker-compose.hbs +1 -1
- package/templates/agent-kit/skills/aifabrix-plan/references/interaction.md +0 -41
- /package/{lib/programmatic/help-content → docs/builder-help/content}/channel-onboarding.md +0 -0
- /package/{lib/programmatic/help-content → docs/builder-help/content}/cip-overview.md +0 -0
- /package/{lib/programmatic/help-content → docs/builder-help/content}/connected-system-ui.md +0 -0
- /package/{lib/programmatic/help-content → docs/builder-help/content}/dimensions-guide.md +0 -0
- /package/{lib/programmatic/help-content → docs/builder-help/content}/enterprise-sync-fabrix.md +0 -0
- /package/{lib/programmatic/help-content → docs/builder-help/content}/overview.md +0 -0
- /package/{lib/programmatic/help-content → docs/builder-help/content}/subscription-guide.md +0 -0
- /package/{lib/programmatic/help-content → docs/builder-help/content}/workflow.md +0 -0
|
@@ -118,6 +118,79 @@ Typical workflow:
|
|
|
118
118
|
|
|
119
119
|
Subcommands:
|
|
120
120
|
deploy <env> Provision/update environment in Miso Controller (see env deploy --help)
|
|
121
|
+
secret Installation configuration on the Controller (push, list)
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
const SECRET_GROUP_HELP_AFTER = `
|
|
125
|
+
Installation configuration held by the Controller. Push updates declared variables and secrets;
|
|
126
|
+
list reads them for one application or every authorized application.
|
|
127
|
+
|
|
128
|
+
Scope, compared with the other two stores:
|
|
129
|
+
aifabrix secret your own local secrets.local.yaml (and the shared store)
|
|
130
|
+
aifabrix credential a Connected System's credentials on the Dataplane
|
|
131
|
+
aifabrix env secret this installation's secrets on the Controller
|
|
132
|
+
|
|
133
|
+
Secret values are write-only: they can be set and never read back. Listing shows values only
|
|
134
|
+
for rows the Controller authoritatively classifies as non-sensitive variables.
|
|
135
|
+
|
|
136
|
+
The environment is a parameter. Omit it to use the one in config.yaml
|
|
137
|
+
(aifabrix auth set-environment <env>).
|
|
138
|
+
|
|
139
|
+
Examples:
|
|
140
|
+
$ aifabrix env secret list --app builder-api
|
|
141
|
+
$ aifabrix env secret list dev --app mori-controller
|
|
142
|
+
$ aifabrix env secret push --app mori-controller
|
|
143
|
+
$ af env secret push miso --app mori-controller --dry-run
|
|
144
|
+
`;
|
|
145
|
+
|
|
146
|
+
const SECRET_PUSH_HELP_AFTER = `
|
|
147
|
+
Reads values from the application's ignored .env and matches each variable name to the
|
|
148
|
+
Controller's declaration. Non-sensitive variables use configuration PUT; secrets use the
|
|
149
|
+
protected system-secret PUT. Undeclared .env names are skipped.
|
|
150
|
+
|
|
151
|
+
Secrets: pass paths only. The value is read from the file and never taken from the command
|
|
152
|
+
line, so it cannot reach shell history or a process list. No value is printed or logged on
|
|
153
|
+
any path, including failure.
|
|
154
|
+
|
|
155
|
+
Environment: omit to use the configured one, or name it explicitly.
|
|
156
|
+
--key is the variable name from .env, not the Controller declaration key.
|
|
157
|
+
Without --key, an interactive terminal asks before pushing all declared values. Automation
|
|
158
|
+
and AI usage must pass --yes explicitly. Dry-run never prompts and never writes.
|
|
159
|
+
|
|
160
|
+
Examples:
|
|
161
|
+
Preview one value from mori-controller's default .env, then push it to dev:
|
|
162
|
+
$ aifabrix env secret push dev --app mori-controller --key NOTIFICATION_EVENT_WEBHOOK_SECRET --dry-run
|
|
163
|
+
$ aifabrix env secret push dev --app mori-controller --key NOTIFICATION_EVENT_WEBHOOK_SECRET
|
|
164
|
+
|
|
165
|
+
Preview every declared configuration value found in the app's default .env:
|
|
166
|
+
$ aifabrix env secret push dev --app mori-controller --dry-run
|
|
167
|
+
|
|
168
|
+
Push every declared value after reviewing the dry run (interactive confirmation):
|
|
169
|
+
$ aifabrix env secret push dev --app mori-controller
|
|
170
|
+
|
|
171
|
+
Push every declared value non-interactively after explicit approval:
|
|
172
|
+
$ aifabrix env secret push dev --app mori-controller --yes
|
|
173
|
+
|
|
174
|
+
Preview values from a different ignored env file:
|
|
175
|
+
$ af env secret push dev --app mori-controller --file ./path/to/ignored.env --dry-run
|
|
176
|
+
`;
|
|
177
|
+
|
|
178
|
+
const SECRET_LIST_HELP_AFTER = `
|
|
179
|
+
Shows declared configuration in a compact table. Without --app, the Application column
|
|
180
|
+
lists every authorized owner; with --app, only that exact owner is shown. Non-sensitive
|
|
181
|
+
variable values are shown. Secret values, references, vault names and ciphertext are never shown.
|
|
182
|
+
|
|
183
|
+
Environment: omit to use the configured one, or name it explicitly.
|
|
184
|
+
--app optionally identifies one exact owner; * means the literal wildcard owner.
|
|
185
|
+
--key searches that owner's secret key and environment-variable names by substring.
|
|
186
|
+
The table has Status, Name, Type and Value headers (plus Application without --app).
|
|
187
|
+
Rows use ✔ for configured, ⚠ for required missing, and ⏭ for optional unset.
|
|
188
|
+
|
|
189
|
+
Examples:
|
|
190
|
+
$ aifabrix env secret list dev
|
|
191
|
+
$ aifabrix env secret list --app mori-controller
|
|
192
|
+
$ aifabrix env secret list dev --app builder-api
|
|
193
|
+
$ aifabrix env secret list --app mori-controller --key policy
|
|
121
194
|
`;
|
|
122
195
|
|
|
123
196
|
function setupEnvironmentCommands(program) {
|
|
@@ -136,6 +209,89 @@ function setupEnvironmentCommands(program) {
|
|
|
136
209
|
.option('--no-poll', 'Do not poll for status'))
|
|
137
210
|
.addHelpText('after', DEPLOY_EXAMPLES)
|
|
138
211
|
.action(deployEnvHandler);
|
|
212
|
+
|
|
213
|
+
setupEnvSecretCommands(env);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @param {string|undefined} envKey - Positional environment
|
|
218
|
+
* @param {Object} options - CLI options
|
|
219
|
+
* @returns {Promise<void>} Exits non-zero on failure
|
|
220
|
+
*/
|
|
221
|
+
async function envSecretPushHandler(envKey, options) {
|
|
222
|
+
try {
|
|
223
|
+
const { resolveEnvSecretContext, resolveAppPaths } = require('../commands/env-secret-context');
|
|
224
|
+
const { runEnvSecretPush } = require('../commands/env-secret-push-run');
|
|
225
|
+
const { confirmBulkSecretPush } = require('../commands/env-secret-push-confirm');
|
|
226
|
+
const base = await resolveEnvSecretContext(envKey, options);
|
|
227
|
+
const paths = resolveAppPaths(options.app, options);
|
|
228
|
+
const confirmed = await confirmBulkSecretPush(base, options);
|
|
229
|
+
if (!confirmed) return;
|
|
230
|
+
const { exitCode } = await runEnvSecretPush({ ...base, ...paths }, {
|
|
231
|
+
key: options.key,
|
|
232
|
+
application: options.app,
|
|
233
|
+
dryRun: options.dryRun === true
|
|
234
|
+
});
|
|
235
|
+
if (exitCode !== 0) {
|
|
236
|
+
process.exit(exitCode);
|
|
237
|
+
}
|
|
238
|
+
} catch (error) {
|
|
239
|
+
handleCommandError(error, 'env secret push');
|
|
240
|
+
process.exit(1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @param {string|undefined} envKey - Positional environment
|
|
246
|
+
* @param {Object} options - CLI options
|
|
247
|
+
* @returns {Promise<void>} Exits non-zero on failure
|
|
248
|
+
*/
|
|
249
|
+
async function envSecretListHandler(envKey, options) {
|
|
250
|
+
try {
|
|
251
|
+
const { resolveEnvSecretContext } = require('../commands/env-secret-context');
|
|
252
|
+
const { runEnvSecretList } = require('../commands/env-secret-list');
|
|
253
|
+
const ctx = await resolveEnvSecretContext(envKey, options);
|
|
254
|
+
const { exitCode } = await runEnvSecretList(ctx, { key: options.key, application: options.app });
|
|
255
|
+
if (exitCode !== 0) {
|
|
256
|
+
process.exit(exitCode);
|
|
257
|
+
}
|
|
258
|
+
} catch (error) {
|
|
259
|
+
handleCommandError(error, 'env secret list');
|
|
260
|
+
process.exit(1);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* `aifabrix env secret` — installation secrets on the Controller.
|
|
266
|
+
* @param {import('commander').Command} env - The env command group
|
|
267
|
+
* @returns {void}
|
|
268
|
+
*/
|
|
269
|
+
function setupEnvSecretCommands(env) {
|
|
270
|
+
const secret = env
|
|
271
|
+
.command('secret')
|
|
272
|
+
.description('Installation configuration on the Controller (secret values remain write-only)')
|
|
273
|
+
.addHelpText('after', SECRET_GROUP_HELP_AFTER);
|
|
274
|
+
|
|
275
|
+
// The API takes the environment in the path, so both commands accept it; omitted, it falls
|
|
276
|
+
// back to the one in config.yaml. Push and list have distinct resource contracts.
|
|
277
|
+
secret
|
|
278
|
+
.command('push [env]')
|
|
279
|
+
.description('Push declared configuration from an app env file (values are never arguments)')
|
|
280
|
+
.option('--app <appKey>', 'Exact application owner of the configuration declarations')
|
|
281
|
+
.option('--file <path>', 'Env file to read values from (default: the app\'s .env)')
|
|
282
|
+
.option('--key <variable>', 'Push one .env variable name')
|
|
283
|
+
.option('--dry-run', 'Show what would be pushed and write nothing')
|
|
284
|
+
.option('-y, --yes', 'Confirm bulk push without prompting (automation / AI usage)')
|
|
285
|
+
.addHelpText('after', SECRET_PUSH_HELP_AFTER)
|
|
286
|
+
.action(envSecretPushHandler);
|
|
287
|
+
|
|
288
|
+
secret
|
|
289
|
+
.command('list [env]')
|
|
290
|
+
.description('List configuration types, safe values and status by application')
|
|
291
|
+
.option('--app <appKey>', 'Only this exact application owner (* is the wildcard owner)')
|
|
292
|
+
.option('--key <text>', 'Search key and environment-variable names')
|
|
293
|
+
.addHelpText('after', SECRET_LIST_HELP_AFTER)
|
|
294
|
+
.action(envSecretListHandler);
|
|
139
295
|
}
|
|
140
296
|
|
|
141
297
|
module.exports = { setupEnvironmentCommands, deployEnvHandler, addMarketplaceOptions };
|
|
@@ -17,6 +17,10 @@ const { handleLogin } = require('../commands/login');
|
|
|
17
17
|
const { handleUpMiso } = require('../commands/up-miso');
|
|
18
18
|
const { handleUpDataplane } = require('../commands/up-dataplane');
|
|
19
19
|
const { handleUpBuilderApi } = require('../commands/up-builder-api');
|
|
20
|
+
const {
|
|
21
|
+
handleUpIntegrationServer,
|
|
22
|
+
isIntegrationServerSelected
|
|
23
|
+
} = require('../commands/up-integration-server');
|
|
20
24
|
const {
|
|
21
25
|
applyUpPlatformForceConfig,
|
|
22
26
|
cleanBuilderAppDirs,
|
|
@@ -26,7 +30,13 @@ const {
|
|
|
26
30
|
const { runGuidedUpPlatform } = require('./infra-guided');
|
|
27
31
|
const { recordInfraInstallationCommand } = require('./installation-log-command');
|
|
28
32
|
|
|
29
|
-
const PLATFORM_APPS = [
|
|
33
|
+
const PLATFORM_APPS = [
|
|
34
|
+
'keycloak',
|
|
35
|
+
'miso-controller',
|
|
36
|
+
'dataplane',
|
|
37
|
+
'builder-api',
|
|
38
|
+
'integration-server'
|
|
39
|
+
];
|
|
30
40
|
|
|
31
41
|
/**
|
|
32
42
|
* @param {Object} options
|
|
@@ -59,6 +69,9 @@ async function runUpPlatformWork(options) {
|
|
|
59
69
|
await handleUpMiso(options);
|
|
60
70
|
await handleUpDataplane(options);
|
|
61
71
|
await handleUpBuilderApi({ ...options, platformInstall: true });
|
|
72
|
+
if (await isIntegrationServerSelected()) {
|
|
73
|
+
await handleUpIntegrationServer({ ...options, platformInstall: true });
|
|
74
|
+
}
|
|
62
75
|
}
|
|
63
76
|
return cleanedAppKeys;
|
|
64
77
|
}
|
|
@@ -61,6 +61,8 @@ function registerSetup(program) {
|
|
|
61
61
|
.option('--pro-password-mode <mode>', 'Pro profile only: autogen or manual')
|
|
62
62
|
.option('--admin-email <email>', 'Admin email (non-interactive fresh install)')
|
|
63
63
|
.option('--admin-password <password>', 'Admin password for dev or pro manual-single (non-interactive)')
|
|
64
|
+
.option('--integration-server', 'Install the integration server (runs once in the miso environment)')
|
|
65
|
+
.option('--no-integration-server', 'Do not install the integration server (default)')
|
|
64
66
|
.option('--mode <mode>', 'Non-interactive mode: fresh (no infra) or update-images (infra running)')
|
|
65
67
|
.option('-y, --yes', 'Skip destructive confirmation prompts (re-install, wipe data, teardown)')
|
|
66
68
|
.addHelpText('after', SETUP_HELP_AFTER)
|
|
@@ -23,6 +23,7 @@ const {
|
|
|
23
23
|
checkUserLoggedIn
|
|
24
24
|
} = require('../utils/auth-config-validator');
|
|
25
25
|
const { hasStoredDeviceTokenForController } = require('../utils/controller-url');
|
|
26
|
+
const { assertEnvironmentAllowedForCurrentMode } = require('../core/environment-mode-policy');
|
|
26
27
|
const logger = require('../utils/logger');
|
|
27
28
|
|
|
28
29
|
/**
|
|
@@ -166,6 +167,7 @@ async function handleSetEnvironment(environment) {
|
|
|
166
167
|
try {
|
|
167
168
|
// Validate environment format
|
|
168
169
|
validateEnvironment(environment);
|
|
170
|
+
await assertEnvironmentAllowedForCurrentMode(environment);
|
|
169
171
|
|
|
170
172
|
// Get current controller from config
|
|
171
173
|
const controllerUrl = await getControllerUrl();
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `datasource capability upsert` command registration.
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Explicit upsert candidate authoring CLI
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
const logger = require('../utils/logger');
|
|
10
|
+
const {
|
|
11
|
+
formatBlockingError,
|
|
12
|
+
headerKeyValue,
|
|
13
|
+
infoLine,
|
|
14
|
+
formatWarningLine,
|
|
15
|
+
formatNextActions
|
|
16
|
+
} = require('../utils/cli-test-layout-chalk');
|
|
17
|
+
const { runCapabilityUpsert } = require('../datasource/capability/run-capability-upsert');
|
|
18
|
+
const { printCapabilitySuccessFooter } = require('./datasource-capability-output');
|
|
19
|
+
|
|
20
|
+
const HELP = `
|
|
21
|
+
Authors a manifest-declared upsert candidate only when create, update, business
|
|
22
|
+
identity, and an exact vendor lookup are already declared. This is static
|
|
23
|
+
authoring eligibility, not live readiness certification.
|
|
24
|
+
|
|
25
|
+
$ aifabrix datasource capability upsert my-datasource --dry-run --json
|
|
26
|
+
$ aifabrix datasource capability upsert ./datasource.yaml --identity domain
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
function printHumanResult(result) {
|
|
30
|
+
if (result.dryRun) {
|
|
31
|
+
logger.log(infoLine('Dry run — planned JSON Patch operations:'));
|
|
32
|
+
logger.log('');
|
|
33
|
+
logger.log(JSON.stringify(result.patchOperations, null, 2));
|
|
34
|
+
} else {
|
|
35
|
+
if (result.backupPath) logger.log(headerKeyValue('Backup:', result.backupPath));
|
|
36
|
+
printCapabilitySuccessFooter(result.resolvedPath, result.updatedSections);
|
|
37
|
+
}
|
|
38
|
+
logger.log(formatWarningLine('Candidate authored — live readiness is not yet verified'));
|
|
39
|
+
logger.log(formatNextActions(result.nextActions));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function printUpsertIssues(issues) {
|
|
43
|
+
(issues || []).forEach((issue) => {
|
|
44
|
+
const code = issue.code ? `[${issue.code}] ` : '';
|
|
45
|
+
logger.log(formatWarningLine(`${code}${issue.message}`));
|
|
46
|
+
const details = [
|
|
47
|
+
['Consequence', issue.consequence],
|
|
48
|
+
['Can AI fix?', issue.aiFixable === true ? 'Yes, with an authorized local manifest change' : 'No automatic fix is safe'],
|
|
49
|
+
['Safe action', issue.remediation],
|
|
50
|
+
['Prevention', issue.prevention],
|
|
51
|
+
['Residual risk', issue.residualRisk]
|
|
52
|
+
];
|
|
53
|
+
details.forEach(([label, value]) => {
|
|
54
|
+
const values = Array.isArray(value) ? value : [value];
|
|
55
|
+
values.filter(Boolean).forEach((item) => logger.log(` ${label}: ${item}`));
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function runUpsertAction(fileOrKey, options) {
|
|
61
|
+
const result = await runCapabilityUpsert({
|
|
62
|
+
fileOrKey,
|
|
63
|
+
as: options.as,
|
|
64
|
+
create: options.create,
|
|
65
|
+
update: options.update,
|
|
66
|
+
identity: options.identity,
|
|
67
|
+
test: Boolean(options.test),
|
|
68
|
+
dryRun: Boolean(options.dryRun),
|
|
69
|
+
overwrite: Boolean(options.overwrite),
|
|
70
|
+
noBackup: Boolean(options.noBackup)
|
|
71
|
+
});
|
|
72
|
+
if (options.json) {
|
|
73
|
+
logger.log(JSON.stringify(result, null, 2));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
printHumanResult(result);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function setupCapabilityUpsertCommand(cap) {
|
|
80
|
+
cap.command('upsert <file-or-key>')
|
|
81
|
+
.description('Author an upsert candidate from declared identity and exact OpenAPI coverage')
|
|
82
|
+
.option('--as <key>', 'Target capability key', 'upsert')
|
|
83
|
+
.option('--create <key>', 'Existing create-shaped capability', 'create')
|
|
84
|
+
.option('--update <key>', 'Existing update-shaped capability', 'update')
|
|
85
|
+
.option('--identity <fields>', 'Comma-separated mapped business identity fields')
|
|
86
|
+
.option('--test', 'Add proof scaffolding when existing safe fixture facts are sufficient')
|
|
87
|
+
.option('--dry-run', 'Print JSON Patch operations; do not write')
|
|
88
|
+
.option('--overwrite', 'Replace only the target upsert slice after full analysis')
|
|
89
|
+
.option('--no-backup', 'Skip backup copy under integration/<app>/backup/')
|
|
90
|
+
.option('--json', 'Print a machine-readable result envelope')
|
|
91
|
+
.addHelpText('after', HELP)
|
|
92
|
+
.action(async(fileOrKey, options) => {
|
|
93
|
+
try {
|
|
94
|
+
await runUpsertAction(fileOrKey, options);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (options.json) {
|
|
97
|
+
logger.log(JSON.stringify({ eligible: false, issues: error.analysis?.issues || [], error: error.message }, null, 2));
|
|
98
|
+
} else {
|
|
99
|
+
logger.error(formatBlockingError(`capability upsert failed: ${error.message}`));
|
|
100
|
+
printUpsertIssues(error.analysis?.issues);
|
|
101
|
+
}
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
module.exports = {
|
|
108
|
+
setupCapabilityUpsertCommand,
|
|
109
|
+
runUpsertAction,
|
|
110
|
+
printHumanResult,
|
|
111
|
+
printUpsertIssues
|
|
112
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Datasource capability subcommands (copy,
|
|
2
|
+
* Datasource capability subcommands (copy, create, upsert, remove, diff, edit, validate).
|
|
3
3
|
*
|
|
4
4
|
* @fileoverview Nested `aifabrix datasource capability` CLI (copy, relate, …)
|
|
5
5
|
* @author AI Fabrix Team
|
|
@@ -26,6 +26,7 @@ const pathMod = require('path');
|
|
|
26
26
|
const { printCapabilitySuccessFooter } = require('./datasource-capability-output');
|
|
27
27
|
const { setupCapabilityRelateCommand } = require('./datasource-capability-relate-cli');
|
|
28
28
|
const { setupCapabilityDimensionCommand } = require('./datasource-capability-dimension-cli');
|
|
29
|
+
const { setupCapabilityUpsertCommand } = require('./datasource-capability-upsert-cli');
|
|
29
30
|
|
|
30
31
|
const CAP_COPY_HELP = `
|
|
31
32
|
Examples:
|
|
@@ -386,7 +387,7 @@ function setupDatasourceCapabilityCommands(datasource) {
|
|
|
386
387
|
const cap = datasource
|
|
387
388
|
.command('capability')
|
|
388
389
|
.description(
|
|
389
|
-
'Copy, remove, relate
|
|
390
|
+
'Copy, create, upsert, remove, relate, diff, edit, or validate datasource capability slices'
|
|
390
391
|
);
|
|
391
392
|
if (typeof cap.alias === 'function') {
|
|
392
393
|
cap.alias('cap');
|
|
@@ -395,6 +396,7 @@ function setupDatasourceCapabilityCommands(datasource) {
|
|
|
395
396
|
setupCapabilityCopyCommand(cap);
|
|
396
397
|
setupCapabilityRemoveCommand(cap);
|
|
397
398
|
setupCapabilityCreateCommand(cap);
|
|
399
|
+
setupCapabilityUpsertCommand(cap);
|
|
398
400
|
setupCapabilityRelateCommand(cap);
|
|
399
401
|
setupCapabilityDimensionCommand(cap);
|
|
400
402
|
setupCapabilityDiffCommand(cap);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve where `aifabrix env secret` reads from and writes to.
|
|
3
|
+
*
|
|
4
|
+
* The controller URL is resolved once and printed before any write, because pushing into
|
|
5
|
+
* the wrong installation is silent and unrecoverable — no value can be read back to show
|
|
6
|
+
* what was overwritten.
|
|
7
|
+
*
|
|
8
|
+
* @fileoverview env secret: controller, environment and file resolution
|
|
9
|
+
* @author AI Fabrix Team
|
|
10
|
+
* @version 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const { resolveControllerUrl } = require('../utils/controller-url');
|
|
18
|
+
const { getOrRefreshDeviceToken } = require('../utils/token-manager');
|
|
19
|
+
const { normalizeControllerUrl, resolveEnvironment } = require('../core/config');
|
|
20
|
+
const { getAppPath, getIntegrationPath } = require('../utils/paths');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} controllerUrl - Raw controller URL
|
|
24
|
+
* @returns {Promise<Object>} Auth config carrying a bearer token
|
|
25
|
+
* @throws {Error} When no usable token is stored
|
|
26
|
+
*/
|
|
27
|
+
async function resolveAuth(controllerUrl) {
|
|
28
|
+
const normalized = normalizeControllerUrl(controllerUrl);
|
|
29
|
+
const deviceToken = await getOrRefreshDeviceToken(normalized);
|
|
30
|
+
if (deviceToken && deviceToken.token) {
|
|
31
|
+
return { token: deviceToken.token, controllerUrl: deviceToken.controller || normalized };
|
|
32
|
+
}
|
|
33
|
+
throw new Error('Not signed in to the Controller. Run: aifabrix login');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Locate the application directory and env file holding the values.
|
|
38
|
+
* @param {string} appKey - Application key
|
|
39
|
+
* @param {Object} options - `file` overrides the env file path
|
|
40
|
+
* @returns {{ appPath: string, envFilePath: string }} Resolved paths
|
|
41
|
+
* @throws {Error} When the application cannot be located
|
|
42
|
+
*/
|
|
43
|
+
function resolveAppPaths(appKey, options = {}) {
|
|
44
|
+
if (!appKey) {
|
|
45
|
+
throw new Error('--app is required: the catalog keys are read from that application env.template');
|
|
46
|
+
}
|
|
47
|
+
// A platform application lives under builder/<appKey>/; an external system under
|
|
48
|
+
// integration/<systemKey>/. Prefer the candidate holding the default .env, then an existing
|
|
49
|
+
// application directory. An explicit --file supplies values but does not change ownership.
|
|
50
|
+
const candidates = [safePath(getAppPath, appKey), safePath(getIntegrationPath, appKey)]
|
|
51
|
+
.filter(Boolean);
|
|
52
|
+
const appPath = candidates.find(dir => fs.existsSync(path.join(dir, '.env'))) ||
|
|
53
|
+
candidates.find(dir => fs.existsSync(dir)) || candidates[0];
|
|
54
|
+
if (!appPath) {
|
|
55
|
+
throw new Error(`Application not found: ${appKey}`);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
appPath,
|
|
59
|
+
envFilePath: options.file ? path.resolve(options.file) : path.join(appPath, '.env')
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {Function} resolver - Path helper
|
|
65
|
+
* @param {string} appKey - Application key
|
|
66
|
+
* @returns {string} Resolved path, or '' when the helper cannot resolve it
|
|
67
|
+
*/
|
|
68
|
+
function safePath(resolver, appKey) {
|
|
69
|
+
try {
|
|
70
|
+
return resolver(appKey) || '';
|
|
71
|
+
} catch {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Build the context both subcommands share.
|
|
78
|
+
*
|
|
79
|
+
* The environment is the one recorded in config.yaml, not something a command accepts. It is
|
|
80
|
+
* changed deliberately with `aifabrix auth set-environment`, so a per-command override would
|
|
81
|
+
* let any string be treated as an environment and fail confusingly against the API.
|
|
82
|
+
*
|
|
83
|
+
* @param {Object} [options] - CLI options
|
|
84
|
+
* @returns {Promise<Object>} controllerUrl, authConfig, envKey
|
|
85
|
+
*/
|
|
86
|
+
async function resolveEnvSecretContext(envKey, options = {}) {
|
|
87
|
+
const controllerUrl = await resolveControllerUrl();
|
|
88
|
+
if (!controllerUrl) {
|
|
89
|
+
throw new Error('No Controller URL configured. Run: aifabrix auth set-controller <url>');
|
|
90
|
+
}
|
|
91
|
+
const auth = await resolveAuth(controllerUrl);
|
|
92
|
+
// The API takes the environment in the path and accepts `*` for every installed
|
|
93
|
+
// environment. Omitted, it falls back to the one recorded in config.yaml.
|
|
94
|
+
const explicit = envKey === undefined || envKey === null ? '' : String(envKey).trim();
|
|
95
|
+
const resolvedEnv = explicit || await resolveEnvironment(options);
|
|
96
|
+
if (!resolvedEnv) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
'No environment given and none configured. Pass one, use * for all, ' +
|
|
99
|
+
'or set a default with: aifabrix auth set-environment <env>'
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
controllerUrl: auth.controllerUrl || controllerUrl,
|
|
104
|
+
authConfig: { token: auth.token },
|
|
105
|
+
envKey: resolvedEnv
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = {
|
|
110
|
+
resolveAuth,
|
|
111
|
+
resolveAppPaths,
|
|
112
|
+
resolveEnvSecretContext
|
|
113
|
+
};
|