@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,523 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable max-lines */
3
- /**
4
- * HubSpot Integration Creation Helper Script
5
- *
6
- * Creates a new HubSpot integration using the wizard and prepares files for manual editing
7
- *
8
- * @fileoverview Helper script for creating HubSpot integrations
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 { execFile } = require('child_process');
17
- const { promisify } = require('util');
18
- const yaml = require('js-yaml');
19
- const chalk = require('chalk');
20
- const logger = require('../../lib/utils/logger');
21
-
22
- const execFileAsync = promisify(execFile);
23
-
24
- const DEFAULT_CONTROLLER_URL = process.env.CONTROLLER_URL || 'http://localhost:3110';
25
- const DEFAULT_ENVIRONMENT = process.env.ENVIRONMENT || 'miso';
26
- const DEFAULT_OPENAPI_FILE = process.env.HUBSPOT_OPENAPI_FILE ||
27
- path.join(process.cwd(), 'integration', 'hubspot-test', 'companies.json');
28
-
29
- /**
30
- * Prints usage information
31
- * @function printUsage
32
- * @returns {void}
33
- */
34
- function printUsage() {
35
- logger.log([
36
- 'Usage:',
37
- ' node integration/hubspot-test/create-hubspot.js [options]',
38
- '',
39
- 'Options:',
40
- ' --name <name> Application name (required)',
41
- ' --openapi <path> Path to OpenAPI file (default: env HUBSPOT_OPENAPI_FILE)',
42
- ' --output <dir> Output directory for files (default: integration/<name>)',
43
- ' --controller <url> Controller URL (default: env CONTROLLER_URL)',
44
- ' --environment <env> Environment name (default: env ENVIRONMENT)',
45
- ' --keep-wizard-files Keep wizard-generated files in integration/ directory',
46
- ' --help Show this help message',
47
- '',
48
- 'Examples:',
49
- ' node integration/hubspot-test/create-hubspot.js --name my-hubspot',
50
- ' node integration/hubspot-test/create-hubspot.js --name my-hubspot --output ~/my-project',
51
- ' node integration/hubspot-test/create-hubspot.js --name my-hubspot --openapi /path/to/openapi.json'
52
- ].join('\n'));
53
- }
54
-
55
- /**
56
- * Parses command line arguments
57
- * @function parseArgs
58
- * @param {string[]} argv - Command line arguments
59
- * @returns {Object} Parsed arguments
60
- */
61
- function parseArgs(argv) {
62
- const args = {
63
- name: null,
64
- openapi: DEFAULT_OPENAPI_FILE,
65
- output: null,
66
- controller: DEFAULT_CONTROLLER_URL,
67
- environment: DEFAULT_ENVIRONMENT,
68
- keepWizardFiles: false,
69
- help: false
70
- };
71
-
72
- const flagMap = {
73
- '--name': 'name',
74
- '--openapi': 'openapi',
75
- '--output': 'output',
76
- '--controller': 'controller',
77
- '--environment': 'environment'
78
- };
79
-
80
- for (let i = 2; i < argv.length; i += 1) {
81
- const arg = argv[i];
82
- const argKey = flagMap[arg];
83
-
84
- if (argKey && argv[i + 1]) {
85
- args[argKey] = argv[i + 1];
86
- i += 1;
87
- continue;
88
- }
89
-
90
- if (arg === '--keep-wizard-files') {
91
- args.keepWizardFiles = true;
92
- continue;
93
- }
94
-
95
- if (arg === '--help' || arg === '-h') {
96
- args.help = true;
97
- }
98
- }
99
-
100
- return args;
101
- }
102
-
103
- /**
104
- * Logs info message
105
- * @function logInfo
106
- * @param {string} message - Message to log
107
- * @returns {void}
108
- */
109
- function logInfo(message) {
110
- logger.log(chalk.cyan(message));
111
- }
112
-
113
- /**
114
- * Logs success message
115
- * @function logSuccess
116
- * @param {string} message - Message to log
117
- * @returns {void}
118
- */
119
- function logSuccess(message) {
120
- logger.log(chalk.green(message));
121
- }
122
-
123
- /**
124
- * Logs error message
125
- * @function logError
126
- * @param {string} message - Message to log
127
- * @returns {void}
128
- */
129
- function logError(message) {
130
- logger.error(chalk.red(message));
131
- }
132
-
133
- /**
134
- * Checks if file exists
135
- * @async
136
- * @function fileExists
137
- * @param {string} filePath - File path to check
138
- * @returns {Promise<boolean>} True if file exists
139
- */
140
- async function fileExists(filePath) {
141
- try {
142
- await fs.access(filePath);
143
- return true;
144
- } catch {
145
- return false;
146
- }
147
- }
148
-
149
- /**
150
- * Ensures directory exists
151
- * @async
152
- * @function ensureDir
153
- * @param {string} dirPath - Directory path
154
- * @returns {Promise<void>} Resolves when directory is created
155
- */
156
- async function ensureDir(dirPath) {
157
- await fs.mkdir(dirPath, { recursive: true });
158
- }
159
-
160
- /**
161
- * Creates wizard configuration file
162
- * @async
163
- * @function createWizardConfig
164
- * @param {string} appName - Application name
165
- * @param {string} openapiFile - OpenAPI file path
166
- * @param {string} controllerUrl - Controller URL
167
- * @param {string} environment - Environment name
168
- * @returns {Promise<string>} Path to created config file
169
- */
170
- async function createWizardConfig(appName, openapiFile, controllerUrl, environment) {
171
- const configDir = path.join(process.cwd(), 'integration', 'hubspot');
172
- await ensureDir(configDir);
173
- const configPath = path.join(configDir, `wizard-${appName}.yaml`);
174
-
175
- const config = {
176
- appName,
177
- mode: 'create-system',
178
- source: {
179
- type: 'openapi-file',
180
- filePath: openapiFile
181
- },
182
- credential: {
183
- action: 'skip'
184
- },
185
- preferences: {
186
- intent: `HubSpot CRM integration for ${appName}`,
187
- fieldOnboardingLevel: 'full',
188
- enableOpenAPIGeneration: true,
189
- enableABAC: true,
190
- enableRBAC: false
191
- },
192
- deployment: {
193
- controller: controllerUrl,
194
- environment
195
- }
196
- };
197
-
198
- const yamlContent = yaml.dump(config, { lineWidth: -1, noRefs: true });
199
- await fs.writeFile(configPath, yamlContent, 'utf8');
200
- return configPath;
201
- }
202
-
203
- /**
204
- * Builds wizard command arguments
205
- * @function buildWizardArgs
206
- * @param {string} configPath - Path to wizard config file
207
- * @param {string} controllerUrl - Controller URL
208
- * @param {string} environment - Environment name
209
- * @returns {string[]} Command arguments
210
- */
211
- function buildWizardArgs(configPath, controllerUrl, environment) {
212
- return [
213
- 'bin/aifabrix.js',
214
- 'wizard',
215
- '--config',
216
- configPath,
217
- '--controller',
218
- controllerUrl,
219
- '--environment',
220
- environment
221
- ];
222
- }
223
-
224
- /**
225
- * Handles wizard command execution errors
226
- * @function handleWizardError
227
- * @param {Error} error - Error object
228
- * @param {string|null} dataplaneUrl - Dataplane URL (for error context; may be null when auto-discovered)
229
- * @returns {Object} Error result object
230
- */
231
- function handleWizardError(error, dataplaneUrl) {
232
- const baseResult = {
233
- success: false,
234
- stdout: error.stdout || '',
235
- stderr: error.stderr || ''
236
- };
237
-
238
- // Check for timeout
239
- if (error.code === 'ETIMEDOUT' || error.signal === 'SIGTERM') {
240
- const dataplaneInfo = dataplaneUrl ? `dataplane at ${dataplaneUrl}` : 'dataplane (auto-discovered)';
241
- return {
242
- ...baseResult,
243
- error: `Wizard command timed out after 2 minutes. This usually indicates the ${dataplaneInfo} is down or unreachable.\n\n` +
244
- 'Please ensure the dataplane service is running and accessible, then try again.'
245
- };
246
- }
247
-
248
- // Check for connection errors
249
- const errorOutput = (error.stdout || '') + (error.stderr || '') + (error.message || '');
250
- const lowerOutput = errorOutput.toLowerCase();
251
- const isConnectionError = lowerOutput.includes('dataplane') ||
252
- lowerOutput.includes('connection') ||
253
- lowerOutput.includes('timeout') ||
254
- lowerOutput.includes('econnrefused');
255
-
256
- if (isConnectionError) {
257
- return {
258
- ...baseResult,
259
- error: `Wizard failed: ${error.message}\n\nThis may be due to dataplane connectivity issues. Ensure the dataplane service is running at ${dataplaneUrl || 'the discovered URL'}.`
260
- };
261
- }
262
-
263
- return { ...baseResult, error: error.message };
264
- }
265
-
266
- /**
267
- * Runs wizard command
268
- * @async
269
- * @function runWizard
270
- * @param {string} configPath - Path to wizard config file
271
- * @param {string} controllerUrl - Controller URL
272
- * @param {string} environment - Environment name
273
- * @returns {Promise<Object>} Command result object
274
- */
275
- async function runWizard(configPath, controllerUrl, environment) {
276
- logInfo('Note: Dataplane URL is auto-discovered from the controller.');
277
- const args = buildWizardArgs(configPath, controllerUrl, environment);
278
-
279
- try {
280
- const result = await execFileAsync('node', args, {
281
- cwd: process.cwd(),
282
- env: { ...process.env },
283
- maxBuffer: 10 * 1024 * 1024,
284
- timeout: 2 * 60 * 1000
285
- });
286
- return { success: true, stdout: result.stdout || '', stderr: result.stderr || '' };
287
- } catch (error) {
288
- return handleWizardError(error, null);
289
- }
290
- }
291
-
292
- /**
293
- * Lists files in directory
294
- * @async
295
- * @function listFiles
296
- * @param {string} dirPath - Directory path
297
- * @returns {Promise<string[]>} Array of file names
298
- */
299
- async function listFiles(dirPath) {
300
- try {
301
- const entries = await fs.readdir(dirPath, { withFileTypes: true });
302
- return entries
303
- .filter(entry => entry.isFile())
304
- .map(entry => entry.name);
305
- } catch {
306
- return [];
307
- }
308
- }
309
-
310
- /**
311
- * Copies file
312
- * @async
313
- * @function copyFile
314
- * @param {string} src - Source file path
315
- * @param {string} dest - Destination file path
316
- * @returns {Promise<void>} Resolves when file is copied
317
- */
318
- async function copyFile(src, dest) {
319
- await ensureDir(path.dirname(dest));
320
- await fs.copyFile(src, dest);
321
- }
322
-
323
- /**
324
- * Copies directory contents
325
- * @async
326
- * @function copyDirectoryContents
327
- * @param {string} srcDir - Source directory
328
- * @param {string} destDir - Destination directory
329
- * @returns {Promise<string[]>} Array of copied file names
330
- */
331
- async function copyDirectoryContents(srcDir, destDir) {
332
- await ensureDir(destDir);
333
- const files = await listFiles(srcDir);
334
- const copiedFiles = [];
335
-
336
- for (const fileName of files) {
337
- const srcPath = path.join(srcDir, fileName);
338
- const destPath = path.join(destDir, fileName);
339
- await copyFile(srcPath, destPath);
340
- copiedFiles.push(fileName);
341
- }
342
-
343
- return copiedFiles;
344
- }
345
-
346
- /**
347
- * Validates command line arguments
348
- * @function validateArgs
349
- * @param {Object} args - Parsed arguments
350
- * @returns {void}
351
- * @throws {Error} If validation fails
352
- */
353
- function validateArgs(args) {
354
- if (!args.name) {
355
- throw new Error('--name is required');
356
- }
357
-
358
- if (!/^[a-z0-9-_]+$/.test(args.name)) {
359
- throw new Error('App name must contain only lowercase letters, numbers, hyphens, and underscores');
360
- }
361
- }
362
-
363
- /**
364
- * Validates OpenAPI file exists
365
- * @async
366
- * @function validateOpenApiFile
367
- * @param {string} openapiPath - OpenAPI file path
368
- * @returns {Promise<void>} Resolves if file exists
369
- * @throws {Error} If file doesn't exist
370
- */
371
- async function validateOpenApiFile(openapiPath) {
372
- if (!(await fileExists(openapiPath))) {
373
- throw new Error(`OpenAPI file not found: ${openapiPath}`);
374
- }
375
- }
376
-
377
- /**
378
- * Handles wizard execution
379
- * @async
380
- * @function executeWizard
381
- * @param {Object} args - Parsed arguments
382
- * @returns {Promise<string>} Path to wizard config file
383
- */
384
- async function executeWizard(args) {
385
- logInfo('\n1. Creating wizard configuration...');
386
- const configPath = await createWizardConfig(
387
- args.name,
388
- args.openapi,
389
- args.controller,
390
- args.environment
391
- );
392
- logSuccess(`✔ Created config: ${configPath}`);
393
-
394
- logInfo('\n2. Running wizard...');
395
- const wizardResult = await runWizard(configPath, args.controller, args.environment);
396
-
397
- if (!wizardResult.success) {
398
- logError('Wizard failed:');
399
- if (wizardResult.stdout) {
400
- logger.log(wizardResult.stdout);
401
- }
402
- if (wizardResult.stderr) {
403
- logger.error(wizardResult.stderr);
404
- }
405
- throw new Error('Wizard execution failed');
406
- }
407
-
408
- logSuccess('✔ Wizard completed successfully');
409
- return configPath;
410
- }
411
-
412
- /**
413
- * Processes generated files
414
- * @async
415
- * @function processGeneratedFiles
416
- * @param {Object} args - Parsed arguments
417
- * @returns {Promise<string>} Output directory path
418
- */
419
- async function processGeneratedFiles(args) {
420
- const wizardOutputDir = path.join(process.cwd(), 'integration', args.name);
421
- if (!(await fileExists(wizardOutputDir))) {
422
- throw new Error(`Wizard output directory not found: ${wizardOutputDir}`);
423
- }
424
-
425
- const generatedFiles = await listFiles(wizardOutputDir);
426
- logInfo(`\n3. Generated files: ${generatedFiles.join(', ')}`);
427
-
428
- const outputDir = args.output || wizardOutputDir;
429
- if (outputDir !== wizardOutputDir) {
430
- logInfo(`\n4. Copying files to: ${outputDir}`);
431
- const copiedFiles = await copyDirectoryContents(wizardOutputDir, outputDir);
432
- logSuccess(`✔ Copied ${copiedFiles.length} files`);
433
- } else {
434
- logInfo(`\n4. Files are in: ${outputDir}`);
435
- }
436
-
437
- return { outputDir, wizardOutputDir };
438
- }
439
-
440
- /**
441
- * Prints summary information
442
- * @async
443
- * @function printSummary
444
- * @param {string} outputDir - Output directory path
445
- * @param {string} appName - Application name
446
- * @param {string} environment - Environment name
447
- * @returns {Promise<void>} Resolves when summary is printed
448
- */
449
- async function printSummary(outputDir, appName, environment) {
450
- logSuccess('\n✔ HubSpot integration created successfully!');
451
- logger.log('\nGenerated files:');
452
- const files = await listFiles(outputDir);
453
- for (const file of files) {
454
- logger.log(` - ${file}`);
455
- }
456
-
457
- logger.log('\nNext steps:');
458
- logger.log(` 1. Review files in: ${outputDir}`);
459
- logger.log(' 2. Edit hubspot-system.json and datasource files as needed');
460
- logger.log(` 3. Validate: node bin/aifabrix.js validate ${appName}`);
461
- logger.log(` 4. Deploy: node bin/aifabrix.js deploy ${appName} --environment ${environment}`);
462
- }
463
-
464
- /**
465
- * Cleans up temporary files
466
- * @async
467
- * @function cleanupFiles
468
- * @param {string} configPath - Config file path
469
- * @param {string} wizardOutputDir - Wizard output directory
470
- * @param {string} outputDir - Final output directory
471
- * @param {boolean} keepWizardFiles - Whether to keep wizard files
472
- * @returns {Promise<void>} Resolves when cleanup is complete
473
- */
474
- async function cleanupFiles(configPath, wizardOutputDir, outputDir, keepWizardFiles) {
475
- if (!keepWizardFiles && outputDir !== wizardOutputDir) {
476
- logInfo('\n5. Cleaning up wizard files...');
477
- await fs.rm(wizardOutputDir, { recursive: true, force: true });
478
- logSuccess('✔ Cleaned up wizard files');
479
- }
480
-
481
- await fs.unlink(configPath).catch(() => {
482
- // Ignore errors
483
- });
484
- }
485
-
486
- /**
487
- * Main function
488
- * @async
489
- * @function main
490
- * @returns {Promise<void>} Resolves when complete
491
- */
492
- async function main() {
493
- const args = parseArgs(process.argv);
494
-
495
- if (args.help) {
496
- printUsage();
497
- return;
498
- }
499
-
500
- try {
501
- validateArgs(args);
502
- await validateOpenApiFile(args.openapi);
503
-
504
- logInfo(`Creating HubSpot integration: ${args.name}`);
505
- logInfo(`OpenAPI file: ${args.openapi}`);
506
- logInfo(`Controller: ${args.controller}`);
507
- logInfo(`Environment: ${args.environment}`);
508
- const configPath = await executeWizard(args);
509
- const { outputDir, wizardOutputDir } = await processGeneratedFiles(args);
510
- await printSummary(outputDir, args.name, args.environment);
511
- await cleanupFiles(configPath, wizardOutputDir, outputDir, args.keepWizardFiles);
512
- } catch (error) {
513
- logError(`Error: ${error.message}`);
514
- if (error.stack) {
515
- logger.error(error.stack);
516
- }
517
- process.exit(1);
518
- }
519
- }
520
- main().catch(error => {
521
- logError(`Unexpected error: ${error.message}`);
522
- process.exit(1);
523
- });
@@ -1,4 +0,0 @@
1
- HUBSPOT_API_VERSION=v3
2
- MAX_PAGE_SIZE=100
3
- KV_HUBSPOT_TEST_CLIENTID=kv://hubspot-test/clientId
4
- KV_HUBSPOT_TEST_CLIENTSECRET=kv://hubspot-test/clientSecret
@@ -1,138 +0,0 @@
1
- {
2
- "key": "hubspot-test-company",
3
- "displayName": "HubSpot Company",
4
- "description": "HubSpot companies datasource with field mappings for CRM company data",
5
- "systemKey": "hubspot-test",
6
- "entityType": "recordStorage",
7
- "resourceType": "customer",
8
- "enabled": true,
9
- "version": "1.0.0",
10
- "primaryKey": [
11
- "id"
12
- ],
13
- "labelKey": [
14
- "name"
15
- ],
16
- "metadataSchema": {
17
- "type": "object",
18
- "required": [
19
- "id",
20
- "externalId",
21
- "properties"
22
- ],
23
- "properties": {
24
- "id": {
25
- "type": "string",
26
- "index": true
27
- },
28
- "externalId": {
29
- "type": "string",
30
- "index": true
31
- },
32
- "name": {
33
- "type": "string",
34
- "filter": true
35
- },
36
- "properties": {
37
- "type": "object",
38
- "additionalProperties": true
39
- }
40
- }
41
- },
42
- "dimensions": {
43
- "country": {
44
- "type": "local",
45
- "field": "country"
46
- },
47
- "domain": {
48
- "type": "local",
49
- "field": "domain"
50
- }
51
- },
52
- "fieldMappings": {
53
- "attributes": {
54
- "id": {
55
- "expression": "{{raw.id}}"
56
- },
57
- "externalId": {
58
- "expression": "{{raw.id}}"
59
- },
60
- "name": {
61
- "expression": "{{raw.properties.name.value}} | trim"
62
- },
63
- "domain": {
64
- "expression": "{{raw.properties.domain.value}} | toLower | trim"
65
- },
66
- "country": {
67
- "expression": "{{raw.properties.country.value}} | toUpper | trim"
68
- },
69
- "city": {
70
- "expression": "{{raw.properties.city.value}} | trim"
71
- },
72
- "industry": {
73
- "expression": "{{raw.properties.industry.value}} | trim"
74
- },
75
- "website": {
76
- "expression": "{{raw.properties.website.value}} | trim"
77
- },
78
- "phone": {
79
- "expression": "{{raw.properties.phone.value}} | trim"
80
- },
81
- "createdAt": {
82
- "expression": "{{raw.properties.createdate.value}}"
83
- },
84
- "updatedAt": {
85
- "expression": "{{raw.properties.hs_lastmodifieddate.value}}"
86
- }
87
- }
88
- },
89
- "exposed": {
90
- "description": "Exposed fields for HubSpot companies",
91
- "schema": {
92
- "id": "metadata.id",
93
- "externalId": "metadata.externalId",
94
- "name": "metadata.name",
95
- "domain": "metadata.domain",
96
- "country": "metadata.country",
97
- "city": "metadata.city",
98
- "industry": "metadata.industry",
99
- "website": "metadata.website",
100
- "phone": "metadata.phone",
101
- "createdAt": "metadata.createdAt",
102
- "updatedAt": "metadata.updatedAt"
103
- }
104
- },
105
- "openapi": {
106
- "enabled": true,
107
- "documentKey": "hubspot-v3",
108
- "baseUrl": "https://api.hubapi.com",
109
- "operations": {
110
- "list": {
111
- "operationId": "getCompanies",
112
- "method": "GET",
113
- "path": "/crm/v3/objects/companies"
114
- },
115
- "get": {
116
- "operationId": "getCompany",
117
- "method": "GET",
118
- "path": "/crm/v3/objects/companies/{companyId}"
119
- },
120
- "create": {
121
- "operationId": "createCompany",
122
- "method": "POST",
123
- "path": "/crm/v3/objects/companies"
124
- },
125
- "update": {
126
- "operationId": "updateCompany",
127
- "method": "PATCH",
128
- "path": "/crm/v3/objects/companies/{companyId}"
129
- },
130
- "delete": {
131
- "operationId": "deleteCompany",
132
- "method": "DELETE",
133
- "path": "/crm/v3/objects/companies/{companyId}"
134
- }
135
- },
136
- "autoRbac": true
137
- }
138
- }