@corva/create-app 0.48.0-0-test-0718ceb → 0.48.0-2

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 (126) hide show
  1. package/common/python/.env +0 -9
  2. package/common/python/.env.sample +1 -17
  3. package/common/python/requirements.txt +1 -1
  4. package/lib/constants/manifest.js +18 -2
  5. package/lib/constants/package.js +20 -10
  6. package/lib/flows/lib/api.js +1 -3
  7. package/lib/flows/lib/manifest.js +31 -0
  8. package/lib/flows/steps/attach/prepare-data.js +1 -1
  9. package/lib/flows/steps/release/prepare-data.js +1 -1
  10. package/lib/flows/steps/rerun/prepare-data.js +1 -1
  11. package/lib/helpers/manifest.js +6 -9
  12. package/lib/helpers/resolve-app-runtime.js +24 -0
  13. package/lib/helpers/versioning.js +1 -2
  14. package/lib/main.js +36 -31
  15. package/package.json +2 -1
  16. package/templates/{javascript/scheduler → scheduler_data-time/javascript}/README.md +0 -0
  17. package/templates/scheduler_data-time/javascript/__test__/processor.spec.js +15 -0
  18. package/templates/scheduler_data-time/javascript/index.js +15 -0
  19. package/templates/{python/scheduler → scheduler_data-time/python}/README.md +0 -0
  20. package/templates/{python/scheduler → scheduler_data-time/python}/lambda_function.py +0 -0
  21. package/templates/{python/scheduler → scheduler_data-time/python}/test/__init__.py +0 -0
  22. package/templates/{python/scheduler → scheduler_data-time/python}/test/app_test.py +0 -0
  23. package/templates/{typescript/scheduler → scheduler_data-time/typescript}/README.md +0 -0
  24. package/templates/scheduler_data-time/typescript/__test__/processor.spec.ts +15 -0
  25. package/templates/scheduler_data-time/typescript/index.ts +8 -0
  26. package/templates/scheduler_depth/javascript/README.md +19 -0
  27. package/templates/scheduler_depth/javascript/__test__/processor.spec.js +17 -0
  28. package/templates/scheduler_depth/javascript/index.js +15 -0
  29. package/templates/scheduler_depth/python/README.md +31 -0
  30. package/templates/scheduler_depth/python/lambda_function.py +7 -0
  31. package/templates/{python/stream → scheduler_depth/python}/test/__init__.py +0 -0
  32. package/templates/scheduler_depth/python/test/app_test.py +10 -0
  33. package/templates/scheduler_depth/typescript/README.md +25 -0
  34. package/templates/scheduler_depth/typescript/__test__/processor.spec.ts +17 -0
  35. package/templates/scheduler_depth/typescript/index.ts +8 -0
  36. package/templates/scheduler_natural-time/javascript/README.md +19 -0
  37. package/templates/scheduler_natural-time/javascript/__test__/processor.spec.js +15 -0
  38. package/templates/scheduler_natural-time/javascript/index.js +15 -0
  39. package/templates/scheduler_natural-time/python/README.md +31 -0
  40. package/templates/scheduler_natural-time/python/lambda_function.py +7 -0
  41. package/templates/{python/task → scheduler_natural-time/python}/test/__init__.py +0 -0
  42. package/templates/scheduler_natural-time/python/test/app_test.py +10 -0
  43. package/templates/scheduler_natural-time/typescript/README.md +25 -0
  44. package/templates/scheduler_natural-time/typescript/__test__/processor.spec.ts +15 -0
  45. package/templates/scheduler_natural-time/typescript/index.ts +8 -0
  46. package/templates/{javascript/stream → stream_depth/javascript}/README.md +0 -0
  47. package/templates/stream_depth/javascript/__test__/processor.spec.js +20 -0
  48. package/templates/stream_depth/javascript/index.js +14 -0
  49. package/templates/{python/stream → stream_depth/python}/README.md +0 -0
  50. package/templates/stream_depth/python/lambda_function.py +7 -0
  51. package/templates/stream_depth/python/test/__init__.py +0 -0
  52. package/templates/stream_depth/python/test/app_test.py +16 -0
  53. package/templates/{typescript/stream → stream_depth/typescript}/README.md +0 -0
  54. package/templates/stream_depth/typescript/__test__/processor.spec.ts +20 -0
  55. package/templates/stream_depth/typescript/index.ts +8 -0
  56. package/templates/stream_time/javascript/README.md +19 -0
  57. package/templates/stream_time/javascript/__test__/processor.spec.js +14 -0
  58. package/templates/stream_time/javascript/index.js +14 -0
  59. package/templates/stream_time/python/README.md +31 -0
  60. package/templates/{python/stream → stream_time/python}/lambda_function.py +0 -0
  61. package/templates/stream_time/python/test/__init__.py +0 -0
  62. package/templates/{python/stream → stream_time/python}/test/app_test.py +0 -0
  63. package/templates/stream_time/typescript/README.md +25 -0
  64. package/templates/stream_time/typescript/__test__/processor.spec.ts +14 -0
  65. package/templates/stream_time/typescript/index.ts +8 -0
  66. package/templates/{javascript/task → task/javascript}/README.md +0 -0
  67. package/templates/task/javascript/__test__/processor.spec.js +16 -0
  68. package/templates/task/javascript/index.js +15 -0
  69. package/templates/{python/task → task/python}/README.md +0 -0
  70. package/templates/{python/task → task/python}/lambda_function.py +0 -0
  71. package/templates/task/python/test/__init__.py +0 -0
  72. package/templates/{python/task → task/python}/test/app_test.py +1 -1
  73. package/templates/{typescript/task → task/typescript}/README.md +0 -0
  74. package/templates/task/typescript/__test__/processor.spec.ts +16 -0
  75. package/templates/task/typescript/index.ts +8 -0
  76. package/templates/{javascript/ui → ui/javascript}/.env +0 -0
  77. package/templates/{javascript/ui → ui/javascript}/.env.sample +0 -0
  78. package/templates/{javascript/ui → ui/javascript}/.eslintrc +0 -0
  79. package/templates/{javascript/ui → ui/javascript}/.prettierrc +0 -0
  80. package/templates/{javascript/ui → ui/javascript}/README.md +0 -0
  81. package/templates/{javascript/ui → ui/javascript}/config-overrides.js +0 -0
  82. package/templates/{javascript/ui → ui/javascript}/gitignore +0 -0
  83. package/templates/{javascript/ui → ui/javascript}/src/App.css +0 -0
  84. package/templates/{javascript/ui → ui/javascript}/src/App.js +0 -0
  85. package/templates/{javascript/ui → ui/javascript}/src/AppSettings.js +0 -0
  86. package/templates/{javascript/ui → ui/javascript}/src/__tests__/TestExample.test.js +0 -0
  87. package/templates/{javascript/ui → ui/javascript}/src/assets/logo.svg +0 -0
  88. package/templates/{javascript/ui → ui/javascript}/src/constants.js +0 -0
  89. package/templates/{javascript/ui → ui/javascript}/src/index.js +0 -0
  90. package/templates/{javascript/ui → ui/javascript}/src/setupTests.js +0 -0
  91. package/templates/{typescript/ui → ui/typescript}/.env +0 -0
  92. package/templates/{typescript/ui → ui/typescript}/.env.sample +0 -0
  93. package/templates/{typescript/ui → ui/typescript}/.eslintrc +0 -0
  94. package/templates/{typescript/ui → ui/typescript}/.prettierrc +0 -0
  95. package/templates/{typescript/ui → ui/typescript}/README.md +0 -0
  96. package/templates/{typescript/ui → ui/typescript}/config-overrides.js +0 -0
  97. package/templates/{typescript/ui → ui/typescript}/gitignore +0 -0
  98. package/templates/{typescript/ui → ui/typescript}/src/App.css +0 -0
  99. package/templates/{typescript/ui → ui/typescript}/src/App.tsx +0 -0
  100. package/templates/{typescript/ui → ui/typescript}/src/AppSettings.tsx +0 -0
  101. package/templates/{typescript/ui → ui/typescript}/src/__tests__/TestExample.test.tsx +0 -0
  102. package/templates/{typescript/ui → ui/typescript}/src/assets/logo.svg +0 -0
  103. package/templates/{typescript/ui → ui/typescript}/src/constants.ts +0 -0
  104. package/templates/{typescript/ui → ui/typescript}/src/custom.d.ts +0 -0
  105. package/templates/{typescript/ui → ui/typescript}/src/index.js +0 -0
  106. package/templates/{typescript/ui → ui/typescript}/src/setupTests.ts +0 -0
  107. package/templates/{typescript/ui → ui/typescript}/tsconfig.json +0 -0
  108. package/CHANGELOG.md +0 -914
  109. package/templates/javascript/scheduler/__test__/processor.test.js +0 -19
  110. package/templates/javascript/scheduler/index.js +0 -15
  111. package/templates/javascript/scheduler/src/processor.js +0 -17
  112. package/templates/javascript/stream/__test__/processor.test.js +0 -44
  113. package/templates/javascript/stream/index.js +0 -15
  114. package/templates/javascript/stream/src/processor.js +0 -18
  115. package/templates/javascript/task/__test__/processor.test.js +0 -18
  116. package/templates/javascript/task/index.js +0 -16
  117. package/templates/javascript/task/src/processor.js +0 -17
  118. package/templates/typescript/scheduler/__test__/processor.spec.ts +0 -20
  119. package/templates/typescript/scheduler/index.ts +0 -8
  120. package/templates/typescript/scheduler/lib/processor.ts +0 -14
  121. package/templates/typescript/stream/__test__/processor.spec.ts +0 -43
  122. package/templates/typescript/stream/index.ts +0 -8
  123. package/templates/typescript/stream/lib/processor.ts +0 -16
  124. package/templates/typescript/task/__test__/processor.spec.ts +0 -27
  125. package/templates/typescript/task/index.ts +0 -8
  126. package/templates/typescript/task/src/processor.ts +0 -14
