@aifabrix/builder 2.52.1 → 2.53.1
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/lib/app/deploy-config.js +3 -2
- package/lib/channels/add-channel.js +11 -41
- package/lib/channels/approval-guides/index.js +3 -0
- package/lib/channels/approval-guides/microsoft-copilot.js +26 -17
- package/lib/channels/channel-add-existing.js +72 -0
- package/lib/channels/channel-runtime-resolver.js +5 -1
- package/lib/channels/channel-status-display.js +30 -3
- package/lib/channels/microsoft-copilot-entra-sso-form.js +73 -2
- package/lib/channels/microsoft-copilot-entra-sso.js +26 -5
- package/lib/channels/microsoft-copilot-limits.js +22 -3
- package/lib/channels/microsoft-copilot-package.js +59 -14
- package/lib/channels/microsoft-copilot-validate.js +40 -10
- package/lib/cli/attach-default-help-examples.js +102 -0
- package/lib/cli/index.js +2 -0
- package/lib/cli/setup-credential-deployment.js +7 -5
- package/lib/cli/setup-utility-validate.js +1 -0
- package/lib/commands/credential-push.js +37 -5
- package/lib/commands/package-score.js +72 -0
- package/lib/commands/role-assistant.js +46 -8
- package/lib/deployment/deployer-poll-run.js +2 -2
- package/lib/deployment/deployer.js +1 -1
- package/lib/deployment/environment.js +2 -2
- package/lib/external-system/deploy.js +11 -21
- package/lib/integration-definition/apply.js +12 -14
- package/lib/integration-definition/enrich-openapi-operations.js +9 -10
- package/lib/lab/package-parity-score.js +417 -0
- package/lib/programmatic/capability-registry.js +1 -0
- package/lib/programmatic/help-content/channel-onboarding.md +35 -0
- package/lib/programmatic/help-content/cip-overview.md +27 -0
- package/lib/programmatic/help-content/connected-system-ui.md +70 -0
- package/lib/programmatic/help-content/dimensions-guide.md +23 -0
- package/lib/programmatic/help-content/enterprise-sync-fabrix.md +123 -0
- package/lib/programmatic/help-content/overview.md +25 -0
- package/lib/programmatic/help-content/subscription-guide.md +27 -0
- package/lib/programmatic/help-content/workflow.md +50 -0
- package/lib/programmatic/openapi-component-schemas.js +1 -0
- package/lib/programmatic/openapi-descriptions.js +6 -0
- package/lib/programmatic/openapi-envelope-examples.js +11 -0
- package/lib/programmatic/openapi-operation-bindings.js +5 -0
- package/lib/programmatic/openapi-request-schemas.js +39 -13
- package/lib/programmatic/openapi-result-schemas.js +30 -0
- package/lib/programmatic/openapi-schema-descriptions-core.js +18 -0
- package/lib/programmatic/openapi-schema-descriptions-operations.js +19 -0
- package/lib/programmatic/persist-supplied-openapi.js +180 -0
- package/lib/programmatic/route-handler-map.js +6 -0
- package/lib/programmatic/run-integration-definition.js +13 -5
- package/lib/role-assistant/evidence-sync.js +55 -7
- package/lib/role-assistant/test-runner-attachments.js +118 -0
- package/lib/role-assistant/test-runner-bid-apply.js +100 -21
- package/lib/role-assistant/test-runner-bid-document.js +1 -1
- package/lib/role-assistant/test-runner-start-payload.js +96 -0
- package/lib/role-assistant/test-runner-workhub-answers.js +11 -7
- package/lib/role-assistant/test-runner-workhub-helpers.js +100 -0
- package/lib/role-assistant/test-runner-workhub-soft.js +86 -0
- package/lib/role-assistant/test-runner-workhub.js +68 -105
- package/lib/role-assistant/test-runner.js +5 -63
- package/lib/role-assistant/test-suite.js +33 -40
- package/lib/schema/external-datasource.schema.json +13 -4
- package/lib/utils/compose-generator.js +10 -1
- package/lib/utils/compose-traefik-extra-routes.js +107 -0
- package/lib/utils/docker-build.js +2 -2
- package/lib/utils/help-builder.js +2 -1
- package/lib/utils/promote-dev-docker-image.js +15 -10
- package/package.json +14 -16
- package/templates/README.md +12 -1
- package/templates/applications/dataplane/application.yaml +8 -1
- package/templates/applications/dataplane/env.template +1 -1
- package/templates/applications/miso-controller/application.yaml +2 -1
- package/templates/applications/miso-controller/rbac.yaml +1 -0
- package/templates/channels/microsoft-copilot/ai-plugin.template.json.hbs +6 -2
- package/templates/channels/microsoft-copilot/entra-sso-registration.template.md.hbs +8 -5
- package/templates/channels/microsoft-copilot/fi-fi.template.json.hbs +7 -0
- package/templates/channels/microsoft-copilot/install.template.md.hbs +74 -22
- package/templates/channels/microsoft-copilot/manifest.template.json.hbs +29 -14
- package/templates/channels/microsoft-copilot/oauth-plugin-vault-required.template.md.hbs +6 -2
- package/templates/python/docker-compose.hbs +36 -0
- package/templates/typescript/docker-compose.hbs +36 -0
- package/.cursor/plans/Archive/157.1-security-quality-violations-by-type.csv +0 -374
- package/.cursor/process/README.md +0 -9
- package/.cursor/rules/anchor-docs.mdc +0 -15
- package/.cursor/rules/assistant-driven-integration-build.mdc +0 -40
- package/.cursor/rules/cli-layout.mdc +0 -81
- package/.cursor/rules/cli-product-neutral.mdc +0 -43
- package/.cursor/rules/deploy-rules/docker-image-ip-policy.mdc +0 -49
- package/.cursor/rules/docs-rules.mdc +0 -32
- package/.cursor/rules/plan-rules/application-lifecycle.mdc +0 -30
- package/.cursor/rules/plan-rules/plan-frontmatter.mdc +0 -35
- package/.cursor/rules/plan-rules/plan-lifecycle.mdc +0 -31
- package/.cursor/rules/plan-rules/plan-validation-gate.mdc +0 -34
- package/.cursor/rules/project-rules.mdc +0 -913
- package/.cursor/skills/README.md +0 -15
- package/.dockerignore +0 -52
- package/.eslintignore +0 -22
- package/.markdownlint.json +0 -14
- package/anchor-docs/README.md +0 -10
- package/anchor-docs/_TEMPLATE +0 -24
- package/babel.config.js +0 -6
- package/bin/builder-api-cleanup.js +0 -26
- package/bin/builder-api-nest.js +0 -10
- package/bin/builder-api-spike.js +0 -19
- package/enterprise-knowledge/README.md +0 -50
- package/enterprise-knowledge/enterprise-integration-lifecycle/README.md +0 -22
- package/enterprise-knowledge/enterprise-integration-lifecycle/application.json +0 -15
- package/enterprise-knowledge/enterprise-integration-lifecycle/deploy.js +0 -69
- package/enterprise-knowledge/enterprise-integration-lifecycle/enterprise-integration-lifecycle-deploy.json +0 -52
- package/enterprise-knowledge/enterprise-integration-lifecycle/enterprise-integration-lifecycle-system.json +0 -29
- package/enterprise-knowledge/enterprise-integration-lifecycle/env.template +0 -2
- package/integration/README.md +0 -81
- package/integration/github/README.md +0 -53
- package/integration/github/application.json +0 -21
- package/integration/github/deploy.js +0 -72
- package/integration/github/env.template +0 -11
- package/integration/github/github-datasource-issue-comments.json +0 -239
- package/integration/github/github-datasource-issues.json +0 -399
- package/integration/github/github-datasource-repository.json +0 -354
- package/integration/github/github-deploy.json +0 -1202
- package/integration/github/github-system.json +0 -82
- package/integration/hubspot-test/README.md +0 -159
- package/integration/hubspot-test/application.json +0 -54
- package/integration/hubspot-test/companies.json +0 -2048
- package/integration/hubspot-test/create-hubspot.js +0 -523
- package/integration/hubspot-test/env.template +0 -4
- package/integration/hubspot-test/hubspot-test-datasource-company.json +0 -138
- package/integration/hubspot-test/hubspot-test-datasource-contact.json +0 -146
- package/integration/hubspot-test/hubspot-test-datasource-deal.json +0 -146
- package/integration/hubspot-test/hubspot-test-datasource-users.json +0 -76
- package/integration/hubspot-test/hubspot-test-deploy.json +0 -2160
- package/integration/hubspot-test/hubspot-test-system.json +0 -74
- package/integration/hubspot-test/rbac.json +0 -166
- package/integration/hubspot-test/test-artifacts/wizard-hubspot-credential-real.yaml +0 -20
- package/integration/hubspot-test/test-artifacts/wizard-hubspot-env-vars.yaml +0 -9
- package/integration/hubspot-test/test-artifacts/wizard-invalid-add-datasource.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-invalid-app-name.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-invalid-credential-create.yaml +0 -7
- package/integration/hubspot-test/test-artifacts/wizard-invalid-credential-select.yaml +0 -7
- package/integration/hubspot-test/test-artifacts/wizard-invalid-known-platform.yaml +0 -4
- package/integration/hubspot-test/test-artifacts/wizard-invalid-missing-app.yaml +0 -4
- package/integration/hubspot-test/test-artifacts/wizard-invalid-missing-source.yaml +0 -2
- package/integration/hubspot-test/test-artifacts/wizard-invalid-mode.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-invalid-openapi-file.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-invalid-openapi-url.yaml +0 -4
- package/integration/hubspot-test/test-artifacts/wizard-invalid-source.yaml +0 -4
- package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-array-test.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-key-test.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-path-test.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-test.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-valid-for-rbac-test.yaml +0 -5
- package/integration/hubspot-test/test-artifacts/wizard-valid-for-rbac-yaml-test.yaml +0 -5
- package/integration/hubspot-test/test-dataplane-down-helpers.js +0 -249
- package/integration/hubspot-test/test-dataplane-down-tests.js +0 -386
- package/integration/hubspot-test/test-dataplane-down.js +0 -209
- package/integration/hubspot-test/test.js +0 -1588
- package/integration/hubspot-test/wizard-hubspot-e2e.yaml +0 -16
- package/integration/hubspot-test/wizard-hubspot-platform.yaml +0 -8
- package/integration/hubspot-test/wizard-hubspot-test-headless.yaml +0 -23
- package/integration/roundtrip-test-local/README.md +0 -143
- package/integration/roundtrip-test-local/application.yaml +0 -13
- package/integration/roundtrip-test-local/env.template +0 -15
- package/integration/roundtrip-test-local/roundtrip-test-local-datasource-roundtrip-test-company.yaml +0 -14
- package/integration/roundtrip-test-local/roundtrip-test-local-deploy.json +0 -61
- package/integration/roundtrip-test-local/roundtrip-test-local-system.yaml +0 -25
- package/integration/roundtrip-test-local2/README.md +0 -143
- package/integration/roundtrip-test-local2/application.yaml +0 -13
- package/integration/roundtrip-test-local2/env.template +0 -15
- package/integration/roundtrip-test-local2/roundtrip-test-local2-datasource-company.yaml +0 -31
- package/integration/roundtrip-test-local2/roundtrip-test-local2-deploy.json +0 -86
- package/integration/roundtrip-test-local2/roundtrip-test-local2-system.yaml +0 -25
- package/integration/test/wizard.yaml +0 -8
- package/jest.config.coverage.js +0 -37
- package/jest.config.default.js +0 -11
- package/jest.config.integration.fixtures.js +0 -22
- package/jest.config.integration.js +0 -33
- package/jest.config.isolated.js +0 -11
- package/jest.config.manual.js +0 -30
- package/jest.global-live-fabrix-hooks.js +0 -36
- package/jest.isolated-projects.js +0 -283
- package/jest.projects.js +0 -79
- package/lib/integration-definition/openapi-enrichment/hubspot-crm-companies.json +0 -205
- package/packages/builder-api/README.md +0 -120
- package/packages/builder-api/package.json +0 -30
- package/packages/builder-api/src/app.module.ts +0 -7
- package/packages/builder-api/src/auth/auth.module.ts +0 -5
- package/packages/builder-api/src/external-system/external-system.module.ts +0 -5
- package/packages/builder-api/src/main.ts +0 -16
- package/packages/builder-api/tsconfig.json +0 -15
- package/scripts/check-builder-api-architecture-grep.js +0 -79
- package/scripts/check-datasource-test-run-schema-sync.js +0 -34
- package/scripts/ci-fix.sh +0 -19
- package/scripts/ci-simulate.sh +0 -19
- package/scripts/diagnose-cli.js +0 -150
- package/scripts/docker_image_content_gate.js +0 -47
- package/scripts/docker_image_content_gate.sh +0 -5
- package/scripts/export-builder-api-evidence.js +0 -262
- package/scripts/install-local.js +0 -490
- package/scripts/lib/builder-api-docker-staging-copy.js +0 -60
- package/scripts/lib/builder-api-docker-staging-core.js +0 -183
- package/scripts/lib/docker-image-content-gate-core.js +0 -166
- package/scripts/lib/plan-actor.js +0 -109
- package/scripts/lib/plan-config.js +0 -20
- package/scripts/lib/plan-gates.js +0 -154
- package/scripts/lib/plan-meta.js +0 -104
- package/scripts/lib/plan-parse.js +0 -162
- package/scripts/lib/plan-prevalidate-gates.js +0 -337
- package/scripts/lib/plan-run-core.js +0 -125
- package/scripts/lib/plan-run-report.js +0 -119
- package/scripts/plan-approve.js +0 -24
- package/scripts/plan-archive.js +0 -49
- package/scripts/plan-run.js +0 -13
- package/scripts/plan-set-actor.js +0 -21
- package/scripts/plan-validate.js +0 -80
- package/scripts/pnpm/af.mjs +0 -125
- package/scripts/pnpm/check-quiet.mjs +0 -32
- package/scripts/pnpm/dev-install.mjs +0 -29
- package/scripts/pnpm/dev-reload.mjs +0 -18
- package/scripts/pnpm/help.mjs +0 -55
- package/scripts/pnpm/lib/dev-reload-core.mjs +0 -189
- package/scripts/pnpm/lib/dev-reload-log-capture.mjs +0 -67
- package/scripts/pnpm/lib/dev-reload-log-utils.mjs +0 -32
- package/scripts/pnpm/lib/resolve-aifabrix-bin.mjs +0 -124
- package/scripts/pnpm/lib/resolve-app-url.mjs +0 -183
- package/scripts/pnpm/lib/spinner.mjs +0 -42
- package/scripts/pnpm-global-remove.js +0 -48
- package/scripts/stage_builder_api_for_docker.js +0 -65
- package/scripts/sync-builder-api-template.js +0 -44
- package/scripts/test-dataplane-bootstrap.js +0 -331
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Test Functions for Dataplane Down Tests
|
|
3
|
-
*
|
|
4
|
-
* Individual test functions for dataplane down test suite.
|
|
5
|
-
*
|
|
6
|
-
* @fileoverview Test functions for dataplane down tests
|
|
7
|
-
* @author AI Fabrix Team
|
|
8
|
-
* @version 2.0.0
|
|
9
|
-
*/
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
const path = require('path');
|
|
13
|
-
const fs = require('fs').promises;
|
|
14
|
-
const {
|
|
15
|
-
logInfo,
|
|
16
|
-
runCommand,
|
|
17
|
-
validateError,
|
|
18
|
-
isTimeoutResult,
|
|
19
|
-
validateDownloadDeleteResult,
|
|
20
|
-
validateDeleteResult,
|
|
21
|
-
validateWizardResult
|
|
22
|
-
} = require('./test-dataplane-down-helpers');
|
|
23
|
-
|
|
24
|
-
const INVALID_DATAPLANE_URL = 'http://localhost:9999';
|
|
25
|
-
const CONTROLLER_URL = process.env.CONTROLLER_URL || 'http://localhost:3110';
|
|
26
|
-
const ENVIRONMENT = process.env.ENVIRONMENT || 'miso';
|
|
27
|
-
const TEST_APP_NAME = 'test-dataplane-down';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Creates wizard config file
|
|
31
|
-
* @async
|
|
32
|
-
* @function createWizardConfig
|
|
33
|
-
* @param {string} configPath - Path to config file
|
|
34
|
-
* @returns {Promise<void>} Resolves when config file is created
|
|
35
|
-
*/
|
|
36
|
-
async function createWizardConfig(configPath) {
|
|
37
|
-
const configContent = `appName: ${TEST_APP_NAME}
|
|
38
|
-
mode: create-system
|
|
39
|
-
source:
|
|
40
|
-
type: known-platform
|
|
41
|
-
platform: hubspot
|
|
42
|
-
deployment:
|
|
43
|
-
controller: ${CONTROLLER_URL}
|
|
44
|
-
environment: ${ENVIRONMENT}
|
|
45
|
-
dataplane: ${INVALID_DATAPLANE_URL}
|
|
46
|
-
`;
|
|
47
|
-
await fs.writeFile(configPath, configContent, 'utf8');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Test wizard command with invalid dataplane
|
|
52
|
-
* @async
|
|
53
|
-
* @function testWizard
|
|
54
|
-
* @returns {Promise<Object>} Test result
|
|
55
|
-
*/
|
|
56
|
-
async function testWizard() {
|
|
57
|
-
logInfo('\n📋 Testing: wizard command');
|
|
58
|
-
|
|
59
|
-
const configPath = path.join(process.cwd(), 'integration', 'test-wizard-config.yaml');
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
await createWizardConfig(configPath);
|
|
63
|
-
|
|
64
|
-
const args = [
|
|
65
|
-
'bin/aifabrix.js',
|
|
66
|
-
'wizard',
|
|
67
|
-
'--config',
|
|
68
|
-
configPath
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
const result = await runCommand('node', args);
|
|
72
|
-
const output = `${result.stdout}\n${result.stderr}`;
|
|
73
|
-
|
|
74
|
-
// Clean up config file
|
|
75
|
-
try {
|
|
76
|
-
await fs.unlink(configPath);
|
|
77
|
-
} catch {
|
|
78
|
-
// Ignore cleanup errors
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return validateWizardResult(result, output);
|
|
82
|
-
} catch (error) {
|
|
83
|
-
return {
|
|
84
|
-
name: 'wizard',
|
|
85
|
-
success: false,
|
|
86
|
-
output: error.message,
|
|
87
|
-
error: error.message
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Test download command with invalid dataplane
|
|
94
|
-
* @async
|
|
95
|
-
* @function testDownload
|
|
96
|
-
* @returns {Promise<Object>} Test result
|
|
97
|
-
*/
|
|
98
|
-
async function testDownload() {
|
|
99
|
-
logInfo('\n📥 Testing: download command');
|
|
100
|
-
|
|
101
|
-
const args = [
|
|
102
|
-
'bin/aifabrix.js',
|
|
103
|
-
'download',
|
|
104
|
-
'non-existent-system-that-should-fail'
|
|
105
|
-
];
|
|
106
|
-
|
|
107
|
-
const result = await runCommand('node', args);
|
|
108
|
-
const output = `${result.stdout}\n${result.stderr}`;
|
|
109
|
-
|
|
110
|
-
const expectedPatterns = [
|
|
111
|
-
'failed to connect',
|
|
112
|
-
'connection refused',
|
|
113
|
-
'network error',
|
|
114
|
-
'econnrefused',
|
|
115
|
-
'fetch failed',
|
|
116
|
-
'timeout',
|
|
117
|
-
'unreachable',
|
|
118
|
-
'failed to download system',
|
|
119
|
-
'not found',
|
|
120
|
-
'external system'
|
|
121
|
-
];
|
|
122
|
-
|
|
123
|
-
const validation = validateDownloadDeleteResult(result, output, expectedPatterns);
|
|
124
|
-
|
|
125
|
-
return {
|
|
126
|
-
name: 'download',
|
|
127
|
-
success: validation.isValid,
|
|
128
|
-
output: validation.output,
|
|
129
|
-
expectedPatterns: validation.expectedPatterns
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Test delete command with invalid dataplane
|
|
135
|
-
* @async
|
|
136
|
-
* @function testDelete
|
|
137
|
-
* @returns {Promise<Object>} Test result
|
|
138
|
-
*/
|
|
139
|
-
async function testDelete() {
|
|
140
|
-
logInfo('\n🗑️ Testing: delete command');
|
|
141
|
-
|
|
142
|
-
const args = [
|
|
143
|
-
'bin/aifabrix.js',
|
|
144
|
-
'delete',
|
|
145
|
-
'non-existent-system-that-should-fail',
|
|
146
|
-
'--type',
|
|
147
|
-
'external',
|
|
148
|
-
'--yes'
|
|
149
|
-
];
|
|
150
|
-
|
|
151
|
-
const result = await runCommand('node', args);
|
|
152
|
-
const output = `${result.stdout}\n${result.stderr}`;
|
|
153
|
-
|
|
154
|
-
const expectedPatterns = [
|
|
155
|
-
'failed to connect',
|
|
156
|
-
'connection refused',
|
|
157
|
-
'network error',
|
|
158
|
-
'econnrefused',
|
|
159
|
-
'fetch failed',
|
|
160
|
-
'timeout',
|
|
161
|
-
'unreachable',
|
|
162
|
-
'failed to delete',
|
|
163
|
-
'not found',
|
|
164
|
-
'external system'
|
|
165
|
-
];
|
|
166
|
-
|
|
167
|
-
const validation = validateDeleteResult(result, output, expectedPatterns);
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
name: 'delete',
|
|
171
|
-
success: validation.isValid,
|
|
172
|
-
output: validation.output,
|
|
173
|
-
expectedPatterns: validation.expectedPatterns,
|
|
174
|
-
error: validation.error
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Creates test datasource file
|
|
180
|
-
* @async
|
|
181
|
-
* @function createTestDatasource
|
|
182
|
-
* @param {string} datasourcePath - Path to datasource file
|
|
183
|
-
* @returns {Promise<void>} Resolves when datasource file is created
|
|
184
|
-
*/
|
|
185
|
-
async function createTestDatasource(datasourcePath) {
|
|
186
|
-
const datasourceContent = JSON.stringify({
|
|
187
|
-
key: 'test-datasource',
|
|
188
|
-
systemKey: 'test-system',
|
|
189
|
-
displayName: 'Test Datasource',
|
|
190
|
-
entityType: 'company',
|
|
191
|
-
resourceType: 'company'
|
|
192
|
-
}, null, 2);
|
|
193
|
-
await fs.writeFile(datasourcePath, datasourceContent, 'utf8');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Builds datasource upload command arguments
|
|
198
|
-
* @function buildDatasourceUploadArgs
|
|
199
|
-
* @param {string} datasourcePath - Path to datasource file
|
|
200
|
-
* @returns {string[]} Command arguments
|
|
201
|
-
*/
|
|
202
|
-
function buildDatasourceUploadArgs(datasourcePath) {
|
|
203
|
-
return ['bin/aifabrix.js', 'datasource', 'upload', datasourcePath];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Gets expected error patterns for datasource upload
|
|
208
|
-
* @function getDatasourceUploadErrorPatterns
|
|
209
|
-
* @returns {string[]} Expected error patterns
|
|
210
|
-
*/
|
|
211
|
-
function getDatasourceUploadErrorPatterns() {
|
|
212
|
-
return [
|
|
213
|
-
'failed to connect',
|
|
214
|
-
'connection refused',
|
|
215
|
-
'network error',
|
|
216
|
-
'econnrefused',
|
|
217
|
-
'fetch failed',
|
|
218
|
-
'timeout',
|
|
219
|
-
'unreachable',
|
|
220
|
-
'failed to publish',
|
|
221
|
-
'upload failed',
|
|
222
|
-
'deployment failed'
|
|
223
|
-
];
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Test datasource upload command with invalid dataplane
|
|
228
|
-
* @async
|
|
229
|
-
* @function testDatasourceUpload
|
|
230
|
-
* @returns {Promise<Object>} Test result
|
|
231
|
-
*/
|
|
232
|
-
async function testDatasourceUpload() {
|
|
233
|
-
logInfo('\n🚀 Testing: datasource upload command');
|
|
234
|
-
|
|
235
|
-
const datasourcePath = path.join(process.cwd(), 'integration', 'test-datasource.json');
|
|
236
|
-
|
|
237
|
-
try {
|
|
238
|
-
await createTestDatasource(datasourcePath);
|
|
239
|
-
const args = buildDatasourceUploadArgs(datasourcePath);
|
|
240
|
-
const result = await runCommand('node', args);
|
|
241
|
-
const output = `${result.stdout}\n${result.stderr}`;
|
|
242
|
-
|
|
243
|
-
// Clean up datasource file
|
|
244
|
-
try {
|
|
245
|
-
await fs.unlink(datasourcePath);
|
|
246
|
-
} catch {
|
|
247
|
-
// Ignore cleanup errors
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const expectedPatterns = getDatasourceUploadErrorPatterns();
|
|
251
|
-
const isValid = !result.success && validateError(output, expectedPatterns);
|
|
252
|
-
|
|
253
|
-
return {
|
|
254
|
-
name: 'datasource upload',
|
|
255
|
-
success: isValid,
|
|
256
|
-
output,
|
|
257
|
-
expectedPatterns
|
|
258
|
-
};
|
|
259
|
-
} catch (error) {
|
|
260
|
-
return {
|
|
261
|
-
name: 'datasource upload',
|
|
262
|
-
success: false,
|
|
263
|
-
output: error.message,
|
|
264
|
-
error: error.message
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Determines test app name for integration test
|
|
271
|
-
* @async
|
|
272
|
-
* @function determineTestApp
|
|
273
|
-
* @returns {Promise<string>} Test app name
|
|
274
|
-
*/
|
|
275
|
-
async function determineTestApp() {
|
|
276
|
-
const hubspotPath = path.join(process.cwd(), 'integration', 'hubspot');
|
|
277
|
-
try {
|
|
278
|
-
await fs.access(hubspotPath);
|
|
279
|
-
return 'hubspot';
|
|
280
|
-
} catch {
|
|
281
|
-
return 'non-existent-app';
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Test test-integration command with invalid dataplane
|
|
287
|
-
* @async
|
|
288
|
-
* @function testIntegration
|
|
289
|
-
* @returns {Promise<Object>} Test result
|
|
290
|
-
*/
|
|
291
|
-
async function testIntegration() {
|
|
292
|
-
logInfo('\n🧪 Testing: test-integration command');
|
|
293
|
-
|
|
294
|
-
const testApp = await determineTestApp();
|
|
295
|
-
|
|
296
|
-
const args = [
|
|
297
|
-
'bin/aifabrix.js',
|
|
298
|
-
'test-integration',
|
|
299
|
-
testApp
|
|
300
|
-
];
|
|
301
|
-
|
|
302
|
-
const result = await runCommand('node', args);
|
|
303
|
-
const output = `${result.stdout}\n${result.stderr}`;
|
|
304
|
-
|
|
305
|
-
const expectedPatterns = [
|
|
306
|
-
'failed to connect',
|
|
307
|
-
'connection refused',
|
|
308
|
-
'network error',
|
|
309
|
-
'econnrefused',
|
|
310
|
-
'fetch failed',
|
|
311
|
-
'timeout',
|
|
312
|
-
'unreachable',
|
|
313
|
-
'failed to run integration tests',
|
|
314
|
-
'not found',
|
|
315
|
-
'dataplane url not found',
|
|
316
|
-
'application not found'
|
|
317
|
-
];
|
|
318
|
-
|
|
319
|
-
const isValid = !result.success && (
|
|
320
|
-
validateError(output, expectedPatterns) ||
|
|
321
|
-
output.includes('Failed') ||
|
|
322
|
-
output.includes('Error') ||
|
|
323
|
-
output.includes('not found')
|
|
324
|
-
);
|
|
325
|
-
|
|
326
|
-
return {
|
|
327
|
-
name: 'test-integration',
|
|
328
|
-
success: isValid,
|
|
329
|
-
output,
|
|
330
|
-
expectedPatterns
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Test dataplane discovery with invalid dataplane
|
|
336
|
-
* @async
|
|
337
|
-
* @function testDataplaneDiscovery
|
|
338
|
-
* @returns {Promise<Object>} Test result
|
|
339
|
-
*/
|
|
340
|
-
async function testDataplaneDiscovery() {
|
|
341
|
-
logInfo('\n🌐 Testing: dataplane discovery');
|
|
342
|
-
|
|
343
|
-
const args = [
|
|
344
|
-
'bin/aifabrix.js',
|
|
345
|
-
'download',
|
|
346
|
-
'non-existent-system-for-discovery-test'
|
|
347
|
-
];
|
|
348
|
-
|
|
349
|
-
const result = await runCommand('node', args);
|
|
350
|
-
const output = `${result.stdout}\n${result.stderr}`;
|
|
351
|
-
|
|
352
|
-
const expectedPatterns = [
|
|
353
|
-
'failed to discover dataplane url',
|
|
354
|
-
'dataplane service not found',
|
|
355
|
-
'application not found',
|
|
356
|
-
'dataplane url not found',
|
|
357
|
-
'failed to download system',
|
|
358
|
-
'not found',
|
|
359
|
-
'external system'
|
|
360
|
-
];
|
|
361
|
-
|
|
362
|
-
const timeout = isTimeoutResult(result);
|
|
363
|
-
const isValid = (!result.success || timeout) && (
|
|
364
|
-
timeout ||
|
|
365
|
-
validateError(output, expectedPatterns) ||
|
|
366
|
-
output.includes('not found') ||
|
|
367
|
-
output.includes('Failed') ||
|
|
368
|
-
output.includes('Error')
|
|
369
|
-
);
|
|
370
|
-
|
|
371
|
-
return {
|
|
372
|
-
name: 'dataplane discovery',
|
|
373
|
-
success: isValid,
|
|
374
|
-
output: timeout ? `${output}\n[Command timed out - this indicates the command may be hanging]` : output,
|
|
375
|
-
expectedPatterns: timeout ? [...expectedPatterns, 'timeout'] : expectedPatterns
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
module.exports = {
|
|
380
|
-
testWizard,
|
|
381
|
-
testDownload,
|
|
382
|
-
testDelete,
|
|
383
|
-
testDatasourceUpload,
|
|
384
|
-
testIntegration,
|
|
385
|
-
testDataplaneDiscovery
|
|
386
|
-
};
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Dataplane Down Test Suite
|
|
4
|
-
*
|
|
5
|
-
* Tests all commands that interact with dataplane when dataplane is unavailable.
|
|
6
|
-
* Validates that appropriate error messages are returned.
|
|
7
|
-
*
|
|
8
|
-
* @fileoverview Dataplane down error handling tests
|
|
9
|
-
* @author AI Fabrix Team
|
|
10
|
-
* @version 2.0.0
|
|
11
|
-
*/
|
|
12
|
-
'use strict';
|
|
13
|
-
|
|
14
|
-
const fs = require('fs').promises;
|
|
15
|
-
const path = require('path');
|
|
16
|
-
const os = require('os');
|
|
17
|
-
const {
|
|
18
|
-
logInfo,
|
|
19
|
-
logSuccess,
|
|
20
|
-
logError,
|
|
21
|
-
logWarn
|
|
22
|
-
} = require('./test-dataplane-down-helpers');
|
|
23
|
-
const {
|
|
24
|
-
testWizard,
|
|
25
|
-
testDownload,
|
|
26
|
-
testDelete,
|
|
27
|
-
testDatasourceUpload,
|
|
28
|
-
testIntegration,
|
|
29
|
-
testDataplaneDiscovery
|
|
30
|
-
} = require('./test-dataplane-down-tests');
|
|
31
|
-
|
|
32
|
-
const INVALID_DATAPLANE_URL = 'http://localhost:9999';
|
|
33
|
-
const ENVIRONMENT = process.env.ENVIRONMENT || 'miso';
|
|
34
|
-
|
|
35
|
-
/** Path to temp config used so CLI uses invalid controller URL and fails with connection error */
|
|
36
|
-
let tempConfigPath = null;
|
|
37
|
-
let originalAifabrixConfig = null;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Create temp config pointing controller to invalid URL so commands fail with connection error
|
|
41
|
-
* @async
|
|
42
|
-
* @returns {Promise<string>} Path to temp config file
|
|
43
|
-
*/
|
|
44
|
-
async function createTempConfig() {
|
|
45
|
-
const dir = path.join(os.tmpdir(), `aifabrix-dataplane-down-${Date.now()}`);
|
|
46
|
-
await fs.mkdir(dir, { recursive: true });
|
|
47
|
-
const configPath = path.join(dir, 'config.yaml');
|
|
48
|
-
const content = `controller: "${INVALID_DATAPLANE_URL}"
|
|
49
|
-
environment: "${ENVIRONMENT}"
|
|
50
|
-
`;
|
|
51
|
-
await fs.writeFile(configPath, content, 'utf8');
|
|
52
|
-
return configPath;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Restore AIFABRIX_CONFIG and remove temp config
|
|
57
|
-
* @async
|
|
58
|
-
* @returns {Promise<void>} Resolves when cleanup is complete
|
|
59
|
-
*/
|
|
60
|
-
async function cleanupTempConfig() {
|
|
61
|
-
if (originalAifabrixConfig !== undefined) {
|
|
62
|
-
if (originalAifabrixConfig === null) {
|
|
63
|
-
delete process.env.AIFABRIX_CONFIG;
|
|
64
|
-
} else {
|
|
65
|
-
process.env.AIFABRIX_CONFIG = originalAifabrixConfig;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
if (tempConfigPath) {
|
|
69
|
-
try {
|
|
70
|
-
await fs.rm(path.dirname(tempConfigPath), { recursive: true, force: true }).catch(() => {});
|
|
71
|
-
} catch {
|
|
72
|
-
// Ignore cleanup errors
|
|
73
|
-
}
|
|
74
|
-
tempConfigPath = null;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Displays failed test details
|
|
80
|
-
* @function displayFailedTestDetails
|
|
81
|
-
* @param {Array} failedTests - Failed test results
|
|
82
|
-
* @returns {void}
|
|
83
|
-
*/
|
|
84
|
-
function displayFailedTestDetails(failedTests) {
|
|
85
|
-
if (failedTests.length === 0) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
logError('\nFailed Tests:');
|
|
90
|
-
for (const test of failedTests) {
|
|
91
|
-
logError(` - ${test.name}`);
|
|
92
|
-
if (test.output) {
|
|
93
|
-
const outputPreview = test.output.length > 500 ? test.output.substring(0, 500) + '...' : test.output;
|
|
94
|
-
logWarn(` Output: ${outputPreview}`);
|
|
95
|
-
}
|
|
96
|
-
if (test.error) {
|
|
97
|
-
logWarn(` Error: ${test.error}`);
|
|
98
|
-
}
|
|
99
|
-
if (test.expectedPatterns) {
|
|
100
|
-
logWarn(` Expected patterns: ${test.expectedPatterns.join(', ')}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Displays test results summary
|
|
107
|
-
* @function displaySummary
|
|
108
|
-
* @param {Array} results - Test results
|
|
109
|
-
* @returns {void}
|
|
110
|
-
*/
|
|
111
|
-
function displaySummary(results) {
|
|
112
|
-
logInfo('\n' + '='.repeat(60));
|
|
113
|
-
logInfo('Test Summary');
|
|
114
|
-
logInfo('='.repeat(60));
|
|
115
|
-
|
|
116
|
-
const passed = results.filter(r => r.success).length;
|
|
117
|
-
const failed = results.filter(r => !r.success).length;
|
|
118
|
-
|
|
119
|
-
logInfo(`Total tests: ${results.length}`);
|
|
120
|
-
logSuccess(`Passed: ${passed}`);
|
|
121
|
-
if (failed > 0) {
|
|
122
|
-
logError(`Failed: ${failed}`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const failedTests = results.filter(r => !r.success);
|
|
126
|
-
displayFailedTestDetails(failedTests);
|
|
127
|
-
|
|
128
|
-
logInfo('='.repeat(60));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Runs all test cases
|
|
133
|
-
* @async
|
|
134
|
-
* @function runTests
|
|
135
|
-
* @returns {Promise<Array>} Test results
|
|
136
|
-
*/
|
|
137
|
-
async function runTests() {
|
|
138
|
-
const tests = [
|
|
139
|
-
testWizard,
|
|
140
|
-
testDownload,
|
|
141
|
-
testDelete,
|
|
142
|
-
testDatasourceUpload,
|
|
143
|
-
testIntegration,
|
|
144
|
-
testDataplaneDiscovery
|
|
145
|
-
];
|
|
146
|
-
|
|
147
|
-
const results = [];
|
|
148
|
-
|
|
149
|
-
for (const testFn of tests) {
|
|
150
|
-
try {
|
|
151
|
-
const result = await testFn();
|
|
152
|
-
results.push(result);
|
|
153
|
-
|
|
154
|
-
if (result.success) {
|
|
155
|
-
logSuccess(`✔ ${result.name}: Error handling validated`);
|
|
156
|
-
} else {
|
|
157
|
-
logError(`✖ ${result.name}: Error handling failed`);
|
|
158
|
-
if (result.output) {
|
|
159
|
-
logWarn(` Output: ${result.output.substring(0, 200)}...`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
} catch (error) {
|
|
163
|
-
logError(`✖ ${testFn.name}: Unexpected error: ${error.message}`);
|
|
164
|
-
results.push({
|
|
165
|
-
name: testFn.name,
|
|
166
|
-
success: false,
|
|
167
|
-
error: error.message
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return results;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Main test runner
|
|
177
|
-
* @async
|
|
178
|
-
* @function main
|
|
179
|
-
* @returns {Promise<void>} Resolves when tests complete
|
|
180
|
-
*/
|
|
181
|
-
async function main() {
|
|
182
|
-
logInfo('='.repeat(60));
|
|
183
|
-
logInfo('Dataplane Down Error Handling Test Suite');
|
|
184
|
-
logInfo('='.repeat(60));
|
|
185
|
-
logInfo(`Invalid Controller URL (used for all commands): ${INVALID_DATAPLANE_URL}`);
|
|
186
|
-
logInfo(`Environment: ${ENVIRONMENT}`);
|
|
187
|
-
logInfo('='.repeat(60));
|
|
188
|
-
|
|
189
|
-
try {
|
|
190
|
-
tempConfigPath = await createTempConfig();
|
|
191
|
-
originalAifabrixConfig = process.env.AIFABRIX_CONFIG || null;
|
|
192
|
-
process.env.AIFABRIX_CONFIG = tempConfigPath;
|
|
193
|
-
|
|
194
|
-
const results = await runTests();
|
|
195
|
-
displaySummary(results);
|
|
196
|
-
|
|
197
|
-
const failed = results.filter(r => !r.success).length;
|
|
198
|
-
if (failed > 0) {
|
|
199
|
-
process.exitCode = 1;
|
|
200
|
-
}
|
|
201
|
-
} finally {
|
|
202
|
-
await cleanupTempConfig();
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
main().catch(error => {
|
|
207
|
-
logError(`Fatal error: ${error.message}`);
|
|
208
|
-
process.exitCode = 1;
|
|
209
|
-
});
|