@corva/create-app 0.11.0-0 → 0.12.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 (60) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +57 -0
  3. package/constants/manifest.js +91 -49
  4. package/constants/package.js +23 -24
  5. package/helpers/manifest.js +25 -12
  6. package/helpers/utils.js +2 -2
  7. package/helpers/versioning.js +14 -14
  8. package/index.js +158 -164
  9. package/package.json +62 -58
  10. package/scripts/ui/index.js +2 -2
  11. package/scripts/ui/zipAppSource.js +31 -41
  12. package/scripts/utils/version.js +9 -22
  13. package/template/scheduler/node/__test__/processor.test.js +12 -12
  14. package/template/scheduler/node/gitignore +21 -0
  15. package/template/scheduler/node/index.js +5 -6
  16. package/template/scheduler/node/package.json +3 -3
  17. package/template/scheduler/node/src/processor.js +9 -13
  18. package/template/scheduler/node-ts/README.md +25 -0
  19. package/template/scheduler/node-ts/__test__/processor.spec.ts +20 -0
  20. package/template/scheduler/node-ts/gitignore +25 -0
  21. package/template/scheduler/node-ts/index.ts +8 -0
  22. package/template/scheduler/node-ts/lib/processor.ts +13 -0
  23. package/template/scheduler/node-ts/package.json +37 -0
  24. package/template/scheduler/node-ts/tsconfig.build.json +11 -0
  25. package/template/scheduler/node-ts/tsconfig.json +33 -0
  26. package/template/stream/node/README.md +1 -1
  27. package/template/stream/node/__test__/processor.test.js +37 -40
  28. package/template/stream/node/gitignore +21 -0
  29. package/template/stream/node/index.js +5 -6
  30. package/template/stream/node/package.json +3 -3
  31. package/template/stream/node/src/processor.js +11 -14
  32. package/template/stream/node-ts/README.md +25 -0
  33. package/template/stream/node-ts/__test__/processor.spec.ts +43 -0
  34. package/template/stream/node-ts/gitignore +25 -0
  35. package/template/stream/node-ts/index.ts +8 -0
  36. package/template/stream/node-ts/lib/processor.ts +16 -0
  37. package/template/stream/node-ts/package.json +37 -0
  38. package/template/stream/node-ts/tsconfig.build.json +11 -0
  39. package/template/stream/node-ts/tsconfig.json +33 -0
  40. package/template/task/node/README.md +1 -1
  41. package/template/task/node/__test__/processor.test.js +18 -0
  42. package/template/task/node/gitignore +21 -0
  43. package/template/task/node/index.js +7 -8
  44. package/template/task/node/package.json +3 -3
  45. package/template/task/node/src/processor.js +9 -14
  46. package/template/task/node-ts/README.md +25 -0
  47. package/template/task/node-ts/__test__/processor.spec.ts +27 -0
  48. package/template/task/node-ts/gitignore +25 -0
  49. package/template/task/node-ts/index.ts +8 -0
  50. package/template/task/node-ts/package.json +37 -0
  51. package/template/task/node-ts/src/processor.ts +13 -0
  52. package/template/task/node-ts/tsconfig.build.json +11 -0
  53. package/template/task/node-ts/tsconfig.json +33 -0
  54. package/template/ui/README.md +1 -1
  55. package/template/ui/gitignore +1 -0
  56. package/template/ui/src/App.js +2 -1
  57. package/template/ui/src/AppSettings.js +1 -1
  58. package/template/ui/src/constants.js +1 -1
  59. package/template/ui/src/index.js +2 -2
  60. package/helpers/metadata.js +0 -29
