@aifabrix/builder 2.31.1 → 2.32.2

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 (118) hide show
  1. package/README.md +9 -9
  2. package/integration/hubspot/README.md +2 -2
  3. package/integration/hubspot/hubspot-deploy-company.json +17 -14
  4. package/integration/hubspot/hubspot-deploy-contact.json +19 -16
  5. package/integration/hubspot/hubspot-deploy-deal.json +21 -18
  6. package/lib/api/types/datasources.types.js +31 -5
  7. package/lib/api/types/wizard.types.js +142 -0
  8. package/lib/api/wizard.api.js +177 -0
  9. package/lib/{app-config.js → app/config.js} +4 -4
  10. package/lib/{app-deploy.js → app/deploy.js} +8 -8
  11. package/lib/app/display.js +90 -0
  12. package/lib/{app-dockerfile.js → app/dockerfile.js} +4 -4
  13. package/lib/{app-down.js → app/down.js} +4 -4
  14. package/lib/app/helpers.js +218 -0
  15. package/lib/app/index.js +298 -0
  16. package/lib/{app-list.js → app/list.js} +6 -6
  17. package/lib/{app-push.js → app/push.js} +4 -4
  18. package/lib/{app-readme.js → app/readme.js} +34 -13
  19. package/lib/{app-register.js → app/register.js} +9 -9
  20. package/lib/{app-rotate-secret.js → app/rotate-secret.js} +10 -10
  21. package/lib/{app-run-helpers.js → app/run-helpers.js} +10 -10
  22. package/lib/{app-run.js → app/run.js} +6 -6
  23. package/lib/{build.js → build/index.js} +59 -32
  24. package/lib/build/package.json +7 -0
  25. package/lib/cli.js +245 -179
  26. package/lib/commands/app.js +3 -3
  27. package/lib/commands/datasource.js +4 -4
  28. package/lib/commands/login-credentials.js +209 -0
  29. package/lib/commands/login-device.js +254 -0
  30. package/lib/commands/login.js +67 -378
  31. package/lib/commands/logout.js +1 -1
  32. package/lib/commands/secrets-set.js +1 -1
  33. package/lib/commands/secure.js +2 -2
  34. package/lib/commands/wizard.js +498 -0
  35. package/lib/{audit-logger.js → core/audit-logger.js} +1 -1
  36. package/lib/{config.js → core/config.js} +28 -26
  37. package/lib/{diff.js → core/diff.js} +157 -72
  38. package/lib/{secrets.js → core/secrets.js} +86 -49
  39. package/lib/{templates.js → core/templates-env.js} +14 -222
  40. package/lib/core/templates.js +279 -0
  41. package/lib/{datasource-deploy.js → datasource/deploy.js} +6 -6
  42. package/lib/{datasource-diff.js → datasource/diff.js} +2 -2
  43. package/lib/datasource/list.js +223 -0
  44. package/lib/{datasource-validate.js → datasource/validate.js} +2 -2
  45. package/lib/{deployer.js → deployment/deployer.js} +48 -18
  46. package/lib/{environment-deploy.js → deployment/environment.js} +163 -84
  47. package/lib/{push.js → deployment/push.js} +1 -1
  48. package/lib/external-system/deploy-helpers.js +145 -0
  49. package/lib/{external-system-deploy.js → external-system/deploy.js} +156 -111
  50. package/lib/external-system/download-helpers.js +114 -0
  51. package/lib/{external-system-download.js → external-system/download.js} +92 -135
  52. package/lib/{external-system-generator.js → external-system/generator.js} +15 -11
  53. package/lib/external-system/test-auth.js +40 -0
  54. package/lib/external-system/test-execution.js +84 -0
  55. package/lib/external-system/test-helpers.js +109 -0
  56. package/lib/{external-system-test.js → external-system/test.js} +174 -192
  57. package/lib/{generator-builders.js → generator/builders.js} +87 -10
  58. package/lib/{generator-external.js → generator/external.js} +115 -52
  59. package/lib/{github-generator.js → generator/github.js} +116 -15
  60. package/lib/{generator-helpers.js → generator/helpers.js} +92 -42
  61. package/lib/{generator.js → generator/index.js} +49 -22
  62. package/lib/{generator-split.js → generator/split.js} +108 -55
  63. package/lib/generator/wizard-prompts.js +357 -0
  64. package/lib/generator/wizard.js +490 -0
  65. package/lib/{infra.js → infrastructure/index.js} +49 -22
  66. package/lib/schema/external-datasource.schema.json +158 -136
  67. package/lib/schema/external-system.schema.json +43 -1
  68. package/lib/utils/api.js +9 -5
  69. package/lib/utils/app-register-api.js +60 -32
  70. package/lib/utils/app-register-auth.js +172 -47
  71. package/lib/utils/app-register-config.js +130 -59
  72. package/lib/utils/app-run-containers.js +29 -8
  73. package/lib/utils/build-helpers.js +1 -1
  74. package/lib/utils/cli-utils.js +78 -30
  75. package/lib/utils/compose-generator.js +145 -65
  76. package/lib/utils/config-paths.js +2 -0
  77. package/lib/utils/deployment-errors.js +1 -1
  78. package/lib/utils/device-code.js +99 -41
  79. package/lib/utils/env-config-loader.js +1 -1
  80. package/lib/utils/env-copy.js +21 -18
  81. package/lib/utils/env-endpoints.js +115 -67
  82. package/lib/utils/env-map.js +13 -14
  83. package/lib/utils/env-ports.js +45 -25
  84. package/lib/utils/env-template.js +84 -42
  85. package/lib/utils/error-formatter.js +26 -9
  86. package/lib/utils/error-formatters/error-parser.js +90 -4
  87. package/lib/utils/error-formatters/http-status-errors.js +54 -17
  88. package/lib/utils/error-formatters/network-errors.js +103 -26
  89. package/lib/utils/external-system-display.js +184 -90
  90. package/lib/utils/external-system-validators.js +164 -42
  91. package/lib/utils/file-upload.js +109 -0
  92. package/lib/utils/health-check.js +199 -83
  93. package/lib/utils/infra-containers.js +1 -1
  94. package/lib/utils/infra-status.js +66 -15
  95. package/lib/utils/local-secrets.js +45 -25
  96. package/lib/utils/paths.js +45 -33
  97. package/lib/utils/schema-loader.js +42 -25
  98. package/lib/utils/schema-resolver.js +123 -74
  99. package/lib/utils/secrets-encryption.js +62 -25
  100. package/lib/utils/secrets-helpers.js +126 -63
  101. package/lib/utils/secrets-path.js +1 -1
  102. package/lib/utils/secrets-url.js +1 -1
  103. package/lib/utils/token-manager-refresh.js +181 -0
  104. package/lib/utils/token-manager.js +76 -123
  105. package/lib/utils/variable-transformer.js +154 -77
  106. package/lib/utils/yaml-preserve.js +41 -47
  107. package/lib/{template-validator.js → validation/template.js} +54 -23
  108. package/lib/{validate.js → validation/validate.js} +205 -125
  109. package/lib/{validator.js → validation/validator.js} +58 -39
  110. package/package.json +31 -2
  111. package/templates/external-system/deploy.ps1.hbs +34 -0
  112. package/templates/external-system/deploy.sh.hbs +34 -0
  113. package/templates/external-system/external-datasource.json.hbs +31 -12
  114. package/lib/app.js +0 -467
  115. package/lib/datasource-list.js +0 -141
  116. /package/lib/{app-prompts.js → app/prompts.js} +0 -0
  117. /package/lib/{env-reader.js → core/env-reader.js} +0 -0
  118. /package/lib/{key-generator.js → core/key-generator.js} +0 -0