@@ -1,12 +1,3 @@
1
- API_KEY=
2
- APP_KEY=${APP_KEY}
3
- APP_NAME=${APP_NAME}
4
- PROVIDER=${PROVIDER}
5
-
6
- API_ROOT_URL=https://api.corva.ai
7
- DATA_API_ROOT_URL=https://data.corva.ai
8
- CACHE_URL=redis://localhost:6379
9
-
10
1
  LOG_LEVEL=DEBUG
11
2
  LOG_THRESHOLD_MESSAGE_SIZE=99999
12
3
  LOG_THRESHOLD_MESSAGE_COUNT=99999
@@ -1,20 +1,4 @@
1
- # Corva API key to perform actions with the API
2
- API_KEY=
3
- # Unique ID of the app
4
- APP_KEY=
5
- # Human readable name of the app
6
- APP_NAME=
7
- # Company short identifier
8
- PROVIDER=
9
-
10
- # Root URL for Corva API
11
- API_ROOT_URL=
12
- # Root URL for Corva Data API
13
- DATA_API_ROOT_URL=
14
- # Redis cache url for caching data in Stream/Scheduler apps
15
- CACHE_URL=
16
-
17
- # Logging configuration, see https://corva-ai.github.io/python-sdk/corva-sdk/1.7.0/index.html#_logging
1
+ # Logging configuration, see https://corva-ai.github.io/python-sdk/corva-sdk/1.8.1/index.html#_logging
18
2
  LOG_LEVEL=DEBUG