@@ -1,21 +1,18 @@
1
1
  class Processor {
2
- constructor({ apiClient, logger}) {
3
- this.apiClient = apiClient;
4
- this.logger = logger;
5
- }
6
-
7
- async process({ event }) {
8
- const {
9
- asset_id,
10
- records,
11
- } = event;
2
+ constructor({ apiClient, logger }) {
3
+ this.apiClient = apiClient;
4
+ this.logger = logger;
5
+ }
12
6
 
13
- if (!records.length) {
14
- return;
15
- }
7
+ async process({ event }) {
8
+ const { asset_id, records } = event;
16
9
 
17
- this.logger.info(`Processing event. Asset: ${asset_id}. Received ${records.length} records.`);
10
+ if (!records.length) {
11
+ return;
18
12
  }
13
+
14
+ this.logger.info(`Processing event. Asset: ${asset_id}. Received ${records.length} records.`);
15
+ }
19
16
  }
20
17
 
21
18
  module.exports = Processor;
@@ -0,0 +1,25 @@
1
+ # Dev Center Node.js TypeScript Real-Time Stream 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,43 @@
1
+ import { Processor } from '../lib/processor';
2
+ import type { HandlerContext } from '@corva/node-sdk';
3
+ import { NormalizedStreamLambdaEvent } from '@corva/node-sdk/lib/lambdas/interfaces';
4
+
5
+ test('process event', async () => {
6
+ const fakeLogger = console as unknown as HandlerContext['logger'];
7
+ const fakeApiClient = {} as unknown as HandlerContext['api'];
8
+
9
+ const processor = new Processor(fakeApiClient, fakeLogger);
10
+
11
+ const event = {
12
+ asset_id: 1234,
13
+ app_stream_id: 2345,
14
+ records: [
15
+ {
16
+ company_id: 1,
17
+ asset_id: 1234,
18
+ timestamp: 157829400,
19
+ data: { hole_depth: 1000 },
20
+ },
21
+ {
22
+ company_id: 1,
23
+ asset_id: 1234,
24
+ timestamp: 157829401,
25
+ data: { hole_depth: 1001 },
26
+ },
27
+ {
28
+ company_id: 1,
29
+ asset_id: 1234,
30
+ timestamp: 157829402,
31
+ data: { hole_depth: 1001 },
32
+ },
33
+ {
34
+ company_id: 1,
35
+ asset_id: 1234,
36
+ timestamp: 157829403,
37
+ data: { hole_depth: 1001.5 },
38
+ },
39
+ ],
40
+ } as unknown as NormalizedStreamLambdaEvent<unknown>;
41
+
42
+ await processor.process(event);
43
+ });
@@ -0,0 +1,25 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+
6
+ # testing
7
+ /coverage
8
+
9
+ # misc
10
+ .env
11
+ .DS_Store
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+
17
+ npm-debug.log*
18
+ yarn-debug.log*
19
+ yarn-error.log*
20
+
21
+ **/*.js
22
+ **/*.js.map
23
+ **/.d.ts
24
+
25
+ *.zip
@@ -0,0 +1,8 @@
1
+ import { Corva } from '@corva/node-sdk';
2
+ import { Processor } from './lib/processor';
3
+
4
+ export const handler = new Corva().stream(async (event, context) => {
5
+ const processor = new Processor(context.api, context.logger);
6
+
7
+ await processor.process(event);
8
+ });
@@ -0,0 +1,16 @@
1
+ import type { HandlerContext } from '@corva/node-sdk';
2
+ import { NormalizedStreamLambdaEvent } from '@corva/node-sdk/lib/lambdas/interfaces';
3
+
4
+ export class Processor {
5
+ constructor(private apiClient: HandlerContext['api'], private logger: HandlerContext['logger']) {}
6
+
7
+ async process(event: NormalizedStreamLambdaEvent<unknown>) {
8
+ const { asset_id, records } = event;
9
+
10
+ if (!records.length) {
11
+ return;
12
+ }
13
+
14
+ this.logger.info(`Processing event. Asset: ${asset_id}. Received ${records.length} records.`);
15
+ }
16
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "my-dev-center-real-time-stream-app",
3
+ "version": "0.0.1",
4
+ "description": "My Dev Center Real-Time Stream Data App",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "bundle": "zip -r $npm_package_name-$npm_package_version.zip package.json $LOCKFILE manifest.json index.js lib -x '*.ts'",
8
+ "test": "npm audit --production && npm run unit",
9
+ "build": "tsc -p tsconfig.build.json",
10
+ "unit": "jest"
11
+ },
12
+ "jest": {
13
+ "moduleFileExtensions": [
14
+ "js",
15
+ "json",
16
+ "ts"
17
+ ],
18
+ "rootDir": ".",
19
+ "testEnvironment": "node",
20
+ "testMatch": [
21
+ "**/*.spec.ts"
22
+ ],
23
+ "transform": {
24
+ "^.+\\.ts$": "ts-jest"
25
+ },
26
+ "verbose": true
27
+ },
28
+ "dependencies": {
29
+ "@corva/node-sdk": "^5.3.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/jest": "^27.0.1",
33
+ "jest": "^27.2.1",
34
+ "ts-jest": "^27.0.5",
35
+ "typescript": "^4.4.3"
36
+ }
37
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": [
4
+ "lib/**/*.ts",
5
+ "index.ts"
6
+ ],
7
+ "exclude": [
8
+ "node_modules",
9
+ "**/*.spec.ts"
10
+ ]
11
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "include": [
3
+ "lib/**/*.ts",
4
+ "__tests__"
5
+ ],
6
+ "exclude": [
7
+ "node_modules"
8
+ ],
9
+ "compilerOptions": {
10
+ "target": "es2019",
11
+ "skipLibCheck": false,
12
+ "baseUrl": "./",
13
+ "moduleResolution": "node",
14
+ "esModuleInterop": true,
15
+ "resolveJsonModule": true,
16
+ "checkJs": false,
17
+ "module": "commonjs",
18
+ "alwaysStrict": true,
19
+ "noImplicitAny": true,
20
+ "allowSyntheticDefaultImports": true,
21
+ "declaration": false,
22
+ "sourceMap": true,
23
+ "types": [
24
+ "jest"
25
+ ],
26
+ "typeRoots": [
27
+ "./node_modules/@types",
28
+ ]
29
+ },
30
+ "typeAcquisition": {
31
+ "enable": true
32
+ }
33
+ }
@@ -16,4 +16,4 @@ npm test
16
16
 
