@aifabrix/builder 2.32.3 → 2.33.0

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 (123) hide show
  1. package/.cursor/rules/project-rules.mdc +8 -0
  2. package/README.md +36 -8
  3. package/bin/aifabrix.js +6 -8
  4. package/integration/hubspot/README.md +8 -7
  5. package/integration/hubspot/companies.json +2048 -0
  6. package/integration/hubspot/create-hubspot.js +665 -0
  7. package/integration/hubspot/{hubspot-deploy-company.json → hubspot-datasource-company.json} +1 -1
  8. package/integration/hubspot/{hubspot-deploy-contact.json → hubspot-datasource-contact.json} +1 -1
  9. package/integration/hubspot/{hubspot-deploy-deal.json → hubspot-datasource-deal.json} +1 -1
  10. package/integration/hubspot/hubspot-deploy.json +832 -81
  11. package/integration/hubspot/hubspot-system.json +99 -0
  12. package/integration/hubspot/test-artifacts/wizard-hubspot-credential-real.yaml +20 -0
  13. package/integration/hubspot/test-artifacts/wizard-hubspot-env-vars.yaml +9 -0
  14. package/integration/hubspot/test-artifacts/wizard-invalid-add-datasource.yaml +5 -0
  15. package/integration/hubspot/test-artifacts/wizard-invalid-app-name.yaml +5 -0
  16. package/integration/hubspot/test-artifacts/wizard-invalid-credential-create.yaml +7 -0
  17. package/integration/hubspot/test-artifacts/wizard-invalid-credential-select.yaml +7 -0
  18. package/integration/hubspot/test-artifacts/wizard-invalid-known-platform.yaml +4 -0
  19. package/integration/hubspot/test-artifacts/wizard-invalid-missing-app.yaml +4 -0
  20. package/integration/hubspot/test-artifacts/wizard-invalid-missing-source.yaml +2 -0
  21. package/integration/hubspot/test-artifacts/wizard-invalid-mode.yaml +5 -0
  22. package/integration/hubspot/test-artifacts/wizard-invalid-openapi-file.yaml +5 -0
  23. package/integration/hubspot/test-artifacts/wizard-invalid-openapi-url.yaml +4 -0
  24. package/integration/hubspot/test-artifacts/wizard-invalid-source.yaml +4 -0
  25. package/integration/hubspot/test-artifacts/wizard-valid-for-dimension-array-test.yaml +5 -0
  26. package/integration/hubspot/test-artifacts/wizard-valid-for-dimension-key-test.yaml +5 -0
  27. package/integration/hubspot/test-artifacts/wizard-valid-for-dimension-path-test.yaml +5 -0
  28. package/integration/hubspot/test-artifacts/wizard-valid-for-dimension-test.yaml +5 -0
  29. package/integration/hubspot/test-artifacts/wizard-valid-for-rbac-test.yaml +5 -0
  30. package/integration/hubspot/test-artifacts/wizard-valid-for-rbac-yaml-test.yaml +5 -0
  31. package/integration/hubspot/test-dataplane-down-helpers.js +246 -0
  32. package/integration/hubspot/test-dataplane-down-tests.js +419 -0
  33. package/integration/hubspot/test-dataplane-down.js +157 -0
  34. package/integration/hubspot/test.js +1517 -0
  35. package/integration/hubspot/variables.yaml +4 -4
  36. package/integration/hubspot/wizard-hubspot-e2e.yaml +16 -0
  37. package/integration/hubspot/wizard-hubspot-platform.yaml +8 -0
  38. package/lib/api/applications.api.js +1 -0
  39. package/lib/api/types/wizard.types.js +176 -38
  40. package/lib/api/wizard.api.js +161 -23
  41. package/lib/app/deploy.js +116 -54
  42. package/lib/app/display.js +6 -5
  43. package/lib/app/dockerfile.js +2 -1
  44. package/lib/app/list.js +17 -10
  45. package/lib/app/readme.js +41 -112
  46. package/lib/app/register.js +44 -9
  47. package/lib/app/rotate-secret.js +48 -31
  48. package/lib/cli.js +219 -70
  49. package/lib/commands/app.js +4 -9
  50. package/lib/commands/auth-config.js +125 -0
  51. package/lib/commands/auth-status.js +7 -8
  52. package/lib/commands/datasource.js +3 -6
  53. package/lib/commands/login-credentials.js +4 -4
  54. package/lib/commands/login-device.js +26 -17
  55. package/lib/commands/login.js +12 -10
  56. package/lib/commands/wizard-config-normalizer.js +92 -0
  57. package/lib/commands/wizard-core.js +515 -0
  58. package/lib/commands/wizard-dataplane.js +122 -0
  59. package/lib/commands/wizard-headless.js +115 -0
  60. package/lib/commands/wizard.js +110 -332
  61. package/lib/core/config.js +46 -0
  62. package/lib/core/secrets.js +3 -22
  63. package/lib/core/templates-env.js +1 -1
  64. package/lib/datasource/deploy.js +29 -21
  65. package/lib/datasource/list.js +8 -6
  66. package/lib/deployment/deployer.js +25 -0
  67. package/lib/deployment/environment.js +10 -13
  68. package/lib/external-system/delete.js +151 -0
  69. package/lib/external-system/deploy.js +53 -378
  70. package/lib/external-system/download-helpers.js +45 -65
  71. package/lib/external-system/download.js +33 -13
  72. package/lib/external-system/generator.js +11 -7
  73. package/lib/external-system/test-auth.js +4 -3
  74. package/lib/generator/builders.js +3 -1
  75. package/lib/generator/external-controller-manifest.js +157 -0
  76. package/lib/generator/external-schema-utils.js +236 -0
  77. package/lib/generator/external.js +55 -3
  78. package/lib/generator/index.js +22 -10
  79. package/lib/generator/wizard-prompts.js +33 -10
  80. package/lib/generator/wizard.js +69 -86
  81. package/lib/infrastructure/compose.js +100 -0
  82. package/lib/infrastructure/helpers.js +139 -0
  83. package/lib/infrastructure/index.js +52 -311
  84. package/lib/infrastructure/services.js +168 -0
  85. package/lib/schema/application-schema.json +23 -4
  86. package/lib/schema/external-datasource.schema.json +2 -2
  87. package/lib/schema/wizard-config.schema.json +234 -0
  88. package/lib/utils/api.js +32 -50
  89. package/lib/utils/app-existence.js +42 -0
  90. package/lib/utils/app-register-config.js +7 -2
  91. package/lib/utils/auth-config-validator.js +92 -0
  92. package/lib/utils/command-header.js +43 -0
  93. package/lib/utils/compose-generator.js +113 -70
  94. package/lib/utils/controller-url.js +65 -17
  95. package/lib/utils/dataplane-health.js +115 -0
  96. package/lib/utils/dataplane-resolver.js +29 -0
  97. package/lib/utils/dev-config.js +6 -2
  98. package/lib/utils/env-copy.js +2 -1
  99. package/lib/utils/env-ports.js +2 -1
  100. package/lib/utils/env-template.js +1 -1
  101. package/lib/utils/error-formatter.js +49 -0
  102. package/lib/utils/external-readme.js +125 -0
  103. package/lib/utils/help-builder.js +190 -0
  104. package/lib/utils/infra-status.js +13 -3
  105. package/lib/utils/paths.js +17 -2
  106. package/lib/utils/port-resolver.js +111 -0
  107. package/lib/utils/secrets-helpers.js +3 -15
  108. package/lib/utils/secrets-utils.js +2 -2
  109. package/lib/utils/token-manager.js +9 -4
  110. package/lib/utils/variable-transformer.js +7 -2
  111. package/lib/validation/external-manifest-validator.js +202 -0
  112. package/lib/validation/validate-display.js +406 -0
  113. package/lib/validation/validate.js +159 -123
  114. package/lib/validation/validator.js +36 -3
  115. package/lib/validation/wizard-config-validator.js +267 -0
  116. package/package.json +4 -2
  117. package/templates/applications/README.md.hbs +18 -16
  118. package/templates/applications/miso-controller/env.template +1 -1
  119. package/templates/applications/miso-controller/rbac.yaml +7 -7
  120. package/templates/external-system/README.md.hbs +99 -0
  121. package/templates/infra/compose.yaml.hbs +35 -0
  122. package/templates/python/docker-compose.hbs +26 -0
  123. package/templates/typescript/docker-compose.hbs +26 -0