19
3
  LOG_THRESHOLD_MESSAGE_SIZE=99999
20
4
  LOG_THRESHOLD_MESSAGE_COUNT=99999
@@ -1,2 +1,2 @@
1
- corva-sdk==1.7.0
1
+ corva-sdk==1.8.1
2
2
  pytest==7.1.1
@@ -34,7 +34,11 @@ export const defaultManifest = {
34
34
 
35
35
  export const defaultUIAppManifest = {
36
36
  application: {
37
- ui: { initial_size: { w: 4, h: 10 } },
37
+ ui: {
38
+ initial_size: { w: 4, h: 10 },
39
+ multi_rig: false,
40
+ full_screen_report: false,
41
+ },
38
42
  },
39
43
  settings: {
40
44
  entrypoint: {
@@ -108,10 +112,15 @@ export const SCHEDULER_TYPE_DATA_TIME = {
108
112
  value: 2,
109
113
  };
110
114
  export const SCHEDULER_TYPE_DEPTH = {
111
- name: 'Date Depth',
115
+ name: 'Depth',
112
116
  value: 4,
113
117
  };
114
118
 
119
+ export const LOG_TYPES = {
120
+ TIME: 'time',
121
+ DEPTH: 'depth',
122
+ };
123
+
115
124
  export const manifestOptions = (projectName = 'Corva Dev Center App') => [
116
125
  {
117
126
  name: 'developerName',
@@ -152,6 +161,13 @@ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
152
161
  when: (answers) => answers.schedulerType === SCHEDULER_TYPE_DEPTH.value,
153
162
  filter: (value) => (isNaN(value) ? value : Number(value)),
154
163
  },
164
+ {
165
+ name: 'logType',
166
+ message: 'Choose the log type',
167
+ default: LOG_TYPES.TIME,
168
+ choices: Object.values(LOG_TYPES),
169
+ when: (answers) => answers.appType === APP_TYPES.STREAM,
170
+ },
155
171
  {
156
172
  name: 'appKey',
157
173
  message: 'Enter the App Key',
@@ -71,26 +71,28 @@ const tsUiPackage = {
71
71
  const nodeNpmScripts = {
72
72
  'bundle': 'create-corva-app zip .',
73
73
  'test': 'npm audit --production && npm run unit',
74
- 'unit': 'jest --passWithNoTests',
75
- 'lint': 'eslint .',
76
- 'lint:fix': 'eslint . --fix',
74
+ 'unit': 'jest --setupFiles dotenv/config',
75
+ 'lint': 'eslint --ext .js,.ts .',
76
+ 'lint:fix': 'eslint --ext .js,.ts --fix .',
77
77
  };
78
78
 
79
79
  const nodeDependencies = {
80
- '@corva/node-sdk': '^7.2.0',
80
+ '@corva/node-sdk': '^8.0.1',
81
81
  };
82
82
 
83
83
  const nodeDevDependencies = {
84
- '@corva/eslint-config-node': '^5.0.0',
84
+ '@corva/eslint-config-node': '^5.1.1',
85
85
  'jest': '^27.5.1',
86
+ 'dotenv': '^16.0.3',
87
+ 'eslint': '^8.2.0',
88
+ 'prettier': '^2.0.0',
89
+ 'typescript': '^4.9.4',
86
90
  };
87
91
 
88
92
  const nodeTsDevDependencies = {
89
- '@corva/eslint-config-node': '^5.0.0',
93
+ ...nodeDevDependencies,
90
94
  '@types/jest': '^27.4.1',
91
- 'jest': '^27.5.1',
92
95
  'ts-jest': '^27.1.4',
93
- 'typescript': '^4.6.3',
94
96
  };
95
97
 
96
98
  const nodeYarnScripts = {
@@ -100,12 +102,16 @@ const nodeYarnScripts = {
100
102
 
101
103
  const nodeTsScripts = {
102
104
  ...nodeNpmScripts,
103
- build: 'tsc -p tsconfig.build.json',
105
+ 'build': 'tsc -p tsconfig.build.json',
106
+ 'lint': 'eslint --ext .ts .',
107
+ 'lint:fix': 'eslint --ext .ts --fix .',
104
108
  };
105
109
 
106
110
  const nodeTsYarnScripts = {
107
111
  ...nodeYarnScripts,
108
- build: 'tsc -p tsconfig.build.json',
112
+ 'build': 'tsc -p tsconfig.build.json',
113
+ 'lint': 'eslint --ext .ts .',
114
+ 'lint:fix': 'eslint --ext .ts --fix .',
109
115
  };
110
116
 
111
117
  const nodeNpmPackage = {
@@ -126,6 +132,10 @@ const nodeTsNpmPackage = {
126
132
  ...nodeNpmPackage,
127
133
  devDependencies: nodeTsDevDependencies,
128
134
  scripts: nodeTsScripts,
135
+ jest: {
136
+ preset: 'ts-jest',
137
+ testEnvironment: 'node',
138
+ },
129
139
  };
130
140
 
131
141
  const nodeTsYarnPackage = {
@@ -50,9 +50,7 @@ export class Api {
50
50
  const app = data.find((app) => app.attributes.app_key === appKey);
51
51
 
52
52
  if (!app) {
53
- throw new Error(
54
- `App with key - ${appKey}, does not exist.\nThe key search is case-sensitive. You might need to update the app key in your app to exactly match the key.`,
55
- );
53
+ throw new Error(`App with key - ${appKey}, not exist`);
56
54
  }
57
55
 
58
56
  return app;
@@ -1,4 +1,15 @@
1
+ import set from 'lodash/set.js';
1
2
  import { APP_TYPES, APP_RUNTIMES } from '../../constants/cli.js';
3
+ import {
4
+ SCHEDULER_TYPE_DATA_TIME,
5
+ SCHEDULER_TYPE_DEPTH,
6
+ SCHEDULER_TYPE_NATURAL_TIME,
7
+ } from '../../constants/manifest.js';
8
+
9
+ const SCHEDULER_MAPPING = [SCHEDULER_TYPE_DATA_TIME, SCHEDULER_TYPE_DEPTH, SCHEDULER_TYPE_NATURAL_TIME].reduce(
10
+ (acc, type) => set(acc, type.value, type.name.toLowerCase().replace(/ /, '-')),
11
+ {},
12
+ );
2
13
 
3
14
  const NODE_RUNTIMES = [APP_RUNTIMES.NODE12, APP_RUNTIMES.NODE14, APP_RUNTIMES.NODE16];
4
15
 
@@ -15,6 +26,22 @@ export class Manifest {
15
26
  return this.manifest.application.type;
16
27
  }
17
28
 
29
+ get subtype() {
30
+ if (this.isScheduler()) {
31
+ return SCHEDULER_MAPPING[this.manifest.settings.app.scheduler_type];
32
+ }
33
+
34
+ if (this.isStream()) {
35
+ return this.manifest.settings.app.log_type;
36
+ }
37
+
38
+ return '';
39
+ }
40
+
41
+ get templateName() {
42
+ return this.type + (this.isScheduler() || this.isStream() ? `_${this.subtype}` : '');
43
+ }
44
+
18
45
  get name() {
19
46
  return this.manifest.application.name;
20
47
  }
@@ -47,4 +74,8 @@ export class Manifest {
47
74
  isScheduler() {
48
75
  return this.manifest.application.type === APP_TYPES.SCHEDULER;
49
76
  }
77
+
78
+ isStream() {
79
+ return this.manifest.application.type === APP_TYPES.STREAM;
80
+ }
50
81
  }
@@ -9,7 +9,7 @@ export const PREPARE_DATA_TASK_STEP = {
9
9
  throw new StepError('Command supports only "scheduler" or "stream" apps');
10
10
  }
11
11
 
12
- const app = await api.getAppByKey(manifest.manifest.application.key);
12
+ const app = await api.getAppByKey(manifest.manifest.application.key.toLowerCase());
13
13
 
14
14
  return {
15
15
  app,
@@ -1,7 +1,7 @@
1
1
  export const RELEASE_PREPARE_DATA_STEP = {
2
2
  message: 'Preparing data...',
3
3
  async fn({ api, manifest }) {
4
- const app = await api.getAppByKey(manifest.manifest.application.key);
4
+ const app = await api.getAppByKey(manifest.manifest.application.key.toLowerCase());
5
5
 
6
6
  return {
7
7
  appId: app.id,
@@ -30,7 +30,7 @@ export const PREPARE_DATA_TASK_STEP = {
30
30
  throw new StepError('Command stopped');
31
31
  }
32
32
 
33
- const app = await api.getAppByKey(manifest.manifest.application.key);
33
+ const app = await api.getAppByKey(manifest.manifest.application.key.toLowerCase());
34
34
  const appDatasets = await api.getAppDatasetsOperationWrite(app.id);
35
35
  const appDatasetsNames = appDatasets.map((dataset) => dataset.attributes.dataset_name);
36
36
 
@@ -34,12 +34,7 @@ export function fillManifest(answers) {
34
34
  settings: {
35
35
  ...defaultManifestProperties.settings,
36
36
  runtime,
37
- app: defaultAppSettings({
38
- type: answers.appType,
39
- schedulerType: answers.schedulerType,
40
- cronString: answers.cronString,
41
- depthMilestone: answers.depthMilestone,
42
- }),
37
+ app: defaultAppSettings(answers),
43
38
  },
44
39
  };
45
40
 
@@ -58,9 +53,11 @@ function _defaultManifestProperties({ type, runtime }) {
58
53
  return manifestConstants.defaultDataAppNodeManifest;
59
54
  }
60
55
 
61
- function defaultAppSettings({ type, schedulerType, cronString, depthMilestone }) {
62
- if (!schedulerType || type !== APP_TYPES.SCHEDULER) {
63
- return {};
56
+ function defaultAppSettings({ appType, schedulerType, cronString, depthMilestone, logType }) {
57
+ if (!schedulerType || appType !== APP_TYPES.SCHEDULER) {
58
+ return {
59
+ log_type: logType,
60
+ };
64
61
  }
65
62
 
66
63
  if (schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value) {
@@ -53,6 +53,27 @@ const checkNodeVersion = (version) => async () => {
53
53
 
54
54
  export const IS_WINDOWS = process.platform === 'win32';
55
55
 
56
+ const semverVersionsMapping = {
57
+ node: {
58
+ 16: '16.19.0',
59
+ 18: '18.13.0',
60
+ },
61
+ python: {
62
+ '3.8': '3.8.16',
63
+ '3.9': '3.9.16',
64
+ '3.10': '3.10.9',
65
+ '3.11': '3.11.1',
66
+ },
67
+ };
68
+
69
+ /**
70
+ * @typedef {Object} Runtime
71
+ * @property {string} language
72
+ * @property {boolean} isRuntimeAvailable
73
+ * @property {string} packageManager
74
+ * @property {string} version
75
+ * @property {string} semver
76
+ */
56
77
  export const resolveAppRuntime = (opts) => {
57
78
  if (opts.appType === APP_TYPES.UI) {
58
79
  const version = '16';
@@ -62,6 +83,7 @@ export const resolveAppRuntime = (opts) => {
62
83
  isRuntimeAvailable: checkNodeVersion(version),
63
84
  packageManager: opts.packageManager,
64
85
  version,
86
+ semver: semverVersionsMapping.node[version],
65
87
  };
66
88
  }
67
89
 
@@ -73,6 +95,7 @@ export const resolveAppRuntime = (opts) => {
73
95
  isRuntimeAvailable: checkNodeVersion(version),
74
96
  packageManager: opts.packageManager,
75
97
  version,
98
+ semver: semverVersionsMapping.node[version],
76
99
  };
77
100
  }
78
101
 
@@ -86,5 +109,6 @@ export const resolveAppRuntime = (opts) => {
86
109
  : checkCliVersion('python3', version),
87
110
  packageManager: 'pip',
88
111
  version,
112
+ semver: semverVersionsMapping.python[version],
89
113
  };
90
114
  };
@@ -23,7 +23,7 @@ export function isInGitRepository(appPath) {
23
23
 
24
24
  export function tryGitInit(appPath) {
25
25
  try {
26
- if (isInGitRepository()) {
26
+ if (isInGitRepository(appPath)) {
27
27
  debug('is in git repository');
28
28
 
29
29
  return false;
@@ -50,7 +50,6 @@ export function tryGitCommit(appPath) {
50
50
  stdio: 'ignore',
51
51
  cwd: appPath,
52
52
  });
53
- logger.log('Added first git commit');
54
53
 
55
54
  return true;
56
55
  } catch (e) {
package/lib/main.js CHANGED
@@ -410,7 +410,7 @@ async function addTemplate(root, manifest, runtime) {
410
410
  logger.log(chalk.green('Copying app template...'));
411
411
  logger.log();
412
412
 
413
- const templateFolder = path.resolve(__dirname, '..', 'templates', runtime.language, manifest.type);
413
+ const templateFolder = path.resolve(__dirname, '..', 'templates', manifest.templateName, runtime.language);
414
414
 
415
415
  utils.copyFolderRecursiveSync(templateFolder, root);
416
416
 
@@ -450,13 +450,24 @@ async function configureApp(root, manifest, runtime) {
450
450
  await addTsConfigs(root, manifest, runtime);
451
451
  }
452
452
 
453
- if (manifest.isPython() && manifest.isScheduler()) {
454
- patchSchedulerForPython(root, manifest, runtime);
453
+ if (manifest.isPython()) {
454
+ await addPythonConfigs(root, manifest, runtime);
455
455
  }
456
456
  }
457
457
 
458
458
  const addNvmRc = async (root, manifest, runtime) => {
459
- await fs.outputFile(path.join(root, '.nvmrc'), `${runtime.version}\n`);
459
+ await fs.outputFile(path.join(root, '.nvmrc'), `${runtime.semver}\n`);
460
+ };
461
+
462
+ /**
463
+ *
464
+ * @param {string} root
465
+ * @param {Manifest} manifest
466
+ * @param {import('./helpers/resolve-app-runtime.js').Runtime} runtime
467
+ */
468
+ const addPythonConfigs = async (root, manifest, runtime) => {
469
+ await fs.writeFile(path.resolve(root, '.python-version'), `${runtime.semver}\n`);
470
+ await fs.writeFile(path.resolve(root, '.python-virtualenv'), `${manifest.unix_name}\n`);
460
471
  };
461
472
 
462
473
  const addTsConfigs = (root, manifest, runtime) => {
@@ -471,6 +482,7 @@ const addTsConfigs = (root, manifest, runtime) => {
471
482
  extends: `@tsconfig/node${runtime.version}/tsconfig.json`,
472
483
  compilerOptions: {
473
484
  inlineSourceMap: true,
485
+ strict: false,
474
486
  },
475
487
  },
476
488
  writejsonOptions,
@@ -487,46 +499,39 @@ const addTsConfigs = (root, manifest, runtime) => {
487
499
  ]);
488
500
  };
489
501
 
490
- function patchSchedulerForPython(root, manifest, runtime) {
491
- const schedulerType = manifest.manifest.settings.app.scheduler_type;
492
-
493
- if (schedulerType === manifestConstants.SCHEDULER_TYPE_DATA_TIME.value) {
494
- return;
495
- }
496
-
497
- const templateFolder = path.resolve(__dirname, '..', 'templates', runtime.language, manifest.type);
498
- const originalType = 'ScheduledDataTimeEvent';
499
- const replacementType =
500
- schedulerType === manifestConstants.SCHEDULER_TYPE_DEPTH.value
501
- ? 'ScheduledDepthEvent'
502
- : 'ScheduledNaturalTimeEvent';
503
- const patchedCode = fs
504
- .readFileSync(path.join(templateFolder, 'lambda_function.py'), 'utf-8')
505
- .replace(new RegExp(originalType, 'g'), replacementType);
506
-
507
- fs.writeFileSync(path.join(root, 'lambda_function.py'), patchedCode);
508
- }
509
-
510
502
  /**
511
503
  *
512
504
  * @param {string} root
513
505
  * @param {import('./flows/lib/manifest').Manifest} manifest
514
506
  */
515
507
  function addPackageJSON(root, manifest, runtime) {
516
- const defaults = getDefaultsForPackageJson(manifest, runtime);
508
+ const {
509
+ version,
510
+ description,
511
+ scripts,
512
+ dependencies,
513
+ devDependencies,
514
+ main,
515
+ license = 'UNLICENSED',
516
+ private: isPrivate = true,
517
+ ...rest
518
+ } = getDefaultsForPackageJson(manifest, runtime);
517
519
 
518
520
  const packageJson = {
519
521
  name: manifest.unix_name,
520
- version: defaults.version,
521
- description: manifest.description || defaults.description,
522
+ version,
523
+ description: manifest.description || description,
524
+ main,
525
+ private: isPrivate,
526
+ license,
522
527
  engines: {
523
528
  node: `^${runtime.version}`,
524
529
  [runtime.packageManager]: '*',
525
530
  },
526
- scripts: defaults.scripts,
527
- dependencies: defaults.dependencies,
528
- devDependencies: defaults.devDependencies,
529
- ...(defaults.jest && { jest: defaults.jest }),
531
+ scripts,
532
+ dependencies,
533
+ devDependencies,
534
+ ...rest,
530
535
  };
531
536
 
532
537
  return fs.writeJSON(path.join(root, 'package.json'), packageJson, writejsonOptions);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corva/create-app",
3
- "version": "0.48.0-0-test-0718ceb",
3
+ "version": "0.48.0-2",
4
4
  "private": false,
5
5
  "description": "Create an app to use it in CORVA.AI",
6
6
  "keywords": [
@@ -67,6 +67,7 @@
67
67
  "@commitlint/config-conventional": "^17.3.0",
68
68
  "@corva/eslint-config-browser": "^0.1.7",
69
69
  "@corva/eslint-config-node": "^5.1.1",
70
+ "@corva/node-sdk": "^8.0.1",
70
71
  "@types/cross-spawn": "^6.0.2",
71
72
  "@typescript-eslint/eslint-plugin": "^5.42.1",
72
73
  "@typescript-eslint/parser": "^5.42.1",
@@ -0,0 +1,15 @@
1
+ const { ScheduledDataTimeEvent } = require('@corva/node-sdk');
2
+ const { app_runner } = require('@corva/node-sdk/lib/testing');
3
+
4
+ const { processor } = require('..');
5
+
6
+ test('processes event', async () => {
7
+ const event = new ScheduledDataTimeEvent({
8
+ company_id: 1,
9
+ asset_id: 1234,
10
+ start_time: 1578291000,
11
+ end_time: 1578291300,
12
+ });
13
+
14
+ expect(await app_runner(processor, event)).toBeUndefined();
15
+ });
@@ -0,0 +1,15 @@
1
+ const { Corva } = require('@corva/node-sdk');
2
+
3
+ /**
4
+ *
5
+ * @param {import('@corva/node-sdk').ScheduledDataTimeEvent} event
6
+ * @param {import('@corva/node-sdk').StatefulContext} context
7
+ */
8
+ const processor = async (event, context) => {
9
+ // Insert your logic here
10
+ context.logger.info('Hello, World!');
11
+ };
12
+
13
+ exports.processor = processor;
14
+
15
+ exports.handler = new Corva().scheduled(processor);
@@ -0,0 +1,15 @@
1
+ import { app_runner } from '@corva/node-sdk/lib/testing';
2
+ import { ScheduledDataTimeEvent } from '@corva/node-sdk';
3
+
4
+ import { processor } from '..';
5
+
6
+ test('processes event', async () => {
7
+ const event = new ScheduledDataTimeEvent({
8
+ company_id: 1,
9
+ asset_id: 1234,
10
+ start_time: 1578291000,
11
+ end_time: 1578291300,
12
+ });
13
+
14
+ expect(await app_runner(processor, event)).toBeUndefined();
15
+ });
@@ -0,0 +1,8 @@
1
+ import { Corva, ScheduledDataTimeEvent, StatefulContext } from '@corva/node-sdk';
2
+
3
+ export const processor = async (event: ScheduledDataTimeEvent, context: StatefulContext) => {
4
+ // Insert your logic here
5
+ context.logger.info('Hello, World!');
6
+ };
7
+
8
+ export const handler = new Corva().scheduled(processor);
@@ -0,0 +1,19 @@
1
+ # Dev Center Node.js Polling Scheduler Data App
2
+
3
+ ## Getting started
4
+
5
+ ### 1. Install Dependencies
6
+
7
+ ```
8
+ npm install
9
+ ```
10
+
11
+ ### 2. Run Tests
12
+
13
+ ```
14
+ npm test
15
+ ```
16
+
17
+ ### 3. Deploy
18
+
19
+ Run `npm run bundle` to create a zip package that can be uploaded to Dev Center
@@ -0,0 +1,17 @@
1
+ const { ScheduledDepthEvent } = require('@corva/node-sdk');
2
+ const { app_runner } = require('@corva/node-sdk/lib/testing');
3
+
4
+ const { processor } = require('..');
5
+
6
+ test('processes event', async () => {
7
+ const event = new ScheduledDepthEvent({
8
+ company_id: 1,
9
+ asset_id: 1234,
10
+ top_depth: 0,
11
+ bottom_depth: 1,
12
+ log_identifier: '5701c048cf9a',
13
+ interval: 1,
14
+ });
15
+
16
+ expect(await app_runner(processor, event)).toBeUndefined();
17
+ });
@@ -0,0 +1,15 @@
1
+ const { Corva } = require('@corva/node-sdk');
2
+
3
+ /**
4
+ *
5
+ * @param {import('@corva/node-sdk').ScheduledDepthEvent} event
6
+ * @param {import('@corva/node-sdk').StatefulContext} context
7
+ */
8
+ const processor = async (event, context) => {
9
+ // Insert your logic here
10
+ context.logger.info('Hello, World!');
11
+ };
12
+
13
+ exports.processor = processor;
14
+
15
+ exports.handler = new Corva().scheduled(processor);
@@ -0,0 +1,31 @@
1
+ # Dev Center Python Polling Scheduler Data App
2
+
3
+ ## Getting started
4
+
5
+ [Python SDK Documentation](https://corva-ai.github.io/python-sdk)
6
+
7
+ ### 1. Install
8
+
9
+ You need to have `make` installed:
10
+
11
+ - Windows: [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install)
12
+ - OS X: [Command Line Tools for Xcode](https://developer.apple.com/download/more/)
13
+ - Linux: refer to your distro-specific docs
14
+
15
+ To install dependencies run:
16
+
17
+ ```sh
18
+ make
19
+ ```
20
+
21
+ ### 2. Run Tests
22
+
23
+ ```sh
24
+ make test
25
+ ```
26
+
27
+ ### 3. Create app zip
28
+
29
+ ```sh
30
+ make bundle
31
+ ```
@@ -0,0 +1,7 @@
1
+ from corva import Api, Cache, Logger, ScheduledDepthEvent, scheduled
2
+
3
+
4
+ @scheduled
5
+ def lambda_handler(event: ScheduledDepthEvent, api: Api, cache: Cache):
6
+ """Insert your logic here"""
7
+ Logger.info('Hello, World!')
@@ -0,0 +1,10 @@
1
+ from corva import ScheduledDepthEvent
2
+ from lambda_function import lambda_handler
3
+
4
+
5
+ def test_app(app_runner):
6
+ event = ScheduledDepthEvent(
7
+ company_id=1, asset_id=1234, top_depth=0, bottom_depth=1, log_identifier="log_identifier", interval=1
8
+ )
9
+
10
+ app_runner(lambda_handler, event=event)