@corva/create-app 0.0.0-73c49372 → 0.0.0-9a3cf8e

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 (53) hide show
  1. package/README.md +7 -0
  2. package/bin/create-corva-app.cjs +4 -9
  3. package/lib/commands/build-release.js +60 -0
  4. package/lib/commands/release.js +6 -0
  5. package/lib/constants/cli.js +13 -3
  6. package/lib/constants/manifest.js +1 -0
  7. package/lib/constants/package.js +18 -6
  8. package/lib/flows/build-release.js +31 -0
  9. package/lib/flows/lib/api.js +6 -12
  10. package/lib/flows/lib/manifest.js +1 -1
  11. package/lib/flows/release.js +2 -1
  12. package/lib/flows/steps/build.js +25 -0
  13. package/lib/flows/steps/release/get-config.js +2 -2
  14. package/lib/flows/steps/release/prepare-data.js +14 -5
  15. package/lib/flows/steps/release/upload-zip-to-corva.js +80 -2
  16. package/lib/flows/steps/resolve-built-files-for-zip.js +35 -0
  17. package/lib/flows/steps/zip-file-list-resolve.js +45 -25
  18. package/lib/helpers/cli-version.js +38 -2
  19. package/lib/helpers/manifest.js +9 -1
  20. package/lib/helpers/resolve-app-runtime.js +3 -3
  21. package/lib/main.js +2 -0
  22. package/package.json +1 -104
  23. package/template_extensions/corva/.eslintrc +32 -0
  24. package/template_extensions/corva/.github/workflows/develop.yml +2 -0
  25. package/templates/scheduler_data-time/javascript/__tests__/processor.spec.js +1 -1
  26. package/templates/scheduler_data-time/typescript/__tests__/processor.spec.ts +1 -1
  27. package/templates/scheduler_depth/javascript/__tests__/processor.spec.js +1 -1
  28. package/templates/scheduler_depth/typescript/__tests__/processor.spec.ts +1 -1
  29. package/templates/scheduler_natural-time/javascript/__tests__/processor.spec.js +1 -1
  30. package/templates/scheduler_natural-time/typescript/__tests__/processor.spec.ts +1 -1
  31. package/templates/stream_depth/javascript/__tests__/processor.spec.js +1 -1
  32. package/templates/stream_depth/typescript/__tests__/processor.spec.ts +1 -1
  33. package/templates/stream_time/javascript/__tests__/processor.spec.js +1 -1
  34. package/templates/stream_time/typescript/__tests__/processor.spec.ts +1 -1
  35. package/templates/task/javascript/__tests__/processor.spec.js +1 -1
  36. package/templates/task/typescript/__tests__/processor.spec.ts +1 -1
  37. package/templates/ui/javascript/config/jest/setupTests.js +19 -0
  38. package/templates/ui/javascript/src/App.completion.js +30 -31
  39. package/templates/ui/javascript/src/App.css +0 -13
  40. package/templates/ui/javascript/src/App.drilling.js +31 -36
  41. package/templates/ui/javascript/src/__tests__/App.test.js +27 -2
  42. package/templates/ui/typescript/config/jest/setupTests.js +19 -0
  43. package/templates/ui/typescript/src/App.completion.tsx +32 -42
  44. package/templates/ui/typescript/src/App.css +0 -13
  45. package/templates/ui/typescript/src/App.drilling.tsx +32 -41
  46. package/templates/ui/typescript/src/AppSettings.tsx +2 -12
  47. package/templates/ui/typescript/src/__mocks__/mockData.ts +194 -0
  48. package/templates/ui/typescript/src/__tests__/App.test.tsx +80 -6
  49. package/templates/ui/typescript/src/__tests__/AppSettings.test.tsx +14 -3
  50. package/templates/ui/typescript/src/types.ts +618 -0
  51. package/templates/ui/typescript/tsconfig.json +0 -1
  52. package/templates/ui/typescript/src/__mocks__/mockAppProps.ts +0 -590
  53. package/templates/ui/typescript/src/__mocks__/mockAppSettingsProps.ts +0 -290