@@ -7,11 +7,11 @@ app:
7
7
  externalIntegration:
8
8
  schemaBasePath: ./
9
9
  systems:
10
- - hubspot-deploy.json
10
+ - hubspot-system.json
11
11
  dataSources:
12
- - hubspot-deploy-company.json
13
- - hubspot-deploy-contact.json
14
- - hubspot-deploy-deal.json
12
+ - hubspot-datasource-company.json
13
+ - hubspot-datasource-contact.json
14
+ - hubspot-datasource-deal.json
15
15
  autopublish: true
16
16
  version: 1.0.0
17
17
 
@@ -0,0 +1,16 @@
1
+ appName: hubspot-test-e2e
2
+ mode: create-system
3
+ source:
4
+ type: openapi-file
5
+ filePath: /workspace/aifabrix-builder/integration/hubspot/companies.json
6
+ credential:
7
+ action: skip
8
+ preferences:
9
+ intent: "HubSpot CRM integration for companies entity"
10
+ fieldOnboardingLevel: full
11
+ enableOpenAPIGeneration: true
12
+ enableABAC: true
13
+ enableRBAC: false
14
+ deployment:
15
+ controller: http://localhost:3110
16
+ environment: miso
@@ -0,0 +1,8 @@
1
+ appName: hubspot-test-platform
2
+ mode: create-system
3
+ source:
4
+ type: known-platform
5
+ platform: hubspot
6
+ preferences:
7
+ intent: "HubSpot CRM integration"
8
+ fieldOnboardingLevel: standard
@@ -123,6 +123,7 @@ async function deleteApplication(controllerUrl, appKey, authConfig) {
123
123
  * @param {string} [registrationData.description] - Application description
124
124
  * @param {string} [registrationData.registryMode] - Registry mode
125
125
  * @param {number} [registrationData.port] - Application port
126
+ * @param {string} [registrationData.url] - Application URL (e.g. http://localhost:3001 when controller is localhost)
126
127
  * @param {string} [registrationData.image] - Container image
127
128
  * @param {Object} [registrationData.externalIntegration] - External integration config
128
129
  * @returns {Promise<Object>} Registration response with application and credentials
@@ -5,33 +5,66 @@
5
5
  */
6
6
 
7
7
  /**
8
- * Wizard mode selection request
9
- * @typedef {Object} WizardModeSelectionRequest
8
+ * Wizard session request
9
+ * @typedef {Object} WizardSessionRequest
10
10
  * @property {string} mode - Wizard mode ('create-system' | 'add-datasource')
11
+ * @property {string} [systemIdOrKey] - Existing system ID or key (required when mode='add-datasource')
11
12
  */
12
13
 
13
14
  /**
14
- * Wizard mode selection response
15
- * @typedef {Object} WizardModeSelectionResponse
15
+ * Wizard session response
16
+ * @typedef {Object} WizardSessionResponse
16
17
  * @property {boolean} success - Request success flag
17
- * @property {Object} data - Mode selection data
18
- * @property {string} data.mode - Selected mode
18
+ * @property {Object} data - Session data
19
+ * @property {Object} data.sessionId - Session identifier object
20
+ * @property {string} data.sessionId.id - Session ID
21
+ * @property {string} data.sessionId.key - Session key
22
+ * @property {string} data.sessionId.name - Session name
23
+ * @property {string} data.sessionId.type - Session type ('WizardSession')
24
+ * @property {string} data.expiresAt - Session expiration timestamp (ISO 8601)
19
25
  * @property {string} timestamp - Response timestamp (ISO 8601)
20
26
  */
21
27
 
22
28
  /**
23
- * Wizard source selection request
24
- * @typedef {Object} WizardSourceSelectionRequest
25
- * @property {string} sourceType - Source type ('openapi-file' | 'openapi-url' | 'mcp-server' | 'known-platform')
26
- * @property {string} [sourceData] - Source data (file path, URL, etc.)
29
+ * Wizard session delete response
30
+ * @typedef {Object} WizardDeleteSessionResponse
31
+ * @property {boolean} success - Request success flag
32
+ * @property {Object} [data] - Delete response data
33
+ * @property {string} [data.message] - Confirmation message
34
+ * @property {string} timestamp - Response timestamp (ISO 8601)
35
+ */
36
+
37
+ /**
38
+ * Wizard session progress response
39
+ * @typedef {Object} WizardProgressResponse
40
+ * @property {boolean} success - Request success flag
41
+ * @property {Object} data - Progress data
42
+ * @property {number} data.currentStep - Current step number
43
+ * @property {number} data.totalSteps - Total number of steps
44
+ * @property {string[]} data.completedSteps - Array of completed step names
45
+ * @property {boolean} data.canProceed - Whether user can proceed to next step
46
+ * @property {string} timestamp - Response timestamp (ISO 8601)
47
+ */
48
+
49
+ /**
50
+ * Credential selection request
51
+ * @typedef {Object} CredentialSelectionRequest
52
+ * @property {string} action - Action type ('create' | 'select' | 'skip')
53
+ * @property {Object} [credentialConfig] - Credential config (required when action='create')
54
+ * @property {string} [credentialConfig.key] - Credential key
55
+ * @property {string} [credentialConfig.displayName] - Credential display name
56
+ * @property {string} [credentialConfig.type] - Credential type (e.g., 'OAUTH2', 'API_KEY')
57
+ * @property {Object} [credentialConfig.config] - Credential configuration
58
+ * @property {string} [credentialIdOrKey] - Credential ID or key (required when action='select')
27
59
  */
28
60
 
29
61
  /**
30
- * Wizard source selection response
31
- * @typedef {Object} WizardSourceSelectionResponse
62
+ * Credential selection response
63
+ * @typedef {Object} CredentialSelectionResponse
32
64
  * @property {boolean} success - Request success flag
33
- * @property {Object} data - Source selection data
34
- * @property {string} data.sourceType - Selected source type
65
+ * @property {Object} data - Credential selection data
66
+ * @property {string} data.action - Selected action
67
+ * @property {string} [data.credentialIdOrKey] - Selected or created credential ID/key
35
68
  * @property {string} timestamp - Response timestamp (ISO 8601)
36
69
  */
37
70
 
@@ -41,14 +74,19 @@
41
74
  * @property {boolean} success - Request success flag
42
75
  * @property {Object} data - Parsed OpenAPI data
43
76
  * @property {Object} data.spec - Parsed OpenAPI specification
44
- * @property {string} data.version - OpenAPI version
77
+ * @property {string} data.validationStatus - Validation status ('valid' | 'invalid')
78
+ * @property {string[]} [data.validationErrors] - Validation errors (if any)
79
+ * @property {Object} data.specInfo - Specification info
80
+ * @property {string} data.specInfo.title - API title
81
+ * @property {string} data.specInfo.version - API version
82
+ * @property {string[]} data.specInfo.servers - Server URLs
45
83
  * @property {string} timestamp - Response timestamp (ISO 8601)
46
84
  */
47
85
 
48
86
  /**
49
87
  * Wizard detect type request
50
88
  * @typedef {Object} WizardDetectTypeRequest
51
- * @property {Object} openApiSpec - OpenAPI specification object
89
+ * @property {Object} openapiSpec - OpenAPI specification object
52
90
  */
53
91
 
54
92
  /**
@@ -56,23 +94,34 @@
56
94
  * @typedef {Object} WizardDetectTypeResponse
57
95
  * @property {boolean} success - Request success flag
58
96
  * @property {Object} data - Type detection data
59
- * @property {string} data.apiType - Detected API type (e.g., 'rest', 'graphql', 'rpc')
60
- * @property {string} data.category - API category (e.g., 'crm', 'support', 'sales')
61
- * @property {Object} data.confidence - Confidence scores for detection
97
+ * @property {Object[]} data.detectedTypes - Array of detected types with confidence
98
+ * @property {string} data.detectedTypes[].type - Detected type
99
+ * @property {number} data.detectedTypes[].confidence - Confidence score (0-1)
100
+ * @property {string} data.detectedTypes[].reasoning - Reasoning for detection
101
+ * @property {string} data.recommendedType - Recommended type
62
102
  * @property {string} timestamp - Response timestamp (ISO 8601)
63
103
  */
64
104
 
65
105
  /**
66
106
  * Wizard generate config request
67
107
  * @typedef {Object} WizardGenerateConfigRequest
68
- * @property {string} mode - Wizard mode
69
- * @property {string} sourceType - Source type
70
- * @property {Object} [openApiSpec] - OpenAPI specification (if applicable)
71
- * @property {string} [userIntent] - User intent (e.g., 'sales-focused', 'support-focused')
72
- * @property {Object} [preferences] - User preferences
73
- * @property {boolean} [preferences.mcp] - Enable MCP
74
- * @property {boolean} [preferences.abac] - Enable ABAC
75
- * @property {boolean} [preferences.rbac] - Enable RBAC
108
+ * @property {Object} openapiSpec - OpenAPI specification object (required)
109
+ * @property {string} detectedType - Detected API type (required, e.g., 'record-based')
110
+ * @property {string} intent - User intent (required, any descriptive text)
111
+ * @property {string} mode - Wizard mode (required, 'create-system' | 'add-datasource')
112
+ * @property {string} [systemIdOrKey] - Existing system ID/key (required for add-datasource)
113
+ * @property {string} [credentialIdOrKey] - Credential ID or key
114
+ * @property {string} [fieldOnboardingLevel] - Field onboarding level ('full' | 'standard' | 'minimal')
115
+ * @property {boolean} [enableOpenAPIGeneration] - Enable OpenAPI operation generation
116
+ * @property {Object} [userPreferences] - User preferences
117
+ * @property {boolean} [userPreferences.enableMCP] - Enable MCP
118
+ * @property {boolean} [userPreferences.enableABAC] - Enable ABAC
119
+ * @property {boolean} [userPreferences.enableRBAC] - Enable RBAC
120
+ */
121
+
122
+ /**
123
+ * Wizard generate config stream request
124
+ * @typedef {WizardGenerateConfigRequest} WizardGenerateConfigStreamRequest
76
125
  */
77
126
 
78
127
  /**
@@ -81,8 +130,17 @@
81
130
  * @property {boolean} success - Request success flag
82
131
  * @property {Object} data - Generated configuration data
83
132
  * @property {Object} data.systemConfig - External system configuration
84
- * @property {Object[]} data.datasourceConfigs - Array of datasource configurations
85
- * @property {string} data.systemKey - Generated system key
133
+ * @property {Object} data.datasourceConfig - Datasource configuration
134
+ * @property {string} [data.systemKey] - Generated system key
135
+ * @property {string} timestamp - Response timestamp (ISO 8601)
136
+ */
137
+
138
+ /**
139
+ * Wizard generate config stream response
140
+ * @typedef {Object} WizardGenerateConfigStreamResponse
141
+ * @property {boolean} success - Request success flag
142
+ * @property {Object} [data] - Stream response metadata
143
+ * @property {string} [data.streamId] - Stream identifier
86
144
  * @property {string} timestamp - Response timestamp (ISO 8601)
87
145
  */
88
146
 
@@ -90,7 +148,7 @@
90
148
  * Wizard validate request
91
149
  * @typedef {Object} WizardValidateRequest
92
150
  * @property {Object} systemConfig - System configuration to validate
93
- * @property {Object[]} datasourceConfigs - Array of datasource configurations to validate
151
+ * @property {Object|Object[]} datasourceConfig - Datasource configuration(s) to validate
94
152
  */
95
153
 
96
154
  /**
@@ -98,9 +156,66 @@
98
156
  * @typedef {Object} WizardValidateResponse
99
157
  * @property {boolean} success - Request success flag
100
158
  * @property {Object} data - Validation data
101
- * @property {boolean} data.valid - Whether configuration is valid
159
+ * @property {boolean} data.isValid - Whether configuration is valid
102
160
  * @property {Object[]} [data.errors] - Array of validation errors (if invalid)
161
+ * @property {string} data.errors[].severity - Error severity
162
+ * @property {string} data.errors[].field - Field with error
163
+ * @property {string} data.errors[].message - Error message
103
164
  * @property {Object[]} [data.warnings] - Array of validation warnings
165
+ * @property {string} data.warnings[].severity - Warning severity
166
+ * @property {string} data.warnings[].field - Field with warning
167
+ * @property {string} data.warnings[].message - Warning message
168
+ * @property {string} timestamp - Response timestamp (ISO 8601)
169
+ */
170
+
171
+ /**
172
+ * Wizard validate all steps response
173
+ * @typedef {Object} WizardValidateAllStepsResponse
174
+ * @property {boolean} success - Request success flag
175
+ * @property {Object} data - Validation data
176
+ * @property {boolean} data.isValid - Whether all steps are valid
177
+ * @property {Object[]} [data.errors] - Array of validation errors (if invalid)
178
+ * @property {Object[]} [data.warnings] - Array of validation warnings
179
+ * @property {string} timestamp - Response timestamp (ISO 8601)
180
+ */
181
+
182
+ /**
183
+ * Wizard step validation response
184
+ * @typedef {Object} WizardStepValidationResponse
185
+ * @property {boolean} success - Request success flag
186
+ * @property {Object} data - Step validation data
187
+ * @property {number} data.step - Step number
188
+ * @property {boolean} data.isValid - Whether step is valid
189
+ * @property {Object[]} [data.errors] - Array of validation errors
190
+ * @property {Object[]} [data.warnings] - Array of validation warnings
191
+ * @property {string[]} [data.suggestions] - Array of suggestions
192
+ * @property {boolean} data.canProceed - Whether user can proceed
193
+ * @property {string} timestamp - Response timestamp (ISO 8601)
194
+ */
195
+
196
+ /**
197
+ * Wizard preview response
198
+ * @typedef {Object} WizardPreviewResponse
199
+ * @property {boolean} success - Request success flag
200
+ * @property {Object} data - Preview data
201
+ * @property {Object} data.sessionId - Session identifier
202
+ * @property {Object} data.systemConfig - System configuration
203
+ * @property {Object} data.datasourceConfig - Datasource configuration
204
+ * @property {Object} data.systemSummary - System summary
205
+ * @property {string} data.systemSummary.key - System key
206
+ * @property {string} data.systemSummary.displayName - Display name
207
+ * @property {string} data.systemSummary.type - System type
208
+ * @property {string} data.systemSummary.baseUrl - Base URL
209
+ * @property {string} data.systemSummary.authenticationType - Authentication type
210
+ * @property {number} data.systemSummary.endpointCount - Number of endpoints
211
+ * @property {Object} data.datasourceSummary - Datasource summary
212
+ * @property {string} data.datasourceSummary.key - Datasource key
213
+ * @property {string} data.datasourceSummary.entity - Entity name
214
+ * @property {string} data.datasourceSummary.resourceType - Resource type
215
+ * @property {number} data.datasourceSummary.cipStepCount - Number of CIP steps
216
+ * @property {number} data.datasourceSummary.fieldMappingCount - Number of field mappings
217
+ * @property {number} data.datasourceSummary.exposedProfileCount - Number of exposed profiles
218
+ * @property {number} data.datasourceSummary.indexingFieldCount - Number of indexing fields
104
219
  * @property {string} timestamp - Response timestamp (ISO 8601)
105
220
  */
106
221
 
@@ -121,12 +236,6 @@
121
236
  * @property {string} timestamp - Response timestamp (ISO 8601)
122
237
  */
123
238
 
124
- /**
125
- * Deployment docs request
126
- * @typedef {Object} DeploymentDocsRequest
127
- * @property {string} systemKey - System key identifier
128
- */
129
-
130
239
  /**
131
240
  * Deployment docs response
132
241
  * @typedef {Object} DeploymentDocsResponse
@@ -138,5 +247,34 @@
138
247
  * @property {string} timestamp - Response timestamp (ISO 8601)
139
248
  */
140
249
 
141
- module.exports = {};
250
+ /**
251
+ * Wizard config YAML structure
252
+ * @typedef {Object} WizardConfigYaml
253
+ * @property {string} appName - Application name (pattern: ^[a-z0-9-_]+$)
254
+ * @property {string} mode - Wizard mode ('create-system' | 'add-datasource')
255
+ * @property {string} [systemIdOrKey] - Existing system ID/key (required when mode='add-datasource')
256
+ * @property {Object} source - Source configuration
257
+ * @property {string} source.type - Source type ('openapi-file' | 'openapi-url' | 'mcp-server' | 'known-platform')
258
+ * @property {string} [source.filePath] - OpenAPI file path (for openapi-file)
259
+ * @property {string} [source.url] - OpenAPI URL (for openapi-url)
260
+ * @property {string} [source.serverUrl] - MCP server URL (for mcp-server)
261
+ * @property {string} [source.token] - MCP token (for mcp-server, supports ${ENV_VAR})
262
+ * @property {string} [source.platform] - Known platform (for known-platform)
263
+ * @property {Object} [credential] - Credential configuration
264
+ * @property {string} credential.action - Action ('create' | 'select' | 'skip')
265
+ * @property {string} [credential.credentialIdOrKey] - Credential ID/key (for select)
266
+ * @property {Object} [credential.config] - Credential config (for create)
267
+ * @property {Object} [preferences] - Generation preferences
268
+ * @property {string} [preferences.intent] - User intent (any descriptive text)
269
+ * @property {string} [preferences.fieldOnboardingLevel] - Field level ('full' | 'standard' | 'minimal')
270
+ * @property {boolean} [preferences.enableOpenAPIGeneration] - Enable OpenAPI generation
271
+ * @property {boolean} [preferences.enableMCP] - Enable MCP
272
+ * @property {boolean} [preferences.enableABAC] - Enable ABAC
273
+ * @property {boolean} [preferences.enableRBAC] - Enable RBAC
274
+ * @property {Object} [deployment] - Deployment settings
275
+ * @property {string} [deployment.controller] - Controller URL
276
+ * @property {string} [deployment.environment] - Environment key
277
+ * @property {string} [deployment.dataplane] - Dataplane URL override
278
+ */
142
279
 
280
+ module.exports = {};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @fileoverview Wizard API functions
2
+ * @fileoverview Wizard API functions for external system creation
3
3
  * @author AI Fabrix Team
4
4
  * @version 2.0.0
5
5
  */
@@ -15,15 +15,15 @@ const { uploadFile } = require('../utils/file-upload');
15
15
  * @param {string} dataplaneUrl - Dataplane base URL
16
16
  * @param {Object} authConfig - Authentication configuration
17
17
  * @param {string} mode - Wizard mode ('create-system' | 'add-datasource')
18
- * @param {string} [systemId] - Existing system ID (required when mode='add-datasource')
18
+ * @param {string} [systemIdOrKey] - Existing system ID or key (required when mode='add-datasource')
19
19
  * @returns {Promise<Object>} Session creation response with sessionId
20
20
  * @throws {Error} If request fails
21
21
  */
22
- async function createWizardSession(dataplaneUrl, authConfig, mode, systemId = null) {
22
+ async function createWizardSession(dataplaneUrl, authConfig, mode, systemIdOrKey = null) {
23
23
  const client = new ApiClient(dataplaneUrl, authConfig);
24
24
  const body = { mode };
25
- if (systemId) {
26
- body.systemId = systemId;
25
+ if (systemIdOrKey) {
26
+ body.systemIdOrKey = systemIdOrKey;
27
27
  }
28
28
  return await client.post('/api/v1/wizard/sessions', {
29
29
  body
@@ -48,7 +48,7 @@ async function getWizardSession(dataplaneUrl, sessionId, authConfig) {
48
48
 
49
49
  /**
50
50
  * Update wizard session
51
- * PATCH /api/v1/wizard/sessions/{sessionId}
51
+ * PUT /api/v1/wizard/sessions/{sessionId}
52
52
  * @async
53
53
  * @function updateWizardSession
54
54
  * @param {string} dataplaneUrl - Dataplane base URL
@@ -72,25 +72,83 @@ async function getWizardSession(dataplaneUrl, sessionId, authConfig) {
72
72
  */
73
73
  async function updateWizardSession(dataplaneUrl, sessionId, authConfig, updateData) {
74
74
  const client = new ApiClient(dataplaneUrl, authConfig);
75
- return await client.patch(`/api/v1/wizard/sessions/${sessionId}`, {
75
+ return await client.put(`/api/v1/wizard/sessions/${sessionId}`, {
76
76
  body: updateData
77
77
  });
78
78
  }
79
79
 
80
80
  /**
81
- * Parse OpenAPI file
81
+ * Delete wizard session
82
+ * DELETE /api/v1/wizard/sessions/{sessionId}
83
+ * @async
84
+ * @function deleteWizardSession
85
+ * @param {string} dataplaneUrl - Dataplane base URL
86
+ * @param {string} sessionId - Session ID
87
+ * @param {Object} authConfig - Authentication configuration
88
+ * @returns {Promise<Object>} Delete response
89
+ * @throws {Error} If request fails
90
+ */
91
+ async function deleteWizardSession(dataplaneUrl, sessionId, authConfig) {
92
+ const client = new ApiClient(dataplaneUrl, authConfig);
93
+ return await client.delete(`/api/v1/wizard/sessions/${sessionId}`);
94
+ }
95
+
96
+ /**
97
+ * Get wizard session progress
98
+ * GET /api/v1/wizard/sessions/{sessionId}/progress
99
+ * @async
100
+ * @function getWizardProgress
101
+ * @param {string} dataplaneUrl - Dataplane base URL
102
+ * @param {string} sessionId - Session ID
103
+ * @param {Object} authConfig - Authentication configuration
104
+ * @returns {Promise<Object>} Session progress response
105
+ * @throws {Error} If request fails
106
+ */
107
+ async function getWizardProgress(dataplaneUrl, sessionId, authConfig) {
108
+ const client = new ApiClient(dataplaneUrl, authConfig);
109
+ return await client.get(`/api/v1/wizard/sessions/${sessionId}/progress`);
110
+ }
111
+
112
+ /**
113
+ * Parse OpenAPI file or URL
82
114
  * POST /api/v1/wizard/parse-openapi
83
115
  * @async
84
116
  * @function parseOpenApi
85
117
  * @param {string} dataplaneUrl - Dataplane base URL
86
118
  * @param {Object} authConfig - Authentication configuration
87
- * @param {string} openApiFilePath - Path to OpenAPI file
119
+ * @param {string} openApiFilePathOrUrl - Path to OpenAPI file or URL
120
+ * @param {boolean} [isUrl=false] - Whether the input is a URL
88
121
  * @returns {Promise<Object>} Parsed OpenAPI response
89
122
  * @throws {Error} If request fails
90
123
  */
91
- async function parseOpenApi(dataplaneUrl, authConfig, openApiFilePath) {
124
+ async function parseOpenApi(dataplaneUrl, authConfig, openApiFilePathOrUrl, isUrl = false) {
125
+ if (isUrl) {
126
+ const client = new ApiClient(dataplaneUrl, authConfig);
127
+ return await client.post(`/api/v1/wizard/parse-openapi?url=${encodeURIComponent(openApiFilePathOrUrl)}`);
128
+ }
92
129
  const url = `${dataplaneUrl.replace(/\/$/, '')}/api/v1/wizard/parse-openapi`;
93
- return await uploadFile(url, openApiFilePath, 'file', authConfig);
130
+ return await uploadFile(url, openApiFilePathOrUrl, 'file', authConfig);
131
+ }
132
+
133
+ /**
134
+ * Credential selection for wizard
135
+ * POST /api/v1/wizard/credential-selection
136
+ * @async
137
+ * @function credentialSelection
138
+ * @param {string} dataplaneUrl - Dataplane base URL
139
+ * @param {Object} authConfig - Authentication configuration
140
+ * @param {Object} selectionData - Credential selection data
141
+ * @param {string} selectionData.action - Action type ('create' | 'select' | 'skip')
142
+ * @param {Object} [selectionData.credentialConfig] - Credential config (required when action='create')
143
+ * @param {string} [selectionData.credentialIdOrKey] - Credential ID or key (required when action='select')
144
+ * @returns {Promise<Object>} Credential selection response
145
+ * @throws {Error} If request fails
146
+ */
147
+ async function credentialSelection(dataplaneUrl, authConfig, selectionData) {
148
+ const client = new ApiClient(dataplaneUrl, authConfig);
149
+ return await client.post('/api/v1/wizard/credential-selection', {
150
+ body: selectionData
151
+ });
94
152
  }
95
153
 
96
154
  /**
@@ -100,14 +158,14 @@ async function parseOpenApi(dataplaneUrl, authConfig, openApiFilePath) {
100
158
  * @function detectType
101
159
  * @param {string} dataplaneUrl - Dataplane base URL
102
160
  * @param {Object} authConfig - Authentication configuration
103
- * @param {Object} openApiSpec - OpenAPI specification object
161
+ * @param {Object} openapiSpec - OpenAPI specification object
104
162
  * @returns {Promise<Object>} Type detection response
105
163
  * @throws {Error} If request fails
106
164
  */
107
- async function detectType(dataplaneUrl, authConfig, openApiSpec) {
165
+ async function detectType(dataplaneUrl, authConfig, openapiSpec) {
108
166
  const client = new ApiClient(dataplaneUrl, authConfig);
109
167
  return await client.post('/api/v1/wizard/detect-type', {
110
- body: { openApiSpec }
168
+ body: { openapiSpec }
111
169
  });
112
170
  }
113
171
 
@@ -119,11 +177,18 @@ async function detectType(dataplaneUrl, authConfig, openApiSpec) {
119
177
  * @param {string} dataplaneUrl - Dataplane base URL
120
178
  * @param {Object} authConfig - Authentication configuration
121
179
  * @param {Object} config - Generation configuration
122
- * @param {string} config.mode - Wizard mode
123
- * @param {string} config.sourceType - Source type
124
- * @param {Object} [config.openApiSpec] - OpenAPI specification (if applicable)
125
- * @param {string} [config.userIntent] - User intent (e.g., 'sales-focused', 'support-focused')
126
- * @param {Object} [config.preferences] - User preferences
180
+ * @param {Object} config.openapiSpec - OpenAPI specification object (required)
181
+ * @param {string} config.detectedType - Detected API type (required, e.g., 'record-based')
182
+ * @param {string} config.intent - User intent (required, any descriptive text)
183
+ * @param {string} config.mode - Wizard mode (required, 'create-system' | 'add-datasource')
184
+ * @param {string} [config.systemIdOrKey] - Existing system ID/key (required for add-datasource)
185
+ * @param {string} [config.credentialIdOrKey] - Credential ID or key
186
+ * @param {string} [config.fieldOnboardingLevel] - Field onboarding level ('full' | 'standard' | 'minimal')
187
+ * @param {boolean} [config.enableOpenAPIGeneration] - Enable OpenAPI operation generation
188
+ * @param {Object} [config.userPreferences] - User preferences
189
+ * @param {boolean} [config.userPreferences.enableMCP] - Enable MCP
190
+ * @param {boolean} [config.userPreferences.enableABAC] - Enable ABAC
191
+ * @param {boolean} [config.userPreferences.enableRBAC] - Enable RBAC
127
192
  * @returns {Promise<Object>} Generated configuration response
128
193
  * @throws {Error} If request fails
129
194
  */
@@ -134,6 +199,24 @@ async function generateConfig(dataplaneUrl, authConfig, config) {
134
199
  });
135
200
  }
136
201
 
202
+ /**
203
+ * Generate configuration via AI (streaming)
204
+ * POST /api/v1/wizard/generate-config-stream
205
+ * @async
206
+ * @function generateConfigStream
207
+ * @param {string} dataplaneUrl - Dataplane base URL
208
+ * @param {Object} authConfig - Authentication configuration
209
+ * @param {Object} config - Generation configuration payload
210
+ * @returns {Promise<Object>} Streaming generation response
211
+ * @throws {Error} If request fails
212
+ */
213
+ async function generateConfigStream(dataplaneUrl, authConfig, config) {
214
+ const client = new ApiClient(dataplaneUrl, authConfig);
215
+ return await client.post('/api/v1/wizard/generate-config-stream', {
216
+ body: config
217
+ });
218
+ }
219
+
137
220
  /**
138
221
  * Validate wizard configuration
139
222
  * POST /api/v1/wizard/validate
@@ -142,20 +225,69 @@ async function generateConfig(dataplaneUrl, authConfig, config) {
142
225
  * @param {string} dataplaneUrl - Dataplane base URL
143
226
  * @param {Object} authConfig - Authentication configuration
144
227
  * @param {Object} systemConfig - System configuration to validate
145
- * @param {Object[]} datasourceConfigs - Array of datasource configurations to validate
228
+ * @param {Object|Object[]} datasourceConfig - Datasource configuration(s) to validate
146
229
  * @returns {Promise<Object>} Validation response
147
230
  * @throws {Error} If request fails
148
231
  */
149
- async function validateWizardConfig(dataplaneUrl, authConfig, systemConfig, datasourceConfigs) {
232
+ async function validateWizardConfig(dataplaneUrl, authConfig, systemConfig, datasourceConfig) {
150
233
  const client = new ApiClient(dataplaneUrl, authConfig);
151
234
  return await client.post('/api/v1/wizard/validate', {
152
235
  body: {
153
236
  systemConfig,
154
- datasourceConfigs
237
+ datasourceConfig
155
238
  }
156
239
  });
157
240
  }
158
241
 
242
+ /**
243
+ * Validate all completed wizard steps
244
+ * GET /api/v1/wizard/sessions/{sessionId}/validate
245
+ * @async
246
+ * @function validateAllSteps
247
+ * @param {string} dataplaneUrl - Dataplane base URL
248
+ * @param {string} sessionId - Session ID
249
+ * @param {Object} authConfig - Authentication configuration
250
+ * @returns {Promise<Object>} Validation response for all steps
251
+ * @throws {Error} If request fails
252
+ */
253
+ async function validateAllSteps(dataplaneUrl, sessionId, authConfig) {
254
+ const client = new ApiClient(dataplaneUrl, authConfig);
255
+ return await client.get(`/api/v1/wizard/sessions/${sessionId}/validate`);
256
+ }
257
+
258
+ /**
259
+ * Validate specific wizard step
260
+ * POST /api/v1/wizard/sessions/{sessionId}/validate-step
261
+ * @async
262
+ * @function validateStep
263
+ * @param {string} dataplaneUrl - Dataplane base URL
264
+ * @param {string} sessionId - Session ID
265
+ * @param {Object} authConfig - Authentication configuration
266
+ * @param {number} stepNumber - Step number to validate (1-7)
267
+ * @returns {Promise<Object>} Validation response for the step
268
+ * @throws {Error} If request fails
269
+ */
270
+ async function validateStep(dataplaneUrl, sessionId, authConfig, stepNumber) {
271
+ const client = new ApiClient(dataplaneUrl, authConfig);
272
+ return await client.post(`/api/v1/wizard/sessions/${sessionId}/validate-step?step=${stepNumber}`);
273
+ }
274
+
275
+ /**
276
+ * Get configuration preview with summaries
277
+ * GET /api/v1/wizard/preview/{sessionId}
278
+ * @async
279
+ * @function getPreview
280
+ * @param {string} dataplaneUrl - Dataplane base URL
281
+ * @param {string} sessionId - Session ID
282
+ * @param {Object} authConfig - Authentication configuration
283
+ * @returns {Promise<Object>} Preview response with system and datasource summaries
284
+ * @throws {Error} If request fails
285
+ */
286
+ async function getPreview(dataplaneUrl, sessionId, authConfig) {
287
+ const client = new ApiClient(dataplaneUrl, authConfig);
288
+ return await client.get(`/api/v1/wizard/preview/${sessionId}`);
289
+ }
290
+
159
291
  /**
160
292
  * Test MCP server connection
161
293
  * POST /api/v1/wizard/test-mcp-connection
@@ -198,11 +330,17 @@ module.exports = {
198
330
  createWizardSession,
199
331
  getWizardSession,
200
332
  updateWizardSession,
333
+ deleteWizardSession,
334
+ getWizardProgress,
201
335
  parseOpenApi,
336
+ credentialSelection,
202
337
  detectType,
203
338
  generateConfig,
339
+ generateConfigStream,
204
340
  validateWizardConfig,
341
+ validateAllSteps,
342
+ validateStep,
343
+ getPreview,
205
344
  testMcpConnection,
206
345
  getDeploymentDocs
207
346
  };
208
-