@@ -1,141 +0,0 @@
1
- /**
2
- * Datasource List Command
3
- *
4
- * Lists datasources from an environment via controller API.
5
- *
6
- * @fileoverview Datasource listing for AI Fabrix Builder
7
- * @author AI Fabrix Team
8
- * @version 2.0.0
9
- */
10
-
11
- const chalk = require('chalk');
12
- const { getConfig } = require('./config');
13
- const { getOrRefreshDeviceToken } = require('./utils/token-manager');
14
- const { listEnvironmentDatasources } = require('./api/environments.api');
15
- const { formatApiError } = require('./utils/api-error-handler');
16
- const logger = require('./utils/logger');
17
-
18
- /**
19
- * Extracts datasources array from API response
20
- * Handles multiple response formats similar to applications list
21
- *
22
- * @function extractDatasources
23
- * @param {Object} response - API response from centralized API client
24
- * @returns {Array} Array of datasources
25
- * @throws {Error} If response format is invalid
26
- */
27
- function extractDatasources(response) {
28
- if (!response.success || !response.data) {
29
- throw new Error('Invalid API response: missing success or data');
30
- }
31
-
32
- const apiResponse = response.data;
33
- let datasources;
34
-
35
- // Check if apiResponse.data is an array (wrapped format)
36
- if (apiResponse && apiResponse.data && Array.isArray(apiResponse.data)) {
37
- datasources = apiResponse.data;
38
- } else if (Array.isArray(apiResponse)) {
39
- // Check if apiResponse is directly an array
40
- datasources = apiResponse;
41
- } else if (apiResponse && Array.isArray(apiResponse.items)) {
42
- // Check if apiResponse.items is an array (paginated format)
43
- datasources = apiResponse.items;
44
- } else if (apiResponse && apiResponse.data && apiResponse.data.items && Array.isArray(apiResponse.data.items)) {
45
- // Check if apiResponse.data.items is an array (wrapped paginated format)
46
- datasources = apiResponse.data.items;
47
- } else {
48
- logger.error(chalk.red('❌ Invalid response: expected data array or items array'));
49
- logger.error(chalk.gray('\nAPI response type:'), typeof apiResponse);
50
- logger.error(chalk.gray('API response:'), JSON.stringify(apiResponse, null, 2));
51
- throw new Error('Invalid API response format: expected array of datasources');
52
- }
53
-
54
- return datasources;
55
- }
56
-
57
- /**
58
- * Displays datasources in a formatted table
59
- *
60
- * @function displayDatasources
61
- * @param {Array} datasources - Array of datasource objects
62
- * @param {string} environment - Environment key
63
- */
64
- function displayDatasources(datasources, environment) {
65
- if (datasources.length === 0) {
66
- logger.log(chalk.yellow(`\nNo datasources found in environment: ${environment}`));
67
- return;
68
- }
69
-
70
- logger.log(chalk.blue(`\n📋 Datasources in environment: ${environment}\n`));
71
- logger.log(chalk.gray('Key'.padEnd(30) + 'Display Name'.padEnd(30) + 'System Key'.padEnd(20) + 'Version'.padEnd(15) + 'Status'));
72
- logger.log(chalk.gray('-'.repeat(120)));
73
-
74
- datasources.forEach((ds) => {
75
- const key = (ds.key || 'N/A').padEnd(30);
76
- const displayName = (ds.displayName || 'N/A').padEnd(30);
77
- const systemKey = (ds.systemKey || 'N/A').padEnd(20);
78
- const version = (ds.version || 'N/A').padEnd(15);
79
- const status = ds.enabled !== false ? chalk.green('enabled') : chalk.red('disabled');
80
- logger.log(`${key}${displayName}${systemKey}${version}${status}`);
81
- });
82
- logger.log('');
83
- }
84
-
85
- /**
86
- * Lists datasources from an environment
87
- *
88
- * @async
89
- * @function listDatasources
90
- * @param {Object} options - Command options
91
- * @param {string} options.environment - Environment ID or key
92
- * @throws {Error} If listing fails
93
- */
94
- async function listDatasources(options) {
95
- const config = await getConfig();
96
-
97
- // Try to get device token
98
- let controllerUrl = null;
99
- let token = null;
100
-
101
- if (config.device) {
102
- const deviceUrls = Object.keys(config.device);
103
- if (deviceUrls.length > 0) {
104
- controllerUrl = deviceUrls[0];
105
- const deviceToken = await getOrRefreshDeviceToken(controllerUrl);
106
- if (deviceToken && deviceToken.token) {
107
- token = deviceToken.token;
108
- controllerUrl = deviceToken.controller;
109
- }
110
- }
111
- }
112
-
113
- if (!token || !controllerUrl) {
114
- logger.error(chalk.red('❌ Not logged in. Run: aifabrix login'));
115
- logger.error(chalk.gray(' Use device code flow: aifabrix login --method device --controller <url>'));
116
- process.exit(1);
117
- }
118
-
119
- // Call controller API using centralized API client
120
- const authConfig = { type: 'bearer', token };
121
- const response = await listEnvironmentDatasources(controllerUrl, options.environment, authConfig);
122
-
123
- if (!response.success || !response.data) {
124
- const formattedError = response.formattedError || formatApiError(response);
125
- logger.error(formattedError);
126
- logger.error(chalk.gray('\nFull response for debugging:'));
127
- logger.error(chalk.gray(JSON.stringify(response, null, 2)));
128
- process.exit(1);
129
- return; // Ensure we don't continue after exit
130
- }
131
-
132
- const datasources = extractDatasources(response);
133
- displayDatasources(datasources, options.environment);
134
- }
135
-
136
- module.exports = {
137
- listDatasources,
138
- displayDatasources,
139
- extractDatasources
140
- };
141
-
File without changes
File without changes
File without changes