@aifabrix/builder 2.11.0 → 2.20.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.
- package/.cursor/rules/project-rules.mdc +194 -0
- package/README.md +12 -0
- package/lib/api/applications.api.js +164 -0
- package/lib/api/auth.api.js +304 -0
- package/lib/api/datasources-core.api.js +87 -0
- package/lib/api/datasources-extended.api.js +117 -0
- package/lib/api/datasources.api.js +13 -0
- package/lib/api/deployments.api.js +126 -0
- package/lib/api/environments.api.js +245 -0
- package/lib/api/external-systems.api.js +251 -0
- package/lib/api/index.js +221 -0
- package/lib/api/pipeline.api.js +234 -0
- package/lib/api/types/applications.types.js +136 -0
- package/lib/api/types/auth.types.js +218 -0
- package/lib/api/types/datasources.types.js +272 -0
- package/lib/api/types/deployments.types.js +184 -0
- package/lib/api/types/environments.types.js +197 -0
- package/lib/api/types/external-systems.types.js +244 -0
- package/lib/api/types/pipeline.types.js +125 -0
- package/lib/app-list.js +5 -7
- package/lib/app-rotate-secret.js +4 -10
- package/lib/commands/login.js +19 -12
- package/lib/datasource-deploy.js +7 -30
- package/lib/datasource-list.js +9 -6
- package/lib/deployer.js +103 -135
- package/lib/environment-deploy.js +15 -26
- package/lib/external-system-deploy.js +12 -39
- package/lib/external-system-download.js +5 -13
- package/lib/external-system-test.js +9 -12
- package/lib/utils/app-register-api.js +5 -10
- package/lib/utils/deployment-errors.js +88 -6
- package/package.json +1 -1
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Environments API type definitions
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pagination metadata
|
|
9
|
+
* @typedef {Object} PaginationMeta
|
|
10
|
+
* @property {number} page - Current page number
|
|
11
|
+
* @property {number} pageSize - Number of items per page
|
|
12
|
+
* @property {number} total - Total number of items
|
|
13
|
+
* @property {number} totalPages - Total number of pages
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Pagination links
|
|
18
|
+
* @typedef {Object} PaginationLinks
|
|
19
|
+
* @property {string} self - Current page URL
|
|
20
|
+
* @property {string} first - First page URL
|
|
21
|
+
* @property {string} last - Last page URL
|
|
22
|
+
* @property {string|null} prev - Previous page URL (null if on first page)
|
|
23
|
+
* @property {string|null} next - Next page URL (null if on last page)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Environment configuration (references environment-config.schema.yaml)
|
|
28
|
+
* @typedef {Object} EnvironmentConfig
|
|
29
|
+
* @property {string} key - Environment key
|
|
30
|
+
* @property {string} environment - Environment type ('dev' | 'tst' | 'pro' | 'miso')
|
|
31
|
+
* @property {string} preset - Deployment preset size
|
|
32
|
+
* @property {string} serviceName - Service name
|
|
33
|
+
* @property {string} location - Azure region location
|
|
34
|
+
* @property {*} [additionalProperties] - Additional configuration properties
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Environment entity
|
|
39
|
+
* @typedef {Object} Environment
|
|
40
|
+
* @property {string} id - Environment ID
|
|
41
|
+
* @property {string} key - Environment key
|
|
42
|
+
* @property {string} environment - Environment type ('dev' | 'tst' | 'pro' | 'miso')
|
|
43
|
+
* @property {EnvironmentConfig} configuration - Environment configuration
|
|
44
|
+
* @property {string} status - Environment status
|
|
45
|
+
* @property {string} createdAt - Creation timestamp (ISO 8601)
|
|
46
|
+
* @property {string} updatedAt - Update timestamp (ISO 8601)
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* List environments request options
|
|
51
|
+
* @typedef {Object} ListEnvironmentsRequest
|
|
52
|
+
* @property {number} [page] - Page number (default: 1)
|
|
53
|
+
* @property {number} [pageSize] - Items per page (default: 10)
|
|
54
|
+
* @property {string} [sort] - Sort parameter
|
|
55
|
+
* @property {string} [filter] - Filter parameter
|
|
56
|
+
* @property {string} [search] - Search term to match across key field
|
|
57
|
+
* @property {string} [environment] - Filter by environment type (legacy parameter)
|
|
58
|
+
* @property {string} [status] - Filter by status (legacy parameter)
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* List environments response
|
|
63
|
+
* @typedef {Object} ListEnvironmentsResponse
|
|
64
|
+
* @property {PaginationMeta} meta - Pagination metadata
|
|
65
|
+
* @property {Environment[]} data - Array of environments
|
|
66
|
+
* @property {PaginationLinks} links - Pagination links
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create environment request
|
|
71
|
+
* @typedef {Object} CreateEnvironmentRequest
|
|
72
|
+
* @property {string} key - Environment key (lowercase, numbers, hyphens only)
|
|
73
|
+
* @property {string} environment - Environment type ('dev' | 'tst' | 'pro')
|
|
74
|
+
* @property {EnvironmentConfig} configuration - Environment configuration
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create environment response
|
|
79
|
+
* @typedef {Object} CreateEnvironmentResponse
|
|
80
|
+
* @property {Environment} data - Created environment
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get environment response
|
|
85
|
+
* @typedef {Object} GetEnvironmentResponse
|
|
86
|
+
* @property {Environment} data - Environment details
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Update environment request
|
|
91
|
+
* @typedef {Object} UpdateEnvironmentRequest
|
|
92
|
+
* @property {EnvironmentConfig} [configuration] - Environment configuration
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Update environment response
|
|
97
|
+
* @typedef {Object} UpdateEnvironmentResponse
|
|
98
|
+
* @property {Environment} data - Updated environment
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Environment status
|
|
103
|
+
* @typedef {Object} EnvironmentStatus
|
|
104
|
+
* @property {number} id - Status ID
|
|
105
|
+
* @property {string} environmentId - Environment ID
|
|
106
|
+
* @property {string} status - Environment status ('healthy' | 'degraded' | 'deploying' | 'error' | 'maintenance')
|
|
107
|
+
* @property {Object} services - Services status object
|
|
108
|
+
* @property {number} resourceCount - Number of resources
|
|
109
|
+
* @property {number} costMonthly - Monthly cost
|
|
110
|
+
* @property {string} costCurrency - Cost currency
|
|
111
|
+
* @property {string|null} lastDeployment - Last deployment timestamp (ISO 8601)
|
|
112
|
+
* @property {string} healthCheckAt - Health check timestamp (ISO 8601)
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get environment status response
|
|
117
|
+
* @typedef {Object} GetEnvironmentStatusResponse
|
|
118
|
+
* @property {EnvironmentStatus} data - Environment status
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* List environment deployments request options
|
|
123
|
+
* @typedef {Object} ListEnvironmentDeploymentsRequest
|
|
124
|
+
* @property {number} [page] - Page number (default: 1)
|
|
125
|
+
* @property {number} [pageSize] - Items per page (default: 10)
|
|
126
|
+
* @property {string} [sort] - Sort parameter
|
|
127
|
+
* @property {string} [filter] - Filter parameter
|
|
128
|
+
* @property {string} [status] - Filter by deployment status (legacy parameter)
|
|
129
|
+
* @property {string} [deploymentType] - Filter by deployment type (legacy parameter)
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Deployment entity (for environment deployments list)
|
|
134
|
+
* @typedef {Object} Deployment
|
|
135
|
+
* @property {string} id - Deployment ID
|
|
136
|
+
* @property {string} deploymentType - Deployment type
|
|
137
|
+
* @property {string} status - Deployment status
|
|
138
|
+
* @property {number} progress - Deployment progress (0-100)
|
|
139
|
+
* @property {string} createdAt - Creation timestamp (ISO 8601)
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* List environment deployments response
|
|
144
|
+
* @typedef {Object} ListEnvironmentDeploymentsResponse
|
|
145
|
+
* @property {PaginationMeta} meta - Pagination metadata
|
|
146
|
+
* @property {Deployment[]} data - Array of deployments
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Role mapping
|
|
151
|
+
* @typedef {Object} RoleMapping
|
|
152
|
+
* @property {string} id - Mapping ID
|
|
153
|
+
* @property {string} groupName - Group name
|
|
154
|
+
* @property {string|null} groupId - Group ID
|
|
155
|
+
* @property {boolean} isActive - Whether mapping is active
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Environment role
|
|
160
|
+
* @typedef {Object} EnvironmentRole
|
|
161
|
+
* @property {string} id - Role ID
|
|
162
|
+
* @property {string} name - Role name
|
|
163
|
+
* @property {string} value - Role value
|
|
164
|
+
* @property {string|null} description - Role description
|
|
165
|
+
* @property {RoleMapping[]} mappings - Role mappings
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* List environment roles response
|
|
170
|
+
* @typedef {Object} ListEnvironmentRolesResponse
|
|
171
|
+
* @property {EnvironmentRole[]} data - Array of environment roles with mappings
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Role group mapping
|
|
176
|
+
* @typedef {Object} RoleGroupMapping
|
|
177
|
+
* @property {string} id - Mapping ID
|
|
178
|
+
* @property {string} roleId - Role ID
|
|
179
|
+
* @property {string} environmentId - Environment ID
|
|
180
|
+
* @property {string} groupName - Group name
|
|
181
|
+
* @property {boolean} isActive - Whether mapping is active
|
|
182
|
+
*/
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Update role groups request
|
|
186
|
+
* @typedef {Object} UpdateRoleGroupsRequest
|
|
187
|
+
* @property {string[]} groups - Array of group names (minItems: 1)
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Update role groups response
|
|
192
|
+
* @typedef {Object} UpdateRoleGroupsResponse
|
|
193
|
+
* @property {RoleGroupMapping[]} data - Array of role group mappings
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
module.exports = {};
|
|
197
|
+
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview External Systems API type definitions
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Pagination metadata
|
|
9
|
+
* @typedef {Object} PaginationMeta
|
|
10
|
+
* @property {number} page - Current page number
|
|
11
|
+
* @property {number} pageSize - Number of items per page
|
|
12
|
+
* @property {number} total - Total number of items
|
|
13
|
+
* @property {number} totalPages - Total number of pages
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Pagination links
|
|
18
|
+
* @typedef {Object} PaginationLinks
|
|
19
|
+
* @property {string} self - Current page URL
|
|
20
|
+
* @property {string} first - First page URL
|
|
21
|
+
* @property {string} last - Last page URL
|
|
22
|
+
* @property {string|null} prev - Previous page URL (null if on first page)
|
|
23
|
+
* @property {string|null} next - Next page URL (null if on last page)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* External system response
|
|
28
|
+
* @typedef {Object} ExternalSystemResponse
|
|
29
|
+
* @property {string} id - System ID
|
|
30
|
+
* @property {string} key - System key (unique identifier)
|
|
31
|
+
* @property {string} displayName - Display name
|
|
32
|
+
* @property {string|null} description - System description
|
|
33
|
+
* @property {string} type - System type ('openapi' | 'mcp' | 'custom')
|
|
34
|
+
* @property {string} status - Status ('draft' | 'published' | 'archived')
|
|
35
|
+
* @property {boolean} isActive - Whether system is active
|
|
36
|
+
* @property {Object} configuration - System configuration
|
|
37
|
+
* @property {string} createdAt - Creation timestamp (ISO 8601)
|
|
38
|
+
* @property {string} updatedAt - Update timestamp (ISO 8601)
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* External system create request
|
|
43
|
+
* @typedef {Object} ExternalSystemCreate
|
|
44
|
+
* @property {string} key - System key
|
|
45
|
+
* @property {string} displayName - Display name
|
|
46
|
+
* @property {string} [description] - Description
|
|
47
|
+
* @property {string} type - System type ('openapi' | 'mcp' | 'custom')
|
|
48
|
+
* @property {Object} [configuration] - System configuration
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* External system update request
|
|
53
|
+
* @typedef {Object} ExternalSystemUpdate
|
|
54
|
+
* @property {string} [displayName] - Display name
|
|
55
|
+
* @property {string} [description] - Description
|
|
56
|
+
* @property {Object} [configuration] - Configuration
|
|
57
|
+
* @property {boolean} [isActive] - Active status
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* External system config response (with dataSources)
|
|
62
|
+
* @typedef {Object} ExternalSystemConfigResponse
|
|
63
|
+
* @property {ExternalSystemResponse} application - External system application schema
|
|
64
|
+
* @property {Object[]} dataSources - Array of datasource configurations
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* List external systems request options
|
|
69
|
+
* @typedef {Object} ListExternalSystemsRequest
|
|
70
|
+
* @property {number} [page] - Page number (default: 1)
|
|
71
|
+
* @property {number} [pageSize] - Items per page (default: 20)
|
|
72
|
+
* @property {string} [sort] - Sort parameter
|
|
73
|
+
* @property {string} [filter] - Filter parameter
|
|
74
|
+
* @property {string} [search] - Search term
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* List external systems response
|
|
79
|
+
* @typedef {Object} ListExternalSystemsResponse
|
|
80
|
+
* @property {ExternalSystemResponse[]} items - Array of external systems
|
|
81
|
+
* @property {PaginationMeta} meta - Pagination metadata
|
|
82
|
+
* @property {PaginationLinks} links - Pagination links
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create external system request
|
|
87
|
+
* @typedef {ExternalSystemCreate} CreateExternalSystemRequest
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Create external system response
|
|
92
|
+
* @typedef {Object} CreateExternalSystemResponse
|
|
93
|
+
* @property {ExternalSystemResponse} data - Created external system
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get external system response
|
|
98
|
+
* @typedef {Object} GetExternalSystemResponse
|
|
99
|
+
* @property {ExternalSystemResponse} data - External system details
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Update external system request
|
|
104
|
+
* @typedef {ExternalSystemUpdate} UpdateExternalSystemRequest
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Update external system response
|
|
109
|
+
* @typedef {Object} UpdateExternalSystemResponse
|
|
110
|
+
* @property {ExternalSystemResponse} data - Updated external system
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Delete external system response
|
|
115
|
+
* @typedef {Object} DeleteExternalSystemResponse
|
|
116
|
+
* @property {null} data - Always null for DELETE operations
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get external system config response
|
|
121
|
+
* @typedef {Object} GetExternalSystemConfigResponse
|
|
122
|
+
* @property {ExternalSystemConfigResponse} data - Full config with application schema and dataSources
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Create from template request
|
|
127
|
+
* @typedef {Object} ExternalSystemCreateFromTemplate
|
|
128
|
+
* @property {string} templateIdOrKey - Integration template ID or key
|
|
129
|
+
* @property {string} key - System key
|
|
130
|
+
* @property {string} displayName - Display name
|
|
131
|
+
* @property {string} [description] - Description
|
|
132
|
+
* @property {Object} [configuration] - Override configuration
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Create from template request
|
|
137
|
+
* @typedef {ExternalSystemCreateFromTemplate} CreateFromTemplateRequest
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Create from template response
|
|
142
|
+
* @typedef {Object} CreateFromTemplateResponse
|
|
143
|
+
* @property {ExternalSystemResponse} data - Created external system (status='draft')
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* List OpenAPI files request options
|
|
148
|
+
* @typedef {Object} ListOpenAPIFilesRequest
|
|
149
|
+
* @property {number} [page] - Page number
|
|
150
|
+
* @property {number} [pageSize] - Items per page
|
|
151
|
+
* @property {string} [sort] - Sort parameter
|
|
152
|
+
* @property {string} [filter] - Filter parameter
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* List OpenAPI files response
|
|
157
|
+
* @typedef {Object} ListOpenAPIFilesResponse
|
|
158
|
+
* @property {Object[]} items - Array of OpenAPI files
|
|
159
|
+
* @property {PaginationMeta} meta - Pagination metadata
|
|
160
|
+
* @property {PaginationLinks} links - Pagination links
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* List OpenAPI endpoints request options
|
|
165
|
+
* @typedef {Object} ListOpenAPIEndpointsRequest
|
|
166
|
+
* @property {number} [page] - Page number
|
|
167
|
+
* @property {number} [pageSize] - Items per page
|
|
168
|
+
* @property {string} [sort] - Sort parameter
|
|
169
|
+
* @property {string} [filter] - Filter parameter
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* List OpenAPI endpoints response
|
|
174
|
+
* @typedef {Object} ListOpenAPIEndpointsResponse
|
|
175
|
+
* @property {Object[]} items - Array of OpenAPI endpoints
|
|
176
|
+
* @property {PaginationMeta} meta - Pagination metadata
|
|
177
|
+
* @property {PaginationLinks} links - Pagination links
|
|
178
|
+
*/
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Publish external system request
|
|
182
|
+
* @typedef {Object} ExternalSystemPublishRequest
|
|
183
|
+
* @property {boolean} [generateMcpContract] - Whether to generate MCP contract
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Publish external system request
|
|
188
|
+
* @typedef {ExternalSystemPublishRequest} PublishExternalSystemRequest
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Publish external system response
|
|
193
|
+
* @typedef {Object} PublishExternalSystemResponse
|
|
194
|
+
* @property {ExternalSystemResponse} data - Published external system
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Rollback external system request
|
|
199
|
+
* @typedef {Object} ExternalSystemRollbackRequest
|
|
200
|
+
* @property {number} version - Version to rollback to
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Rollback external system request
|
|
205
|
+
* @typedef {ExternalSystemRollbackRequest} RollbackExternalSystemRequest
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Rollback external system response
|
|
210
|
+
* @typedef {Object} RollbackExternalSystemResponse
|
|
211
|
+
* @property {ExternalSystemResponse} data - Rolled back external system
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Save template request
|
|
216
|
+
* @typedef {Object} ExternalSystemSaveTemplateRequest
|
|
217
|
+
* @property {string} templateKey - Template key
|
|
218
|
+
* @property {string} templateName - Template name
|
|
219
|
+
* @property {string} [description] - Template description
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Save template request
|
|
224
|
+
* @typedef {ExternalSystemSaveTemplateRequest} SaveAsTemplateRequest
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Integration template response
|
|
229
|
+
* @typedef {Object} IntegrationTemplateResponse
|
|
230
|
+
* @property {string} id - Template ID
|
|
231
|
+
* @property {string} key - Template key
|
|
232
|
+
* @property {string} name - Template name
|
|
233
|
+
* @property {string} [description] - Template description
|
|
234
|
+
* @property {Object} configuration - Template configuration
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Save template response
|
|
239
|
+
* @typedef {Object} SaveAsTemplateResponse
|
|
240
|
+
* @property {IntegrationTemplateResponse} data - Saved integration template
|
|
241
|
+
*/
|
|
242
|
+
|
|
243
|
+
module.exports = {};
|
|
244
|
+
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Pipeline API type definitions
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Application configuration (references application-config.schema.yaml)
|
|
9
|
+
* @typedef {Object} ApplicationConfig
|
|
10
|
+
* @property {string} key - Unique application identifier
|
|
11
|
+
* @property {string} displayName - Human-readable application name
|
|
12
|
+
* @property {string} description - Application description
|
|
13
|
+
* @property {string} type - Azure application type
|
|
14
|
+
* @property {string} deploymentKey - SHA256 hash of deployment manifest
|
|
15
|
+
* @property {*} [additionalProperties] - Additional configuration properties
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validation request
|
|
20
|
+
* @typedef {Object} ValidationRequest
|
|
21
|
+
* @property {string} clientId - Client ID for application authentication
|
|
22
|
+
* @property {string} repositoryUrl - Full repository URL for pipeline validation (GitHub, Azure DevOps, GitLab)
|
|
23
|
+
* @property {Object} applicationConfig - Application configuration
|
|
24
|
+
* @property {string} applicationConfig.key - Application key
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Validation response
|
|
29
|
+
* @typedef {Object} ValidationResponse
|
|
30
|
+
* @property {boolean} valid - Validation success flag
|
|
31
|
+
* @property {string|null} validateToken - One-time deployment token for /deploy endpoint (64 bytes, 512 bits entropy)
|
|
32
|
+
* @property {string|null} imageServer - Azure Container Registry server URL
|
|
33
|
+
* @property {string|null} imageUsername - ACR username for image push/pull
|
|
34
|
+
* @property {string|null} imagePassword - ACR password/token for image push/pull
|
|
35
|
+
* @property {string|null} expiresAt - Token expiration timestamp (ISO 8601)
|
|
36
|
+
* @property {string|null} draftDeploymentId - Draft deployment ID created during validation
|
|
37
|
+
* @property {string[]} errors - Array of validation errors (empty on success)
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Validate pipeline request
|
|
42
|
+
* @typedef {Object} ValidatePipelineRequest
|
|
43
|
+
* @property {string} clientId - Client ID (via x-client-id header or body)
|
|
44
|
+
* @property {string} repositoryUrl - Repository URL for validation
|
|
45
|
+
* @property {ApplicationConfig} applicationConfig - Application configuration to validate
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Validate pipeline response
|
|
50
|
+
* @typedef {Object} ValidatePipelineResponse
|
|
51
|
+
* @property {boolean} valid - Validation success flag
|
|
52
|
+
* @property {string|null} validateToken - One-time deployment token
|
|
53
|
+
* @property {string|null} imageServer - ACR server URL
|
|
54
|
+
* @property {string|null} imageUsername - ACR username
|
|
55
|
+
* @property {string|null} imagePassword - ACR password/token
|
|
56
|
+
* @property {string|null} expiresAt - Token expiration timestamp
|
|
57
|
+
* @property {string|null} draftDeploymentId - Draft deployment ID
|
|
58
|
+
* @property {string[]} errors - Validation errors array
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Deploy request
|
|
63
|
+
* @typedef {Object} DeployRequest
|
|
64
|
+
* @property {string} validateToken - One-time deployment token obtained from /validate endpoint (required)
|
|
65
|
+
* @property {string} imageTag - Container image tag to deploy (e.g., "latest", "v1.0.0", "main-abc123")
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Deploy pipeline request
|
|
70
|
+
* @typedef {Object} DeployPipelineRequest
|
|
71
|
+
* @property {string} validateToken - One-time deployment token (required)
|
|
72
|
+
* @property {string} imageTag - Container image tag to deploy
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Deploy pipeline response
|
|
77
|
+
* @typedef {Object} DeployPipelineResponse
|
|
78
|
+
* @property {boolean} success - Request success flag
|
|
79
|
+
* @property {string} deploymentId - Deployment ID
|
|
80
|
+
* @property {string} status - Deployment status (e.g., 'pending', 'deploying')
|
|
81
|
+
* @property {string|null} deploymentUrl - Deployment URL if available
|
|
82
|
+
* @property {string|null} healthCheckUrl - Health check URL if available
|
|
83
|
+
* @property {string} message - Deployment message
|
|
84
|
+
* @property {string} timestamp - Timestamp when deployment was initiated (ISO 8601)
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Pipeline deployment status
|
|
89
|
+
* @typedef {Object} PipelineDeploymentStatus
|
|
90
|
+
* @property {string} id - Deployment ID
|
|
91
|
+
* @property {string} status - Deployment status ('pending' | 'deploying' | 'completed' | 'failed')
|
|
92
|
+
* @property {number} progress - Deployment progress percentage (0-100)
|
|
93
|
+
* @property {string|null} message - Deployment message if available
|
|
94
|
+
* @property {string|null} error - Error message if deployment failed
|
|
95
|
+
* @property {string|null} startedAt - Deployment start timestamp (ISO 8601)
|
|
96
|
+
* @property {string|null} completedAt - Deployment completion timestamp (ISO 8601)
|
|
97
|
+
* @property {string|null} deploymentUrl - Deployment URL if available
|
|
98
|
+
* @property {string|null} healthCheckUrl - Health check URL if available
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Get pipeline deployment request
|
|
103
|
+
* @typedef {Object} GetPipelineDeploymentRequest
|
|
104
|
+
* @property {string} deploymentId - Deployment ID
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get pipeline deployment response
|
|
109
|
+
* @typedef {Object} GetPipelineDeploymentResponse
|
|
110
|
+
* @property {boolean} success - Request success flag
|
|
111
|
+
* @property {PipelineDeploymentStatus} data - Minimal deployment status
|
|
112
|
+
* @property {string} timestamp - Response timestamp (ISO 8601)
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Pipeline health check response
|
|
117
|
+
* @typedef {Object} GetPipelineHealthResponse
|
|
118
|
+
* @property {boolean} success - Request success flag
|
|
119
|
+
* @property {Object} data - Health check data
|
|
120
|
+
* @property {boolean} data.healthy - Health status
|
|
121
|
+
* @property {string} data.environment - Environment key
|
|
122
|
+
*/
|
|
123
|
+
|
|
124
|
+
module.exports = {};
|
|
125
|
+
|
package/lib/app-list.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const chalk = require('chalk');
|
|
12
12
|
const { getConfig } = require('./config');
|
|
13
13
|
const { getOrRefreshDeviceToken } = require('./utils/token-manager');
|
|
14
|
-
const {
|
|
14
|
+
const { listEnvironmentApplications } = require('./api/environments.api');
|
|
15
15
|
const { formatApiError } = require('./utils/api-error-handler');
|
|
16
16
|
const logger = require('./utils/logger');
|
|
17
17
|
|
|
@@ -22,7 +22,7 @@ const logger = require('./utils/logger');
|
|
|
22
22
|
* 2. Direct array: { success: true, data: [...] }
|
|
23
23
|
* 3. Paginated format: { success: true, data: { items: [...] } }
|
|
24
24
|
* 4. Wrapped paginated: { success: true, data: { success: true, data: { items: [...] } } }
|
|
25
|
-
* @param {Object} response - API response from
|
|
25
|
+
* @param {Object} response - API response from centralized API client
|
|
26
26
|
* @returns {Array} Array of applications
|
|
27
27
|
* @throws {Error} If response format is invalid
|
|
28
28
|
*/
|
|
@@ -109,11 +109,9 @@ async function listApplications(options) {
|
|
|
109
109
|
process.exit(1);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
token
|
|
116
|
-
);
|
|
112
|
+
// Use centralized API client
|
|
113
|
+
const authConfig = { type: 'bearer', token: token };
|
|
114
|
+
const response = await listEnvironmentApplications(controllerUrl, options.environment, authConfig);
|
|
117
115
|
|
|
118
116
|
if (!response.success || !response.data) {
|
|
119
117
|
const formattedError = response.formattedError || formatApiError(response);
|
package/lib/app-rotate-secret.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const chalk = require('chalk');
|
|
12
12
|
const { getConfig } = require('./config');
|
|
13
13
|
const { getOrRefreshDeviceToken } = require('./utils/token-manager');
|
|
14
|
-
const {
|
|
14
|
+
const { rotateApplicationSecret } = require('./api/applications.api');
|
|
15
15
|
const { formatApiError } = require('./utils/api-error-handler');
|
|
16
16
|
const logger = require('./utils/logger');
|
|
17
17
|
const { saveLocalSecret, isLocalhost } = require('./utils/local-secrets');
|
|
@@ -115,15 +115,9 @@ async function rotateSecret(appKey, options) {
|
|
|
115
115
|
// Validate environment
|
|
116
116
|
validateEnvironment(options.environment);
|
|
117
117
|
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
const response = await
|
|
121
|
-
`${controllerUrl}/api/v1/environments/${encodeURIComponent(options.environment)}/applications/${encodeURIComponent(appKey)}/rotate-secret`,
|
|
122
|
-
{
|
|
123
|
-
method: 'POST'
|
|
124
|
-
},
|
|
125
|
-
token
|
|
126
|
-
);
|
|
118
|
+
// Use centralized API client
|
|
119
|
+
const authConfig = { type: 'bearer', token: token };
|
|
120
|
+
const response = await rotateApplicationSecret(controllerUrl, options.environment, appKey, authConfig);
|
|
127
121
|
|
|
128
122
|
if (!response.success) {
|
|
129
123
|
const formattedError = response.formattedError || formatApiError(response);
|
package/lib/commands/login.js
CHANGED
|
@@ -13,7 +13,8 @@ const inquirer = require('inquirer');
|
|
|
13
13
|
const chalk = require('chalk');
|
|
14
14
|
const ora = require('ora');
|
|
15
15
|
const { setCurrentEnvironment, saveDeviceToken, saveClientToken } = require('../config');
|
|
16
|
-
const {
|
|
16
|
+
const { getToken, initiateDeviceCodeFlow } = require('../api/auth.api');
|
|
17
|
+
const { pollDeviceCodeToken, displayDeviceCodeInfo } = require('../utils/api');
|
|
17
18
|
const { formatApiError } = require('../utils/api-error-handler');
|
|
18
19
|
const { loadClientCredentials } = require('../utils/token-manager');
|
|
19
20
|
const logger = require('../utils/logger');
|
|
@@ -187,16 +188,8 @@ async function handleCredentialsLogin(controllerUrl, appName, clientId, clientSe
|
|
|
187
188
|
credentials = await promptForCredentials(clientId, clientSecret);
|
|
188
189
|
}
|
|
189
190
|
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
const response = await makeApiCall(`${controllerUrl}/api/v1/auth/token`, {
|
|
193
|
-
method: 'POST',
|
|
194
|
-
headers: {
|
|
195
|
-
'Content-Type': 'application/json',
|
|
196
|
-
'x-client-id': credentials.clientId,
|
|
197
|
-
'x-client-secret': credentials.clientSecret
|
|
198
|
-
}
|
|
199
|
-
});
|
|
191
|
+
// Use centralized API client for token generation
|
|
192
|
+
const response = await getToken(credentials.clientId, credentials.clientSecret, controllerUrl);
|
|
200
193
|
|
|
201
194
|
if (!response.success) {
|
|
202
195
|
const formattedError = response.formattedError || formatApiError(response);
|
|
@@ -346,7 +339,21 @@ async function handleDeviceCodeLogin(controllerUrl, environment, offline, scope)
|
|
|
346
339
|
}
|
|
347
340
|
|
|
348
341
|
try {
|
|
349
|
-
|
|
342
|
+
// Use centralized API client for device code flow initiation
|
|
343
|
+
const deviceCodeApiResponse = await initiateDeviceCodeFlow(controllerUrl, envKey, requestScope);
|
|
344
|
+
|
|
345
|
+
// Handle API response format: { success: boolean, data: DeviceCodeResponse }
|
|
346
|
+
const apiResponse = deviceCodeApiResponse.data;
|
|
347
|
+
const deviceCodeData = apiResponse.data || apiResponse;
|
|
348
|
+
|
|
349
|
+
// Convert camelCase from API to snake_case for compatibility with existing code
|
|
350
|
+
const deviceCodeResponse = {
|
|
351
|
+
device_code: deviceCodeData.deviceCode || deviceCodeData.device_code,
|
|
352
|
+
user_code: deviceCodeData.userCode || deviceCodeData.user_code,
|
|
353
|
+
verification_uri: deviceCodeData.verificationUri || deviceCodeData.verification_uri,
|
|
354
|
+
expires_in: deviceCodeData.expiresIn || deviceCodeData.expires_in || 600,
|
|
355
|
+
interval: deviceCodeData.interval || 5
|
|
356
|
+
};
|
|
350
357
|
|
|
351
358
|
displayDeviceCodeInfo(deviceCodeResponse.user_code, deviceCodeResponse.verification_uri, logger, chalk);
|
|
352
359
|
|