Skip to content
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
6d24e66
Adding new project? and oauth? params to CreateServerClientOpts
dylburger Sep 26, 2024
9b7dcf1
Small refactor
dylburger Sep 26, 2024
975d669
Simplifying
dylburger Sep 26, 2024
651d41b
Fixing JSDoc
dylburger Sep 26, 2024
71dd92f
CodeRabbit fix
dylburger Sep 26, 2024
ad1804d
Merge remote-tracking branch 'origin/master' into sdk/connect-workflo…
dylburger Oct 7, 2024
4385093
AppId -> AppNameSlug
dylburger Oct 7, 2024
87d8d86
Forcing OAuth for invoking workflows for external users
dylburger Oct 7, 2024
ce22436
Mocking client and mock OAuth client once
dylburger Oct 8, 2024
d4a8394
Improving tests
dylburger Oct 8, 2024
1b02d65
Small comment
dylburger Oct 8, 2024
0bce50e
Adding support for baseWorkflowDomain, ID vs URL
dylburger Oct 8, 2024
075e400
Adding authType to invokeWorkflow example
dylburger Oct 8, 2024
7c7b4ac
Merge remote-tracking branch 'origin/master' into sdk/connect-workflo…
dylburger Oct 28, 2024
ccf848e
Biz PR feedback
dylburger Oct 28, 2024
9a4af88
Merge remote-tracking branch 'origin/master' into sdk/connect-workflo…
dylburger Oct 28, 2024
faf0f8d
ServerClient -> BackendClient
dylburger Oct 29, 2024
5e85ef5
Updating all names to noun-verb form.
dylburger Oct 29, 2024
85748a4
Merge remote-tracking branch 'origin/master' into sdk/connect-workflo…
dylburger Oct 29, 2024
06a17b5
1.0.0
dylburger Oct 29, 2024
e63a89f
Fixing browser / server exports
dylburger Oct 30, 2024
bfbc249
createClient -> createBackendClient
dylburger Oct 30, 2024
314b644
frontend: createClient -> createFrontendClient
dylburger Oct 30, 2024
1a1faf0
Adding `npm link` docs
dylburger Oct 30, 2024
0e9866f
Adding cd
dylburger Oct 30, 2024
cf31cda
Fixing one command
dylburger Oct 30, 2024
fe7a66d
Localize the Node.js version change
jverce Oct 30, 2024
0c20e6c
Adding npm watch
dylburger Oct 30, 2024
6d23fb9
New lock file
dylburger Oct 30, 2024
2db68e3
Merge branch 'sdk/connect-workflow-invocation' of github.com:Pipedrea…
dylburger Oct 30, 2024
aa7fb1a
Move contributor guide to its own file
jverce Oct 30, 2024
9999664
Apply suggestion from CodeRabbit
jverce Oct 30, 2024
89ff7c1
Cosmetic changes in the README
jverce Oct 30, 2024
7964dde
Revert to old naming convention
jverce Oct 31, 2024
3429a92
A bit of test cleanup
jverce Oct 31, 2024
1886bd9
Final touches
jverce Oct 31, 2024
d27a9b1
Fix typo
jverce Oct 31, 2024
e775d04
Lint markdown files in the SDK
jverce Oct 31, 2024
60ac2da
Fix indentation in docstring
jverce Oct 31, 2024
4695be5
Verify that project ID is present
jverce Oct 31, 2024
a97736d
Only lint SDK files
jverce Oct 31, 2024
003aea7
Name Github workflow accordingly
jverce Oct 31, 2024
9525871
Fix pnpm case
jverce Oct 31, 2024
0e0b7b3
TS suggestions from CodeRabbit
jverce Oct 31, 2024
0f4f1a3
Dry the tests as per CodeRabbit
jverce Nov 1, 2024
4d89d5c
Use latest checkout action
jverce Nov 1, 2024
866efdd
Limit concurrency of the SDK CI/CD workflows
jverce Nov 1, 2024
60e9e81
Merge branch 'master' into sdk/connect-workflow-invocation
jverce Nov 1, 2024
3025cf5
Validate workflow URLs better
jverce Nov 1, 2024
7ec1156
Disable linting on ts-ignore lines
jverce Nov 1, 2024
a33b75f
More URL sanitizing
jverce Nov 1, 2024
6596349
Merge branch 'master' into sdk/connect-workflow-invocation
jverce Nov 1, 2024
7994412
Merge branch 'master' into sdk/connect-workflow-invocation
jverce Nov 4, 2024
0c7ca6f
Turn enums into const
jverce Nov 4, 2024
29ab565
Enhance param validation for workflow invocation
jverce Nov 4, 2024
401522c
YOLO version
jverce Nov 4, 2024
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
1 change: 1 addition & 0 deletions packages/sdk/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 22.10.0
13 changes: 13 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## [1.0.0-rc.1`] - 2024-11-01

### Changed

- Renamed the server-side client class from `ServerClient` to `BackendClient` to
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use a Markdown linter locally? I use one in VSCode but it doesn't break after 80 (?) characters like yours does, so when I edit these files, it always overwrites your changes. Happy to keep this formatting for dev readability but just want to make sure it's enforced for everyone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I use markdownlint in VSCode, which is based off of another engine. I just added a Github workflow to lint the markdown files in this directory, and see if it's useful.

better indicate its purpose.
- Removed the `oauthClient` optional argument to the `BackendClient` constructor
- Renamed the client factory methods so that developers can know exactly the
kind of client they are creating.
- Removed project-key-based authentication in favor of a more secure
token-based authentication using OAuth.
96 changes: 96 additions & 0 deletions packages/sdk/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# How to Contribute to the SDK

