@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.
- package/common/python/.env +0 -9
- package/common/python/.env.sample +1 -17
- package/common/python/requirements.txt +1 -1
- package/lib/constants/manifest.js +13 -1
- package/lib/constants/package.js +20 -10
- package/lib/flows/lib/manifest.js +31 -0
- package/lib/helpers/manifest.js +6 -9
- package/lib/helpers/resolve-app-runtime.js +24 -0
- package/lib/main.js +36 -31
- package/package.json +2 -1
- package/templates/{javascript/scheduler → scheduler_data-time/javascript}/README.md +0 -0
- package/templates/scheduler_data-time/javascript/__test__/processor.spec.js +15 -0
- package/templates/scheduler_data-time/javascript/index.js +15 -0
- package/templates/{python/scheduler → scheduler_data-time/python}/README.md +0 -0
- package/templates/{python/scheduler → scheduler_data-time/python}/lambda_function.py +0 -0
- package/templates/{python/scheduler → scheduler_data-time/python}/test/__init__.py +0 -0
- package/templates/{python/scheduler → scheduler_data-time/python}/test/app_test.py +0 -0
- package/templates/{typescript/scheduler → scheduler_data-time/typescript}/README.md +0 -0
- package/templates/scheduler_data-time/typescript/__test__/processor.spec.ts +15 -0
- package/templates/scheduler_data-time/typescript/index.ts +8 -0
- package/templates/scheduler_depth/javascript/README.md +19 -0
- package/templates/scheduler_depth/javascript/__test__/processor.spec.js +17 -0
- package/templates/scheduler_depth/javascript/index.js +15 -0
- package/templates/scheduler_depth/python/README.md +31 -0
- package/templates/scheduler_depth/python/lambda_function.py +7 -0
- package/templates/{python/stream → scheduler_depth/python}/test/__init__.py +0 -0
- package/templates/scheduler_depth/python/test/app_test.py +10 -0
- package/templates/scheduler_depth/typescript/README.md +25 -0
- package/templates/scheduler_depth/typescript/__test__/processor.spec.ts +17 -0
- package/templates/scheduler_depth/typescript/index.ts +8 -0
- package/templates/scheduler_natural-time/javascript/README.md +19 -0
- package/templates/scheduler_natural-time/javascript/__test__/processor.spec.js +15 -0
- package/templates/scheduler_natural-time/javascript/index.js +15 -0
- package/templates/scheduler_natural-time/python/README.md +31 -0
- package/templates/scheduler_natural-time/python/lambda_function.py +7 -0
- package/templates/{python/task → scheduler_natural-time/python}/test/__init__.py +0 -0
- package/templates/scheduler_natural-time/python/test/app_test.py +10 -0
- package/templates/scheduler_natural-time/typescript/README.md +25 -0
- package/templates/scheduler_natural-time/typescript/__test__/processor.spec.ts +15 -0
- package/templates/scheduler_natural-time/typescript/index.ts +8 -0
- package/templates/{javascript/stream → stream_depth/javascript}/README.md +0 -0
- package/templates/stream_depth/javascript/__test__/processor.spec.js +20 -0
- package/templates/stream_depth/javascript/index.js +14 -0
- package/templates/{python/stream → stream_depth/python}/README.md +0 -0
- package/templates/stream_depth/python/lambda_function.py +7 -0
- package/templates/stream_depth/python/test/__init__.py +0 -0
- package/templates/stream_depth/python/test/app_test.py +16 -0
- package/templates/{typescript/stream → stream_depth/typescript}/README.md +0 -0
- package/templates/stream_depth/typescript/__test__/processor.spec.ts +20 -0
- package/templates/stream_depth/typescript/index.ts +8 -0
- package/templates/stream_time/javascript/README.md +19 -0
- package/templates/stream_time/javascript/__test__/processor.spec.js +14 -0
- package/templates/stream_time/javascript/index.js +14 -0
- package/templates/stream_time/python/README.md +31 -0
- package/templates/{python/stream → stream_time/python}/lambda_function.py +0 -0
- package/templates/stream_time/python/test/__init__.py +0 -0
- package/templates/{python/stream → stream_time/python}/test/app_test.py +0 -0
- package/templates/stream_time/typescript/README.md +25 -0
- package/templates/stream_time/typescript/__test__/processor.spec.ts +14 -0
- package/templates/stream_time/typescript/index.ts +8 -0
- package/templates/{javascript/task → task/javascript}/README.md +0 -0
- package/templates/task/javascript/__test__/processor.spec.js +16 -0
- package/templates/task/javascript/index.js +15 -0
- package/templates/{python/task → task/python}/README.md +0 -0
- package/templates/{python/task → task/python}/lambda_function.py +0 -0
- package/templates/task/python/test/__init__.py +0 -0
- package/templates/{python/task → task/python}/test/app_test.py +1 -1
- package/templates/{typescript/task → task/typescript}/README.md +0 -0
- package/templates/task/typescript/__test__/processor.spec.ts +16 -0
- package/templates/task/typescript/index.ts +8 -0
- package/templates/{javascript/ui → ui/javascript}/.env +0 -0
- package/templates/{javascript/ui → ui/javascript}/.env.sample +0 -0
- package/templates/{javascript/ui → ui/javascript}/.eslintrc +0 -0
- package/templates/{javascript/ui → ui/javascript}/.prettierrc +0 -0
- package/templates/{javascript/ui → ui/javascript}/README.md +0 -0
- package/templates/{javascript/ui → ui/javascript}/config-overrides.js +0 -0
- package/templates/{javascript/ui → ui/javascript}/gitignore +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/App.css +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/App.js +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/AppSettings.js +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/__tests__/TestExample.test.js +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/assets/logo.svg +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/constants.js +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/index.js +0 -0
- package/templates/{javascript/ui → ui/javascript}/src/setupTests.js +0 -0
- package/templates/{typescript/ui → ui/typescript}/.env +0 -0
- package/templates/{typescript/ui → ui/typescript}/.env.sample +0 -0
- package/templates/{typescript/ui → ui/typescript}/.eslintrc +0 -0
- package/templates/{typescript/ui → ui/typescript}/.prettierrc +0 -0
- package/templates/{typescript/ui → ui/typescript}/README.md +0 -0
- package/templates/{typescript/ui → ui/typescript}/config-overrides.js +0 -0
- package/templates/{typescript/ui → ui/typescript}/gitignore +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/App.css +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/App.tsx +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/AppSettings.tsx +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/__tests__/TestExample.test.tsx +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/assets/logo.svg +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/constants.ts +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/custom.d.ts +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/index.js +0 -0
- package/templates/{typescript/ui → ui/typescript}/src/setupTests.ts +0 -0
- package/templates/{typescript/ui → ui/typescript}/tsconfig.json +0 -0
- package/templates/javascript/scheduler/__test__/processor.test.js +0 -19
- package/templates/javascript/scheduler/index.js +0 -15
- package/templates/javascript/scheduler/src/processor.js +0 -17
- package/templates/javascript/stream/__test__/processor.test.js +0 -44
- package/templates/javascript/stream/index.js +0 -15
- package/templates/javascript/stream/src/processor.js +0 -18
- package/templates/javascript/task/__test__/processor.test.js +0 -18
- package/templates/javascript/task/index.js +0 -16
- package/templates/javascript/task/src/processor.js +0 -17
- package/templates/typescript/scheduler/__test__/processor.spec.ts +0 -20
- package/templates/typescript/scheduler/index.ts +0 -8
- package/templates/typescript/scheduler/lib/processor.ts +0 -14
- package/templates/typescript/stream/__test__/processor.spec.ts +0 -43
- package/templates/typescript/stream/index.ts +0 -8
- package/templates/typescript/stream/lib/processor.ts +0 -16
- package/templates/typescript/task/__test__/processor.spec.ts +0 -27
- package/templates/typescript/task/index.ts +0 -8
- package/templates/typescript/task/src/processor.ts +0 -14
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { Corva } = require('@corva/node-sdk');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {import('@corva/node-sdk').ScheduledNaturalTimeEvent} 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
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from corva import ScheduledNaturalTimeEvent
|
|
2
|
+
from lambda_function import lambda_handler
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_app(app_runner):
|
|
6
|
+
event = ScheduledNaturalTimeEvent(
|
|
7
|
+
company_id=1, asset_id=1234, schedule_start=1578291000, interval=60
|
|
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,15 @@
|
|
|
1
|
+
import { app_runner } from '@corva/node-sdk/lib/testing';
|
|
2
|
+
import { ScheduledNaturalTimeEvent } from '@corva/node-sdk';
|
|
3
|
+
|
|
4
|
+
import { processor } from '..';
|
|
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
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Corva, ScheduledNaturalTimeEvent, StatefulContext } from '@corva/node-sdk';
|
|
2
|
+
|
|
3
|
+
export const processor = async (event: ScheduledNaturalTimeEvent, context: StatefulContext) => {
|
|
4
|
+
// Insert your logic here
|
|
5
|
+
context.logger.info('Hello, World!');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const handler = new Corva().scheduled(processor);
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const { StreamDepthEvent, StreamDepthRecord } = 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 StreamDepthEvent({
|
|
8
|
+
company_id: 1,
|
|
9
|
+
asset_id: 1234,
|
|
10
|
+
records: [
|
|
11
|
+
new StreamDepthRecord({
|
|
12
|
+
data: { bit_depth: 4980, hole_depth: 5000 },
|
|
13
|
+
measured_depth: 5000,
|
|
14
|
+
log_identifier: '5701c048cf9a',
|
|
15
|
+
}),
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(await app_runner(processor, event)).toBeUndefined();
|
|
20
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { Corva } = require('@corva/node-sdk');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('@corva/node-sdk').StreamDepthEvent} event
|
|
5
|
+
* @param {import('@corva/node-sdk').StatefulContext} context
|
|
6
|
+
*/
|
|
7
|
+
const processor = async (event, context) => {
|
|
8
|
+
// Insert your logic here
|
|
9
|
+
context.logger.info('Hello, World!');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.processor = processor;
|
|
13
|
+
|
|
14
|
+
exports.handler = new Corva().stream(processor);
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from corva import StreamDepthEvent, StreamTimeRecord
|
|
2
|
+
from lambda_function import lambda_handler
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_app(app_runner):
|
|
6
|
+
event = StreamDepthEvent(
|
|
7
|
+
company_id=1,
|
|
8
|
+
asset_id=1234,
|
|
9
|
+
records=[
|
|
10
|
+
StreamDepthRecord(
|
|
11
|
+
data={'bit_depth': 4980, 'hole_depth': 5000}, measured_depth=5000, log_identifier="5701c048cf9a",
|
|
12
|
+
)
|
|
13
|
+
],
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
app_runner(lambda_handler, event=event)
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { app_runner } from '@corva/node-sdk/lib/testing';
|
|
2
|
+
import { StreamDepthEvent, StreamDepthRecord } from '@corva/node-sdk';
|
|
3
|
+
|
|
4
|
+
import { processor } from '..';
|
|
5
|
+
|
|
6
|
+
test('processes event', async () => {
|
|
7
|
+
const event = new StreamDepthEvent({
|
|
8
|
+
company_id: 1,
|
|
9
|
+
asset_id: 1234,
|
|
10
|
+
records: [
|
|
11
|
+
new StreamDepthRecord({
|
|
12
|
+
data: { bit_depth: 4980, hole_depth: 5000 },
|
|
13
|
+
measured_depth: 5000,
|
|
14
|
+
log_identifier: '5701c048cf9a',
|
|
15
|
+
}),
|
|
16
|
+
],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
expect(await app_runner(processor, event)).toBeUndefined();
|
|
20
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Corva, StatefulContext, StreamDepthEvent } from '@corva/node-sdk';
|
|
2
|
+
|
|
3
|
+
export const processor = async (event: StreamDepthEvent, context: StatefulContext) => {
|
|
4
|
+
// Insert your logic here
|
|
5
|
+
context.logger.info('Hello, World!');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const handler = new Corva().stream(processor);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Dev Center Node.js 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. Deploy
|
|
18
|
+
|
|
19
|
+
Run `npm run bundle` to create a zip package that can be uploaded to Dev Center
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { StreamTimeEvent, StreamTimeRecord } = 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 StreamTimeEvent({
|
|
8
|
+
company_id: 1,
|
|
9
|
+
asset_id: 1234,
|
|
10
|
+
records: [new StreamTimeRecord({ data: { bit_depth: 4980, hole_depth: 5000 }, timestamp: 1620905165 })],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
expect(await app_runner(processor, event)).toBeUndefined();
|
|
14
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { Corva } = require('@corva/node-sdk');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {import('@corva/node-sdk').StreamTimeEvent} event
|
|
5
|
+
* @param {import('@corva/node-sdk').StatefulContext} context
|
|
6
|
+
*/
|
|
7
|
+
const processor = async (event, context) => {
|
|
8
|
+
// Insert your logic here
|
|
9
|
+
context.logger.info('Hello, World!');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.processor = processor;
|
|
13
|
+
|
|
14
|
+
exports.handler = new Corva().stream(processor);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Dev Center Python Real-Time Stream 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
|
+
```
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -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,14 @@
|
|
|
1
|
+
import { app_runner } from '@corva/node-sdk/lib/testing';
|
|
2
|
+
import { StreamTimeEvent, StreamTimeRecord } from '@corva/node-sdk';
|
|
3
|
+
|
|
4
|
+
import { processor } from '..';
|
|
5
|
+
|
|
6
|
+
test('processes event', async () => {
|
|
7
|
+
const event = new StreamTimeEvent({
|
|
8
|
+
company_id: 1,
|
|
9
|
+
asset_id: 1234,
|
|
10
|
+
records: [new StreamTimeRecord({ data: { bit_depth: 4980, hole_depth: 5000 }, timestamp: 1620905165 })],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
expect(await app_runner(processor, event)).toBeUndefined();
|
|
14
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Corva, StatefulContext, StreamTimeEvent } from '@corva/node-sdk';
|
|
2
|
+
|
|
3
|
+
export const processor = async (event: StreamTimeEvent, context: StatefulContext) => {
|
|
4
|
+
// Insert your logic here
|
|
5
|
+
context.logger.info('Hello, World!');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const handler = new Corva().stream(processor);
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { TaskEvent } = 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 TaskEvent({
|
|
8
|
+
company_id: 1,
|
|
9
|
+
asset_id: 1234,
|
|
10
|
+
properties: {
|
|
11
|
+
foo: 'bar',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
expect(await app_runner(processor, event)).toBeUndefined();
|
|
16
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const { Corva } = require('@corva/node-sdk');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {import('@corva/node-sdk').TaskEvent} event
|
|
6
|
+
* @param {import('@corva/node-sdk').StatelessContext} 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().task(processor);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { app_runner } from '@corva/node-sdk/lib/testing';
|
|
2
|
+
import { TaskEvent } from '@corva/node-sdk';
|
|
3
|
+
|
|
4
|
+
import { processor } from '..';
|
|
5
|
+
|
|
6
|
+
test('processes event', async () => {
|
|
7
|
+
const event = new TaskEvent({
|
|
8
|
+
company_id: 1,
|
|
9
|
+
asset_id: 1234,
|
|
10
|
+
properties: {
|
|
11
|
+
foo: 'bar',
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
expect(await app_runner(processor, event)).toBeUndefined();
|
|
16
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Corva, StatelessContext, TaskEvent } from '@corva/node-sdk';
|
|
2
|
+
|
|
3
|
+
export const processor = async (event: TaskEvent, context: StatelessContext) => {
|
|
4
|
+
// Insert your logic here
|
|
5
|
+
context.logger.info('Hello, World!');
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const handler = new Corva().task(processor);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const Processor = require('../src/processor');
|
|
2
|
-
|
|
3
|
-
test('process event', async () => {
|
|
4
|
-
const fakeLogger = console;
|
|
5
|
-
const fakeApiClient = {};
|
|
6
|
-
|
|
7
|
-
const event = {
|
|
8
|
-
company: 1,
|
|
9
|
-
asset_id: 1234,
|
|
10
|
-
schedule: 206977482,
|
|
11
|
-
interval: 300,
|
|
12
|
-
schedule_start: 157829100000,
|
|
13
|
-
schedule_end: 157829400000,
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const processor = new Processor({ logger: fakeLogger, apiClient: fakeApiClient });
|
|
17
|
-
|
|
18
|
-
await processor.process({ event });
|
|
19
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { Corva } = require('@corva/node-sdk');
|
|
2
|
-
const Processor = require('./src/processor');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {import('@corva/node-sdk').ScheduledLambdaEvent} event
|
|
6
|
-
* @param {import('@corva/node-sdk').HandlerContext} context
|
|
7
|
-
*/
|
|
8
|
-
exports.handler = new Corva().scheduled(async (event, context) => {
|
|
9
|
-
const processor = new Processor({
|
|
10
|
-
apiClient: context.api,
|
|
11
|
-
logger: context.logger,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
await processor.process({ event });
|
|
15
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
class Processor {
|
|
2
|
-
constructor({ apiClient, logger }) {
|
|
3
|
-
this.apiClient = apiClient;
|
|
4
|
-
this.logger = logger;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
async process({ event }) {
|
|
8
|
-
this.logger.debug({ event }, 'Event');
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line no-unused-vars
|
|
11
|
-
const { asset_id: assetId, schedule_start: scheduleStart, interval } = event;
|
|
12
|
-
|
|
13
|
-
this.logger.info(`Processing event. Asset: ${assetId}. Schedule start: ${scheduleStart}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = Processor;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const Processor = require('../src/processor');
|
|
2
|
-
|
|
3
|
-
test('process event', async () => {
|
|
4
|
-
const fakeLogger = console;
|
|
5
|
-
const fakeApiClient = {};
|
|
6
|
-
|
|
7
|
-
const processor = new Processor({
|
|
8
|
-
apiClient: fakeApiClient,
|
|
9
|
-
logger: fakeLogger,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
const event = {
|
|
13
|
-
asset_id: 1234,
|
|
14
|
-
app_stream_id: 2345,
|
|
15
|
-
records: [
|
|
16
|
-
{
|
|
17
|
-
company_id: 1,
|
|
18
|
-
asset_id: 1234,
|
|
19
|
-
timestamp: 157829400,
|
|
20
|
-
data: { hole_depth: 1000 },
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
company_id: 1,
|
|
24
|
-
asset_id: 1234,
|
|
25
|
-
timestamp: 157829401,
|
|
26
|
-
data: { hole_depth: 1001 },
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
company_id: 1,
|
|
30
|
-
asset_id: 1234,
|
|
31
|
-
timestamp: 157829402,
|
|
32
|
-
data: { hole_depth: 1001 },
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
company_id: 1,
|
|
36
|
-
asset_id: 1234,
|
|
37
|
-
timestamp: 157829403,
|
|
38
|
-
data: { hole_depth: 1001.5 },
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
await processor.process({ event });
|
|
44
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { Corva } = require('@corva/node-sdk');
|
|
2
|
-
const Processor = require('./src/processor');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @param {import('@corva/node-sdk').StreamLambdaEvent} event
|
|
6
|
-
* @param {import('@corva/node-sdk').HandlerContext} context
|
|
7
|
-
*/
|
|
8
|
-
exports.handler = new Corva().stream(async (event, context) => {
|
|
9
|
-
const processor = new Processor({
|
|
10
|
-
apiClient: context.api,
|
|
11
|
-
logger: context.logger,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
await processor.process({ event });
|
|
15
|
-
});
|