Skip to content
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

feat!: Initial release #2

Merged
merged 7 commits into from
Jan 12, 2024
Merged
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
9 changes: 7 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module.exports = {
extends: [require.resolve("@vertigis/workflow-sdk/config/.eslintrc")],
extends: [
require.resolve("@vertigis/workflow-sdk/config/.eslintrc"),
"plugin:eslint-comments/recommended"
],
parserOptions: {
tsconfigRootDir: __dirname,
},
rules: {},
rules: {
"eslint-comments/no-unused-disable": "error"
},
};
72 changes: 72 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI/CD

on:
push:
branches:
- main
- beta
pull_request:
branches:
- main
- beta

env:
CI: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20.x

- run: npm install

- run: npm run build

- run: npm run lint

- run: cp LICENSE package.json README.md build

- uses: actions/upload-artifact@v3
with:
name: release
path: build/

release:
runs-on: ubuntu-latest
needs:
- test
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta'
steps:
- uses: actions/checkout@v4
with:
# Pulls all commits and tags (needed for semantic release to correctly version)
fetch-depth: 0
persist-credentials: false
sparse-checkout: |
README.md

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20.x

- run: npm install

- name: Download release artifact
uses: actions/download-artifact@v3
with:
name: release
path: release

- name: Release 🚀
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release@^22
working-directory: ./release
17 changes: 17 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Lint PR"

on:
pull_request:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
access=public
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tabWidth": 4
}
11 changes: 11 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"preset": "conventionalcommits",
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true }
]
}
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Cloning the repository

If you are a member of our organization and have push permissions to this repository, you can simply clone this repository, create a branch, and begin making changes. Otherwise you can follow this guide to forking a repository: https://help.github.com/en/github/getting-started-with-github/fork-a-repo.

Once you're happy with your changes and have committed them to a branch, you can submit a pull request in this project where a maintainer can review and merge your changes.

## Pull request guidelines

This project uses [semantic-release](https://github.com/semantic-release/semantic-release) to automate the versioning and deployment of this repository. **The version used during release is determined based on the title of the merged pull request. The title must follow the [Conventional Commits standard](https://www.conventionalcommits.org/).**
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 VertiGIS North America Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
66 changes: 58 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,52 @@
This project contains activities for accessing an organization's data via the Salesforce REST API. [Click here](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest.htm) for more information on the resources and requests available via the Salesforce REST API
# Salesforce Activities

[![CI/CD](https://github.com/vertigis/workflow-activities-salesforce/workflows/CI/CD/badge.svg)](https://github.com/vertigis/workflow-activities-salesforce/actions)
[![npm](https://img.shields.io/npm/v/@vertigis/workflow-activities-salesforce)](https://www.npmjs.com/package/@vertigis/workflow-activities-salesforce)

This project contains activities for accessing an organization's data via the Salesforce REST API. [Click here](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest.htm) for more information on the resources and requests available via the Salesforce REST API.

## Requirements

### Salesforce
1. The target Salesforce instance must include the requesting origin in its Cross-Origin Resource Sharing (CORS) white list. [https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/extend_code_cors.htm]
2. A connected app and an OAuth 2.0 authorization flow must be configured in Salesforce. [https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_oauth_and_connected_apps.htm].
3. The provided [callback.html](../main/static/callback.html) page must be deployed to a CORS enabled web server.
### Cross-Origin Resource Sharing (CORS)
The target Salesforce instance must include the requesting origin of the application running the workflow in its Cross-Origin Resource Sharing (CORS) Allowlist. For example: `https://acme.apps.vertigisstudio.com`. [Learn more](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/extend_code_cors.htm).

### OAuth2 App

A connected app and an OAuth 2.0 authorization flow must be configured in Salesforce to facilitate the sign in to Salesforce from the application running the workflow. [Learn more](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_oauth_and_connected_apps.htm).

### OAuth2 Callback Page

This activity pack requires that you host a HTML page on a web server you control that uses [`postMessage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) to provide the OAuth callback result URL back to the browser window running the workflow. For example:

```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>OAuth2 Callback</title>
<script>
window.opener.postMessage(location.href, "*");
setTimeout(() => window.close(), 500);
</script>
</head>
<body>
...
</body>
</html>
```

Note: It is important to change the target origin from `"*"` to the actual origin of the application running the workflow. For example: `https://acme.apps.vertigisstudio.com`.

### VertiGIS Studio Workflow Versions

These activities are designed to work with VertiGIS Studio Workflow versions `5.30.1` and above.
These activities are designed to work with VertiGIS Studio Workflow versions `5.36.0` and above.

## Usage
To use these activities in [VertiGIS Studio Workflow Designer](https://apps.vertigisstudio.com/workflow/designer/) you need to register an activity pack and then add the activities to a workflow.

### Register the Configurable Queries activity pack
### Register the Salesforce activity pack

1. Sign in to ArcGIS Online or Portal for ArcGIS
1. Go to **My Content**
Expand All @@ -23,12 +56,29 @@ To use these activities in [VertiGIS Studio Workflow Designer](https://apps.vert
- API: `JavaScript`
- URL: The URL to this activity pack manifest
- Use https://unpkg.com/@vertigis/workflow-activities-salesforce/activitypack.json for the latest version
- Use https://unpkg.com/@vertigis/workflow-activities-salesforce@1/activitypack.json for the latest revision of a specific major version
- Use https://unpkg.com/@vertigis/workflow-activities-salesforce@1.0.0/activitypack.json for a specific version
- Use https://localhost:5000/activitypack.json for a local development version
- Title: Your desired title
- Tags: Must include `geocortex-workflow-activity-pack`
1. Reload [VertiGIS Studio Workflow Designer](https://apps.vertigisstudio.com/workflow/designer/)
1. These activities will now appear in the activity toolbox in a `Configurable Queries` category
1. These activities will now appear in the activity toolbox in a `Salesforce` category

### Use the Salesforce activities in a workflow

1. Authenticate with the Salesforce service
1. Add the `Create Salesforce Service` activity to a workflow
1. Set the `URL` input to the root URL of your Salesforce instance. For example, `https://acme.my.salesforce.com`.
1. Set the `Version` input to the desired version of the Salesforce REST API to use. For example, `59.0`.
1. Set the `Client ID` input to the Client ID of your Salesforce connected app
1. Set the `Redirect URI` input to the URL of your OAuth2 callback page
1. Use the Salesforce service
1. Add one of the other Salesforce activities to the workflow. For example, `Get Salesforce Object`.
1. Set the `Service` input of the activity to be the output of the `Create Salesforce Service` activity
- Typically this would use an expression like `=$sfService1.service`
1. Supply any additional inputs to the activity
1. Supply the `result` output of the activity to the inputs of other activities in the workflow
1. Run the workflow

## Development

Expand Down
Loading