@aifabrix/builder 2.31.1 → 2.32.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/README.md +9 -9
- package/integration/hubspot/README.md +2 -2
- package/integration/hubspot/hubspot-deploy-company.json +17 -14
- package/integration/hubspot/hubspot-deploy-contact.json +19 -16
- package/integration/hubspot/hubspot-deploy-deal.json +21 -18
- package/lib/api/types/datasources.types.js +31 -5
- package/lib/api/types/wizard.types.js +142 -0
- package/lib/api/wizard.api.js +177 -0
- package/lib/{app-config.js → app/config.js} +4 -4
- package/lib/{app-deploy.js → app/deploy.js} +8 -8
- package/lib/app/display.js +90 -0
- package/lib/{app-dockerfile.js → app/dockerfile.js} +4 -4
- package/lib/{app-down.js → app/down.js} +4 -4
- package/lib/app/helpers.js +218 -0
- package/lib/app/index.js +298 -0
- package/lib/{app-list.js → app/list.js} +6 -6
- package/lib/{app-push.js → app/push.js} +4 -4
- package/lib/{app-readme.js → app/readme.js} +34 -13
- package/lib/{app-register.js → app/register.js} +9 -9
- package/lib/{app-rotate-secret.js → app/rotate-secret.js} +10 -10
- package/lib/{app-run-helpers.js → app/run-helpers.js} +10 -10
- package/lib/{app-run.js → app/run.js} +6 -6
- package/lib/{build.js → build/index.js} +59 -32
- package/lib/build/package.json +7 -0
- package/lib/cli.js +245 -179
- package/lib/commands/app.js +3 -3
- package/lib/commands/datasource.js +4 -4
- package/lib/commands/login-credentials.js +209 -0
- package/lib/commands/login-device.js +254 -0
- package/lib/commands/login.js +67 -378
- package/lib/commands/logout.js +1 -1
- package/lib/commands/secrets-set.js +1 -1
- package/lib/commands/secure.js +2 -2
- package/lib/commands/wizard.js +498 -0
- package/lib/{audit-logger.js → core/audit-logger.js} +1 -1
- package/lib/{config.js → core/config.js} +28 -26
- package/lib/{diff.js → core/diff.js} +157 -72
- package/lib/{secrets.js → core/secrets.js} +86 -49
- package/lib/{templates.js → core/templates-env.js} +14 -222
- package/lib/core/templates.js +279 -0
- package/lib/{datasource-deploy.js → datasource/deploy.js} +6 -6
- package/lib/{datasource-diff.js → datasource/diff.js} +2 -2
- package/lib/datasource/list.js +223 -0
- package/lib/{datasource-validate.js → datasource/validate.js} +2 -2
- package/lib/{deployer.js → deployment/deployer.js} +48 -18
- package/lib/{environment-deploy.js → deployment/environment.js} +163 -84
- package/lib/{push.js → deployment/push.js} +1 -1
- package/lib/external-system/deploy-helpers.js +145 -0
- package/lib/{external-system-deploy.js → external-system/deploy.js} +156 -111
- package/lib/external-system/download-helpers.js +114 -0
- package/lib/{external-system-download.js → external-system/download.js} +92 -135
- package/lib/{external-system-generator.js → external-system/generator.js} +15 -11
- package/lib/external-system/test-auth.js +40 -0
- package/lib/external-system/test-execution.js +84 -0
- package/lib/external-system/test-helpers.js +109 -0
- package/lib/{external-system-test.js → external-system/test.js} +174 -192
- package/lib/{generator-builders.js → generator/builders.js} +87 -10
- package/lib/{generator-external.js → generator/external.js} +115 -52
- package/lib/{github-generator.js → generator/github.js} +116 -15
- package/lib/{generator-helpers.js → generator/helpers.js} +92 -42
- package/lib/{generator.js → generator/index.js} +49 -22
- package/lib/{generator-split.js → generator/split.js} +108 -55
- package/lib/generator/wizard-prompts.js +357 -0
- package/lib/generator/wizard.js +490 -0
- package/lib/{infra.js → infrastructure/index.js} +49 -22
- package/lib/schema/external-datasource.schema.json +145 -133
- package/lib/schema/external-system.schema.json +42 -0
- package/lib/utils/api.js +9 -5
- package/lib/utils/app-register-api.js +60 -32
- package/lib/utils/app-register-auth.js +172 -47
- package/lib/utils/app-register-config.js +130 -59
- package/lib/utils/app-run-containers.js +29 -8
- package/lib/utils/build-helpers.js +1 -1
- package/lib/utils/cli-utils.js +78 -30
- package/lib/utils/compose-generator.js +145 -65
- package/lib/utils/config-paths.js +2 -0
- package/lib/utils/deployment-errors.js +1 -1
- package/lib/utils/device-code.js +99 -41
- package/lib/utils/env-config-loader.js +1 -1
- package/lib/utils/env-copy.js +21 -18
- package/lib/utils/env-endpoints.js +115 -67
- package/lib/utils/env-map.js +13 -14
- package/lib/utils/env-ports.js +45 -25
- package/lib/utils/env-template.js +84 -42
- package/lib/utils/error-formatter.js +26 -9
- package/lib/utils/error-formatters/error-parser.js +90 -4
- package/lib/utils/error-formatters/http-status-errors.js +54 -17
- package/lib/utils/error-formatters/network-errors.js +103 -26
- package/lib/utils/external-system-display.js +184 -90
- package/lib/utils/external-system-validators.js +164 -42
- package/lib/utils/file-upload.js +109 -0
- package/lib/utils/health-check.js +199 -83
- package/lib/utils/infra-containers.js +1 -1
- package/lib/utils/infra-status.js +66 -15
- package/lib/utils/local-secrets.js +45 -25
- package/lib/utils/paths.js +45 -33
- package/lib/utils/schema-loader.js +42 -25
- package/lib/utils/schema-resolver.js +123 -74
- package/lib/utils/secrets-encryption.js +62 -25
- package/lib/utils/secrets-helpers.js +126 -63
- package/lib/utils/secrets-path.js +1 -1
- package/lib/utils/secrets-url.js +1 -1
- package/lib/utils/token-manager-refresh.js +181 -0
- package/lib/utils/token-manager.js +76 -123
- package/lib/utils/variable-transformer.js +154 -77
- package/lib/utils/yaml-preserve.js +41 -47
- package/lib/{template-validator.js → validation/template.js} +54 -23
- package/lib/{validate.js → validation/validate.js} +205 -125
- package/lib/{validator.js → validation/validator.js} +58 -39
- package/package.json +31 -2
- package/templates/external-system/deploy.ps1.hbs +34 -0
- package/templates/external-system/deploy.sh.hbs +34 -0
- package/templates/external-system/external-datasource.json.hbs +31 -12
- package/lib/app.js +0 -467
- package/lib/datasource-list.js +0 -141
- /package/lib/{app-prompts.js → app/prompts.js} +0 -0
- /package/lib/{env-reader.js → core/env-reader.js} +0 -0
- /package/lib/{key-generator.js → core/key-generator.js} +0 -0
package/lib/datasource-list.js
DELETED
|
@@ -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
|