Skip to content

[do not merge]chore: add adaas snap-in #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 15-adaas/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DEV_ORG=navneel
[email protected]
12 changes: 12 additions & 0 deletions 15-adaas/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# IDE-specific configs
/.vscode/*
.code-workspace
/.idea/*

# Allow run configurations / launch files
!/.idea/runConfigurations
!/.vscode/launch.json

build.tar.gz
nohup.out
.env
30 changes: 30 additions & 0 deletions 15-adaas/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
include .env

# export values in .env to be used in the shell scripts
export $(shell sed 's/=.*//' .env)

default:
$(MAKE) build

deps:
cd code && npm ci
.PHONY: deps

build:
cd code && npm run build
.PHONY: build

auth:
devrev profiles authenticate --org $(DEV_ORG) --usr $(USER_EMAIL) --expiry 7 # days

.PHONY: auth

deploy: auth
./code/scripts/deploy.sh
.PHONY: deploy

# Removes the latest snap-in from the org. This is useful when you want to
# re-deploy the same snap-in to the same org.
uninstall:
./code/scripts/cleanup.sh
.PHONY: uninstall
53 changes: 53 additions & 0 deletions 15-adaas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# ADaaS Template

This GitHub repository provides a template with example code to implement an Airdrop as a Service (ADaaS) Snap-in .

## Prerequisites

1\. Install [DevRev CLI](https://developer.devrev.ai/snapin-development/references/cli-install) by following the instructions as per the Operating System.

2\. Install [jq](https://jqlang.github.io/jq/download/).

## Build, Deploy and Run

1\. Clone Repository:

- Either clone this repository or create a new repository from it by clicking the "Use this template" button above.
- Set the desired repository name for your own copy (e.g., `<organization>-<external system>-adaas`).

2\. Open the project in your IDE and set up project environment variables, by following these steps:

- Rename `.env.example` to `.env`.
- In `.env` set the slug of your organization, and your email.

4\. Build the Snap-in using the following command:

```bash
make build
```

5\. Deploy the Snap-in to the organization:

```bash
make deploy
```

NOTE: This process may take some time. Command authenticates you to the org using the DevRev CLI, creates a Snap-in package, its Snap-in version, and finally the Snap-in draft.

6\. After the Snap-in draft is created, install the Snap-in in the DevRev UI (`Settings` -> `Snap-ins` -> `Install snap-in`).

7\. Start the import (`Imports` -> `Start import` -> `<your Snap-in>`).

## Common Pitfalls

#### Q: `Conflict` error after the `Creating snap-in package...` output during `make deploy`.

A: Snap-in package with the same slug already exists. Override the `SNAP_IN_SLUG` variable by explicitly updating the variable in `scripts/vars.sh`.

#### Q: Snap-in version `build/deployment failed` after the `Waiting for snap-in version to be ready...` message

A: The snap-in version could not be built. Check the logs by running the DevRev CLI command `devrev snap_in_package logs`. For prettier UI, pipe the output to `jq`

### Q: `Token is expired` when deploying or cleaning up.

A: Authentication token to the `DEV_ORG` has expired. Run `make auth` to reconnect to the organization.
3 changes: 3 additions & 0 deletions 15-adaas/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
.env
1 change: 1 addition & 0 deletions 15-adaas/code/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
1 change: 1 addition & 0 deletions 15-adaas/code/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/**/*
15 changes: 15 additions & 0 deletions 15-adaas/code/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxSingleQuote": false,
"arrowParens": "always",
"proseWrap": "never",
"htmlWhitespaceSensitivity": "strict",
"endOfLine": "lf",
"organizeImportsSkipDestructiveCodeActions": true
}
6 changes: 6 additions & 0 deletions 15-adaas/code/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
],
};
18 changes: 18 additions & 0 deletions 15-adaas/code/context.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"dev_org_id": "DEV-Sweb0eGN",
"dev_user_id": "DEVU-1",
"external_sync_unit_id": "369026867",
"external_sync_unit_name": "blubox",
"external_system": "testing",
"import_slug": "template-extractor",
"mode": "initial",
"keyring_id": "don:integration:dvrv-us-1:devo/Sweb0eGN:keyring/1c710311-cc0d-4947-b1b8-17187f6be417",
"connection_id": "don:integration:dvrv-us-1:devo/Sweb0eGN:connection/1c710311-cc0d-4947-b1b8-17187f6be417",
"snap_in_slug": "ad-testing",
"external_system_type": "ADaaS",
"sync_run_id": "f85c5bdf-f582-4bd0-af71-223536954bcf",
"sync_tier": "sync_tier_2",
"sync_unit_id": "70058cd5-cf8e-40ff-95f7-930935d348df",
"uuid": "bdca52cf-ebfa-4de9-8cf8-74501f22545b",
"worker_data_url": "https://api.devrev.ai/internal/airdrop.external-worker"
}
4 changes: 4 additions & 0 deletions 15-adaas/code/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
68 changes: 68 additions & 0 deletions 15-adaas/code/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"record_types": {
"issues": {
"name": "Issues",
"description": "The metadata inferred from the data: TODO: review and correct, and put an useful description here. The field \"id\" (deleted as the primary key shouldn't be mentioned) is inferred as the primary key due its all unique values TODO: identify the primary key.",
"fields": {
"body": {
"name": "Body",
"description": "Inferred as a text field due to length of 0 to 2879: TODO: discover hard limits, or if maybe rich text.",
"type": "text",
"text": {}
},
"state": {
"name": "State",
"description": "Two allowed values. TODO: investigate if more exists, or if maybe they have boolean semantics. Inferred as required due to always being present. TODO: see if this is a coincidence, if this is a system field, or if some of its values might be defaults zero values.",
"is_required": true,
"type": "enum",
"enum": {
"values": [
{
"key": "closed",
"name": "TODO: meaningful nice name and description.",
"description": "seen 130 times"
},
{
"key": "open",
"name": "TODO: meaningful nice name and description.",
"description": "seen 52 times"
}
]
}
},
"title": {
"name": "Title",
"description": "Inferred as text due to 91 unique values in 182 occurrences: TODO: it might still be id reference or an enum. Inferred as required due to always being present. TODO: see if this is a coincidence, if this is a system field, or if some of its values might be defaults zero values.",
"is_required": true,
"type": "text"
}
}
},
"users": {
"name": "Users",
"description": "The metadata inferred from the data: TODO: review and correct, and put an useful description here. The field \"id\" (deleted as the primary key shouldn't be mentioned) is inferred as the primary key due its all unique values TODO: identify the primary key.",
"fields": {
"email": {
"name": "TODO: provide an user-friendly field name.",
"description": "Only one allowed value. TODO: Investigate if more exist, or if this is a boolean field.",
"type": "enum",
"enum": {
"values": [
{
"key": "[email protected]",
"name": "TODO: meaningful nice name and description.",
"description": "seen 2 times"
}
]
}
},
"name": {
"name": "TODO: provide an user-friendly field name.",
"description": "Inferred as text due to 5 unique values in 10 occurrences: TODO: it might still be id reference or an enum. Inferred as required due to always being present. TODO: see if this is a coincidence, if this is a system field, or if some of its values might be defaults zero values.",
"is_required": true,
"type": "text"
}
}
}
}
}
6 changes: 6 additions & 0 deletions 15-adaas/code/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"execMap": {
"ts": "ts-node",
"watch": ["src"]
}
}
Loading