@@ -9,3 +9,22 @@ import '@testing-library/jest-dom/extend-expect';
9
9
 
10
10
  // Set UTC timezone for tests to not use the environment timezone
11
11
  process.env.TZ = 'UTC';
12
+
13
+ // Mock ResizeObserver & MutationObserver
14
+ class FakeObserver {
15
+ observe() {}
16
+ unobserve() {}
17
+ disconnect() {}
18
+ }
19
+
20
+ global.ResizeObserver = FakeObserver;
21
+ global.MutationObserver = FakeObserver;
22
+
23
+ // Suppressing "Could not parse CSS stylesheet" from JSDOM
24
+ const originalConsoleError = global.console.error;
25
+ global.console.error = (message, ...optionalParams) => {
26
+ if (message.includes('Could not parse CSS stylesheet')) {
27
+ return;
28
+ }
29
+ originalConsoleError(message, ...optionalParams);
30
+ };
@@ -1,63 +1,53 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
5
+ import { AppProps, CustomAppSettings } from './types';
4
6
  import logo from './assets/logo.svg';
5
7
 
6
8
  import styles from './App.css';
7
9
 
8
- type AppProps = {
9
- appHeaderProps: {
10
- [key: string]: any;
11
- app: any;
12
- };
13
- isExampleCheckboxChecked?: boolean;
14
- fracFleet?: { name: string };
15
- well?: { name: string };
16
- wells?: { name: string }[];
17
- };
18
-
19
10
  function App({
20
- appHeaderProps,
21
11
  isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
22
12
  fracFleet,
23
13
  well,
24
14
  wells,
25
- }: AppProps): JSX.Element {
15
+ }: AppProps & CustomAppSettings): JSX.Element {
16
+ const { appKey } = useAppCommons();
26
17
  // NOTE: On general type dashboard app receives wells array
27
18
  // on asset type dashboard app receives well object
28
19
  const wellsList = wells || [well];
29
20
 
30
21
  return (
31
- <div className={styles.container}>
32
- <AppHeader {...appHeaderProps} />
33
- <div className={styles.content}>
34
- <div>
35
- <img src={logo} alt="logo" className={styles.logo} />
36
- <p>
37
- Edit <code>src/App.js</code> and save to reload.
38
- <br />
39
- <br />
40
- </p>
41
- <p>
42
- Frac Fleet: {fracFleet?.name || 'No Frac Fleet'}
43
- <br />
44
- Wells: {wellsList.map(well => well.name).join(', ')}
45
- </p>
46
- <a
47
- className="App-link"
48
- href="https://reactjs.org"
49
- target="_blank"
50
- rel="noopener noreferrer"
51
- >
52
- Learn React
53
- </a>
54
- </div>
55
- <div>
56
- Settings &quot;Example&quot; checkbox is{' '}
22
+ <AppContainer header={<AppHeader />} testId={appKey}>
23
+ <div className={styles.container}>
24
+ <img src={logo} alt="logo" className={styles.logo} />
25
+ <p>
26
+ Edit <code>src/App.js</code> and save to reload.
27
+ <br />
28
+ <br />
29
+ </p>
30
+ <p>
31
+ Frac Fleet: <span data-testid="fracFleet">{fracFleet?.name || 'No Frac Fleet'}</span>
32
+ <br />
33
+ Wells: <span data-testid="wellsList">{wellsList.map(well => well?.name).join(', ')}</span>
34
+ </p>
35
+ <a
36
+ className="App-link"
37
+ href="https://reactjs.org"
38
+ target="_blank"
39
+ rel="noopener noreferrer"
40
+ >
41
+ Learn React
42
+ </a>
43
+ </div>
44
+ <div>
45
+ Settings &quot;Example&quot; checkbox is{' '}
46
+ <span data-testid="exampleCheckboxState">
57
47
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
58
- </div>
48
+ </span>
59
49
  </div>
60
- </div>
50
+ </AppContainer>
61
51
  );
62
52
  }
63
53
 
