@aifabrix/builder 2.11.0 → 2.21.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 (36) hide show
  1. package/.cursor/rules/project-rules.mdc +194 -0
  2. package/README.md +12 -0
  3. package/lib/api/applications.api.js +164 -0
  4. package/lib/api/auth.api.js +303 -0
  5. package/lib/api/datasources-core.api.js +87 -0
  6. package/lib/api/datasources-extended.api.js +117 -0
  7. package/lib/api/datasources.api.js +13 -0
  8. package/lib/api/deployments.api.js +126 -0
  9. package/lib/api/environments.api.js +245 -0
  10. package/lib/api/external-systems.api.js +251 -0
  11. package/lib/api/index.js +236 -0
  12. package/lib/api/pipeline.api.js +234 -0
  13. package/lib/api/types/applications.types.js +136 -0
  14. package/lib/api/types/auth.types.js +218 -0
  15. package/lib/api/types/datasources.types.js +272 -0
  16. package/lib/api/types/deployments.types.js +184 -0
  17. package/lib/api/types/environments.types.js +197 -0
  18. package/lib/api/types/external-systems.types.js +244 -0
  19. package/lib/api/types/pipeline.types.js +125 -0
  20. package/lib/app-list.js +5 -7
  21. package/lib/app-rotate-secret.js +4 -10
  22. package/lib/cli.js +30 -0
  23. package/lib/commands/login.js +41 -12
  24. package/lib/datasource-deploy.js +7 -30
  25. package/lib/datasource-list.js +9 -6
  26. package/lib/deployer.js +103 -135
  27. package/lib/environment-deploy.js +15 -26
  28. package/lib/external-system-deploy.js +12 -39
  29. package/lib/external-system-download.js +5 -13
  30. package/lib/external-system-test.js +9 -12
  31. package/lib/generator-split.js +342 -0
  32. package/lib/generator.js +94 -5
  33. package/lib/utils/app-register-api.js +5 -10
  34. package/lib/utils/deployment-errors.js +88 -6
  35. package/package.json +1 -1
  36. package/tatus +0 -181