17
17
  ### 3. Deploy
18
18
 
19
- Run `npm run bundle` to create a zip package that can be uploaded to Dev Center
19
+ Run `npm run bundle` to create a zip package that can be uploaded to Dev Center
@@ -0,0 +1,18 @@
1
+ const Processor = require('../src/processor');
2
+
3
+ test('process event', async () => {
4
+ const fakeLogger = console;
5
+ const fakeApiClient = {};
6
+
7
+ const event = {
8
+ asset_id: 123,
9
+ company_id: 1234,
10
+ properties: {
11
+ foo: 'bar',
12
+ },
13
+ };
14
+
15
+ const processor = new Processor({ logger: fakeLogger, apiClient: fakeApiClient });
16
+
17
+ await processor.process({ event });
18
+ });
@@ -0,0 +1,21 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+
6
+ # testing
7
+ /coverage
8
+
9
+ # misc
10
+ .env
11
+ .DS_Store
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+
17
+ npm-debug.log*
18
+ yarn-debug.log*
19
+ yarn-error.log*
20
+
21
+ *.zip
@@ -2,16 +2,15 @@ const { Corva } = require('@corva/node-sdk');
2
2
  const Processor = require('./src/processor');
3
3
 
4
4
  /**
5
- * @param {import('@corva/node-sdk').TaskLambdaEvent} event
5
+ * @param {import('@corva/node-sdk').Task} event
6
6
  * @param {import('@corva/node-sdk').HandlerContext} context
7
7
  */
8
8
  exports.handler = new Corva().task((event, context) => {
9
+ const processor = new Processor({
10
+ apiClient: context.api,
11
+ logger: context.logger,
12
+ config: context.config,
13
+ });
9
14
 
10
- const processor = new Processor({
11
- apiClient: context.api,
12
- logger: context.logger,
13
- config: context.config,
14
- });
15
-
16
- return processor.process({ event });
15
+ return processor.process({ event });
17
16
  });
@@ -4,14 +4,14 @@
4
4
  "description": "My Dev Center Task Data App",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "bundle": "zip -r $npm_package_name-$npm_package_version.zip package.json package-lock.json manifest.json index.js src",
7
+ "bundle": "zip -r $npm_package_name-$npm_package_version.zip package.json $LOCKFILE manifest.json index.js src",
8
8
  "test": "npm audit --production && npm run unit",
9
9
  "unit": "jest"
10
10
  },
11
11
  "dependencies": {
12
- "@corva/node-sdk": "^1.5.5"
12
+ "@corva/node-sdk": "^5.3.1"
13
13
  },
