Skip to content

Commit 1ea6a35

Browse files
authored
Upgrade to the v2 SDK (#18520)
Use the new v2 version of the Pipedream SDK in the `connect-react` package. This change involves migrating to the new types mostly, but also runtime changes involving the API calls. The runtime behaviour should not be affected from a user's perspective, except for consumers of the `connect-react` package itself, since some components (e.g. `FrontendClientProvider`) expect their consumers to inject a client instance of the same SDK version. For this reason, this change bumps the **major** version of this package.
1 parent 1744391 commit 1ea6a35

31 files changed

+532
-433
lines changed

components/apex/apex.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/openthesaurus/openthesaurus.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

packages/connect-react/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
# Changelog
44

5+
## [2.0.0] - 2025-10-02
6+
7+
### Breaking Changes
8+
9+
Use the new v2 version of the Pipedream SDK (i.e. `@pipedreamhq/pipedream-sdk`).
10+
This change involves migrating to the new types mostly, but also runtime changes
11+
involving the API calls.
12+
13+
The runtime behavior should not be affected from a user's perspective, except
14+
for consumers of the `connect-react` package itself, since some components (e.g.
15+
`FrontendClientProvider`) expect their consumers to inject a client instance of
16+
the same SDK version. For this reason, this change bumps the **major** version
17+
of this package.
18+
519
## [1.5.0] - 2025-08-18
620

721
### Fixed

packages/connect-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/connect-react",
3-
"version": "1.6.0",
3+
"version": "2.0.0",
44
"description": "Pipedream Connect library for React",
55
"files": [
66
"dist"
@@ -30,7 +30,7 @@
3030
"author": "Pipedream Engineering",
3131
"license": "MIT",
3232
"dependencies": {
33-
"@pipedream/sdk": "^1.8.0",
33+
"@pipedream/sdk": "^2.0.13",
3434
"@tanstack/react-query": "^5.59.16",
3535
"lodash.isequal": "^4.5.0",
3636
"react-markdown": "^9.0.1",

packages/connect-react/src/components/ComponentForm.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import {
2-
FormContextProvider, type FormContext,
3-
} from "../hooks/form-context";
4-
import { DynamicProps } from "../types";
51
import type {
2+
Component,
63
ConfigurableProps,
74
ConfiguredProps,
8-
V1Component,
5+
DynamicProps,
96
} from "@pipedream/sdk";
7+
8+
import {
9+
type FormContext,
10+
FormContextProvider,
11+
} from "../hooks/form-context";
1012
import { InternalComponentForm } from "./InternalComponentForm";
1113

1214
export type ComponentFormProps<T extends ConfigurableProps, U = ConfiguredProps<T>> = {
@@ -18,7 +20,7 @@ export type ComponentFormProps<T extends ConfigurableProps, U = ConfiguredProps<
1820
* @deprecated Use `externalUserId` instead.
1921
*/
2022
userId?: string;
21-
component: V1Component<T>;
23+
component: Component;
2224
configuredProps?: U; // XXX value?
2325
disableQueryDisabling?: boolean;
2426
// dynamicPropsId?: string // XXX need to load this initially when passed

packages/connect-react/src/components/Control.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function Control<T extends ConfigurableProps, U extends ConfigurableProp>
3838
return <RemoteOptionsContainer queryEnabled={queryDisabledIdx == null || queryDisabledIdx >= idx} />;
3939
}
4040

41-
if ("options" in prop && prop.options) {
41+
if ("options" in prop && Array.isArray(prop.options) && prop.options.length > 0) {
4242
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4343
const options: LabelValueOption<any>[] = prop.options.map(sanitizeOption);
4444
return <ControlSelect options={options} components={{

packages/connect-react/src/components/ControlAny.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import { useFormFieldContext } from "../hooks/form-field-context";
2-
import { useCustomize } from "../hooks/customization-context";
1+
import {
2+
ConfiguredPropValueInteger,
3+
ConfiguredPropValueObject,
4+
ConfiguredPropValueString,
5+
ConfiguredPropValueStringArray,
6+
} from "@pipedream/sdk";
37
import type { CSSProperties } from "react";
48

9+
import { useCustomize } from "../hooks/customization-context";
10+
import { useFormFieldContext } from "../hooks/form-field-context";
11+
512
export function ControlAny() {
613
const formFieldContext = useFormFieldContext();
714
const {
@@ -18,7 +25,11 @@ export function ControlAny() {
1825
boxShadow: theme.boxShadow.input,
1926
};
2027

21-
let jsonValue = value;
28+
let jsonValue = value as
29+
| ConfiguredPropValueInteger
30+
| ConfiguredPropValueObject
31+
| ConfiguredPropValueString
32+
| ConfiguredPropValueStringArray;
2233
if (typeof jsonValue === "object") {
2334
jsonValue = JSON.stringify(jsonValue);
2435
}

packages/connect-react/src/components/ControlApp.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export function ControlApp({ app }: ControlAppProps) {
7777
};
7878
const selectProps = select.getProps("controlAppSelect", baseSelectProps);
7979

80-
const oauthAppId = oauthAppConfig?.[app.name_slug];
80+
const oauthAppId = oauthAppConfig?.[app.nameSlug];
8181
const {
8282
isLoading: isLoadingAccounts,
8383
// TODO error
@@ -86,14 +86,12 @@ export function ControlApp({ app }: ControlAppProps) {
8686
} = useAccounts(
8787
{
8888
external_user_id: externalUserId,
89-
app: app.name_slug,
89+
app: app.nameSlug,
9090
oauth_app_id: oauthAppId,
9191
},
9292
{
9393
useQueryOpts: {
9494
enabled: !!app,
95-
96-
// @ts-expect-error this seems to work (this overrides enabled so don't just set to true)
9795
suspense: !!app,
9896
},
9997
},
@@ -161,7 +159,7 @@ export function ControlApp({ app }: ControlAppProps) {
161159
isLoading={isLoadingAccounts}
162160
isClearable={true}
163161
isSearchable={true}
164-
getOptionLabel={(a) => a.name}
162+
getOptionLabel={(a) => a.name ?? ""}
165163
getOptionValue={(a) => a.id}
166164
onChange={(a) => {
167165
if (a) {

packages/connect-react/src/components/ControlInput.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { CSSProperties } from "react";
22
import { useFormFieldContext } from "../hooks/form-field-context";
33
import { useCustomize } from "../hooks/customization-context";
4+
import { isConfigurablePropOfType } from "../utils/type-guards";
45

56
export function ControlInput() {
67
const formFieldContextProps = useFormFieldContext();
@@ -46,20 +47,23 @@ export function ControlInput() {
4647
autoComplete = "new-password"; // in chrome, this is better than "off" here
4748
}
4849

50+
const min = isConfigurablePropOfType(prop, "integer")
51+
? prop.min
52+
: undefined;
53+
const max = isConfigurablePropOfType(prop, "integer")
54+
? prop.max
55+
: undefined;
56+
4957
return (
5058
<input
5159
id={id}
5260
type={inputType}
5361
name={prop.name}
54-
value={value ?? ""}
62+
value={String(value ?? "")}
5563
onChange={(e) => onChange(toOnChangeValue(e.target.value))}
5664
{...getProps("controlInput", baseStyles, formFieldContextProps)}
57-
min={"min" in prop
58-
? prop.min
59-
: undefined}
60-
max={"max" in prop
61-
? prop.max
62-
: undefined}
65+
min={min}
66+
max={max}
6367
autoComplete={autoComplete}
6468
data-lpignore="true"
6569
data-1p-ignore="true"

packages/connect-react/src/components/ControlSelect.tsx

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { PropOptionValue } from "@pipedream/sdk";
12
import {
23
useEffect,
34
useMemo,
@@ -22,7 +23,7 @@ import {
2223
import { LoadMoreButton } from "./LoadMoreButton";
2324

2425
// XXX T and ConfigurableProp should be related
25-
type ControlSelectProps<T> = {
26+
type ControlSelectProps<T extends PropOptionValue> = {
2627
isCreatable?: boolean;
2728
options: LabelValueOption<T>[];
2829
selectProps?: ReactSelectProps<LabelValueOption<T>, boolean>;
@@ -31,7 +32,7 @@ type ControlSelectProps<T> = {
3132
components?: ReactSelectProps<LabelValueOption<T>, boolean>["components"];
3233
};
3334

34-
export function ControlSelect<T>({
35+
export function ControlSelect<T extends PropOptionValue>({
3536
isCreatable,
3637
options,
3738
selectProps,
@@ -83,37 +84,29 @@ export function ControlSelect<T>({
8384
return null;
8485
}
8586

86-
let ret = rawValue;
87-
if (Array.isArray(ret)) {
87+
if (Array.isArray(rawValue)) {
8888
// if simple, make lv (XXX combine this with other place this happens)
89-
if (!isOptionWithLabel(ret[0])) {
90-
return ret.map((o) =>
91-
selectOptions.find((item) => item.value === o) || {
92-
label: String(o),
93-
value: o,
94-
});
89+
if (!isOptionWithLabel(rawValue[0])) {
90+
return rawValue.map((o) =>
91+
selectOptions.find((item) => item.value === o) || sanitizeOption(o as T));
9592
}
96-
} else if (ret && typeof ret === "object" && "__lv" in ret) {
97-
// Extract the actual option from __lv wrapper
98-
ret = ret.__lv;
99-
} else if (!isOptionWithLabel(ret)) {
93+
} else if (rawValue && typeof rawValue === "object" && "__lv" in (rawValue as Record<string, unknown>)) {
94+
// Extract the actual option from __lv wrapper and sanitize to LV
95+
return sanitizeOption(((rawValue as Record<string, unknown>).__lv) as T);
96+
} else if (!isOptionWithLabel(rawValue)) {
10097
const lvOptions = selectOptions?.[0] && isOptionWithLabel(selectOptions[0]);
10198
if (lvOptions) {
10299
for (const item of selectOptions) {
103100
if (item.value === rawValue) {
104-
ret = item;
105-
break;
101+
return item;
106102
}
107103
}
108104
} else {
109-
ret = {
110-
label: String(rawValue),
111-
value: rawValue,
112-
}
105+
return sanitizeOption(rawValue as T);
113106
}
114107
}
115108

116-
return ret;
109+
return null;
117110
}, [
118111
rawValue,
119112
selectOptions,

0 commit comments

Comments
 (0)