@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,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Authentication API functions
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { ApiClient } = require('./index');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get authentication token using client credentials
|
|
11
|
+
* POST /api/v1/auth/token
|
|
12
|
+
* @async
|
|
13
|
+
* @function getToken
|
|
14
|
+
* @param {string} clientId - Client ID
|
|
15
|
+
* @param {string} clientSecret - Client secret
|
|
16
|
+
* @param {string} controllerUrl - Controller base URL
|
|
17
|
+
* @returns {Promise<Object>} Token response with access token
|
|
18
|
+
* @throws {Error} If authentication fails
|
|
19
|
+
*/
|
|
20
|
+
async function getToken(clientId, clientSecret, controllerUrl) {
|
|
21
|
+
const client = new ApiClient(controllerUrl, {
|
|
22
|
+
type: 'client-credentials',
|
|
23
|
+
clientId,
|
|
24
|
+
clientSecret
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return await client.post('/api/v1/auth/token');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get client token for frontend application
|
|
32
|
+
* GET/POST /api/v1/auth/client-token
|
|
33
|
+
* @async
|
|
34
|
+
* @function getClientToken
|
|
35
|
+
* @param {string} controllerUrl - Controller base URL
|
|
36
|
+
* @param {string} [method] - HTTP method ('GET' or 'POST', default: 'POST')
|
|
37
|
+
* @returns {Promise<Object>} Client token response
|
|
38
|
+
* @throws {Error} If token generation fails
|
|
39
|
+
*/
|
|
40
|
+
async function getClientToken(controllerUrl, method = 'POST') {
|
|
41
|
+
const client = new ApiClient(controllerUrl);
|
|
42
|
+
|
|
43
|
+
if (method === 'GET') {
|
|
44
|
+
return await client.get('/api/v1/auth/client-token');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return await client.post('/api/v1/auth/client-token');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get current user information
|
|
52
|
+
* GET /api/v1/auth/user
|
|
53
|
+
* @async
|
|
54
|
+
* @function getAuthUser
|
|
55
|
+
* @param {string} controllerUrl - Controller base URL
|
|
56
|
+
* @param {Object} authConfig - Authentication configuration
|
|
57
|
+
* @returns {Promise<Object>} User information response
|
|
58
|
+
* @throws {Error} If request fails
|
|
59
|
+
*/
|
|
60
|
+
async function getAuthUser(controllerUrl, authConfig) {
|
|
61
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
62
|
+
return await client.get('/api/v1/auth/user');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get login URL for OAuth2 authorization flow
|
|
67
|
+
* GET /api/v1/auth/login
|
|
68
|
+
* @async
|
|
69
|
+
* @function getAuthLogin
|
|
70
|
+
* @param {string} controllerUrl - Controller base URL
|
|
71
|
+
* @param {string} redirect - Redirect URI for OAuth2 callback
|
|
72
|
+
* @param {string} [state] - State parameter for CSRF protection
|
|
73
|
+
* @param {Object} authConfig - Authentication configuration
|
|
74
|
+
* @returns {Promise<Object>} Login URL response
|
|
75
|
+
* @throws {Error} If request fails
|
|
76
|
+
*/
|
|
77
|
+
async function getAuthLogin(controllerUrl, redirect, state, authConfig) {
|
|
78
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
79
|
+
return await client.get('/api/v1/auth/login', {
|
|
80
|
+
params: { redirect, state }
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Initiate OAuth2 Device Code Flow
|
|
86
|
+
* POST /api/v1/auth/login
|
|
87
|
+
* @async
|
|
88
|
+
* @function initiateDeviceCodeFlow
|
|
89
|
+
* @param {string} controllerUrl - Controller base URL
|
|
90
|
+
* @param {string} [environment] - Environment key
|
|
91
|
+
* @param {string} [scope] - OAuth2 scope string (defaults to 'openid profile email')
|
|
92
|
+
* @returns {Promise<Object>} Device code response
|
|
93
|
+
* @throws {Error} If device code flow initiation fails
|
|
94
|
+
*/
|
|
95
|
+
async function initiateDeviceCodeFlow(controllerUrl, environment, scope) {
|
|
96
|
+
const client = new ApiClient(controllerUrl);
|
|
97
|
+
const body = {};
|
|
98
|
+
|
|
99
|
+
if (environment) {
|
|
100
|
+
body.environment = environment;
|
|
101
|
+
}
|
|
102
|
+
if (scope) {
|
|
103
|
+
body.scope = scope;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Use query params if environment provided (per OpenAPI spec)
|
|
107
|
+
if (environment) {
|
|
108
|
+
const params = { environment };
|
|
109
|
+
if (scope) {
|
|
110
|
+
params.scope = scope;
|
|
111
|
+
}
|
|
112
|
+
return await client.post('/api/v1/auth/login', {
|
|
113
|
+
params
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Otherwise use body
|
|
118
|
+
return await client.post('/api/v1/auth/login', {
|
|
119
|
+
body: Object.keys(body).length > 0 ? body : undefined
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Poll for device code token
|
|
125
|
+
* POST /api/v1/auth/login/device/token
|
|
126
|
+
* @async
|
|
127
|
+
* @function pollDeviceCodeToken
|
|
128
|
+
* @param {string} deviceCode - Device code from initiate device code flow
|
|
129
|
+
* @param {string} controllerUrl - Controller base URL
|
|
130
|
+
* @returns {Promise<Object>} Token response (may return 202 with authorization_pending)
|
|
131
|
+
* @throws {Error} If polling fails
|
|
132
|
+
*/
|
|
133
|
+
async function pollDeviceCodeToken(deviceCode, controllerUrl) {
|
|
134
|
+
const client = new ApiClient(controllerUrl);
|
|
135
|
+
return await client.post('/api/v1/auth/login/device/token', {
|
|
136
|
+
body: { deviceCode }
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Refresh device code access token
|
|
142
|
+
* POST /api/v1/auth/login/device/refresh
|
|
143
|
+
* @async
|
|
144
|
+
* @function refreshDeviceToken
|
|
145
|
+
* @param {string} refreshToken - Refresh token obtained from device code token flow
|
|
146
|
+
* @param {string} controllerUrl - Controller base URL
|
|
147
|
+
* @returns {Promise<Object>} New token response
|
|
148
|
+
* @throws {Error} If token refresh fails
|
|
149
|
+
*/
|
|
150
|
+
async function refreshDeviceToken(refreshToken, controllerUrl) {
|
|
151
|
+
const client = new ApiClient(controllerUrl);
|
|
152
|
+
return await client.post('/api/v1/auth/login/device/refresh', {
|
|
153
|
+
body: { refreshToken }
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Refresh user access token
|
|
159
|
+
* POST /api/v1/auth/refresh
|
|
160
|
+
* @async
|
|
161
|
+
* @function refreshUserToken
|
|
162
|
+
* @param {string} refreshToken - Refresh token obtained from OAuth callback flow
|
|
163
|
+
* @param {string} controllerUrl - Controller base URL
|
|
164
|
+
* @returns {Promise<Object>} New token response
|
|
165
|
+
* @throws {Error} If token refresh fails
|
|
166
|
+
*/
|
|
167
|
+
async function refreshUserToken(refreshToken, controllerUrl) {
|
|
168
|
+
const client = new ApiClient(controllerUrl);
|
|
169
|
+
return await client.post('/api/v1/auth/refresh', {
|
|
170
|
+
body: { refreshToken }
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Validate authentication token
|
|
176
|
+
* POST /api/v1/auth/validate
|
|
177
|
+
* @async
|
|
178
|
+
* @function validateToken
|
|
179
|
+
* @param {string} token - JWT token to validate
|
|
180
|
+
* @param {string} controllerUrl - Controller base URL
|
|
181
|
+
* @param {Object} authConfig - Authentication configuration
|
|
182
|
+
* @param {string} [environment] - Optional environment key
|
|
183
|
+
* @param {string} [application] - Optional application key
|
|
184
|
+
* @returns {Promise<Object>} Token validation response
|
|
185
|
+
* @throws {Error} If validation fails
|
|
186
|
+
*/
|
|
187
|
+
async function validateToken(token, controllerUrl, authConfig, environment, application) {
|
|
188
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
189
|
+
const body = { token };
|
|
190
|
+
|
|
191
|
+
if (environment) {
|
|
192
|
+
body.environment = environment;
|
|
193
|
+
}
|
|
194
|
+
if (application) {
|
|
195
|
+
body.application = application;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return await client.post('/api/v1/auth/validate', {
|
|
199
|
+
body
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Get user roles
|
|
205
|
+
* GET /api/v1/auth/roles
|
|
206
|
+
* @async
|
|
207
|
+
* @function getAuthRoles
|
|
208
|
+
* @param {string} controllerUrl - Controller base URL
|
|
209
|
+
* @param {Object} authConfig - Authentication configuration
|
|
210
|
+
* @param {string} [environment] - Optional environment key filter
|
|
211
|
+
* @param {string} [application] - Optional application key filter
|
|
212
|
+
* @returns {Promise<Object>} User roles response
|
|
213
|
+
* @throws {Error} If request fails
|
|
214
|
+
*/
|
|
215
|
+
async function getAuthRoles(controllerUrl, authConfig, environment, application) {
|
|
216
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
217
|
+
return await client.get('/api/v1/auth/roles', {
|
|
218
|
+
params: { environment, application }
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Refresh user roles
|
|
224
|
+
* GET /api/v1/auth/roles/refresh
|
|
225
|
+
* @async
|
|
226
|
+
* @function refreshAuthRoles
|
|
227
|
+
* @param {string} controllerUrl - Controller base URL
|
|
228
|
+
* @param {Object} authConfig - Authentication configuration
|
|
229
|
+
* @returns {Promise<Object>} Refreshed roles response
|
|
230
|
+
* @throws {Error} If request fails
|
|
231
|
+
*/
|
|
232
|
+
async function refreshAuthRoles(controllerUrl, authConfig) {
|
|
233
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
234
|
+
return await client.get('/api/v1/auth/roles/refresh');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Get user permissions
|
|
239
|
+
* GET /api/v1/auth/permissions
|
|
240
|
+
* @async
|
|
241
|
+
* @function getAuthPermissions
|
|
242
|
+
* @param {string} controllerUrl - Controller base URL
|
|
243
|
+
* @param {Object} authConfig - Authentication configuration
|
|
244
|
+
* @param {string} [environment] - Optional environment key filter
|
|
245
|
+
* @param {string} [application] - Optional application key filter
|
|
246
|
+
* @returns {Promise<Object>} User permissions response
|
|
247
|
+
* @throws {Error} If request fails
|
|
248
|
+
*/
|
|
249
|
+
async function getAuthPermissions(controllerUrl, authConfig, environment, application) {
|
|
250
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
251
|
+
return await client.get('/api/v1/auth/permissions', {
|
|
252
|
+
params: { environment, application }
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Refresh user permissions
|
|
258
|
+
* GET /api/v1/auth/permissions/refresh
|
|
259
|
+
* @async
|
|
260
|
+
* @function refreshAuthPermissions
|
|
261
|
+
* @param {string} controllerUrl - Controller base URL
|
|
262
|
+
* @param {Object} authConfig - Authentication configuration
|
|
263
|
+
* @returns {Promise<Object>} Refreshed permissions response
|
|
264
|
+
* @throws {Error} If request fails
|
|
265
|
+
*/
|
|
266
|
+
async function refreshAuthPermissions(controllerUrl, authConfig) {
|
|
267
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
268
|
+
return await client.get('/api/v1/auth/permissions/refresh');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Get device code login diagnostics
|
|
273
|
+
* GET /api/v1/auth/login/diagnostics
|
|
274
|
+
* @async
|
|
275
|
+
* @function getAuthLoginDiagnostics
|
|
276
|
+
* @param {string} controllerUrl - Controller base URL
|
|
277
|
+
* @param {string} [environment] - Optional environment key
|
|
278
|
+
* @returns {Promise<Object>} Diagnostic information response
|
|
279
|
+
* @throws {Error} If request fails
|
|
280
|
+
*/
|
|
281
|
+
async function getAuthLoginDiagnostics(controllerUrl, environment) {
|
|
282
|
+
const client = new ApiClient(controllerUrl);
|
|
283
|
+
return await client.get('/api/v1/auth/login/diagnostics', {
|
|
284
|
+
params: { environment }
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
module.exports = {
|
|
289
|
+
getToken,
|
|
290
|
+
getClientToken,
|
|
291
|
+
getAuthUser,
|
|
292
|
+
getAuthLogin,
|
|
293
|
+
initiateDeviceCodeFlow,
|
|
294
|
+
pollDeviceCodeToken,
|
|
295
|
+
refreshDeviceToken,
|
|
296
|
+
refreshUserToken,
|
|
297
|
+
validateToken,
|
|
298
|
+
getAuthRoles,
|
|
299
|
+
refreshAuthRoles,
|
|
300
|
+
getAuthPermissions,
|
|
301
|
+
refreshAuthPermissions,
|
|
302
|
+
getAuthLoginDiagnostics
|
|
303
|
+
};
|
|
304
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Datasources Core API functions
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { ApiClient } = require('./index');
|
|
8
|
+
|
|
9
|
+
async function listDatasources(dataplaneUrl, authConfig, options = {}) {
|
|
10
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
11
|
+
return await client.get('/api/v1/external/', { params: options });
|
|
12
|
+
}
|
|
13
|
+
async function createDatasource(dataplaneUrl, authConfig, datasourceData) {
|
|
14
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
15
|
+
return await client.post('/api/v1/external/', { body: datasourceData });
|
|
16
|
+
}
|
|
17
|
+
async function getDatasource(dataplaneUrl, sourceIdOrKey, authConfig) {
|
|
18
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
19
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}`);
|
|
20
|
+
}
|
|
21
|
+
async function updateDatasource(dataplaneUrl, sourceIdOrKey, authConfig, updateData) {
|
|
22
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
23
|
+
return await client.put(`/api/v1/external/${sourceIdOrKey}`, { body: updateData });
|
|
24
|
+
}
|
|
25
|
+
async function deleteDatasource(dataplaneUrl, sourceIdOrKey, authConfig) {
|
|
26
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
27
|
+
return await client.delete(`/api/v1/external/${sourceIdOrKey}`);
|
|
28
|
+
}
|
|
29
|
+
async function getDatasourceConfig(dataplaneUrl, sourceIdOrKey, authConfig) {
|
|
30
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
31
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/config`);
|
|
32
|
+
}
|
|
33
|
+
async function publishDatasource(dataplaneUrl, sourceIdOrKey, authConfig, publishData = {}) {
|
|
34
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
35
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/publish`, { body: publishData });
|
|
36
|
+
}
|
|
37
|
+
async function rollbackDatasource(dataplaneUrl, sourceIdOrKey, authConfig, rollbackData) {
|
|
38
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
39
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/rollback`, { body: rollbackData });
|
|
40
|
+
}
|
|
41
|
+
async function testDatasource(dataplaneUrl, sourceIdOrKey, authConfig, testData = {}) {
|
|
42
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
43
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/test`, { body: testData });
|
|
44
|
+
}
|
|
45
|
+
async function listDatasourceOpenAPIEndpoints(dataplaneUrl, sourceIdOrKey, authConfig, options = {}) {
|
|
46
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
47
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/openapi-endpoints`, { params: options });
|
|
48
|
+
}
|
|
49
|
+
async function listExecutionLogs(dataplaneUrl, sourceIdOrKey, authConfig, options = {}) {
|
|
50
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
51
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/executions`, { params: options });
|
|
52
|
+
}
|
|
53
|
+
async function getExecutionLog(dataplaneUrl, sourceIdOrKey, executionId, authConfig) {
|
|
54
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
55
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/executions/${executionId}`);
|
|
56
|
+
}
|
|
57
|
+
async function listAllExecutionLogs(dataplaneUrl, authConfig, options = {}) {
|
|
58
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
59
|
+
return await client.get('/api/v1/external/executions', { params: options });
|
|
60
|
+
}
|
|
61
|
+
async function bulkOperation(dataplaneUrl, sourceIdOrKey, authConfig, bulkData) {
|
|
62
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
63
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/bulk`, { body: bulkData });
|
|
64
|
+
}
|
|
65
|
+
async function getDatasourceStatus(dataplaneUrl, sourceIdOrKey, authConfig) {
|
|
66
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
67
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/status`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = {
|
|
71
|
+
listDatasources,
|
|
72
|
+
createDatasource,
|
|
73
|
+
getDatasource,
|
|
74
|
+
updateDatasource,
|
|
75
|
+
deleteDatasource,
|
|
76
|
+
getDatasourceConfig,
|
|
77
|
+
publishDatasource,
|
|
78
|
+
rollbackDatasource,
|
|
79
|
+
testDatasource,
|
|
80
|
+
listDatasourceOpenAPIEndpoints,
|
|
81
|
+
listExecutionLogs,
|
|
82
|
+
getExecutionLog,
|
|
83
|
+
listAllExecutionLogs,
|
|
84
|
+
bulkOperation,
|
|
85
|
+
getDatasourceStatus
|
|
86
|
+
};
|
|
87
|
+
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Datasources Extended API functions (records, grants, policies, sync, documents)
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { ApiClient } = require('./index');
|
|
8
|
+
|
|
9
|
+
async function listRecords(dataplaneUrl, sourceIdOrKey, authConfig, options = {}) {
|
|
10
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
11
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/records`, { params: options });
|
|
12
|
+
}
|
|
13
|
+
async function createRecord(dataplaneUrl, sourceIdOrKey, authConfig, recordData) {
|
|
14
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
15
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/records`, { body: recordData });
|
|
16
|
+
}
|
|
17
|
+
async function getRecord(dataplaneUrl, sourceIdOrKey, recordIdOrKey, authConfig) {
|
|
18
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
19
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/records/${recordIdOrKey}`);
|
|
20
|
+
}
|
|
21
|
+
async function updateRecord(dataplaneUrl, sourceIdOrKey, recordIdOrKey, authConfig, updateData) {
|
|
22
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
23
|
+
return await client.put(`/api/v1/external/${sourceIdOrKey}/records/${recordIdOrKey}`, { body: updateData });
|
|
24
|
+
}
|
|
25
|
+
async function deleteRecord(dataplaneUrl, sourceIdOrKey, recordIdOrKey, authConfig) {
|
|
26
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
27
|
+
return await client.delete(`/api/v1/external/${sourceIdOrKey}/records/${recordIdOrKey}`);
|
|
28
|
+
}
|
|
29
|
+
async function listGrants(dataplaneUrl, sourceIdOrKey, authConfig, options = {}) {
|
|
30
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
31
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/grants`, { params: options });
|
|
32
|
+
}
|
|
33
|
+
async function createGrant(dataplaneUrl, sourceIdOrKey, authConfig, grantData) {
|
|
34
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
35
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/grants`, { body: grantData });
|
|
36
|
+
}
|
|
37
|
+
async function getGrant(dataplaneUrl, sourceIdOrKey, grantIdOrKey, authConfig) {
|
|
38
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
39
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/grants/${grantIdOrKey}`);
|
|
40
|
+
}
|
|
41
|
+
async function updateGrant(dataplaneUrl, sourceIdOrKey, grantIdOrKey, authConfig, updateData) {
|
|
42
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
43
|
+
return await client.put(`/api/v1/external/${sourceIdOrKey}/grants/${grantIdOrKey}`, { body: updateData });
|
|
44
|
+
}
|
|
45
|
+
async function deleteGrant(dataplaneUrl, sourceIdOrKey, grantIdOrKey, authConfig) {
|
|
46
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
47
|
+
return await client.delete(`/api/v1/external/${sourceIdOrKey}/grants/${grantIdOrKey}`);
|
|
48
|
+
}
|
|
49
|
+
async function listPolicies(dataplaneUrl, sourceIdOrKey, authConfig, options = {}) {
|
|
50
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
51
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/policies`, { params: options });
|
|
52
|
+
}
|
|
53
|
+
async function attachPolicy(dataplaneUrl, sourceIdOrKey, authConfig, policyData) {
|
|
54
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
55
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/policies`, { body: policyData });
|
|
56
|
+
}
|
|
57
|
+
async function detachPolicy(dataplaneUrl, sourceIdOrKey, policyIdOrKey, authConfig) {
|
|
58
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
59
|
+
return await client.delete(`/api/v1/external/${sourceIdOrKey}/policies/${policyIdOrKey}`);
|
|
60
|
+
}
|
|
61
|
+
async function listSyncJobs(dataplaneUrl, sourceIdOrKey, authConfig, options = {}) {
|
|
62
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
63
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/sync`, { params: options });
|
|
64
|
+
}
|
|
65
|
+
async function createSyncJob(dataplaneUrl, sourceIdOrKey, authConfig, syncData) {
|
|
66
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
67
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/sync`, { body: syncData });
|
|
68
|
+
}
|
|
69
|
+
async function getSyncJob(dataplaneUrl, sourceIdOrKey, syncJobId, authConfig) {
|
|
70
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
71
|
+
return await client.get(`/api/v1/external/${sourceIdOrKey}/sync/${syncJobId}`);
|
|
72
|
+
}
|
|
73
|
+
async function updateSyncJob(dataplaneUrl, sourceIdOrKey, syncJobId, authConfig, updateData) {
|
|
74
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
75
|
+
return await client.put(`/api/v1/external/${sourceIdOrKey}/sync/${syncJobId}`, { body: updateData });
|
|
76
|
+
}
|
|
77
|
+
async function executeSyncJob(dataplaneUrl, sourceIdOrKey, syncJobId, authConfig) {
|
|
78
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
79
|
+
return await client.post(`/api/v1/external/${sourceIdOrKey}/sync/${syncJobId}/execute`);
|
|
80
|
+
}
|
|
81
|
+
async function validateDocuments(dataplaneUrl, sourceIdOrKey, authConfig, validateData) {
|
|
82
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
83
|
+
return await client.post(`/api/v1/external/data-sources/${sourceIdOrKey}/documents/validate`, { body: validateData });
|
|
84
|
+
}
|
|
85
|
+
async function bulkDocuments(dataplaneUrl, sourceIdOrKey, authConfig, bulkData) {
|
|
86
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
87
|
+
return await client.post(`/api/v1/external/data-sources/${sourceIdOrKey}/documents/bulk`, { body: bulkData });
|
|
88
|
+
}
|
|
89
|
+
async function listDocuments(dataplaneUrl, sourceIdOrKey, authConfig, options = {}) {
|
|
90
|
+
const client = new ApiClient(dataplaneUrl, authConfig);
|
|
91
|
+
return await client.get(`/api/v1/external/data-sources/${sourceIdOrKey}/documents`, { params: options });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = {
|
|
95
|
+
listRecords,
|
|
96
|
+
createRecord,
|
|
97
|
+
getRecord,
|
|
98
|
+
updateRecord,
|
|
99
|
+
deleteRecord,
|
|
100
|
+
listGrants,
|
|
101
|
+
createGrant,
|
|
102
|
+
getGrant,
|
|
103
|
+
updateGrant,
|
|
104
|
+
deleteGrant,
|
|
105
|
+
listPolicies,
|
|
106
|
+
attachPolicy,
|
|
107
|
+
detachPolicy,
|
|
108
|
+
listSyncJobs,
|
|
109
|
+
createSyncJob,
|
|
110
|
+
getSyncJob,
|
|
111
|
+
updateSyncJob,
|
|
112
|
+
executeSyncJob,
|
|
113
|
+
validateDocuments,
|
|
114
|
+
bulkDocuments,
|
|
115
|
+
listDocuments
|
|
116
|
+
};
|
|
117
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Datasources API functions
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const coreApi = require('./datasources-core.api');
|
|
8
|
+
const extendedApi = require('./datasources-extended.api');
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
...coreApi,
|
|
12
|
+
...extendedApi
|
|
13
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Deployments API functions
|
|
3
|
+
* @author AI Fabrix Team
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { ApiClient } = require('./index');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Deploy an application to an environment
|
|
11
|
+
* POST /api/v1/environments/{envKey}/applications/deploy
|
|
12
|
+
* @async
|
|
13
|
+
* @function deployApplication
|
|
14
|
+
* @param {string} controllerUrl - Controller base URL
|
|
15
|
+
* @param {string} envKey - Environment key
|
|
16
|
+
* @param {Object} authConfig - Authentication configuration
|
|
17
|
+
* @param {Object} deployData - Deployment data
|
|
18
|
+
* @param {string} deployData.applicationKey - Application key to deploy
|
|
19
|
+
* @param {string} deployData.image - Container image path
|
|
20
|
+
* @param {Object} [deployData.configuration] - Additional deployment configuration
|
|
21
|
+
* @param {boolean} [deployData.dryRun] - If true, perform a dry run
|
|
22
|
+
* @returns {Promise<Object>} Deployment response
|
|
23
|
+
* @throws {Error} If deployment fails
|
|
24
|
+
*/
|
|
25
|
+
async function deployApplication(controllerUrl, envKey, authConfig, deployData) {
|
|
26
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
27
|
+
return await client.post(`/api/v1/environments/${envKey}/applications/deploy`, {
|
|
28
|
+
body: deployData
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Deploy environment infrastructure
|
|
34
|
+
* POST /api/v1/environments/{envKey}/deploy
|
|
35
|
+
* @async
|
|
36
|
+
* @function deployEnvironment
|
|
37
|
+
* @param {string} controllerUrl - Controller base URL
|
|
38
|
+
* @param {string} envKey - Environment key
|
|
39
|
+
* @param {Object} authConfig - Authentication configuration
|
|
40
|
+
* @param {Object} deployData - Deployment data
|
|
41
|
+
* @param {Object} deployData.environmentConfig - Environment configuration
|
|
42
|
+
* @param {boolean} [deployData.dryRun] - If true, perform a dry run
|
|
43
|
+
* @returns {Promise<Object>} Deployment response
|
|
44
|
+
* @throws {Error} If deployment fails
|
|
45
|
+
*/
|
|
46
|
+
async function deployEnvironment(controllerUrl, envKey, authConfig, deployData) {
|
|
47
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
48
|
+
return await client.post(`/api/v1/environments/${envKey}/deploy`, {
|
|
49
|
+
body: deployData
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* List deployments for an environment
|
|
55
|
+
* GET /api/v1/environments/{envKey}/deployments
|
|
56
|
+
* @async
|
|
57
|
+
* @function listDeployments
|
|
58
|
+
* @param {string} controllerUrl - Controller base URL
|
|
59
|
+
* @param {string} envKey - Environment key
|
|
60
|
+
* @param {Object} authConfig - Authentication configuration
|
|
61
|
+
* @param {Object} [options] - List options
|
|
62
|
+
* @param {number} [options.page] - Page number
|
|
63
|
+
* @property {number} [options.pageSize] - Items per page
|
|
64
|
+
* @param {string} [options.sort] - Sort parameter
|
|
65
|
+
* @param {string} [options.filter] - Filter parameter
|
|
66
|
+
* @param {string} [options.search] - Search term
|
|
67
|
+
* @param {string} [options.status] - Filter by status (legacy)
|
|
68
|
+
* @param {string} [options.deploymentType] - Filter by deployment type (legacy)
|
|
69
|
+
* @returns {Promise<Object>} Paginated list of deployments
|
|
70
|
+
* @throws {Error} If request fails
|
|
71
|
+
*/
|
|
72
|
+
async function listDeployments(controllerUrl, envKey, authConfig, options = {}) {
|
|
73
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
74
|
+
return await client.get(`/api/v1/environments/${envKey}/deployments`, {
|
|
75
|
+
params: options
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get deployment with jobs and logs
|
|
81
|
+
* GET /api/v1/environments/{envKey}/deployments/{deploymentId}
|
|
82
|
+
* @async
|
|
83
|
+
* @function getDeployment
|
|
84
|
+
* @param {string} controllerUrl - Controller base URL
|
|
85
|
+
* @param {string} envKey - Environment key
|
|
86
|
+
* @param {string} deploymentId - Deployment ID
|
|
87
|
+
* @param {Object} authConfig - Authentication configuration
|
|
88
|
+
* @returns {Promise<Object>} Full deployment record with jobs and logs
|
|
89
|
+
* @throws {Error} If request fails
|
|
90
|
+
*/
|
|
91
|
+
async function getDeployment(controllerUrl, envKey, deploymentId, authConfig) {
|
|
92
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
93
|
+
return await client.get(`/api/v1/environments/${envKey}/deployments/${deploymentId}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get deployment job logs
|
|
98
|
+
* GET /api/v1/environments/{envKey}/deployments/{deploymentId}/logs
|
|
99
|
+
* @async
|
|
100
|
+
* @function getDeploymentLogs
|
|
101
|
+
* @param {string} controllerUrl - Controller base URL
|
|
102
|
+
* @param {string} envKey - Environment key
|
|
103
|
+
* @param {string} deploymentId - Deployment ID
|
|
104
|
+
* @param {Object} authConfig - Authentication configuration
|
|
105
|
+
* @param {Object} [options] - Log options
|
|
106
|
+
* @param {string} [options.jobId] - Filter logs for specific job ID
|
|
107
|
+
* @param {string} [options.level] - Filter by log level
|
|
108
|
+
* @param {string} [options.since] - Get logs since timestamp (ISO 8601)
|
|
109
|
+
* @returns {Promise<Object>} Array of job logs
|
|
110
|
+
* @throws {Error} If request fails
|
|
111
|
+
*/
|
|
112
|
+
async function getDeploymentLogs(controllerUrl, envKey, deploymentId, authConfig, options = {}) {
|
|
113
|
+
const client = new ApiClient(controllerUrl, authConfig);
|
|
114
|
+
return await client.get(`/api/v1/environments/${envKey}/deployments/${deploymentId}/logs`, {
|
|
115
|
+
params: options
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
deployApplication,
|
|
121
|
+
deployEnvironment,
|
|
122
|
+
listDeployments,
|
|
123
|
+
getDeployment,
|
|
124
|
+
getDeploymentLogs
|
|
125
|
+
};
|
|
126
|
+
|