Skip to content

Adding support for oauthAppId in connect-react #17116

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
11 changes: 10 additions & 1 deletion components/discord/actions/common/common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export default {
props: {
discord,
channel: {

Check warning on line 7 in components/discord/actions/common/common.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop channel must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 7 in components/discord/actions/common/common.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop channel must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "$.discord.channel",
appProp: "discord",
},
Expand Down Expand Up @@ -66,7 +66,16 @@
},
getSentViaPipedreamText() {
const workflowId = process.env.PIPEDREAM_WORKFLOW_ID;
return `Sent via [Pipedream](<https://pipedream.com/@/${workflowId}?o=a&a=discord>)`;
const baseLink = "https://pipedream.com";
const linkText = !workflowId
? "Pipedream Connect"
: "Pipedream";

const link = !workflowId
? `${baseLink}/connect`
: `${baseLink}/@/${workflowId}?o=a&a=discord`;

return `Sent via [${linkText}](<${link}>)`;
},
getMessageFlags(suppressNotifications) {
let flags = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "discord-send-message-advanced",
name: "Send Message (Advanced)",
description: "Send a simple or structured message (using embeds) to a Discord channel",
version: "1.0.2",
version: "1.0.3",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "discord-send-message-with-file",
name: "Send Message With File",
description: "Post a message with an attached file",
version: "1.1.1",
version: "1.1.2",
type: "action",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/discord/actions/send-message/send-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "discord-send-message",
name: "Send Message",
description: "Send a simple message to a Discord channel",
version: "1.0.2",
version: "1.0.3",
type: "action",
async run({ $ }) {
const {
Expand Down
4 changes: 2 additions & 2 deletions components/discord/discord.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default {
type: "boolean",
optional: true,
default: true,
label: "Include link to workflow",
description: "Defaults to `true`, includes a link to this workflow at the end of your Discord message.",
label: "Include link to Pipedream",
description: "Defaults to `true`, includes a link to Pipedream at the end of your Discord message.",
},
embeds: {
type: "any",
Expand Down
2 changes: 1 addition & 1 deletion components/discord/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/discord",
"version": "1.2.4",
"version": "1.2.5",
"description": "Pipedream Discord Components",
"main": "discord.app.mjs",
"keywords": [
Expand Down
20 changes: 20 additions & 0 deletions packages/connect-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

# Changelog

# [1.3.1] - 2025-06-13

## Added

- Support for `oauthAppId` parameter in `ComponentForm` and `ComponentFormContainer` components
- Pass `oauthAppId` through to `ControlApp` component for OAuth app-specific account connections

## Usage

```typescript
<ComponentForm
externalUserId="user123"
component={component}
oauthAppId="your-oauth-app-id" // New optional prop
// ... other props
/>
```

This allows you to specify which OAuth app to use when connecting accounts, matching the behavior of the SDK's `connectAccount` method.

# [1.3.0] - 2025-06-10

## Added
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/connect-react",
"version": "1.3.0",
"version": "1.3.1",
"description": "Pipedream Connect library for React",
"files": [
"dist"
Expand Down
4 changes: 4 additions & 0 deletions packages/connect-react/src/components/ComponentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export type ComponentFormProps<T extends ConfigurableProps, U = ConfiguredProps<
hideOptionalProps?: boolean;
sdkResponse?: unknown | undefined;
enableDebugging?: boolean;
/**
* The OAuth app ID to use when connecting accounts for app props.
*/
oauthAppId?: string;
} & (
| { externalUserId: string; userId?: never }
| { userId: string; externalUserId?: never }
Expand Down
2 changes: 1 addition & 1 deletion packages/connect-react/src/components/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function Control<T extends ConfigurableProps, U extends ConfigurableProp>
// case "any":
// return <ControlAny />
case "app":
return <ControlApp app={app!} />;
return <ControlApp app={app!} oauthAppId={field.extra.oauthAppId} />;
case "boolean":
return <ControlBoolean />;
case "string":
Expand Down
6 changes: 3 additions & 3 deletions packages/connect-react/src/components/ControlApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@

type ControlAppProps = {
app: AppResponse;
oauthAppId?: string;
};

export function ControlApp({ app }: ControlAppProps) {
export function ControlApp({ app, oauthAppId }: ControlAppProps) {

Check failure on line 31 in packages/connect-react/src/components/ControlApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break before this closing brace

Check failure on line 31 in packages/connect-react/src/components/ControlApp.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a line break after this opening brace
const client = useFrontendClient();
const { externalUserId } = useFormContext();
const formFieldCtx = useFormFieldContext<ConfigurablePropApp>();
Expand Down Expand Up @@ -67,15 +68,14 @@
};
const selectProps = select.getProps("controlAppSelect", baseSelectProps);

const oauthAppId = undefined; // XXX allow customizing
const {
isLoading: isLoadingAccounts,
// TODO error
accounts,
refetch: refetchAccounts,
} = useAccounts(
{
externalUserId,
external_user_id: externalUserId,
app: app.name_slug,
oauth_app_id: oauthAppId,
},
Expand Down
3 changes: 2 additions & 1 deletion packages/connect-react/src/components/InternalField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function InternalField<T extends ConfigurableProp>({
}: FieldInternalProps<T>) {
const formCtx = useFormContext();
const {
id: formId, configuredProps, registerField, setConfiguredProp, errors, enableDebugging,
id: formId, configuredProps, registerField, setConfiguredProp, errors, enableDebugging, oauthAppId,
} = formCtx;

const appSlug = prop.type === "app" && "app" in prop
Expand Down Expand Up @@ -43,6 +43,7 @@ export function InternalField<T extends ConfigurableProp>({
},
extra: {
app, // XXX fix ts
oauthAppId,
},
errors,
enableDebugging,
Expand Down
4 changes: 3 additions & 1 deletion packages/connect-react/src/hooks/form-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type FormContext<T extends ConfigurableProps> = {
/** @deprecated Use externalUserId instead */
userId: string;
enableDebugging?: boolean;
oauthAppId?: string;
};

export const skippablePropTypes = [
Expand Down Expand Up @@ -80,7 +81,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
const id = useId();

const {
component, configuredProps: __configuredProps, propNames, externalUserId, userId, sdkResponse, enableDebugging,
component, configuredProps: __configuredProps, propNames, externalUserId, userId, sdkResponse, enableDebugging, oauthAppId,
} = formProps;

// Resolve user ID with deprecation warning
Expand Down Expand Up @@ -593,6 +594,7 @@ export const FormContextProvider = <T extends ConfigurableProps>({
submitting,
sdkErrors,
enableDebugging,
oauthAppId,
};
return <FormContext.Provider value={value}>{children}</FormContext.Provider>;
};
1 change: 1 addition & 0 deletions packages/connect-react/src/hooks/form-field-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {

export type FormFieldContextExtra<T extends ConfigurableProp> = T extends ConfigurablePropApp ? {
app?: AppResponse;
oauthAppId?: string;
} : Record<string, never>;

export type FormFieldContext<T extends ConfigurableProp> = {
Expand Down
Loading