@@ -1,18 +1,5 @@
1
1
  .container {
2
- display: flex;
3
- flex-direction: column;
4
- height: 100%;
5
- padding: 12px 12px 30px 12px;
6
- }
7
-
8
- .content {
9
- display: flex;
10
- flex-direction: column;
11
2
  text-align: center;
12
- align-items: center;
13
- justify-content: center;
14
- flex-grow: 1;
15
- overflow: auto;
16
3
  }
17
4
 
18
5
  @keyframes App-logo-spin {
@@ -1,57 +1,48 @@
1
- import { AppHeader } from '@corva/ui/components';
1
+ import { AppContainer, AppHeader } from '@corva/ui/componentsV2';
2
+ import { useAppCommons } from '@corva/ui/effects';
2
3
 
3
4
  import { DEFAULT_SETTINGS } from './constants';
5
+ import { AppProps, CustomAppSettings } from './types';
4
6
  import logo from './assets/logo.svg';
5
7
 
6
8
  import styles from './App.css';
7
9
 
8
- type AppProps = {
9
- appHeaderProps: {
10
- [key: string]: any;
11
- app: any;
12
- };
13
- isExampleCheckboxChecked?: boolean;
14
- rig: { name: string };
15
- well: { name: string };
16
- };
17
-
18
10
  function App({
19
- appHeaderProps,
20
11
  isExampleCheckboxChecked = DEFAULT_SETTINGS.isExampleCheckboxChecked,
21
12
  rig,
22
13
  well,
23
- }: AppProps): JSX.Element {
14
+ }: AppProps & CustomAppSettings): JSX.Element {
15
+ const { appKey } = useAppCommons();
24
16
  return (
25
- <div className={styles.container}>
26
- <AppHeader {...appHeaderProps} />
27
- <div className={styles.content}>
28
- <div>
29
- <img src={logo} alt="logo" className={styles.logo} />
30
- <p>
31
- Edit <code>src/App.js</code> and save to reload.
32
- <br />
33
- <br />
34
- </p>
35
- <p>
36
- Rig: {rig.name}
37
- <br />
38
- Well: {well.name}
39
- </p>
40
- <a
41
- className="App-link"
42
- href="https://reactjs.org"
43
- target="_blank"
44
- rel="noopener noreferrer"
45
- >
46
- Learn React
47
- </a>
48
- </div>
49
- <div>
50
- Settings &quot;Example&quot; checkbox is{' '}
17
+ <AppContainer header={<AppHeader />} testId={appKey}>
18
+ <div className={styles.container}>
19
+ <img src={logo} alt="logo" className={styles.logo} />
20
+ <p>
21
+ Edit <code>src/App.js</code> and save to reload.
22
+ <br />
23
+ <br />
24
+ </p>
25
+ <p>
26
+ Rig: <span data-testid="rig">{rig?.name}</span>
27
+ <br />
28
+ Well: <span data-testid="well">{well?.name}</span>
29
+ </p>
30
+ <a
31
+ className="App-link"
32
+ href="https://reactjs.org"
33
+ target="_blank"
34
+ rel="noopener noreferrer"
35
+ >
36
+ Learn React
37
+ </a>
38
+ </div>
39
+ <div>
40
+ Settings &quot;Example&quot; checkbox is{' '}
41
+ <span data-testid="exampleCheckboxState">
51
42
  {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
52
- </div>
43
+ </span>
53
44
  </div>
54
- </div>
45
+ </AppContainer>
55
46
  );
56
47
  }
57
48
 
@@ -1,19 +1,9 @@
1
1
  import { Checkbox, FormControlLabel } from '@material-ui/core';
2
2
 
3
3
  import { DEFAULT_SETTINGS } from './constants';
4
+ import { AppSettingsProps, CustomAppSettings } from './types';
4
5
 
5
- type AppSettingsProps = {
6
- app: { [key: string]: any };
7
- appData: { [key: string]: any };
8
- company: { [key: string]: any };
9
- onSettingChange: (key: string, value: any) => void;
10
- settings: {
11
- isExampleCheckboxChecked: boolean;
12
- };
13
- user: { [key: string]: any };
14
- };
15
-
16
- const AppSettings = (props: AppSettingsProps): JSX.Element => {
6
+ const AppSettings = (props: AppSettingsProps & CustomAppSettings): JSX.Element => {
17
7
  const { settings: apiSettings, onSettingChange } = props;
18
8
  const settings = { ...DEFAULT_SETTINGS, ...apiSettings };
19
9
 
@@ -0,0 +1,194 @@
1
+ import { AppInstance, AppInstanceData, User, AppHeaderData } from '../types';
2
+
3
+ export const mockApp: AppInstance = {
4
+ app: { app_key: 'test', platform: 'test' },
5
+ id: 1,
6
+ package: {
7
+ manifest: {
8
+ format: 1,
9
+ license: { type: 'test', url: 'test' },
10
+ developer: { name: 'test', identifier: 'test', authors: [] },
11
+ application: {
12
+ type: 'test',
13
+ key: 'test',
14
+ visibility: 'test',
15
+ name: 'test',
16
+ description: 'test',
17
+ summary: 'test',
18
+ category: 'test',
19
+ website: 'test',
20
+ segments: ['test'],
21
+ ui: {
22
+ initial_size: { w: 100, h: 100 },
23
+ multi_rig: false,
24
+ full_screen_report: false,
25
+ use_app_header_v3: false,
26
+ },
27
+ },
28
+ settings: {
29
+ entrypoint: { file: 'test', function: 'test' },
30
+ environment: {},
31
+ runtime: 'test',
32
+ app: { log_type: 'test' },
33
+ enable_isolation: false,
34
+ },
35
+ datasets: {},
36
+ },
37
+ build: 'test',
38
+ version: 'test',
39
+ },
40
+ segment: ['test'],
41
+ settings: {},
42
+ };
43
+
44
+ export const mockUser: User = {
45
+ id: 1,
46
+ company_id: 1,
47
+ first_name: 'Test',
48
+ last_name: 'User',
49
+ email: 'test@test.com',
50
+ mobile: '1234567890',
51
+ created_at: '2023-01-01',
52
+ terms_acceptance_at: '2023-01-01',
53
+ profile_photo: null,
54
+ recently_viewed_asset_ids: [],
55
+ unit_system: null,
56
+ custom_unit_system: null,
57
+ role: 'test',
58
+ title: null,
59
+ group: null,
60
+ favorite_asset_id: null,
61
+ current_segment: 'test',
62
+ theme: 'test',
63
+ messaging_id: 'test',
64
+ restricted_assets: [],
65
+ restricted_programs: [],
66
+ settings: {
67
+ favorites: [],
68
+ home_page: { selected_assets_tab: 'test' },
69
+ onboarded: false,
70
+ beta_2_158: {},
71
+ uiSettings: {},
72
+ singleAsset: {
73
+ padId: 1,
74
+ rigId: 1,
75
+ wellId: null,
76
+ rigAssetId: 1,
77
+ fracFleetId: 1,
78
+ wellAssetId: null,
79
+ drilloutUnitId: 1,
80
+ completionWellAssetId: 1,
81
+ },
82
+ feed_filters: {
83
+ company_id: null,
84
+ start_date: '2023-01-01',
85
+ content_types: [],
86
+ selected_rigs_ids: [],
87
+ selected_user_ids: [],
88
+ users_radio_value: 'test',
89
+ assets_radio_value: 'test',
90
+ date_range_radio_value: 'test',
91
+ },
92
+ sms_blacklisted: false,
93
+ favorit_asset_ids: [],
94
+ restricted_assets: [],
95
+ alerts_list_filters: {
96
+ end_date: '2023-01-01',
97
+ segments: [],
98
+ alert_name: 'test',
99
+ start_date: '2023-01-01',
100
+ validation: 'test',
101
+ alert_levels: [],
102
+ subscription: 'test',
103
+ classification: 'test',
104
+ assets_radio_value: 'test',
105
+ date_range_radio_value: 'test',
106
+ },
107
+ restricted_programs: [],
108
+ is_dnd_feature_shown: false,
109
+ last_new_alerts_check: '2023-01-01',
110
+ notifications_filters: {
111
+ end_date: '2023-01-01',
112
+ start_date: '2023-01-01',
113
+ content_types: [],
114
+ date_range_radio_value: 'test',
115
+ },
116
+ directional_app_settings: {
117
+ curve_to_lat_threshold: 0,
118
+ vert_to_curve_threshold: 0,
119
+ },
120
+ last_new_feed_items_check: '2023-01-01',
121
+ participates_in_beta_apps: false,
122
+ 'cross-plot__gradient-manager': [],
123
+ last_new_dashboard_shares_check: '2023-01-01',
124
+ formation_evaluation_lithology_types: {},
125
+ formation_evaluation_custom_gradients: [],
126
+ },
127
+ last_sign_in_at: '2023-01-01',
128
+ locked_access: false,
129
+ unit_ids: [],
130
+ intercom_admin_id: null,
131
+ resource: [],
132
+ consent_to_process_data: false,
133
+ identity_verification_enabled: null,
134
+ intercom_user_hash: 'test',
135
+ impersonating: false,
136
+ profile_groups: [],
137
+ preference: {
138
+ id: 1,
139
+ push_notifications_enabled: false,
140
+ emails_enabled: false,
141
+ sms_enabled: false,
142
+ alert_levels: [],
143
+ play_alerts_sound: false,
144
+ show_intercom_icon: false,
145
+ segment: [],
146
+ disable_create_dashboard: false,
147
+ disable_costs: false,
148
+ disable_documents: false,
149
+ realtime_operation_mode: false,
150
+ disable_file_upload: false,
151
+ stay_on_app_store: false,
152
+ new_navigation_beta: false,
153
+ new_mobile_app_enabled: false,
154
+ },
155
+ company: {
156
+ id: 1,
157
+ name: 'Test Company',
158
+ time_zone: 'UTC',
159
+ language: 'en',
160
+ provider: 'test',
161
+ unit_system: {},
162
+ custom_unit_system: {},
163
+ custom_units: {},
164
+ dev_center_enabled: false,
165
+ with_subscription: false,
166
+ competitor_analysis_enabled: false,
167
+ ai_model_scope: 'test',
168
+ },
169
+ groups: [],
170
+ };
171
+
172
+ export const mockAppData: AppInstanceData = {
173
+ id: 1,
174
+ rig: null,
175
+ well: null,
176
+ fracFleet: null,
177
+ program: {
178
+ id: null,
179
+ name: null,
180
+ },
181
+ wells: null,
182
+ isLoading: false,
183
+ appHash: 'test',
184
+ };
185
+
186
+ export const mockAppHeaderProps: AppHeaderData = {
187
+ app: mockApp,
188
+ appLastAnnotation: null,
189
+ appSettings: {},
190
+ coordinates: { w: 0, h: 0, x: 0, y: 0, pixelHeight: 0, pixelWidth: 0 },
191
+ currentUser: mockUser,
192
+ isMaximized: false,
193
+ layoutEnvironment: { type: 'test', pdfReportMode: false },
194
+ };
@@ -1,20 +1,94 @@
1
1
  import { render, screen } from '@testing-library/react';
2
+ import { AppTestWrapper } from '@corva/ui/testing';
2
3
 
3
4
  import App from '../App';
4
- import { mockAppProps } from '../__mocks__/mockAppProps';
5
+ import { mockApp, mockUser, mockAppHeaderProps } from '../__mocks__/mockData';
5
6
 
6
7
  describe('<App />', () => {
7
8
  it('should show correct layout', () => {
8
- render(<App {...mockAppProps} />);
9
+ render(
10
+ <AppTestWrapper
11
+ app={{}}
12
+ appId={123}
13
+ maximized={false}
14
+ appSettings={{}}
15
+ onSettingChange={() => {
16
+ /* noop */
17
+ }}
18
+ >
19
+ <App
20
+ app={mockApp}
21
+ package="test"
22
+ coordinates={{ w: 0, h: 0, x: 0, y: 0, pixelHeight: 0, pixelWidth: 0 }}
23
+ currentUser={mockUser}
24
+ devCenterRouter={{ location: { pathname: '', query: {} } }}
25
+ segment="test"
26
+ appHeaderProps={mockAppHeaderProps}
27
+ isNative={false}
28
+ layoutEnvironment={{ type: 'test', pdfReportMode: false }}
29
+ onSettingChange={() => {
30
+ /* noop */
31
+ }}
32
+ onSettingsChange={() => {
33
+ /* noop */
34
+ }}
35
+ setIsFullscreenModalMode={() => Promise.resolve()}
36
+ setIsMaximized={() => {
37
+ /* noop */
38
+ }}
39
+ setMainMenuItems={() => {
40
+ /* noop */
41
+ }}
42
+ setSecondaryMenuItems={() => {
43
+ /* noop */
44
+ }}
45
+ />
46
+ </AppTestWrapper>
47
+ );
9
48
 
10
49
  screen.getByText(/checked/i);
11
50
  });
12
51
 
13
52
  it('should show correct layout when settings are not provided', () => {
14
- const propsWithoutSettings = mockAppProps;
15
- delete propsWithoutSettings.isExampleCheckboxChecked;
16
-
17
- render(<App {...propsWithoutSettings} />);
53
+ render(
54
+ <AppTestWrapper
55
+ app={{}}
56
+ appId={123}
57
+ maximized={false}
58
+ appSettings={{}}
59
+ onSettingChange={() => {
60
+ /* noop */
61
+ }}
62
+ >
63
+ <App
64
+ app={mockApp}
65
+ package="test"
66
+ coordinates={{ w: 0, h: 0, x: 0, y: 0, pixelHeight: 0, pixelWidth: 0 }}
67
+ currentUser={mockUser}
68
+ devCenterRouter={{ location: { pathname: '', query: {} } }}
69
+ segment="test"
70
+ appHeaderProps={mockAppHeaderProps}
71
+ isNative={false}
72
+ layoutEnvironment={{ type: 'test', pdfReportMode: false }}
73
+ onSettingChange={() => {
74
+ /* noop */
75
+ }}
76
+ onSettingsChange={() => {
77
+ /* noop */
78
+ }}
79
+ setIsFullscreenModalMode={() => Promise.resolve()}
80
+ setIsMaximized={() => {
81
+ /* noop */
82
+ }}
83
+ setMainMenuItems={() => {
84
+ /* noop */
85
+ }}
86
+ setSecondaryMenuItems={() => {
87
+ /* noop */
88
+ }}
89
+ />
90
+ </AppTestWrapper>
91
+ );
18
92
 
19
93
  screen.getByText(/unchecked/i);
20
94
  });
@@ -2,15 +2,26 @@ import { render, screen, act } from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
 
4
4
  import AppSettings from '../AppSettings';
5
- import { mockAppSettingsProps } from '../__mocks__/mockAppSettingsProps';
5
+ import { mockApp, mockUser, mockAppData } from '../__mocks__/mockData';
6
6
 
7
7
  describe('<AppSettings />', () => {
8
8
  it('should call onChange with a changed setting on settings change', async () => {
9
9
  const handleSettingsChange = jest.fn();
10
+ const handleSettingsChangeAll = jest.fn();
10
11
 
11
- render(<AppSettings {...mockAppSettingsProps} onSettingChange={handleSettingsChange} />);
12
+ render(
13
+ <AppSettings
14
+ app={mockApp}
15
+ appData={mockAppData}
16
+ settings={{ isExampleCheckboxChecked: true }}
17
+ layoutEnvironment={{ type: 'test', pdfReportMode: false }}
18
+ currentUser={mockUser}
19
+ onSettingChange={handleSettingsChange}
20
+ onSettingsChange={handleSettingsChangeAll}
21
+ />
22
+ );
12
23
 
13
- const exampleCheckbox = screen.getByTestId('exampleCheckbox').querySelector('input');
24
+ const exampleCheckbox = screen.getByRole('checkbox', { name: /example/i });
14
25
 
15
26
  await act(async () => {
16
27
  await userEvent.click(exampleCheckbox);