@@ -0,0 +1,303 @@
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
+ const params = {};
99
+
100
+ // Environment goes in query params (per OpenAPI spec)
101
+ if (environment) {
102
+ params.environment = environment;
103
+ }
104
+
105
+ // Scope goes in request body
106
+ if (scope) {
107
+ body.scope = scope;
108
+ }
109
+
110
+ // Build request options
111
+ const requestOptions = {};
112
+ if (Object.keys(params).length > 0) {
113
+ requestOptions.params = params;
114
+ }
115
+ if (Object.keys(body).length > 0) {
116
+ requestOptions.body = body;
117
+ }
118
+
119
+ return await client.post('/api/v1/auth/login', requestOptions);
120
+ }
121
+
122
+ /**
123
+ * Poll for device code token
124
+ * POST /api/v1/auth/login/device/token
125
+ * @async
126
+ * @function pollDeviceCodeToken
127
+ * @param {string} deviceCode - Device code from initiate device code flow
128
+ * @param {string} controllerUrl - Controller base URL
129
+ * @returns {Promise<Object>} Token response (may return 202 with authorization_pending)
130
+ * @throws {Error} If polling fails
131
+ */
132
+ async function pollDeviceCodeToken(deviceCode, controllerUrl) {
133
+ const client = new ApiClient(controllerUrl);
134
+ return await client.post('/api/v1/auth/login/device/token', {
135
+ body: { deviceCode }
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Refresh device code access token
141
+ * POST /api/v1/auth/login/device/refresh
142
+ * @async
143
+ * @function refreshDeviceToken
144
+ * @param {string} refreshToken - Refresh token obtained from device code token flow
145
+ * @param {string} controllerUrl - Controller base URL
146
+ * @returns {Promise<Object>} New token response
147
+ * @throws {Error} If token refresh fails
148
+ */
149
+ async function refreshDeviceToken(refreshToken, controllerUrl) {
150
+ const client = new ApiClient(controllerUrl);
151
+ return await client.post('/api/v1/auth/login/device/refresh', {
152
+ body: { refreshToken }
153
+ });
154
+ }
155
+
156
+ /**
157
+ * Refresh user access token
158
+ * POST /api/v1/auth/refresh
159
+ * @async
160
+ * @function refreshUserToken
161
+ * @param {string} refreshToken - Refresh token obtained from OAuth callback flow
162
+ * @param {string} controllerUrl - Controller base URL
163
+ * @returns {Promise<Object>} New token response
164
+ * @throws {Error} If token refresh fails
165
+ */
166
+ async function refreshUserToken(refreshToken, controllerUrl) {
167
+ const client = new ApiClient(controllerUrl);
168
+ return await client.post('/api/v1/auth/refresh', {
169
+ body: { refreshToken }
170
+ });
171
+ }
172
+
173
+ /**
174
+ * Validate authentication token
175
+ * POST /api/v1/auth/validate
176
+ * @async
177
+ * @function validateToken
178
+ * @param {string} token - JWT token to validate
179
+ * @param {string} controllerUrl - Controller base URL
180
+ * @param {Object} authConfig - Authentication configuration
181
+ * @param {string} [environment] - Optional environment key
182
+ * @param {string} [application] - Optional application key
183
+ * @returns {Promise<Object>} Token validation response
184
+ * @throws {Error} If validation fails
185
+ */
186
+ async function validateToken(token, controllerUrl, authConfig, environment, application) {
187
+ const client = new ApiClient(controllerUrl, authConfig);
188
+ const body = { token };
189
+
190
+ if (environment) {
191
+ body.environment = environment;
192
+ }
193
+ if (application) {
194
+ body.application = application;
195
+ }
196
+
197
+ return await client.post('/api/v1/auth/validate', {
198
+ body
199
+ });
200
+ }
201
+
202
+ /**
203
+ * Get user roles
204
+ * GET /api/v1/auth/roles
205
+ * @async
206
+ * @function getAuthRoles
207
+ * @param {string} controllerUrl - Controller base URL
208
+ * @param {Object} authConfig - Authentication configuration
209
+ * @param {string} [environment] - Optional environment key filter
210
+ * @param {string} [application] - Optional application key filter
211
+ * @returns {Promise<Object>} User roles response
212
+ * @throws {Error} If request fails
213
+ */
214
+ async function getAuthRoles(controllerUrl, authConfig, environment, application) {
215
+ const client = new ApiClient(controllerUrl, authConfig);
216
+ return await client.get('/api/v1/auth/roles', {
217
+ params: { environment, application }
218
+ });
219
+ }
220
+
221
+ /**
222
+ * Refresh user roles
223
+ * GET /api/v1/auth/roles/refresh
224
+ * @async
225
+ * @function refreshAuthRoles
226
+ * @param {string} controllerUrl - Controller base URL
227
+ * @param {Object} authConfig - Authentication configuration
228
+ * @returns {Promise<Object>} Refreshed roles response
229
+ * @throws {Error} If request fails
230
+ */
231
+ async function refreshAuthRoles(controllerUrl, authConfig) {
232
+ const client = new ApiClient(controllerUrl, authConfig);
233
+ return await client.get('/api/v1/auth/roles/refresh');
234
+ }
235
+
236
+ /**
237
+ * Get user permissions
238
+ * GET /api/v1/auth/permissions
239
+ * @async
240
+ * @function getAuthPermissions
241
+ * @param {string} controllerUrl - Controller base URL
242
+ * @param {Object} authConfig - Authentication configuration
243
+ * @param {string} [environment] - Optional environment key filter
244
+ * @param {string} [application] - Optional application key filter
245
+ * @returns {Promise<Object>} User permissions response
246
+ * @throws {Error} If request fails
247
+ */
248
+ async function getAuthPermissions(controllerUrl, authConfig, environment, application) {
249
+ const client = new ApiClient(controllerUrl, authConfig);
250
+ return await client.get('/api/v1/auth/permissions', {
251
+ params: { environment, application }
252
+ });
253
+ }
254
+
255
+ /**
256
+ * Refresh user permissions
257
+ * GET /api/v1/auth/permissions/refresh
258
+ * @async
259
+ * @function refreshAuthPermissions
260
+ * @param {string} controllerUrl - Controller base URL
261
+ * @param {Object} authConfig - Authentication configuration
262
+ * @returns {Promise<Object>} Refreshed permissions response
263
+ * @throws {Error} If request fails
264
+ */
265
+ async function refreshAuthPermissions(controllerUrl, authConfig) {
266
+ const client = new ApiClient(controllerUrl, authConfig);
267
+ return await client.get('/api/v1/auth/permissions/refresh');
268
+ }
269
+
270
+ /**
271
+ * Get device code login diagnostics
272
+ * GET /api/v1/auth/login/diagnostics
273
+ * @async
274
+ * @function getAuthLoginDiagnostics
275
+ * @param {string} controllerUrl - Controller base URL
276
+ * @param {string} [environment] - Optional environment key
277
+ * @returns {Promise<Object>} Diagnostic information response
278
+ * @throws {Error} If request fails
279
+ */
280
+ async function getAuthLoginDiagnostics(controllerUrl, environment) {
281
+ const client = new ApiClient(controllerUrl);
282
+ return await client.get('/api/v1/auth/login/diagnostics', {
283
+ params: { environment }
284
+ });
285
+ }
286
+
287
+ module.exports = {
288
+ getToken,
289
+ getClientToken,
290
+ getAuthUser,
291
+ getAuthLogin,
292
+ initiateDeviceCodeFlow,
293
+ pollDeviceCodeToken,
294
+ refreshDeviceToken,
295
+ refreshUserToken,
296
+ validateToken,
297
+ getAuthRoles,
298
+ refreshAuthRoles,
299
+ getAuthPermissions,
300
+ refreshAuthPermissions,
301
+ getAuthLoginDiagnostics
302
+ };
303
+
@@ -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
+