@corva/create-app 0.54.0-1 → 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.
@@ -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
- CORVA_API_ENV,
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 streamId = mappedAssetsToStreams.get(parseInt(assetId)).id;
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 result = await api
45
- .queueAppRun(app.id, version, interval, wellId, appDatasetsNames, streamId)
46
- .catch((e) => {
47
- console.log(e.response.body);
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
- throw e;
50
- });
55
+ throw e;
56
+ });
51
57
 
52
- logger.write(
53
- `\n ${i}. Created a new task with ID ${chalk.yellow(result.id)} for asset ID - ${chalk.green(assetId)}`,
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 connectedApp = stream.app_connections.find((connection) => connection.app_id === parseInt(appId));
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 ID: ${stream.id}, for asset ID: ${assetId}`,
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, connect ID - ${chalk.green(newConnection.id)}, for asset ID: ${assetId}`,
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.54.0-1",
3
+ "version": "0.54.0-rc.0",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [
@@ -24,6 +24,7 @@
24
24
  "bin/**/*.js",
25
25
  "lib/**/*.js",
26
26
  "templates",
27
+ "template_extensions",
27
28
  "common"
28
29
  ],
29
30
  "scripts": {
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": ["@commitlint/config-conventional"],
3
+ "rules": {
4
+ "subject-case": [0]
5
+ }
6
+ }
@@ -0,0 +1,14 @@
1
+ # Description
2
+
3
+ [Optional]: a screenshot / video / text description / please check the ticket using the ticket ID
4
+
5
+ ### To be merged the changes also should be approved by:
6
+
7
+ - QA, PO ( for features / fixes / tech tickets that also require QA/PO validation )
8
+ - Designer ( when there're design changes )
9
+ - BE developer ( when there're MongoDB queries, to be sure they are optimal )
10
+
11
+ ### Checklist
12
+
13
+ - [ ] I have commented possibly difficult-to-understand places
14
+ - [ ] I have covered the new code with the tests _([Our tests guide](https://corva.notion.site/Tests-guide-520058fa52454e5aa08ef9225d7d76e9))_
@@ -0,0 +1,28 @@
1
+ name: Code checks (lint, tests, etc.)
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - feat/*
7
+ - fix/*
8
+ - develop
9
+ - release-fix/[0-9]+.[0-9]+.[0-9]+
10
+
11
+ jobs:
12
+ code-checks:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - uses: actions/setup-node@v2
17
+ with:
18
+ node-version: 16
19
+ cache: 'yarn'
20
+
21
+ - name: Install dependencies
22
+ run: yarn
23
+
24
+ - name: Run linter
25
+ run: yarn lint
26
+
27
+ - name: Run tests
28
+ run: yarn coverage
@@ -0,0 +1,29 @@
1
+ name: develop branch flow
2
+ on:
3
+ push:
4
+ branches:
5
+ - 'develop'
6
+
7
+ jobs:
8
+ develop-flow:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: develop branch flow
12
+ id: shared-workflow
13
+ uses: corva-ai/gh-actions/shared-dc-workflows/develop@develop
14
+ with:
15
+ is-upload-to-qa: true
16
+ qa-api-key: ${{ secrets.API_KEY_QA }}
17
+ is-upload-to-prod: false
18
+ prod-api-key: ${{ secrets.API_KEY }}
19
+ npm-token: ${{ secrets.CORVA_NPM_TOKEN }}
20
+ github-pr-approve-token: ${{ secrets.GH_ACTIONS_AUTOMATION }}
21
+ # github-pr-approve-token: ${{ secrets.GH_ACTIONS_AUTOMATION }}
22
+ # - name: trigger circle ci develop e2e tests
23
+ # if: ${{ steps.shared-workflow.outputs.is-release-created }}
24
+ # run: |
25
+ # curl --request POST \
26
+ # --url https://circleci.com/api/v2/project/gh/corva-ai/${{ github.event.repository.name }}/pipeline \
27
+ # --header 'Circle-Token: ${{ secrets.CIRCLE_CI_API_TOKEN }}' \
28
+ # --header 'content-type: application/json' \
29
+ # --data '{"branch": "develop", "parameters":{"run_develop_e2e_tests_workflow":true,"app_repository_name":"${{ github.event.repository.name }}"}}'
@@ -0,0 +1,16 @@
1
+ name: branch deletion flow
2
+ on:
3
+ delete:
4
+
5
+ jobs:
6
+ branch-deletion-flow:
7
+ runs-on: ubuntu-latest
8
+ if: startsWith(github.event.ref, 'feat/') || startsWith(github.event.ref, 'fix/')
9
+ steps:
10
+ - name: branch deletion flow
11
+ uses: corva-ai/gh-actions/shared-dc-workflows/feat-fix-delete@develop
12
+ with:
13
+ is-delete-from-qa: true
14
+ qa-api-key: ${{ secrets.API_KEY_QA }}
15
+ is-delete-from-prod: false
16
+ prod-api-key: ${{ secrets.API_KEY }}
@@ -0,0 +1,32 @@
1
+ name: feat/fix branch flow
2
+ on:
3
+ push:
4
+ branches:
5
+ - feat/*
6
+ - fix/*
7
+
8
+ concurrency:
9
+ group: ${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ feat-fix-flow:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: feat/fix flow
17
+ uses: corva-ai/gh-actions/shared-dc-workflows/feat-fix@develop
18
+ with:
19
+ is-upload-to-qa: true
20
+ qa-api-key: ${{ secrets.API_KEY_QA }}
21
+ is-upload-to-prod: false
22
+ prod-api-key: ${{ secrets.API_KEY }}
23
+ npm-token: ${{ secrets.CORVA_NPM_TOKEN }}
24
+ jira-user-email: ${{ secrets.JIRA_AUTOTEST_USERNAME }}
25
+ jira-api-token: ${{ secrets.JIRA_AUTOTEST_API_TOKEN }}
26
+ # - name: trigger circle ci branch e2e tests
27
+ # run: |
28
+ # curl --request POST \
29
+ # --url https://circleci.com/api/v2/project/gh/corva-ai/${{ github.event.repository.name }}/pipeline \
30
+ # --header 'Circle-Token: ${{ secrets.CIRCLE_CI_API_TOKEN }}' \
31
+ # --header 'content-type: application/json' \
32
+ # --data '{"branch": "${{ github.ref_name }}", "parameters":{"run_branch_e2e_tests_workflow":true,"app_repository_name":"${{ github.event.repository.name }}"}}'
@@ -0,0 +1,18 @@
1
+ name: release-fix/X.X.X branch flow
2
+ on:
3
+ push:
4
+ branches:
5
+ - 'release-fix/[0-9]+.[0-9]+.[0-9]+'
6
+
7
+ jobs:
8
+ release-fix-flow:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - name: release-fix/X.X.X flow
12
+ uses: corva-ai/gh-actions/shared-dc-workflows/release-fix-X.X.X@develop
13
+ with:
14
+ is-upload-to-qa: true
15
+ qa-api-key: ${{ secrets.API_KEY_QA }}
16
+ is-upload-to-prod: false
17
+ prod-api-key: ${{ secrets.API_KEY }}
18
+ npm-token: ${{ secrets.CORVA_NPM_TOKEN }}
@@ -0,0 +1,19 @@
1
+ name: 'PR title matches "<type>(<scope>): <description>"'
2
+
3
+ on:
4
+ pull_request:
5
+ types:
6
+ - opened
7
+ - edited
8
+ - synchronize
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.head_ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ validate-pr-title:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - name: Validate PR title
19
+ uses: corva-ai/gh-actions/shared-dc-workflows/validate-pr-title@develop
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ echo "Validating commit message..."
5
+ ./node_modules/.bin/commitlint --edit $1
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ ./node_modules/.bin/lint-staged