@corva/create-app 0.54.0-2 → 0.54.0-rc.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/lib/flows/lib/api.js +3 -1
- package/lib/flows/steps/rerun/create-task.js +19 -16
- package/lib/flows/steps/rerun/ensure-that-app-in-stream.js +18 -7
- package/lib/flows/steps/rerun/prepare-data.js +4 -1
- package/lib/flows/steps/rerun/prepare-well-and-stream-data.js +1 -1
- package/package.json +1 -1
package/lib/flows/lib/api.js
CHANGED
|
@@ -172,10 +172,11 @@ export class Api {
|
|
|
172
172
|
* @param {string} wellId
|
|
173
173
|
* @param {string[]} appDatasetsNames
|
|
174
174
|
* @param {string} streamId
|
|
175
|
+
* @param {number} appConnectionId
|
|
175
176
|
*
|
|
176
177
|
* @returns {object}
|
|
177
178
|
*/
|
|
178
|
-
async queueAppRun(appId, version, interval, wellId, appDatasetsNames, streamId) {
|
|
179
|
+
async queueAppRun(appId, version, interval, wellId, appDatasetsNames, streamId, appConnectionId) {
|
|
179
180
|
const json = {
|
|
180
181
|
app_run: {
|
|
181
182
|
app_stream_id: streamId,
|
|
@@ -189,6 +190,7 @@ export class Api {
|
|
|
189
190
|
start: 0,
|
|
190
191
|
},
|
|
191
192
|
},
|
|
193
|
+
app_connection_id: appConnectionId,
|
|
192
194
|
};
|
|
193
195
|
|
|
194
196
|
if (interval) {
|
|
@@ -18,17 +18,21 @@ export const CREATE_TASK_STEP = {
|
|
|
18
18
|
api,
|
|
19
19
|
version,
|
|
20
20
|
interval,
|
|
21
|
-
|
|
21
|
+
corvaUrl,
|
|
22
22
|
}) => {
|
|
23
23
|
if (!assets.length) {
|
|
24
24
|
logger.write(`\n\n${chalk.yellow.bold('There is no asset ID to create a new task')}`);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
logger.write(`\n ${corvaUrl}/dev-center/apps/${app.id}/runner`);
|
|
28
|
+
|
|
27
29
|
let i = 1;
|
|
28
30
|
|
|
29
31
|
for (const assetId of assets) {
|
|
30
32
|
const wellId = mappedAssetsToWells.get(parseInt(assetId)).id;
|
|
31
|
-
const
|
|
33
|
+
const stream = mappedAssetsToStreams.get(parseInt(assetId));
|
|
34
|
+
const streamId = stream.id;
|
|
35
|
+
const connectedApps = stream.app_connections.filter((connectedApp) => connectedApp.app_id === Number(app.id));
|
|
32
36
|
|
|
33
37
|
if (!wellId || !streamId) {
|
|
34
38
|
logger.write(
|
|
@@ -41,23 +45,22 @@ export const CREATE_TASK_STEP = {
|
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
try {
|
|
44
|
-
const
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
for (const connectedApp of connectedApps) {
|
|
49
|
+
const extraNotification = connectedApps.length > 1 ? `(connected app ID ${connectedApp.id})` : '';
|
|
50
|
+
const result = await api
|
|
51
|
+
.queueAppRun(app.id, version, interval, wellId, appDatasetsNames, stream.id, connectedApp.id)
|
|
52
|
+
.catch((e) => {
|
|
53
|
+
console.log(e.response.body);
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
throw e;
|
|
56
|
+
});
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
logger.write(`
|
|
59
|
+
\n${i}/${assets.length}. Re-run ID ${chalk.yellow(
|
|
60
|
+
result.id,
|
|
61
|
+
)} for the asset - ${corvaUrl}/assets/${assetId} ${extraNotification}`);
|
|
62
|
+
}
|
|
55
63
|
|
|
56
|
-
logger.write(
|
|
57
|
-
`\n Task link - https://app${
|
|
58
|
-
CORVA_API_ENV === 'production' ? '.' : `.${CORVA_API_ENV}.`
|
|
59
|
-
}corva.ai/dev-center/apps/${app.id}/runner`,
|
|
60
|
-
);
|
|
61
64
|
i++;
|
|
62
65
|
} catch (e) {
|
|
63
66
|
logger.write(
|
|
@@ -9,11 +9,11 @@ export const ENSURE_APP_IN_STREAM_TASK_STEP = {
|
|
|
9
9
|
* @param {object} context
|
|
10
10
|
*/
|
|
11
11
|
fn: async (context) => {
|
|
12
|
-
const { mappedAssetsToStreams, app, api, manifest } = context;
|
|
12
|
+
const { mappedAssetsToStreams, app, api, manifest, corvaUrl } = context;
|
|
13
13
|
|
|
14
14
|
await Promise.all(
|
|
15
15
|
[...mappedAssetsToStreams].map(([assetId, stream]) => {
|
|
16
|
-
return ensureAppIsInTheStream(assetId, stream, app.id, api, manifest);
|
|
16
|
+
return ensureAppIsInTheStream(assetId, stream, app.id, api, manifest, corvaUrl);
|
|
17
17
|
}),
|
|
18
18
|
);
|
|
19
19
|
|
|
@@ -29,16 +29,27 @@ export const ENSURE_APP_IN_STREAM_TASK_STEP = {
|
|
|
29
29
|
* @param {string} appId
|
|
30
30
|
* @param {import('../lib/api').Api} api
|
|
31
31
|
* @param {object} manifest
|
|
32
|
+
* @param {string} corvaUrl
|
|
32
33
|
*
|
|
33
34
|
* @returns {void}
|
|
34
35
|
*/
|
|
35
|
-
const ensureAppIsInTheStream = async (assetId, stream, appId, api, manifest) => {
|
|
36
|
-
const
|
|
36
|
+
const ensureAppIsInTheStream = async (assetId, stream, appId, api, manifest, corvaUrl) => {
|
|
37
|
+
const connectedApps = stream.app_connections.filter((connection) => connection.app_id === parseInt(appId));
|
|
38
|
+
|
|
39
|
+
if (connectedApps.length) {
|
|
40
|
+
if (connectedApps.length > 1) {
|
|
41
|
+
logger.write(
|
|
42
|
+
`\n\n${chalk.black.underline.bold(
|
|
43
|
+
`Attention, this app connected to the stream more than once: ${corvaUrl}/config/streams/${stream.id}, Asset ID: ${assetId}. Logic will make a rerun per each app`,
|
|
44
|
+
)}`,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
37
49
|
|
|
38
|
-
if (connectedApp) {
|
|
39
50
|
logger.write(
|
|
40
51
|
`\n\n${chalk.black.underline.bold(
|
|
41
|
-
`App has been already connected to the stream
|
|
52
|
+
`App has been already connected to the stream: ${corvaUrl}/config/streams/${stream.id}, Asset ID: ${assetId}`,
|
|
42
53
|
)}`,
|
|
43
54
|
);
|
|
44
55
|
|
|
@@ -49,7 +60,7 @@ const ensureAppIsInTheStream = async (assetId, stream, appId, api, manifest) =>
|
|
|
49
60
|
|
|
50
61
|
logger.write(
|
|
51
62
|
`\n\n${chalk.black.underline.bold(
|
|
52
|
-
`Added app to the stream
|
|
63
|
+
`Added app to the stream: ${corvaUrl}/config/streams/${stream.id} App: ${corvaUrl}/config/streams/${stream.id}/apps/${newConnection.id}, Asset ID: ${assetId}`,
|
|
53
64
|
)}`,
|
|
54
65
|
);
|
|
55
66
|
};
|
|
@@ -9,7 +9,7 @@ const MAX_ASSET_IDS_COUNT = 300;
|
|
|
9
9
|
export const PREPARE_DATA_TASK_STEP = {
|
|
10
10
|
message: 'Preparing and checking data...',
|
|
11
11
|
fn: async (context) => {
|
|
12
|
-
const { manifest, options, api } = context;
|
|
12
|
+
const { manifest, options, api, CORVA_API_ENV } = context;
|
|
13
13
|
let { assets, interval, companyId } = options;
|
|
14
14
|
|
|
15
15
|
if (companyId) {
|
|
@@ -51,8 +51,11 @@ export const PREPARE_DATA_TASK_STEP = {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
const corvaUrl = `https://app${CORVA_API_ENV === 'production' ? '.' : `.${CORVA_API_ENV}.`}corva.ai`;
|
|
55
|
+
|
|
54
56
|
return {
|
|
55
57
|
assets,
|
|
58
|
+
corvaUrl,
|
|
56
59
|
app,
|
|
57
60
|
options,
|
|
58
61
|
manifest,
|
|
@@ -152,7 +152,7 @@ const prepareWellAndStreamData = async (assets, api, manifest) => {
|
|
|
152
152
|
const streams = await api.getStreamsByAssetIds([assetId], manifest.manifest.application.segments);
|
|
153
153
|
|
|
154
154
|
if (!streams || !streams.length) {
|
|
155
|
-
throw new Error(`Could not found streams for asset ID - ${assetId}`);
|
|
155
|
+
throw new Error(`Could not found streams in Complete status for the asset ID - ${assetId}`);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
const stream = await getStreamWithPrompt(streams);
|