@aifabrix/builder 2.41.0 ā 2.42.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/.cursor/rules/docs-rules.mdc +30 -0
- package/README.md +2 -2
- package/integration/hubspot/README.md +11 -5
- package/integration/hubspot/application.json +54 -0
- package/integration/hubspot/create-hubspot.js +9 -136
- package/integration/hubspot/env.template +3 -4
- package/integration/hubspot/hubspot-datasource-company.json +343 -5
- package/integration/hubspot/hubspot-datasource-contact.json +413 -5
- package/integration/hubspot/hubspot-datasource-deal.json +341 -4
- package/integration/hubspot/hubspot-datasource-users.json +116 -0
- package/integration/hubspot/hubspot-deploy.json +1250 -108
- package/integration/hubspot/hubspot-system.json +15 -32
- package/integration/hubspot/test-dataplane-down-tests.js +17 -16
- package/integration/hubspot/test-dataplane-down.js +2 -2
- package/jest.config.manual.js +2 -1
- package/lib/api/external-test.api.js +111 -0
- package/lib/api/index.js +42 -19
- package/lib/api/pipeline.api.js +66 -120
- package/lib/api/types/pipeline.types.js +37 -0
- package/lib/api/wizard-platform.api.js +61 -0
- package/lib/api/wizard.api.js +36 -2
- package/lib/app/config.js +23 -11
- package/lib/app/index.js +5 -3
- package/lib/app/prompts.js +46 -31
- package/lib/app/readme.js +11 -4
- package/lib/app/run-env-compose.js +64 -1
- package/lib/app/run-helpers.js +1 -1
- package/lib/app/show-display.js +1 -1
- package/lib/cli/setup-app.js +45 -14
- package/lib/cli/setup-credential-deployment.js +31 -6
- package/lib/cli/setup-dev.js +27 -0
- package/lib/cli/setup-environment.js +12 -4
- package/lib/cli/setup-external-system.js +19 -4
- package/lib/cli/setup-infra.js +54 -14
- package/lib/cli/setup-utility.js +117 -21
- package/lib/commands/auth-config.js +22 -12
- package/lib/commands/credential-env.js +162 -0
- package/lib/commands/credential-list.js +17 -22
- package/lib/commands/credential-push.js +96 -0
- package/lib/commands/datasource.js +77 -6
- package/lib/commands/dev-init.js +39 -1
- package/lib/commands/repair-auth-config.js +99 -0
- package/lib/commands/repair-datasource-keys.js +208 -0
- package/lib/commands/repair-datasource.js +235 -0
- package/lib/commands/repair-env-template.js +348 -0
- package/lib/commands/repair-internal.js +85 -0
- package/lib/commands/repair-rbac.js +158 -0
- package/lib/commands/repair.js +518 -0
- package/lib/commands/secrets-set.js +6 -0
- package/lib/commands/test-e2e-external.js +165 -0
- package/lib/commands/up-dataplane.js +90 -6
- package/lib/commands/upload.js +71 -40
- package/lib/commands/wizard-core-helpers.js +230 -5
- package/lib/commands/wizard-core.js +68 -29
- package/lib/commands/wizard-dataplane.js +1 -1
- package/lib/commands/wizard-entity-selection.js +43 -0
- package/lib/commands/wizard-headless.js +49 -5
- package/lib/commands/wizard-helpers.js +7 -3
- package/lib/commands/wizard.js +93 -64
- package/lib/core/config.js +7 -1
- package/lib/core/secrets.js +33 -12
- package/lib/datasource/deploy.js +12 -3
- package/lib/datasource/test-e2e.js +219 -0
- package/lib/datasource/test-integration.js +154 -0
- package/lib/deployment/deployer.js +7 -5
- package/lib/external-system/download-helpers.js +3 -1
- package/lib/external-system/download.js +182 -204
- package/lib/external-system/generator.js +204 -56
- package/lib/external-system/test-execution.js +2 -1
- package/lib/external-system/test-system-level.js +73 -0
- package/lib/external-system/test.js +51 -18
- package/lib/generator/external-controller-manifest.js +29 -2
- package/lib/generator/external-schema-utils.js +4 -2
- package/lib/generator/external.js +10 -3
- package/lib/generator/index.js +4 -1
- package/lib/generator/split-readme.js +1 -0
- package/lib/generator/split-variables.js +7 -1
- package/lib/generator/split.js +194 -54
- package/lib/generator/wizard-prompts-secondary.js +326 -0
- package/lib/generator/wizard-prompts.js +105 -106
- package/lib/generator/wizard-readme.js +91 -0
- package/lib/generator/wizard.js +180 -179
- package/lib/infrastructure/compose.js +11 -1
- package/lib/infrastructure/index.js +11 -3
- package/lib/infrastructure/services.js +22 -11
- package/lib/schema/application-schema.json +8 -5
- package/lib/schema/external-datasource.schema.json +49 -26
- package/lib/schema/external-system.schema.json +82 -6
- package/lib/schema/wizard-config.schema.json +23 -1
- package/lib/utils/api.js +38 -10
- package/lib/utils/auth-headers.js +8 -7
- package/lib/utils/compose-generator.js +1 -1
- package/lib/utils/compose-handlebars-helpers.js +11 -0
- package/lib/utils/config-format-preference.js +51 -0
- package/lib/utils/config-format.js +36 -0
- package/lib/utils/configuration-env-resolver.js +179 -0
- package/lib/utils/credential-display.js +83 -0
- package/lib/utils/credential-secrets-env.js +115 -25
- package/lib/utils/dataplane-pipeline-warning.js +28 -0
- package/lib/utils/deployment-validation-helpers.js +4 -4
- package/lib/utils/dev-ca-install.js +139 -0
- package/lib/utils/env-copy.js +23 -3
- package/lib/utils/error-formatters/http-status-errors.js +0 -1
- package/lib/utils/error-formatters/permission-errors.js +0 -1
- package/lib/utils/error-formatters/validation-errors.js +0 -1
- package/lib/utils/external-readme.js +89 -30
- package/lib/utils/external-system-display.js +59 -1
- package/lib/utils/external-system-test-helpers.js +21 -8
- package/lib/utils/external-system-validators.js +3 -0
- package/lib/utils/file-upload.js +20 -50
- package/lib/utils/help-builder.js +1 -0
- package/lib/utils/infra-status.js +50 -44
- package/lib/utils/local-secrets.js +5 -5
- package/lib/utils/paths.js +85 -4
- package/lib/utils/secrets-canonical.js +93 -0
- package/lib/utils/secrets-generator.js +20 -0
- package/lib/utils/secrets-helpers.js +75 -89
- package/lib/utils/test-log-writer.js +56 -0
- package/lib/utils/token-manager.js +24 -32
- package/lib/validation/env-template-auth.js +157 -0
- package/lib/validation/env-template-kv.js +41 -0
- package/lib/validation/external-manifest-validator.js +25 -0
- package/lib/validation/external-system-auth-rules.js +86 -0
- package/lib/validation/validate-batch.js +149 -0
- package/lib/validation/validate-datasource-keys-api.js +33 -0
- package/lib/validation/validate-display.js +94 -16
- package/lib/validation/validate.js +25 -12
- package/lib/validation/validator.js +7 -9
- package/lib/validation/wizard-datasource-validation.js +50 -0
- package/package.json +7 -2
- package/templates/applications/dataplane/application.yaml +1 -1
- package/templates/applications/dataplane/env.template +5 -5
- package/templates/applications/dataplane/rbac.yaml +2 -2
- package/templates/applications/miso-controller/env.template +1 -1
- package/templates/external-system/README.md.hbs +75 -22
- package/templates/external-system/deploy.js.hbs +4 -2
- package/templates/external-system/external-datasource.yaml.hbs +217 -0
- package/templates/external-system/external-system.json.hbs +1 -18
- package/templates/infra/compose.yaml.hbs +6 -0
- package/templates/python/docker-compose.hbs +4 -4
- package/templates/typescript/docker-compose.hbs +4 -4
- package/integration/hubspot/application.yaml +0 -37
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datasource integration test - run config test for one datasource via pipeline
|
|
3
|
+
* @fileoverview Datasource integration test logic
|
|
4
|
+
* @author AI Fabrix Team
|
|
5
|
+
* @version 2.0.0
|
|
6
|
+
*/
|
|
7
|
+
/* eslint-disable max-lines-per-function,max-statements,complexity -- Load config, resolve datasource, call pipeline test */
|
|
8
|
+
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const chalk = require('chalk');
|
|
11
|
+
const logger = require('../utils/logger');
|
|
12
|
+
const { getIntegrationPath, resolveIntegrationAppKeyFromCwd } = require('../utils/paths');
|
|
13
|
+
const { resolveApplicationConfigPath } = require('../utils/app-config-resolver');
|
|
14
|
+
const { loadConfigFile } = require('../utils/config-format');
|
|
15
|
+
const { setupIntegrationTestAuth } = require('../external-system/test-auth');
|
|
16
|
+
const { getConfig } = require('../core/config');
|
|
17
|
+
const { testDatasourceViaPipeline } = require('../api/pipeline.api');
|
|
18
|
+
const { writeTestLog } = require('../utils/test-log-writer');
|
|
19
|
+
const testHelpers = require('../utils/external-system-test-helpers');
|
|
20
|
+
const fs = require('fs').promises;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Resolve systemKey and appKey for datasource test-integration
|
|
24
|
+
* @param {string} [appKey] - Explicit app key from --app
|
|
25
|
+
* @returns {Promise<{appKey: string, systemKey: string}>}
|
|
26
|
+
*/
|
|
27
|
+
async function resolveSystemKey(appKey) {
|
|
28
|
+
let resolvedAppKey = appKey;
|
|
29
|
+
if (!resolvedAppKey) {
|
|
30
|
+
resolvedAppKey = resolveIntegrationAppKeyFromCwd();
|
|
31
|
+
}
|
|
32
|
+
if (!resolvedAppKey) {
|
|
33
|
+
throw new Error(
|
|
34
|
+
'Could not determine app context. Use --app <appKey> or run from integration/<appKey>/ directory.'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
const appPath = getIntegrationPath(resolvedAppKey);
|
|
38
|
+
const configPath = resolveApplicationConfigPath(appPath);
|
|
39
|
+
const config = loadConfigFile(configPath);
|
|
40
|
+
if (!config.externalIntegration || !config.externalIntegration.systems || config.externalIntegration.systems.length === 0) {
|
|
41
|
+
throw new Error(`No externalIntegration.systems found in ${configPath}`);
|
|
42
|
+
}
|
|
43
|
+
const systemFile = config.externalIntegration.systems[0];
|
|
44
|
+
const systemPath = path.isAbsolute(systemFile)
|
|
45
|
+
? systemFile
|
|
46
|
+
: path.join(appPath, systemFile);
|
|
47
|
+
const systemContent = await fs.readFile(systemPath, 'utf8');
|
|
48
|
+
const yaml = require('js-yaml');
|
|
49
|
+
const systemConfig = yaml.load(systemContent);
|
|
50
|
+
const systemKey = systemConfig?.key || path.basename(systemFile, '-system.yaml').replace('-system', '');
|
|
51
|
+
return { appKey: resolvedAppKey, systemKey };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Run integration test for one datasource
|
|
56
|
+
* @async
|
|
57
|
+
* @param {string} datasourceKey - Datasource key
|
|
58
|
+
* @param {Object} options - Options
|
|
59
|
+
* @param {string} [options.app] - App key (or resolve from cwd)
|
|
60
|
+
* @param {string} [options.payload] - Path to custom payload file
|
|
61
|
+
* @param {string} [options.environment] - Environment (dev, tst, pro)
|
|
62
|
+
* @param {boolean} [options.debug] - Include debug, write log file
|
|
63
|
+
* @param {number} [options.timeout] - Request timeout ms
|
|
64
|
+
* @returns {Promise<Object>} Test result
|
|
65
|
+
*/
|
|
66
|
+
async function runDatasourceTestIntegration(datasourceKey, options = {}) {
|
|
67
|
+
if (!datasourceKey || typeof datasourceKey !== 'string') {
|
|
68
|
+
throw new Error('Datasource key is required');
|
|
69
|
+
}
|
|
70
|
+
const { appKey, systemKey } = await resolveSystemKey(options.app);
|
|
71
|
+
const appPath = getIntegrationPath(appKey);
|
|
72
|
+
const config = loadConfigFile(resolveApplicationConfigPath(appPath));
|
|
73
|
+
const schemaBasePath = config.externalIntegration?.schemaBasePath || './';
|
|
74
|
+
const datasourceFiles = config.externalIntegration?.dataSources || [];
|
|
75
|
+
const datasourceFile = datasourceFiles.find(f => {
|
|
76
|
+
const base = path.basename(f, path.extname(f));
|
|
77
|
+
return base === datasourceKey || base.includes(datasourceKey);
|
|
78
|
+
});
|
|
79
|
+
if (!datasourceFile) {
|
|
80
|
+
throw new Error(`Datasource '${datasourceKey}' not found in application config`);
|
|
81
|
+
}
|
|
82
|
+
const datasourcePath = path.isAbsolute(schemaBasePath)
|
|
83
|
+
? path.join(schemaBasePath, datasourceFile)
|
|
84
|
+
: path.join(appPath, schemaBasePath, datasourceFile);
|
|
85
|
+
const datasourceContent = await fs.readFile(datasourcePath, 'utf8');
|
|
86
|
+
const datasource = JSON.parse(datasourceContent);
|
|
87
|
+
if (datasource.key !== datasourceKey) {
|
|
88
|
+
throw new Error(`Datasource key mismatch: file has '${datasource.key}', expected '${datasourceKey}'`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const configObj = await getConfig();
|
|
92
|
+
const { authConfig, dataplaneUrl } = await setupIntegrationTestAuth(appKey, options, configObj);
|
|
93
|
+
const customPayload = await testHelpers.loadCustomPayload(options.payload);
|
|
94
|
+
const payloadTemplate = testHelpers.determinePayloadTemplate(datasource, datasourceKey, customPayload);
|
|
95
|
+
if (!payloadTemplate) {
|
|
96
|
+
throw new Error(`No test payload found for datasource '${datasourceKey}'`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
logger.log(chalk.blue(`\nš” Testing datasource: ${datasourceKey} (system: ${systemKey})`));
|
|
100
|
+
|
|
101
|
+
const testData = { payloadTemplate };
|
|
102
|
+
if (options.debug) {
|
|
103
|
+
testData.includeDebug = true;
|
|
104
|
+
}
|
|
105
|
+
const timeout = parseInt(options.timeout, 10) || 30000;
|
|
106
|
+
|
|
107
|
+
let response;
|
|
108
|
+
try {
|
|
109
|
+
response = await testDatasourceViaPipeline({
|
|
110
|
+
dataplaneUrl,
|
|
111
|
+
systemKey,
|
|
112
|
+
datasourceKey,
|
|
113
|
+
authConfig,
|
|
114
|
+
testData,
|
|
115
|
+
options: { timeout }
|
|
116
|
+
});
|
|
117
|
+
} catch (error) {
|
|
118
|
+
const result = { key: datasourceKey, success: false, error: error.message };
|
|
119
|
+
if (options.debug) {
|
|
120
|
+
await writeTestLog(appKey, { request: { systemKey, datasourceKey }, error: error.message }, 'test-integration');
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const data = response.data || response;
|
|
126
|
+
const success = data.success !== false;
|
|
127
|
+
const result = {
|
|
128
|
+
key: datasourceKey,
|
|
129
|
+
systemKey,
|
|
130
|
+
success,
|
|
131
|
+
skipped: false,
|
|
132
|
+
validationResults: data.validationResults || {},
|
|
133
|
+
fieldMappingResults: data.fieldMappingResults || {},
|
|
134
|
+
endpointTestResults: data.endpointTestResults || {}
|
|
135
|
+
};
|
|
136
|
+
if (data.error) {
|
|
137
|
+
result.error = data.error;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (options.debug) {
|
|
141
|
+
const logPath = await writeTestLog(appKey, {
|
|
142
|
+
request: { systemKey, datasourceKey, includeDebug: true },
|
|
143
|
+
response: data
|
|
144
|
+
}, 'test-integration');
|
|
145
|
+
logger.log(chalk.gray(` Debug log: ${logPath}`));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = {
|
|
152
|
+
runDatasourceTestIntegration,
|
|
153
|
+
resolveSystemKey
|
|
154
|
+
};
|
|
@@ -193,14 +193,16 @@ function buildDeploymentData(validateToken, authConfig, options) {
|
|
|
193
193
|
* @throws {Error} If deployment failed
|
|
194
194
|
*/
|
|
195
195
|
function handleDeploymentResponse(response) {
|
|
196
|
-
|
|
196
|
+
const bodyFailed = response.data?.success === false;
|
|
197
|
+
if (response.success && !bodyFailed) {
|
|
197
198
|
return response.data.data || response.data;
|
|
198
199
|
}
|
|
199
200
|
|
|
200
|
-
// Handle deployment errors
|
|
201
|
-
if (response.status >= 400) {
|
|
202
|
-
const
|
|
203
|
-
error
|
|
201
|
+
// Handle deployment errors (HTTP error or 200 with success: false in body)
|
|
202
|
+
if (!response.success || bodyFailed || response.status >= 400) {
|
|
203
|
+
const msg = response.formattedError || response.error || response.data?.formattedError || response.data?.error || 'Unknown error';
|
|
204
|
+
const error = new Error(`Deployment request failed: ${msg}`);
|
|
205
|
+
error.status = response.status || (bodyFailed ? 400 : undefined);
|
|
204
206
|
error.data = response.data;
|
|
205
207
|
throw error;
|
|
206
208
|
}
|
|
@@ -77,13 +77,15 @@ function generateReadme(systemKey, application, dataSources) {
|
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
const authType = application.authentication?.type || application.authentication?.method;
|
|
80
81
|
return generateExternalReadmeContent({
|
|
81
82
|
appName: systemKey,
|
|
82
83
|
systemKey,
|
|
83
84
|
systemType: application.type,
|
|
84
85
|
displayName: application.displayName,
|
|
85
86
|
description: application.description,
|
|
86
|
-
datasources
|
|
87
|
+
datasources,
|
|
88
|
+
authType
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
91
|
|