@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.
Files changed (225) hide show
  1. package/lib/app/deploy-config.js +3 -2
  2. package/lib/channels/add-channel.js +11 -41
  3. package/lib/channels/approval-guides/index.js +3 -0
  4. package/lib/channels/approval-guides/microsoft-copilot.js +26 -17
  5. package/lib/channels/channel-add-existing.js +72 -0
  6. package/lib/channels/channel-runtime-resolver.js +5 -1
  7. package/lib/channels/channel-status-display.js +30 -3
  8. package/lib/channels/microsoft-copilot-entra-sso-form.js +73 -2
  9. package/lib/channels/microsoft-copilot-entra-sso.js +26 -5
  10. package/lib/channels/microsoft-copilot-limits.js +22 -3
  11. package/lib/channels/microsoft-copilot-package.js +59 -14
  12. package/lib/channels/microsoft-copilot-validate.js +40 -10
  13. package/lib/cli/attach-default-help-examples.js +102 -0
  14. package/lib/cli/index.js +2 -0
  15. package/lib/cli/setup-credential-deployment.js +7 -5
  16. package/lib/cli/setup-utility-validate.js +1 -0
  17. package/lib/commands/credential-push.js +37 -5
  18. package/lib/commands/package-score.js +72 -0
  19. package/lib/commands/role-assistant.js +46 -8
  20. package/lib/deployment/deployer-poll-run.js +2 -2
  21. package/lib/deployment/deployer.js +1 -1
  22. package/lib/deployment/environment.js +2 -2
  23. package/lib/external-system/deploy.js +11 -21
  24. package/lib/integration-definition/apply.js +12 -14
  25. package/lib/integration-definition/enrich-openapi-operations.js +9 -10
  26. package/lib/lab/package-parity-score.js +417 -0
  27. package/lib/programmatic/capability-registry.js +1 -0
  28. package/lib/programmatic/help-content/channel-onboarding.md +35 -0
  29. package/lib/programmatic/help-content/cip-overview.md +27 -0
  30. package/lib/programmatic/help-content/connected-system-ui.md +70 -0
  31. package/lib/programmatic/help-content/dimensions-guide.md +23 -0
  32. package/lib/programmatic/help-content/enterprise-sync-fabrix.md +123 -0
  33. package/lib/programmatic/help-content/overview.md +25 -0
  34. package/lib/programmatic/help-content/subscription-guide.md +27 -0
  35. package/lib/programmatic/help-content/workflow.md +50 -0
  36. package/lib/programmatic/openapi-component-schemas.js +1 -0
  37. package/lib/programmatic/openapi-descriptions.js +6 -0
  38. package/lib/programmatic/openapi-envelope-examples.js +11 -0
  39. package/lib/programmatic/openapi-operation-bindings.js +5 -0
  40. package/lib/programmatic/openapi-request-schemas.js +39 -13
  41. package/lib/programmatic/openapi-result-schemas.js +30 -0
  42. package/lib/programmatic/openapi-schema-descriptions-core.js +18 -0
  43. package/lib/programmatic/openapi-schema-descriptions-operations.js +19 -0
  44. package/lib/programmatic/persist-supplied-openapi.js +180 -0
  45. package/lib/programmatic/route-handler-map.js +6 -0
  46. package/lib/programmatic/run-integration-definition.js +13 -5
  47. package/lib/role-assistant/evidence-sync.js +55 -7
  48. package/lib/role-assistant/test-runner-attachments.js +118 -0
  49. package/lib/role-assistant/test-runner-bid-apply.js +100 -21
  50. package/lib/role-assistant/test-runner-bid-document.js +1 -1
  51. package/lib/role-assistant/test-runner-start-payload.js +96 -0
  52. package/lib/role-assistant/test-runner-workhub-answers.js +11 -7
  53. package/lib/role-assistant/test-runner-workhub-helpers.js +100 -0
  54. package/lib/role-assistant/test-runner-workhub-soft.js +86 -0
  55. package/lib/role-assistant/test-runner-workhub.js +68 -105
  56. package/lib/role-assistant/test-runner.js +5 -63
  57. package/lib/role-assistant/test-suite.js +33 -40
  58. package/lib/schema/external-datasource.schema.json +13 -4
  59. package/lib/utils/compose-generator.js +10 -1
  60. package/lib/utils/compose-traefik-extra-routes.js +107 -0
  61. package/lib/utils/docker-build.js +2 -2
  62. package/lib/utils/help-builder.js +2 -1
  63. package/lib/utils/promote-dev-docker-image.js +15 -10
  64. package/package.json +14 -16
  65. package/templates/README.md +12 -1
  66. package/templates/applications/dataplane/application.yaml +8 -1
  67. package/templates/applications/dataplane/env.template +1 -1
  68. package/templates/applications/miso-controller/application.yaml +2 -1
  69. package/templates/applications/miso-controller/rbac.yaml +1 -0
  70. package/templates/channels/microsoft-copilot/ai-plugin.template.json.hbs +6 -2
  71. package/templates/channels/microsoft-copilot/entra-sso-registration.template.md.hbs +8 -5
  72. package/templates/channels/microsoft-copilot/fi-fi.template.json.hbs +7 -0
  73. package/templates/channels/microsoft-copilot/install.template.md.hbs +74 -22
  74. package/templates/channels/microsoft-copilot/manifest.template.json.hbs +29 -14
  75. package/templates/channels/microsoft-copilot/oauth-plugin-vault-required.template.md.hbs +6 -2
  76. package/templates/python/docker-compose.hbs +36 -0
  77. package/templates/typescript/docker-compose.hbs +36 -0
  78. package/.cursor/plans/Archive/157.1-security-quality-violations-by-type.csv +0 -374
  79. package/.cursor/process/README.md +0 -9
  80. package/.cursor/rules/anchor-docs.mdc +0 -15
  81. package/.cursor/rules/assistant-driven-integration-build.mdc +0 -40
  82. package/.cursor/rules/cli-layout.mdc +0 -81
  83. package/.cursor/rules/cli-product-neutral.mdc +0 -43
  84. package/.cursor/rules/deploy-rules/docker-image-ip-policy.mdc +0 -49
  85. package/.cursor/rules/docs-rules.mdc +0 -32
  86. package/.cursor/rules/plan-rules/application-lifecycle.mdc +0 -30
  87. package/.cursor/rules/plan-rules/plan-frontmatter.mdc +0 -35
  88. package/.cursor/rules/plan-rules/plan-lifecycle.mdc +0 -31
  89. package/.cursor/rules/plan-rules/plan-validation-gate.mdc +0 -34
  90. package/.cursor/rules/project-rules.mdc +0 -913
  91. package/.cursor/skills/README.md +0 -15
  92. package/.dockerignore +0 -52
  93. package/.eslintignore +0 -22
  94. package/.markdownlint.json +0 -14
  95. package/anchor-docs/README.md +0 -10
  96. package/anchor-docs/_TEMPLATE +0 -24
  97. package/babel.config.js +0 -6
  98. package/bin/builder-api-cleanup.js +0 -26
  99. package/bin/builder-api-nest.js +0 -10
  100. package/bin/builder-api-spike.js +0 -19
  101. package/enterprise-knowledge/README.md +0 -50
  102. package/enterprise-knowledge/enterprise-integration-lifecycle/README.md +0 -22
  103. package/enterprise-knowledge/enterprise-integration-lifecycle/application.json +0 -15
  104. package/enterprise-knowledge/enterprise-integration-lifecycle/deploy.js +0 -69
  105. package/enterprise-knowledge/enterprise-integration-lifecycle/enterprise-integration-lifecycle-deploy.json +0 -52
  106. package/enterprise-knowledge/enterprise-integration-lifecycle/enterprise-integration-lifecycle-system.json +0 -29
  107. package/enterprise-knowledge/enterprise-integration-lifecycle/env.template +0 -2
  108. package/integration/README.md +0 -81
  109. package/integration/github/README.md +0 -53
  110. package/integration/github/application.json +0 -21
  111. package/integration/github/deploy.js +0 -72
  112. package/integration/github/env.template +0 -11
  113. package/integration/github/github-datasource-issue-comments.json +0 -239
  114. package/integration/github/github-datasource-issues.json +0 -399
  115. package/integration/github/github-datasource-repository.json +0 -354
  116. package/integration/github/github-deploy.json +0 -1202
  117. package/integration/github/github-system.json +0 -82
  118. package/integration/hubspot-test/README.md +0 -159
  119. package/integration/hubspot-test/application.json +0 -54
  120. package/integration/hubspot-test/companies.json +0 -2048
  121. package/integration/hubspot-test/create-hubspot.js +0 -523
  122. package/integration/hubspot-test/env.template +0 -4
  123. package/integration/hubspot-test/hubspot-test-datasource-company.json +0 -138
  124. package/integration/hubspot-test/hubspot-test-datasource-contact.json +0 -146
  125. package/integration/hubspot-test/hubspot-test-datasource-deal.json +0 -146
  126. package/integration/hubspot-test/hubspot-test-datasource-users.json +0 -76
  127. package/integration/hubspot-test/hubspot-test-deploy.json +0 -2160
  128. package/integration/hubspot-test/hubspot-test-system.json +0 -74
  129. package/integration/hubspot-test/rbac.json +0 -166
  130. package/integration/hubspot-test/test-artifacts/wizard-hubspot-credential-real.yaml +0 -20
  131. package/integration/hubspot-test/test-artifacts/wizard-hubspot-env-vars.yaml +0 -9
  132. package/integration/hubspot-test/test-artifacts/wizard-invalid-add-datasource.yaml +0 -5
  133. package/integration/hubspot-test/test-artifacts/wizard-invalid-app-name.yaml +0 -5
  134. package/integration/hubspot-test/test-artifacts/wizard-invalid-credential-create.yaml +0 -7
  135. package/integration/hubspot-test/test-artifacts/wizard-invalid-credential-select.yaml +0 -7
  136. package/integration/hubspot-test/test-artifacts/wizard-invalid-known-platform.yaml +0 -4
  137. package/integration/hubspot-test/test-artifacts/wizard-invalid-missing-app.yaml +0 -4
  138. package/integration/hubspot-test/test-artifacts/wizard-invalid-missing-source.yaml +0 -2
  139. package/integration/hubspot-test/test-artifacts/wizard-invalid-mode.yaml +0 -5
  140. package/integration/hubspot-test/test-artifacts/wizard-invalid-openapi-file.yaml +0 -5
  141. package/integration/hubspot-test/test-artifacts/wizard-invalid-openapi-url.yaml +0 -4
  142. package/integration/hubspot-test/test-artifacts/wizard-invalid-source.yaml +0 -4
  143. package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-array-test.yaml +0 -5
  144. package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-key-test.yaml +0 -5
  145. package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-path-test.yaml +0 -5
  146. package/integration/hubspot-test/test-artifacts/wizard-valid-for-dimension-test.yaml +0 -5
  147. package/integration/hubspot-test/test-artifacts/wizard-valid-for-rbac-test.yaml +0 -5
  148. package/integration/hubspot-test/test-artifacts/wizard-valid-for-rbac-yaml-test.yaml +0 -5
  149. package/integration/hubspot-test/test-dataplane-down-helpers.js +0 -249
  150. package/integration/hubspot-test/test-dataplane-down-tests.js +0 -386
  151. package/integration/hubspot-test/test-dataplane-down.js +0 -209
  152. package/integration/hubspot-test/test.js +0 -1588
  153. package/integration/hubspot-test/wizard-hubspot-e2e.yaml +0 -16
  154. package/integration/hubspot-test/wizard-hubspot-platform.yaml +0 -8
  155. package/integration/hubspot-test/wizard-hubspot-test-headless.yaml +0 -23
  156. package/integration/roundtrip-test-local/README.md +0 -143
  157. package/integration/roundtrip-test-local/application.yaml +0 -13
  158. package/integration/roundtrip-test-local/env.template +0 -15
  159. package/integration/roundtrip-test-local/roundtrip-test-local-datasource-roundtrip-test-company.yaml +0 -14
  160. package/integration/roundtrip-test-local/roundtrip-test-local-deploy.json +0 -61
  161. package/integration/roundtrip-test-local/roundtrip-test-local-system.yaml +0 -25
  162. package/integration/roundtrip-test-local2/README.md +0 -143
  163. package/integration/roundtrip-test-local2/application.yaml +0 -13
  164. package/integration/roundtrip-test-local2/env.template +0 -15
  165. package/integration/roundtrip-test-local2/roundtrip-test-local2-datasource-company.yaml +0 -31
  166. package/integration/roundtrip-test-local2/roundtrip-test-local2-deploy.json +0 -86
  167. package/integration/roundtrip-test-local2/roundtrip-test-local2-system.yaml +0 -25
  168. package/integration/test/wizard.yaml +0 -8
  169. package/jest.config.coverage.js +0 -37
  170. package/jest.config.default.js +0 -11
  171. package/jest.config.integration.fixtures.js +0 -22
  172. package/jest.config.integration.js +0 -33
  173. package/jest.config.isolated.js +0 -11
  174. package/jest.config.manual.js +0 -30
  175. package/jest.global-live-fabrix-hooks.js +0 -36
  176. package/jest.isolated-projects.js +0 -283
  177. package/jest.projects.js +0 -79
  178. package/lib/integration-definition/openapi-enrichment/hubspot-crm-companies.json +0 -205
  179. package/packages/builder-api/README.md +0 -120
  180. package/packages/builder-api/package.json +0 -30
  181. package/packages/builder-api/src/app.module.ts +0 -7
  182. package/packages/builder-api/src/auth/auth.module.ts +0 -5
  183. package/packages/builder-api/src/external-system/external-system.module.ts +0 -5
  184. package/packages/builder-api/src/main.ts +0 -16
  185. package/packages/builder-api/tsconfig.json +0 -15
  186. package/scripts/check-builder-api-architecture-grep.js +0 -79
  187. package/scripts/check-datasource-test-run-schema-sync.js +0 -34
  188. package/scripts/ci-fix.sh +0 -19
  189. package/scripts/ci-simulate.sh +0 -19
  190. package/scripts/diagnose-cli.js +0 -150
  191. package/scripts/docker_image_content_gate.js +0 -47
  192. package/scripts/docker_image_content_gate.sh +0 -5
  193. package/scripts/export-builder-api-evidence.js +0 -262
  194. package/scripts/install-local.js +0 -490
  195. package/scripts/lib/builder-api-docker-staging-copy.js +0 -60
  196. package/scripts/lib/builder-api-docker-staging-core.js +0 -183
  197. package/scripts/lib/docker-image-content-gate-core.js +0 -166
  198. package/scripts/lib/plan-actor.js +0 -109
  199. package/scripts/lib/plan-config.js +0 -20
  200. package/scripts/lib/plan-gates.js +0 -154
  201. package/scripts/lib/plan-meta.js +0 -104
  202. package/scripts/lib/plan-parse.js +0 -162
  203. package/scripts/lib/plan-prevalidate-gates.js +0 -337
  204. package/scripts/lib/plan-run-core.js +0 -125
  205. package/scripts/lib/plan-run-report.js +0 -119
  206. package/scripts/plan-approve.js +0 -24
  207. package/scripts/plan-archive.js +0 -49
  208. package/scripts/plan-run.js +0 -13
  209. package/scripts/plan-set-actor.js +0 -21
  210. package/scripts/plan-validate.js +0 -80
  211. package/scripts/pnpm/af.mjs +0 -125
  212. package/scripts/pnpm/check-quiet.mjs +0 -32
  213. package/scripts/pnpm/dev-install.mjs +0 -29
  214. package/scripts/pnpm/dev-reload.mjs +0 -18
  215. package/scripts/pnpm/help.mjs +0 -55
  216. package/scripts/pnpm/lib/dev-reload-core.mjs +0 -189
  217. package/scripts/pnpm/lib/dev-reload-log-capture.mjs +0 -67
  218. package/scripts/pnpm/lib/dev-reload-log-utils.mjs +0 -32
  219. package/scripts/pnpm/lib/resolve-aifabrix-bin.mjs +0 -124
  220. package/scripts/pnpm/lib/resolve-app-url.mjs +0 -183
  221. package/scripts/pnpm/lib/spinner.mjs +0 -42
  222. package/scripts/pnpm-global-remove.js +0 -48
  223. package/scripts/stage_builder_api_for_docker.js +0 -65
  224. package/scripts/sync-builder-api-template.js +0 -44
  225. 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
- });