@corva/create-app 0.48.0-0 → 0.48.0-1

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 (120) 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 +13 -1
  5. package/lib/constants/package.js +20 -10
  6. package/lib/flows/lib/manifest.js +31 -0
  7. package/lib/helpers/manifest.js +6 -9
  8. package/lib/helpers/resolve-app-runtime.js +24 -0
  9. package/lib/main.js +36 -31
  10. package/package.json +2 -1
  11. package/templates/{javascript/scheduler → scheduler_data-time/javascript}/README.md +0 -0
  12. package/templates/scheduler_data-time/javascript/__test__/processor.spec.js +15 -0
  13. package/templates/scheduler_data-time/javascript/index.js +15 -0
  14. package/templates/{python/scheduler → scheduler_data-time/python}/README.md +0 -0
  15. package/templates/{python/scheduler → scheduler_data-time/python}/lambda_function.py +0 -0
  16. package/templates/{python/scheduler → scheduler_data-time/python}/test/__init__.py +0 -0
  17. package/templates/{python/scheduler → scheduler_data-time/python}/test/app_test.py +0 -0
  18. package/templates/{typescript/scheduler → scheduler_data-time/typescript}/README.md +0 -0
  19. package/templates/scheduler_data-time/typescript/__test__/processor.spec.ts +15 -0
  20. package/templates/scheduler_data-time/typescript/index.ts +8 -0
  21. package/templates/scheduler_depth/javascript/README.md +19 -0
  22. package/templates/scheduler_depth/javascript/__test__/processor.spec.js +17 -0
  23. package/templates/scheduler_depth/javascript/index.js +15 -0
  24. package/templates/scheduler_depth/python/README.md +31 -0
  25. package/templates/scheduler_depth/python/lambda_function.py +7 -0
  26. package/templates/{python/stream → scheduler_depth/python}/test/__init__.py +0 -0
  27. package/templates/scheduler_depth/python/test/app_test.py +10 -0
  28. package/templates/scheduler_depth/typescript/README.md +25 -0
  29. package/templates/scheduler_depth/typescript/__test__/processor.spec.ts +17 -0
  30. package/templates/scheduler_depth/typescript/index.ts +8 -0
  31. package/templates/scheduler_natural-time/javascript/README.md +19 -0
  32. package/templates/scheduler_natural-time/javascript/__test__/processor.spec.js +15 -0
  33. package/templates/scheduler_natural-time/javascript/index.js +15 -0
  34. package/templates/scheduler_natural-time/python/README.md +31 -0
  35. package/templates/scheduler_natural-time/python/lambda_function.py +7 -0
  36. package/templates/{python/task → scheduler_natural-time/python}/test/__init__.py +0 -0
  37. package/templates/scheduler_natural-time/python/test/app_test.py +10 -0
  38. package/templates/scheduler_natural-time/typescript/README.md +25 -0
  39. package/templates/scheduler_natural-time/typescript/__test__/processor.spec.ts +15 -0
  40. package/templates/scheduler_natural-time/typescript/index.ts +8 -0
  41. package/templates/{javascript/stream → stream_depth/javascript}/README.md +0 -0
  42. package/templates/stream_depth/javascript/__test__/processor.spec.js +20 -0
  43. package/templates/stream_depth/javascript/index.js +14 -0
  44. package/templates/{python/stream → stream_depth/python}/README.md +0 -0
  45. package/templates/stream_depth/python/lambda_function.py +7 -0
  46. package/templates/stream_depth/python/test/__init__.py +0 -0
  47. package/templates/stream_depth/python/test/app_test.py +16 -0
  48. package/templates/{typescript/stream → stream_depth/typescript}/README.md +0 -0
  49. package/templates/stream_depth/typescript/__test__/processor.spec.ts +20 -0
  50. package/templates/stream_depth/typescript/index.ts +8 -0
  51. package/templates/stream_time/javascript/README.md +19 -0
  52. package/templates/stream_time/javascript/__test__/processor.spec.js +14 -0
  53. package/templates/stream_time/javascript/index.js +14 -0
  54. package/templates/stream_time/python/README.md +31 -0
  55. package/templates/{python/stream → stream_time/python}/lambda_function.py +0 -0
  56. package/templates/stream_time/python/test/__init__.py +0 -0
  57. package/templates/{python/stream → stream_time/python}/test/app_test.py +0 -0
  58. package/templates/stream_time/typescript/README.md +25 -0
  59. package/templates/stream_time/typescript/__test__/processor.spec.ts +14 -0
  60. package/templates/stream_time/typescript/index.ts +8 -0
  61. package/templates/{javascript/task → task/javascript}/README.md +0 -0
  62. package/templates/task/javascript/__test__/processor.spec.js +16 -0
  63. package/templates/task/javascript/index.js +15 -0
  64. package/templates/{python/task → task/python}/README.md +0 -0
  65. package/templates/{python/task → task/python}/lambda_function.py +0 -0
  66. package/templates/task/python/test/__init__.py +0 -0
  67. package/templates/{python/task → task/python}/test/app_test.py +1 -1
  68. package/templates/{typescript/task → task/typescript}/README.md +0 -0
  69. package/templates/task/typescript/__test__/processor.spec.ts +16 -0
  70. package/templates/task/typescript/index.ts +8 -0
  71. package/templates/{javascript/ui → ui/javascript}/.env +0 -0
  72. package/templates/{javascript/ui → ui/javascript}/.env.sample +0 -0
  73. package/templates/{javascript/ui → ui/javascript}/.eslintrc +0 -0
  74. package/templates/{javascript/ui → ui/javascript}/.prettierrc +0 -0
  75. package/templates/{javascript/ui → ui/javascript}/README.md +0 -0
  76. package/templates/{javascript/ui → ui/javascript}/config-overrides.js +0 -0
  77. package/templates/{javascript/ui → ui/javascript}/gitignore +0 -0
  78. package/templates/{javascript/ui → ui/javascript}/src/App.css +0 -0
  79. package/templates/{javascript/ui → ui/javascript}/src/App.js +0 -0
  80. package/templates/{javascript/ui → ui/javascript}/src/AppSettings.js +0 -0
  81. package/templates/{javascript/ui → ui/javascript}/src/__tests__/TestExample.test.js +0 -0
  82. package/templates/{javascript/ui → ui/javascript}/src/assets/logo.svg +0 -0
  83. package/templates/{javascript/ui → ui/javascript}/src/constants.js +0 -0
  84. package/templates/{javascript/ui → ui/javascript}/src/index.js +0 -0
  85. package/templates/{javascript/ui → ui/javascript}/src/setupTests.js +0 -0
  86. package/templates/{typescript/ui → ui/typescript}/.env +0 -0
  87. package/templates/{typescript/ui → ui/typescript}/.env.sample +0 -0
  88. package/templates/{typescript/ui → ui/typescript}/.eslintrc +0 -0
  89. package/templates/{typescript/ui → ui/typescript}/.prettierrc +0 -0
  90. package/templates/{typescript/ui → ui/typescript}/README.md +0 -0
  91. package/templates/{typescript/ui → ui/typescript}/config-overrides.js +0 -0
  92. package/templates/{typescript/ui → ui/typescript}/gitignore +0 -0
  93. package/templates/{typescript/ui → ui/typescript}/src/App.css +0 -0
  94. package/templates/{typescript/ui → ui/typescript}/src/App.tsx +0 -0
  95. package/templates/{typescript/ui → ui/typescript}/src/AppSettings.tsx +0 -0
  96. package/templates/{typescript/ui → ui/typescript}/src/__tests__/TestExample.test.tsx +0 -0
  97. package/templates/{typescript/ui → ui/typescript}/src/assets/logo.svg +0 -0
  98. package/templates/{typescript/ui → ui/typescript}/src/constants.ts +0 -0
  99. package/templates/{typescript/ui → ui/typescript}/src/custom.d.ts +0 -0
  100. package/templates/{typescript/ui → ui/typescript}/src/index.js +0 -0
  101. package/templates/{typescript/ui → ui/typescript}/src/setupTests.ts +0 -0
  102. package/templates/{typescript/ui → ui/typescript}/tsconfig.json +0 -0
  103. package/templates/javascript/scheduler/__test__/processor.test.js +0 -19
  104. package/templates/javascript/scheduler/index.js +0 -15
  105. package/templates/javascript/scheduler/src/processor.js +0 -17
  106. package/templates/javascript/stream/__test__/processor.test.js +0 -44
  107. package/templates/javascript/stream/index.js +0 -15
  108. package/templates/javascript/stream/src/processor.js +0 -18
  109. package/templates/javascript/task/__test__/processor.test.js +0 -18
  110. package/templates/javascript/task/index.js +0 -16
  111. package/templates/javascript/task/src/processor.js +0 -17
  112. package/templates/typescript/scheduler/__test__/processor.spec.ts +0 -20
  113. package/templates/typescript/scheduler/index.ts +0 -8
  114. package/templates/typescript/scheduler/lib/processor.ts +0 -14
  115. package/templates/typescript/stream/__test__/processor.spec.ts +0 -43
  116. package/templates/typescript/stream/index.ts +0 -8
  117. package/templates/typescript/stream/lib/processor.ts +0 -16
  118. package/templates/typescript/task/__test__/processor.spec.ts +0 -27
  119. package/templates/typescript/task/index.ts +0 -8
  120. 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
