Skip to content

Commit 6d75a75

Browse files
authored
Pipedream v2 migration (#1710)
1 parent ed2625f commit 6d75a75

File tree

46 files changed

+1907
-1018
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1907
-1018
lines changed

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"@monaco-editor/react": "4.6.0",
3535
"@napi-rs/canvas": "0.1.68",
3636
"@pilcrowjs/object-parser": "0.0.4",
37-
"@pipedream/sdk": "^1.6.9",
37+
"@pipedream/sdk": "^2.0.0",
3838
"@sentry/nextjs": "9.10.1",
3939
"@sindresorhus/slugify": "2.2.1",
4040
"@t3-oss/env-nextjs": "0.10.1",
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
'use server'
22

3+
import { z } from 'zod'
34
import { authProcedure } from '../../procedures'
45
import { createConnectToken } from '@latitude-data/core/services/integrations/pipedream/createConnectToken'
56

67
export const createPipedreamTokenAction = authProcedure
78
.createServerAction()
8-
.handler(async ({ ctx }) => {
9-
return createConnectToken({ workspace: ctx.workspace }).then((r) =>
10-
r.unwrap(),
11-
)
9+
.input(
10+
z.object({
11+
externalUserId: z.string(),
12+
}),
13+
)
14+
.handler(async ({ input, ctx }) => {
15+
const { externalUserId } = input
16+
17+
return createConnectToken({
18+
workspace: ctx.workspace,
19+
externalUserId,
20+
}).then((r) => r.unwrap())
1221
})

apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/preview/@modal/(.)triggers/new/_components/IntegrationsList/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ export function IntegrationsList({
6363

6464
const availableApps: SearchableOptionItem<TriggerIntegrationType>[] =
6565
pipedreamApps
66-
.filter((app) => !connectedSlugs[app.name_slug])
66+
.filter((app) => !connectedSlugs[app.nameSlug])
6767
.map(
6868
(app) =>
6969
({
7070
type: 'item',
71-
value: app.name_slug,
72-
keywords: [app.name, app.name_slug],
71+
value: app.nameSlug,
72+
keywords: [app.name, app.nameSlug],
7373
metadata: { type: DocumentTriggerType.Integration },
7474
title: app.name,
75-
description: `${app.triggerCount} triggers`,
75+
description: `${app.triggers.length} triggers`,
7676
imageIcon: {
7777
type: 'image',
78-
src: app.img_src,
78+
src: app.imgSrc,
7979
alt: app.name,
8080
},
8181
}) satisfies SearchableOptionItem<TriggerIntegrationType>,

apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/preview/@modal/(.)triggers/new/_components/TriggerTypes/PipedreamTrigger/TriggerConfiguration/ConnectAccount/PipedreamConnect/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ export function PipedreamConnect({
5656
const [integration, createError] = await create({
5757
type: IntegrationType.Pipedream,
5858
configuration: {
59-
appName: app.name_slug,
59+
appName: app.nameSlug,
6060
connectionId,
6161
externalUserId,
62-
authType: app.auth_type,
62+
authType: app.authType ?? 'none',
6363
oauthAppId: app.id,
6464
metadata: {
6565
displayName: app.name,
66-
imageUrl: app.img_src,
66+
imageUrl: app.imgSrc,
6767
},
6868
},
6969
name: integrationName,

apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/preview/@modal/(.)triggers/new/_components/TriggerTypes/PipedreamTrigger/TriggerConfiguration/ConnectAccount/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function ConnectAccount({
4545
}) {
4646
const [showConnect, setShowConnect] = useState(false)
4747
const { options, accounts, isLoading } = useConnectedPipedreamAccounts({
48-
pipedreamSlug: pipedreamApp.name_slug,
48+
pipedreamSlug: pipedreamApp.nameSlug,
4949
})
5050
const onSelectAccount = useCallback(
5151
(accountId: number) => {

apps/web/src/app/(private)/settings/_components/Integrations/New/_components/Configuration/Pipedream.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ export const PipedreamIntegrationConfiguration = forwardRef<{
3030
return {
3131
type: IntegrationType.Pipedream,
3232
configuration: {
33-
appName: app.name_slug,
33+
appName: app.nameSlug,
3434
connectionId,
3535
externalUserId,
36-
authType: app.auth_type,
36+
authType: app.authType ?? 'none',
3737
oauthAppId: app.id,
3838
metadata: {
3939
displayName: app.name,
40-
imageUrl: app.img_src,
40+
imageUrl: app.imgSrc,
4141
},
4242
},
4343
}

apps/web/src/app/(private)/settings/_components/Integrations/New/_components/Configuration/Pipedream/AppCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function AppComponentsCard<C extends PipedreamComponentType>({
9898

9999
function AppComponents({ app }: { app: App }) {
100100
const { data, isLoading: isLoadingPipedreamApp } = usePipedreamApp(
101-
app.name_slug,
101+
app.nameSlug,
102102
)
103103
const isLoading = isLoadingPipedreamApp
104104

@@ -149,7 +149,7 @@ export function PipedreamAppCard({ app }: { app: App | undefined }) {
149149
<div className='w-full flex flex-col gap-4 border border-border p-4 rounded-lg'>
150150
<div className='flex gap-2 items-center'>
151151
<Image
152-
src={app.img_src}
152+
src={app.imgSrc}
153153
alt={app.name}
154154
width={24}
155155
height={24}

apps/web/src/app/(private)/settings/_components/Integrations/New/_components/Configuration/Pipedream/AppSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ export function AppSelector({
5656
onChange={onChange}
5757
fetch={fetchOptions}
5858
serialize={(app: App) => ({
59-
value: app.name_slug,
59+
value: app.nameSlug,
6060
label: app.name,
6161
description: app.description,
6262
icon: (
6363
<Image
64-
src={app.img_src}
64+
src={app.imgSrc}
6565
alt={app.name}
6666
width={16}
6767
height={16}

apps/web/src/components/Pipedream/PipedreamPropsForm.tsx

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ import {
77
import { SwitchToggle } from '@latitude-data/web-ui/atoms/Switch'
88
import { Text } from '@latitude-data/web-ui/atoms/Text'
99
import { cn } from '@latitude-data/web-ui/utils'
10-
import {
10+
import type {
1111
ConfigurableProp,
12+
ConfigurablePropAlert,
1213
ConfigurablePropBoolean,
14+
ConfigurablePropInteger,
15+
ConfigurablePropIntegerArray,
1316
ConfigurableProps,
17+
ConfigurablePropStringArray,
1418
ConfiguredProps,
1519
} from '@pipedream/sdk/browser'
1620
import DynamicPipedreamProp, { isDynamicProp } from './Props/DynamicProp'
@@ -19,13 +23,14 @@ import { Alert } from '@latitude-data/web-ui/atoms/Alert'
1923
import { AlertProps } from '@latitude-data/web-ui/atoms/Alert/Primitives'
2024
import PipedreamTimerProp from './Props/TimerProp'
2125
import ArrayPipedreamProp from './Props/ArrayProp'
26+
import type {
27+
ConfigurablePropAlertType,
28+
ConfigurablePropTimer,
29+
} from '@pipedream/sdk'
2230

2331
type Defined<T> = Exclude<T, undefined | null>
24-
type AlertType = Defined<
25-
Extract<ConfigurableProp, { type: 'alert' }>['alertType']
26-
>
2732
type AlertVariant = Defined<AlertProps['variant']>
28-
const ALERT_VARIANTS: Record<AlertType, AlertVariant> = {
33+
const ALERT_VARIANTS: Record<ConfigurablePropAlertType, AlertVariant> = {
2934
info: 'default',
3035
neutral: 'default',
3136
warning: 'warning',
@@ -159,7 +164,7 @@ function PipedreamPropsForm({
159164
if (prop.type === 'boolean') {
160165
return (
161166
<BooleanPipedreamProp
162-
prop={prop}
167+
prop={prop as ConfigurablePropBoolean}
163168
value={value}
164169
setValue={setValue}
165170
disabled={disabled}
@@ -178,16 +183,26 @@ function PipedreamPropsForm({
178183
description={prop.description}
179184
type={prop.type === 'string' ? 'text' : 'number'}
180185
disabled={disabled || prop.disabled}
181-
min={prop.type === 'integer' ? prop.min : undefined}
182-
max={prop.type === 'integer' ? prop.max : undefined}
186+
min={
187+
prop.type === 'integer'
188+
? (prop as ConfigurablePropInteger).min
189+
: undefined
190+
}
191+
max={
192+
prop.type === 'integer'
193+
? (prop as ConfigurablePropInteger).max
194+
: undefined
195+
}
183196
/>
184197
)
185198
}
186199

187200
if (prop.type === 'string[]' || prop.type === 'integer[]') {
188201
return (
189202
<ArrayPipedreamProp
190-
prop={prop}
203+
prop={
204+
prop as ConfigurablePropStringArray | ConfigurablePropIntegerArray
205+
}
191206
type={prop.type === 'string[]' ? 'text' : 'number'}
192207
value={value}
193208
setValue={setValue}
@@ -199,8 +214,10 @@ function PipedreamPropsForm({
199214
if (prop.type === 'alert') {
200215
return (
201216
<Alert
202-
variant={ALERT_VARIANTS[prop.alertType ?? 'info']}
203-
description={prop.content}
217+
variant={
218+
ALERT_VARIANTS[(prop as ConfigurablePropAlert).alertType ?? 'info']
219+
}
220+
description={(prop as ConfigurablePropAlert).content}
204221
/>
205222
)
206223
}
@@ -209,7 +226,7 @@ function PipedreamPropsForm({
209226
return (
210227
<PipedreamTimerProp
211228
integration={integration}
212-
prop={prop}
229+
prop={prop as ConfigurablePropTimer}
213230
component={component}
214231
configuredProps={configuredProps}
215232
value={value}

apps/web/src/components/Pipedream/Props/ArrayProp.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import {
1+
import type {
22
ConfigurablePropIntegerArray,
33
ConfigurablePropStringArray,
44
} from '@pipedream/sdk/browser'
55
import { MultipleInput } from '@latitude-data/web-ui/molecules/MultipleInput'
66
import { MultiSelect } from '@latitude-data/web-ui/molecules/MultiSelect'
7-
import { useState } from 'react'
7+
import { useMemo, useState } from 'react'
8+
import { getPropOptions } from '@latitude-data/core/browser'
89

910
export default function ArrayPipedreamProp<
1011
T extends 'text' | 'number' = 'text',
@@ -27,7 +28,9 @@ export default function ArrayPipedreamProp<
2728
return value.map((v) => String(v))
2829
})
2930

30-
if (prop.options) {
31+
const options = useMemo(() => getPropOptions(prop), [prop])
32+
33+
if (options) {
3134
return (
3235
<MultiSelect
3336
label={prop.label ?? prop.name}
@@ -36,15 +39,10 @@ export default function ArrayPipedreamProp<
3639
if (type === 'text') return newValues
3740
return newValues.map((v) => Number(v)) as V[]
3841
}}
39-
options={prop.options.map((option) => {
40-
if (typeof option === 'object') {
41-
return {
42-
label: option.label,
43-
value: String(option.value),
44-
}
45-
}
46-
return { label: String(option), value: String(option) }
47-
})}
42+
options={Object.entries(options).map(([label, value]) => ({
43+
label,
44+
value,
45+
}))}
4846
defaultValue={initialValue}
4947
required={!prop.optional}
5048
disabled={disabled || prop.disabled}

0 commit comments

Comments
 (0)