From 0107fb2a0248ebd577dee8fbc5223616c712ee49 Mon Sep 17 00:00:00 2001 From: navneel mandal Date: Mon, 1 Jul 2024 10:59:59 +0530 Subject: [PATCH 01/15] chore: add 3P workflow operations --- 14-operations/README.md | 153 + 14-operations/code/.eslintrc.js | 35 + 14-operations/code/.gitignore | 39 + 14-operations/code/.npmrc | 1 + 14-operations/code/.prettierignore | 4 + 14-operations/code/.prettierrc | 15 + 14-operations/code/babel.config.js | 3 + 14-operations/code/jest.config.js | 12 + 14-operations/code/nodemon.json | 5 + 14-operations/code/package-lock.json | 10482 ++++++++++++++++ 14-operations/code/package.json | 60 + .../src/fixtures/on_work_created_event.json | 81 + 14-operations/code/src/function-factory.ts | 10 + .../functions/on_work_creation/index.test.ts | 69 + .../src/functions/on_work_creation/index.ts | 33 + .../operation_handler/get_temperature.ts | 60 + .../src/functions/operation_handler/index.ts | 27 + 14-operations/code/src/index.ts | 1 + 14-operations/code/src/main.ts | 27 + 14-operations/code/src/operations/index.ts | 26 + .../code/src/test-runner/example.test.ts | 15 + .../code/src/test-runner/test-runner.ts | 27 + 14-operations/code/test/http_client.ts | 52 + 14-operations/code/test/main.ts | 29 + 14-operations/code/test/runner.ts | 264 + 14-operations/code/test/types.ts | 87 + 14-operations/code/tsconfig.eslint.json | 4 + 14-operations/code/tsconfig.json | 24 + 14-operations/manifest.yaml | 45 + 29 files changed, 11690 insertions(+) create mode 100644 14-operations/README.md create mode 100644 14-operations/code/.eslintrc.js create mode 100644 14-operations/code/.gitignore create mode 100644 14-operations/code/.npmrc create mode 100644 14-operations/code/.prettierignore create mode 100644 14-operations/code/.prettierrc create mode 100644 14-operations/code/babel.config.js create mode 100644 14-operations/code/jest.config.js create mode 100644 14-operations/code/nodemon.json create mode 100644 14-operations/code/package-lock.json create mode 100644 14-operations/code/package.json create mode 100644 14-operations/code/src/fixtures/on_work_created_event.json create mode 100644 14-operations/code/src/function-factory.ts create mode 100644 14-operations/code/src/functions/on_work_creation/index.test.ts create mode 100644 14-operations/code/src/functions/on_work_creation/index.ts create mode 100644 14-operations/code/src/functions/operation_handler/get_temperature.ts create mode 100644 14-operations/code/src/functions/operation_handler/index.ts create mode 100644 14-operations/code/src/index.ts create mode 100644 14-operations/code/src/main.ts create mode 100644 14-operations/code/src/operations/index.ts create mode 100644 14-operations/code/src/test-runner/example.test.ts create mode 100644 14-operations/code/src/test-runner/test-runner.ts create mode 100644 14-operations/code/test/http_client.ts create mode 100644 14-operations/code/test/main.ts create mode 100644 14-operations/code/test/runner.ts create mode 100644 14-operations/code/test/types.ts create mode 100644 14-operations/code/tsconfig.eslint.json create mode 100644 14-operations/code/tsconfig.json create mode 100644 14-operations/manifest.yaml diff --git a/14-operations/README.md b/14-operations/README.md new file mode 100644 index 0000000..64f8d2c --- /dev/null +++ b/14-operations/README.md @@ -0,0 +1,153 @@ +## DevRev Snaps TypeScript Template + +This repository contains a template for the functions that can be deployed as +part of Snap-Ins. + +For reference on snap-ins, refer to the [documentation](https://github.com/devrev/snap-in-docs). + +### Getting started with the template + +1. Create a new repository using this template. +2. In the new repository, you can add functions at the path `src/functions` where the folder name corresponds to the function name in your manifest file. +3. Ensure to include each new function in the file named "src/function-factory.ts". + +### Testing locally + +To test your code locally, add test events under 'src/fixtures' following the example event provided. Additionally, you can include keyring values in the event payload to test API calls.``` + +After adding the event, execute the following commands to test your code: + +``` +npm install +npm run start -- --functionName=on_work_creation --fixturePath=on_work_created_event.json +``` + +### Adding external dependencies + +You can also add dependencies on external packages to package.json under the “dependencies” key. These dependencies will be made available to your function at runtime and during testing. + +### Linting + +To check for lint errors, run the following command: + +```bash +npm run lint +``` + +To automatically fix fixable lint errors, run: + +```bash +npm run lint:fix +``` + +### Deploying Snap-ins + +Once you are done with the testing, run the following commands to deploy your snap-in: + +1. Authenticate to devrev CLI, run the following command: + +``` +devrev profiles authenticate --org --usr +``` + +2. To create a snap_in_version, run the following command: + +``` +devrev snap_in_version create-one --path