@@ -108,10 +108,15 @@ export const SCHEDULER_TYPE_DATA_TIME = {
108
108
  value: 2,
109
109
  };
110
110
  export const SCHEDULER_TYPE_DEPTH = {
111
- name: 'Date Depth',
111
+ name: 'Depth',
112
112
  value: 4,
113
113
  };
114
114
 
115
+ export const LOG_TYPES = {
116
+ TIME: 'time',
117
+ DEPTH: 'depth',
118
+ };
119
+
115
120
  export const manifestOptions = (projectName = 'Corva Dev Center App') => [
116
121
  {
117
122
  name: 'developerName',
@@ -152,6 +157,13 @@ export const manifestOptions = (projectName = 'Corva Dev Center App') => [
152
157
  when: (answers) => answers.schedulerType === SCHEDULER_TYPE_DEPTH.value,
153
158
  filter: (value) => (isNaN(value) ? value : Number(value)),
154
159
  },
160
+ {
161
+ name: 'logType',
162
+ message: 'Choose the log type',
163
+ default: LOG_TYPES.TIME,
164
+ choices: Object.values(LOG_TYPES),
165
+ when: (answers) => answers.appType === APP_TYPES.STREAM,
166
+ },
155
167
  {
156
168
  name: 'appKey',
157
169
  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 = {
@@ -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
  }
@@ -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
  };
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",
3
+ "version": "0.48.0-1",
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)
@@ -0,0 +1,25 @@
1
+ # Dev Center Node.js TypeScript 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. Build
18
+
19
+ ```
20
+ npm run build
21
+ ```
22
+
23
+ ### 4. Deploy
24
+
25
+ Run `npm run bundle` to create a zip package that can be uploaded to Dev Center
@@ -0,0 +1,17 @@
1
+ import { app_runner } from '@corva/node-sdk/lib/testing';
2
+ import { ScheduledDepthEvent } from '@corva/node-sdk';
3
+
4
+ import { processor } from '..';
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,8 @@
1
+ import { Corva, ScheduledDepthEvent, StatefulContext } from '@corva/node-sdk';
2
+
3
+ export const processor = async (event: ScheduledDepthEvent, 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,15 @@
1
+ const { ScheduledNaturalTimeEvent } = 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 ScheduledNaturalTimeEvent({
8
+ company_id: 1,
9
+ asset_id: 1234,
10
+ schedule_start: 1578291000,
11
+ interval: 60,
12
+ });
13
+
14
+ expect(await app_runner(processor, event)).toBeUndefined();
15
+ });