Skip to content

Commit 3c1d5ea

Browse files
committed
Initial commit
0 parents  commit 3c1d5ea

30 files changed

+5601
-0
lines changed

.devrev/repo.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deployable: true

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- @radovanjorgic @patricijabrecko @devrev/airdrop

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.DS_Store
2+
3+
# Ignore Node.js dependencies
4+
node_modules/
5+
6+
# Ignore intermediate build folders
7+
build.*/
8+
conformance_tests.backup/
9+
10+
# Ignore temporary folders used for runnning tests
11+
node_build/
12+
node_conformance_tests/
13+
14+
.venv/
15+
16+
chef-cli
17+
18+
secrets_config.yaml
19+
20+
manual_testing/

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# DevRev Repository for Snap-In Shared Files
2+
3+
This repository contains files that are shared between DevRev snapins. Example of related repositories:
4+
5+
- [devrev-trello-snapin](https://github.com/devrev/airdrop-trello-snap-in)
6+
- [devrev-asana-snapin](https://github.com/devrev/airdrop-asana-snap-in)
7+
8+
Files in this repository are commonly shared between the above Snap-Ins, but you have the ability to override them for specific Snap-Ins.
9+
10+
## Folder structure
11+
12+
This setup assumes this repository (`devrev-snapin-shared`) is cloned on the same level as the Snap-In repositories.
13+
14+
```bash
15+
❯ ls
16+
devrev-asana-snapin devrev-snapin-shared devrev-trello-snapin
17+
```
18+
19+
Make sure you have this setup locally as well.
20+
21+
## Additional required files
22+
23+
### chef-cli
24+
25+
You must download locally to this folder chef-cli binary available at https://github.com/devrev/adaas-chef-cli/releases.
26+
27+
The chef-cli must be version 0.7.1 or newer.
28+
29+
## The Shared Files
30+
31+
- Base folder: (`base_folder/`) - This folder represents starting point for the Snap-In. It's adjusted based on our needs from https://github.com/devrev/airdrop-template.
32+
- DevRev Plain Snap-In template (`devrev-snapin-template.plain`).
33+
- Resource files:
34+
- `test_data/` - This folder represents test data JSON files, referenced in the `.plain` files.
35+
- `external_domain_metadata_schema.json` - This file represents the external domain metadata schema.
36+
- Scripts:
37+
- `run_unittests_jest.sh` - Script for running unit tests for the Snap-In.
38+
- `run_devrev_snapin_conformance_tests.sh` - Script for running conformance tests for the Snap-In.
39+
- Auxiliary files:
40+
- `jest.setup.js`, `mock_callback_server.py` - Auxiliary files for unittest and conformance test scripts.
41+
42+
## How to Override the Shared Files for Specific Snap-Ins
43+
44+
You have the ability to override the contents of the shared repository for your specific Snap-In. Files in the directory containting your plain source file will always have bigger preference than files from the shared folder.
45+
46+
- `devrev-snapin-template.plain` - In the workspace of your Plain source file (e.g. `devrev-trello-snapin`), define your custom `devrev-snapin-template.plain` file.
47+
- Resource files: You can override the contents resources by attaching a resource file to the same location relative to your plain source file.
48+
Example: If you have a resource file `test_data/data_extraction_check.json` in the shared repository, you can override it by attaching a resource file `test_data/data_extraction_check.json` to the same location relative to your plain source file.
49+
- Scripts and auxiliary files: You can copy+paste the script to your plain source file repository and adjust it to your needs.

base_folder/babel.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }],
4+
'@babel/preset-typescript',
5+
],
6+
};

base_folder/jest.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

base_folder/package.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "devrev-snapin",
3+
"version": "1.1.6",
4+
"description": "DevRev ADaaS (Airdrop-as-a-service) Connector",
5+
"main": "./dist/index.js",
6+
"scripts": {
7+
"lint": "eslint .",
8+
"lint:fix": "eslint --fix -- .",
9+
"build": "rimraf ./dist && tsc",
10+
"build:watch": "tsc --watch",
11+
"prepackage": "npm run build",
12+
"package": "tar -cvzf build.tar.gz dist package.json package-lock.json .npmrc",
13+
"start": "ts-node ./src/main.ts",
14+
"start:production": "node dist/main.js",
15+
"test:server": "ts-node test/main.ts",
16+
"test": "jest",
17+
"test:watch": "jest --watch"
18+
},
19+
"keywords": [],
20+
"author": "",
21+
"license": "ISC",
22+
"devDependencies": {
23+
"@babel/core": "^7.26.10",
24+
"@babel/preset-env": "^7.20.2",
25+
"@babel/preset-typescript": "^7.18.6",
26+
"@types/body-parser": "^1.19.5",
27+
"@types/express": "^4.17.21",
28+
"@types/jest": "^29.4.0",
29+
"@types/node": "^18.13.0",
30+
"@types/yargs": "^17.0.24",
31+
"@typescript-eslint/eslint-plugin": "^8.32.0",
32+
"@typescript-eslint/parser": "^8.32.0",
33+
"babel-jest": "^29.4.2",
34+
"body-parser": "^1.20.3",
35+
"dotenv": "^16.0.3",
36+
"eslint": "^9.26.0",
37+
"eslint-config-prettier": "^9.0.0",
38+
"eslint-plugin-import": "^2.28.1",
39+
"eslint-plugin-prettier": "4.0.0",
40+
"eslint-plugin-simple-import-sort": "^10.0.0",
41+
"eslint-plugin-sort-keys-fix": "^1.1.2",
42+
"eslint-plugin-unused-imports": "^4.1.4",
43+
"express": "^4.21.0",
44+
"jest": "^29.4.2",
45+
"nodemon": "^3.0.3",
46+
"prettier": "^2.8.3",
47+
"prettier-plugin-organize-imports": "^3.2.2",
48+
"rimraf": "^4.1.2",
49+
"ts-jest": "^29.0.5",
50+
"ts-node": "^10.9.1",
51+
"typescript": "^4.9.5",
52+
"yargs": "^17.6.2"
53+
},
54+
"dependencies": {
55+
"@devrev/ts-adaas": "1.4.2",
56+
"axios": "^1.9.0",
57+
"dotenv": "^16.0.3",
58+
"js-jsonl": "^1.1.1",
59+
"yargs": "^17.6.2"
60+
}
61+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const functionFactory = {
2+
// Add your functions here
3+
} as const;
4+
5+
export type FunctionFactoryType = keyof typeof functionFactory;

base_folder/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './function-factory';

base_folder/test/http_client.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
2+
3+
interface SetupOptions {
4+
endpoint: string;
5+
token?: string;
6+
}
7+
8+
export interface HttpRequest {
9+
headers?: any;
10+
path: string;
11+
body: unknown;
12+
}
13+
14+
export class HTTPClient {
15+
public instance: AxiosInstance;
16+
17+
constructor({ endpoint, token }: SetupOptions) {
18+
const axiosConfig: AxiosRequestConfig = {
19+
baseURL: endpoint,
20+
headers: {
21+
Authorization: token,
22+
},
23+
};
24+
25+
this.instance = axios.create({
26+
...axiosConfig,
27+
});
28+
}
29+
30+
async post<T>({ headers, path, body }: HttpRequest): Promise<AxiosResponse<T>> {
31+
return this.instance.request({
32+
method: 'POST',
33+
headers: headers,
34+
data: body,
35+
url: path,
36+
});
37+
}
38+
}

0 commit comments

Comments
 (0)