From 0ac9fb47ef55288fc5305ceba4355b11a39fa86d Mon Sep 17 00:00:00 2001 From: Samarth-DevTools Date: Wed, 19 Feb 2025 19:39:24 +0530 Subject: [PATCH] Project solution uploaded --- devrev-snaps-typescript-template/README.md | 153 + .../code/.eslintrc.js | 35 + .../code/.gitignore | 39 + devrev-snaps-typescript-template/code/.npmrc | 1 + .../code/.prettierignore | 4 + .../code/.prettierrc | 15 + .../code/babel.config.js | 3 + .../code/jest.config.js | 12 + .../code/nodemon.json | 5 + .../code/package-lock.json | 10512 ++++++++++++++++ .../code/package.json | 61 + .../src/fixtures/on_work_created_event.json | 79 + .../code/src/function-factory.ts | 8 + .../functions/on_work_creation/index.test.ts | 74 + .../src/functions/on_work_creation/index.ts | 49 + .../code/src/index.ts | 1 + .../code/src/main.ts | 27 + .../code/src/operations/index.ts | 26 + .../code/src/test-runner/test-runner.ts | 27 + .../code/test/http_client.ts | 52 + .../code/test/main.ts | 29 + .../code/test/runner.ts | 294 + .../code/test/types.ts | 87 + .../code/tsconfig.eslint.json | 4 + .../code/tsconfig.json | 24 + .../manifest.yaml | 46 + 26 files changed, 11667 insertions(+) create mode 100644 devrev-snaps-typescript-template/README.md create mode 100644 devrev-snaps-typescript-template/code/.eslintrc.js create mode 100644 devrev-snaps-typescript-template/code/.gitignore create mode 100644 devrev-snaps-typescript-template/code/.npmrc create mode 100644 devrev-snaps-typescript-template/code/.prettierignore create mode 100644 devrev-snaps-typescript-template/code/.prettierrc create mode 100644 devrev-snaps-typescript-template/code/babel.config.js create mode 100644 devrev-snaps-typescript-template/code/jest.config.js create mode 100644 devrev-snaps-typescript-template/code/nodemon.json create mode 100644 devrev-snaps-typescript-template/code/package-lock.json create mode 100644 devrev-snaps-typescript-template/code/package.json create mode 100644 devrev-snaps-typescript-template/code/src/fixtures/on_work_created_event.json create mode 100644 devrev-snaps-typescript-template/code/src/function-factory.ts create mode 100644 devrev-snaps-typescript-template/code/src/functions/on_work_creation/index.test.ts create mode 100644 devrev-snaps-typescript-template/code/src/functions/on_work_creation/index.ts create mode 100644 devrev-snaps-typescript-template/code/src/index.ts create mode 100644 devrev-snaps-typescript-template/code/src/main.ts create mode 100644 devrev-snaps-typescript-template/code/src/operations/index.ts create mode 100644 devrev-snaps-typescript-template/code/src/test-runner/test-runner.ts create mode 100644 devrev-snaps-typescript-template/code/test/http_client.ts create mode 100644 devrev-snaps-typescript-template/code/test/main.ts create mode 100644 devrev-snaps-typescript-template/code/test/runner.ts create mode 100644 devrev-snaps-typescript-template/code/test/types.ts create mode 100644 devrev-snaps-typescript-template/code/tsconfig.eslint.json create mode 100644 devrev-snaps-typescript-template/code/tsconfig.json create mode 100644 devrev-snaps-typescript-template/manifest.yaml diff --git a/devrev-snaps-typescript-template/README.md b/devrev-snaps-typescript-template/README.md new file mode 100644 index 0000000..5e10102 --- /dev/null +++ b/devrev-snaps-typescript-template/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