14
14
  "devDependencies": {
15
- "jest": "^26.6.3"
15
+ "jest": "^27.2.0"
16
16
  }
17
17
  }
@@ -1,21 +1,16 @@
1
1
  class Processor {
2
+ constructor({ apiClient, logger, config }) {
3
+ this.apiClient = apiClient;
4
+ this.logger = logger;
5
+ }
2
6
 
3
- constructor({ apiClient, logger, config }) {
4
- this.apiClient = apiClient;
5
- this.logger = logger;
6
- this.config = config;
7
- }
7
+ async process({ event }) {
8
+ this.logger.debug({ event }, 'Event');
8
9
 
9
- async process({ event }) {
10
- this.logger.debug({ event }, 'Event');
10
+ const { asset_id: assetId, company_id: companyId } = event;
11
11
 
12
- const {
13
- asset_id: assetId,
14
- company_id: companyId
15
- } = event;
16
-
17
- this.logger.info(`Processing event. Asset: ${assetId}`);
18
- }
12
+ this.logger.info(`Processing event. Asset: ${assetId}`);
13
+ }
19
14
  }
20
15
 
21
16
  module.exports = Processor;
@@ -0,0 +1,25 @@
1
+ # Dev Center Node.js Task 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,27 @@
1
+ import { HandlerContext, Task, TaskState } from '@corva/node-sdk';
2
+ import { Processor } from '../src/processor';
3
+
4
+ test('process event', async () => {
5
+ const fakeLogger = console as unknown as HandlerContext['logger'];
6
+ const fakeApiClient = {} as unknown as HandlerContext['api'];
7
+
8
+ const event: Task<{
9
+ foo: string;
10
+ }> = {
11
+ id: 'id',
12
+ state: TaskState.Running,
13
+ fail_reason: null,
14
+ asset_id: 123,
15
+ company_id: 1234,
16
+ properties: {
17
+ foo: 'bar',
18
+ },
19
+ document_bucket: 'test',
20
+ payload: null,
21
+ app_id: 42,
22
+ };
23
+
24
+ const processor = new Processor(fakeApiClient, fakeLogger);
25
+
26
+ await processor.process(event);
27
+ });
@@ -0,0 +1,25 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+
6
+ # testing
7
+ /coverage
8
+
9
+ # misc
10
+ .env
11
+ .DS_Store
12
+ .env.local
13
+ .env.development.local
14
+ .env.test.local
15
+ .env.production.local
16
+
17
+ npm-debug.log*
18
+ yarn-debug.log*
19
+ yarn-error.log*
20
+
21
+ **/*.js
22
+ **/*.js.map
23
+ **/.d.ts
24
+
25
+ *.zip
@@ -0,0 +1,8 @@
1
+ import { Corva } from '@corva/node-sdk';
2
+ import { Processor } from './src/processor';
3
+
4
+ exports.handler = new Corva().task((event, context) => {
5
+ const processor = new Processor(context.api, context.logger);
6
+
7
+ return processor.process(event);
8
+ });
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "my-dev-center-task-app",
3
+ "version": "0.0.1",
4
+ "description": "My Dev Center Task Data App",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "bundle": "zip -r $npm_package_name-$npm_package_version.zip package.json $LOCKFILE manifest.json index.js lib -x '*.ts'",
8
+ "test": "npm audit --production && npm run unit",
9
+ "build": "tsc -p tsconfig.build.json",
10
+ "unit": "jest"
11
+ },
12
+ "jest": {
13
+ "moduleFileExtensions": [
14
+ "js",
15
+ "json",
16
+ "ts"
17
+ ],
18
+ "rootDir": ".",
19
+ "testEnvironment": "node",
20
+ "testMatch": [
21
+ "**/*.spec.ts"
22
+ ],
23
+ "transform": {
24
+ "^.+\\.ts$": "ts-jest"
25
+ },
26
+ "verbose": true
27
+ },
28
+ "dependencies": {
29
+ "@corva/node-sdk": "^5.3.1"
30
+ },
31
+ "devDependencies": {
32
+ "@types/jest": "^27.0.1",
33
+ "jest": "^27.2.1",
34
+ "ts-jest": "^27.0.5",
35
+ "typescript": "^4.4.3"
36
+ }
37
+ }
@@ -0,0 +1,13 @@
1
+ import type { HandlerContext, Task } from '@corva/node-sdk';
2
+
3
+ export class Processor {
4
+ constructor(private apiClient: HandlerContext['api'], private logger: HandlerContext['logger']) {}
5
+
6
+ async process(event: Task) {
7
+ this.logger.debug({ event }, 'Event');
8
+
9
+ const { asset_id: assetId, company_id: companyId } = event;
10
+
11
+ this.logger.info(`Processing event. Asset: ${assetId}`);
12
+ }
13
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": [
4
+ "lib/**/*.ts",
5
+ "index.ts"
6
+ ],
7
+ "exclude": [
8
+ "node_modules",
9
+ "**/*.spec.ts"
10
+ ]
11
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "include": [
3
+ "lib/**/*.ts",
4
+ "__tests__"
5
+ ],
6
+ "exclude": [
7
+ "node_modules"
8
+ ],
9
+ "compilerOptions": {
10
+ "target": "es2019",
11
+ "skipLibCheck": false,
12
+ "baseUrl": "./",
13
+ "moduleResolution": "node",
14
+ "esModuleInterop": true,
15
+ "resolveJsonModule": true,
16
+ "checkJs": false,
17
+ "module": "commonjs",
18
+ "alwaysStrict": true,
19
+ "noImplicitAny": true,
20
+ "allowSyntheticDefaultImports": true,
21
+ "declaration": false,
22
+ "sourceMap": true,
23
+ "types": [
24
+ "jest"
25
+ ],
26
+ "typeRoots": [
27
+ "./node_modules/@types",
28
+ ]
29
+ },
30
+ "typeAcquisition": {
31
+ "enable": true
32
+ }
33
+ }
@@ -16,7 +16,7 @@ You will also see any lint errors in the console.
16
16
 