## Local Environment Setup

### Global Dependencies

Clone the repo (ideally your own fork of it) and initialize the global
dependencies like Node.js, NPM, etc. We use [`asdf`](https://asdf-vm.com/) to
manage these, so assuming we're located in this directory (i.e. `packages/sdk/`)
we can run the following command to install them:

```shell
asdf install
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are also some deps at the root package.json (like pnpm) that we should probably have people install yeah?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command should traverse its way up the chain until the root of the repo.

```

If you prefer to use another tool make sure you use the same versions that are
specified in the `.tool-versions` files [in this current directory, and
recursively going up until you reach the root of the
repo](https://asdf-vm.com/guide/getting-started.html#_6-set-a-version).

### Local Dependencies

You can install the package's dependencies by using `pnpm` or `npm`:

```shell
pnpm install
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have people install root deps, should we do npx pnpm install?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asdf install should install pnpm as a standalone executable I think.
We should probably revisit the main CONTRIBUTING.md docs since pnpm is used across the repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice yes, cool since that's in .tool-versions that works

```

Since other packages in this repository already use `pnpm`, we recommend you use
it in this case too to keep your `node_modules` footprint low.

## Build the Package

There's a script that you can invoke with `pnpm` to build the package artifacts:

```shell
pnpm build
```

You can also watch the code for changes, and automatically build a new artifact
after each change with the `watch` script:

```shell
pnpm watch
```

### Use the Package

You can use PNPM's `link` command to point other code to your local version of
this package during development. This lets you test the SDK in other local apps,
end-to-end.

In this `packages/sdk/` directory:

```shell
pnpm link --global
```

> [!NOTE]
When using the version of Node.js specified in
[`.tool-versions`](./.tool-versions) (via `asdf`), the command above will
install the package in the `asdf` Node.js environment. To use this package
elsewhere, you'll need to use the same version of Node.js. Please reference the
latest version of [the `.tool-versions` file](./.tool-versions) and add that to
the `.tool-versions` file in your local project where you'd like to use the SDK.

For example, in your app's directory:

```shell
# Replace /path/to/pipedream with the actual path to this repository
grep nodejs /path/to/pipedream/packages/sdk/.tool-versions >> .tool-versions
asdf install
pnpm install @pipedream/sdk
Comment on lines +70 to +73
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider automating Node.js version detection

The manual path replacement and version copying could be error-prone. Consider providing a script to automate this process.

-# Replace /path/to/pipedream with the actual path to this repository
-grep nodejs /path/to/pipedream/packages/sdk/.tool-versions >> .tool-versions
-asdf install
+# Create a setup script (e.g., setup.sh):
+#!/bin/bash
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+SDK_DIR=$(find "$SCRIPT_DIR" -name "packages/sdk" -type d | head -n 1)
+if [ -n "$SDK_DIR" ]; then
+  grep nodejs "$SDK_DIR/.tool-versions" >> .tool-versions
+  asdf install
+else
+  echo "Error: Could not locate SDK directory"
+  exit 1
+fi

Committable suggestion skipped: line range outside the PR's diff.

```

Then, link the SDK package to it's local path:

```shell
pnpm link @pipedream/sdk
```

To confirm you successfully installed the correct version of the SDK, and that
it's tied to your local copy of the Pipedream SDK:

```shell
ls -l node_modules/@pipedream
```

You should see an output like this one (notice the last line):

```text
total 0
drwxr-xr-x 9 jay staff 288 30 Oct 14:01 mysql
drwxr-xr-x 10 jay staff 320 30 Oct 14:01 platform
lrwxr-xr-x 1 jay staff 31 30 Oct 14:06 sdk -> ../../../pipedream/packages/sdk
```
38 changes: 33 additions & 5 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# `@pipedream/sdk`

TypeScript SDK for [Pipedream](https://pipedream.com). [See the docs](https://pipedream.com/docs/connect) for usage instructions.
TypeScript SDK for [Pipedream](https://pipedream.com). [See the
docs](https://pipedream.com/docs/connect) for usage instructions.

## Install

Expand All @@ -10,12 +11,39 @@ npm i @pipedream/sdk

## Quickstart

The [quickstart](https://pipedream.com/docs/connect/quickstart) is the easiest way to get started with the SDK and Pipedream Connect.
The [quickstart](https://pipedream.com/docs/connect/quickstart) is the easiest
way to get started with the SDK and Pipedream Connect.

## Usage

[See the SDK docs](https://pipedream.com/docs/connect) for full usage instructions and examples for each method.
[See the SDK docs](https://pipedream.com/docs/connect) for full usage
instructions and examples for each method.

## Example app
## Example App

Clone and run the [example app](https://github.com/PipedreamHQ/pipedream-connect-examples/) to get started.
Clone and run the [example
app](https://github.com/PipedreamHQ/pipedream-connect-examples/) to get started.

## Importing the Client

You can import the SDK from the root package name, and it will automatically
load the appropriate code depending on the environment (e.g. Node.js server,
browser, etc.).

### CommonJS Modules

```javascript
const { createClient } = require("@pipedream/sdk");
```

### ES Modules

```javascript
import { createClient } from "@pipedream/sdk";
```

### Browser

```javascript
import { createClient } from "@pipedream/sdk";
```
2 changes: 2 additions & 0 deletions packages/sdk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const fetchMock = require("jest-fetch-mock");
fetchMock.enableMocks();
global.fetch = fetchMock;

jest.mock("simple-oauth2");
Loading
Loading