17
17
  Bundles the app into static files for production.
18
18
 
19
- ### `yarn zip`
19
+ ### `yarn zip`
20
20
 
21
21
  Bundles the app into ZIP file in app root directory
22
22
 
@@ -12,6 +12,7 @@
12
12
  /build
13
13
 
14
14
  # misc
15
+ .env
15
16
  .DS_Store
16
17
  .env.local
17
18
  .env.development.local
@@ -28,7 +28,8 @@ function App(props) {
28
28
  </a>
29
29
  </div>
30
30
  <div>
31
- Settings &quot;Example&quot; checkbox is {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
31
+ Settings &quot;Example&quot; checkbox is{' '}
32
+ {isExampleCheckboxChecked ? 'checked' : 'unchecked'}
32
33
  </div>
33
34
  </div>
34
35
  </div>
@@ -33,7 +33,7 @@ AppSettings.propTypes = {
33
33
  company: PropTypes.shape({}),
34
34
  onSettingChange: PropTypes.func.isRequired,
35
35
  settings: PropTypes.shape({
36
- isExampleCheckboxChecked: PropTypes.bool
36
+ isExampleCheckboxChecked: PropTypes.bool,
37
37
  }).isRequired,
38
38
  user: PropTypes.shape({}),
39
39
  };
@@ -1,3 +1,3 @@
1
1
  export const DEFAULT_SETTINGS = {
2
- isExampleCheckboxChecked: false
2
+ isExampleCheckboxChecked: false,
3
3
  };
@@ -1,5 +1,5 @@
1
- import App from "./App";
2
- import AppSettings from "./AppSettings";
1
+ import App from './App';
2
+ import AppSettings from './AppSettings';
3
3
 
4
4
  export default {
5
5
  component: App,
@@ -1,29 +0,0 @@
1
- function getType(item) {
2
- if (typeof item === "string") return null;
3
- if (Array.isArray(item)) return "rawlist";
4
-
5
- if (typeof item === "boolean") return "expand";
6
- }
7
-
8
- function getChoices(item) {
9
- if (typeof item === "string") return null;
10
-
11
- if (Array.isArray(item)) return item;
12
-
13
- if (typeof item === "boolean")
14
- return [
15
- {
16
- key: "y",
17
- value: true,
18
- },
19
- {
20
- key: "n",
21
- value: false,
22
- },
23
- ];
24
- }
25
-
26
- module.exports = {
27
- getType,
28
- getChoices,
29
- };