Skip to content

Commit 66dd29f

Browse files
authored
Type improvements for configurable props (#17056)
* Add types for the missing configurable props * Fix the `Defaultable` type to correctly handle arrays * Fixed the `ConfigurablePropTimer` type to define cron expressions and time intervals * Mark the `auth` field in the SQL prop type as optional * Mark `alertType` as not required * Add missing fields for the `getApps` call
1 parent 0359787 commit 66dd29f

File tree

4 files changed

+127
-14
lines changed

4 files changed

+127
-14
lines changed

packages/sdk/CHANGELOG.md

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

33
# Changelog
44

5+
## [1.6.9] - 2025-06-10
6+
7+
### Added
8+
9+
- Added types for the missing configurable props
10+
11+
## Changed
12+
13+
- Fixed the `Defaultable` type to correctly handle arrays
14+
- Fixed the `ConfigurablePropTimer` type to define cron expressions and
15+
time intervals
16+
- Marked the `auth` field in the SQL prop type as optional
17+
- Fixed the `App` type to include the `description` field returned by the API
18+
- Fixed the `GetAppsResponse` type to include the pagination stuff
19+
520
## [1.6.8] - 2025-06-07
621

722
### Added

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pipedream/sdk",
33
"type": "module",
4-
"version": "1.6.8",
4+
"version": "1.6.9",
55
"description": "Pipedream SDK",
66
"main": "./dist/server.js",
77
"module": "./dist/server.js",

packages/sdk/src/shared/component.ts

Lines changed: 103 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,59 +55,150 @@ type BaseConfigurableProp = {
5555
};
5656

5757
// XXX fix duplicating mapping to value type here and with PropValue
58-
type Defaultable<T> = { default?: T; options?: T[]; };
58+
59+
type LabelValueOption<T> = {
60+
label: string;
61+
value: T;
62+
};
63+
64+
type Defaultable<T, SingleT = T> = {
65+
default?: T;
66+
options?: SingleT[] | Array<LabelValueOption<SingleT>>;
67+
}
5968

6069
export type ConfigurablePropAlert = BaseConfigurableProp & {
6170
type: "alert";
62-
alertType: "info" | "neutral" | "warning" | "error"; // TODO check the types
71+
alertType?: "info" | "neutral" | "warning" | "error"; // TODO check the types
6372
content: string;
6473
};
74+
6575
export type ConfigurablePropAny = BaseConfigurableProp & {
6676
type: "any";
6777
} & Defaultable<any>; // eslint-disable-line @typescript-eslint/no-explicit-any
78+
6879
export type ConfigurablePropApp = BaseConfigurableProp & {
6980
type: "app";
7081
app: string;
7182
};
72-
export type ConfigurablePropBoolean = BaseConfigurableProp & { type: "boolean"; };
83+
84+
export type ConfigurablePropBoolean = BaseConfigurableProp & {
85+
type: "boolean";
86+
} & Defaultable<boolean>;
87+
7388
export type ConfigurablePropInteger = BaseConfigurableProp & {
7489
type: "integer";
7590
min?: number;
7691
max?: number;
7792
} & Defaultable<number>;
93+
7894
export type ConfigurablePropObject = BaseConfigurableProp & {
7995
type: "object";
8096
} & Defaultable<object>;
97+
8198
export type ConfigurablePropString = BaseConfigurableProp & {
8299
type: "string";
83100
secret?: boolean;
84101
} & Defaultable<string>;
102+
85103
export type ConfigurablePropStringArray = BaseConfigurableProp & {
86104
type: "string[]";
87105
secret?: boolean; // TODO is this supported
88-
} & Defaultable<string[]>; // TODO
106+
} & Defaultable<string[], string>;
107+
108+
export type TimerInterval = {
109+
intervalSeconds: number;
110+
}
111+
112+
export type TimerCron = {
113+
cron: string;
114+
}
115+
116+
export type ConfigurablePropTimer = BaseConfigurableProp & {
117+
type: "$.interface.timer";
118+
static?: TimerInterval | TimerCron;
119+
} & Defaultable<TimerInterval | TimerCron>;
120+
121+
export type ConfigurablePropApphook = BaseConfigurableProp & {
122+
type: "$.interface.apphook";
123+
appProp: string;
124+
eventNames?: Array<string>;
125+
remote?: boolean;
126+
static?: Array<unknown>;
127+
}
128+
129+
export type ConfigurablePropIntegerArray = BaseConfigurableProp & {
130+
type: "integer[]";
131+
min?: number;
132+
max?: number;
133+
} & Defaultable<number[], number>
134+
135+
export type ConfigurablePropHttp = BaseConfigurableProp & {
136+
type: "$.interface.http";
137+
customResponse?: boolean;
138+
}
139+
140+
export type ConfigurablePropDb = BaseConfigurableProp & {
141+
type: "$.service.db";
142+
}
143+
89144
export type ConfigurablePropSql = BaseConfigurableProp & {
90145
type: "sql";
91-
auth: {
146+
auth?: {
92147
app: string;
93148
};
94149
} & Defaultable<string>;
95-
// | { type: "$.interface.http" } // source only
96-
// | { type: "$.interface.timer" } // source only
97-
// | { type: "$.service.db" }
98-
// | { type: "data_store" }
99-
// | { type: "http_request" }
150+
151+
export type ConfigurablePropAirtableBaseId = BaseConfigurableProp & {
152+
type: "$.airtable.baseId";
153+
appProp: string;
154+
}
155+
156+
export type ConfigurablePropAirtableTableId = BaseConfigurableProp & {
157+
type: "$.airtable.tableId";
158+
baseIdProp: string;
159+
}
160+
161+
export type ConfigurablePropAirtableViewId = BaseConfigurableProp & {
162+
type: "$.airtable.viewId";
163+
tableIdProp: string;
164+
}
165+
166+
export type ConfigurablePropAirtableFieldId = BaseConfigurableProp & {
167+
type: "$.airtable.fieldId";
168+
tableIdProp: string;
169+
}
170+
171+
export type ConfigurablePropDiscordChannel = BaseConfigurableProp & {
172+
type: "$.discord.channel";
173+
appProp: string;
174+
}
175+
176+
export type ConfigurablePropDiscordChannelArray = BaseConfigurableProp & {
177+
type: "$.discord.channel[]";
178+
appProp: string;
179+
}
180+
100181
export type ConfigurableProp =
182+
| ConfigurablePropAirtableBaseId
183+
| ConfigurablePropAirtableFieldId
184+
| ConfigurablePropAirtableTableId
185+
| ConfigurablePropAirtableViewId
101186
| ConfigurablePropAlert
102187
| ConfigurablePropAny
103188
| ConfigurablePropApp
189+
| ConfigurablePropApphook
104190
| ConfigurablePropBoolean
191+
| ConfigurablePropDb
192+
| ConfigurablePropDiscordChannel
193+
| ConfigurablePropDiscordChannelArray
194+
| ConfigurablePropHttp
105195
| ConfigurablePropInteger
196+
| ConfigurablePropIntegerArray
106197
| ConfigurablePropObject
198+
| ConfigurablePropSql
107199
| ConfigurablePropString
108200
| ConfigurablePropStringArray
109-
| ConfigurablePropSql
110-
| (BaseConfigurableProp & { type: "$.discord.channel"; });
201+
| ConfigurablePropTimer
111202

112203
export type ConfigurableProps = Readonly<ConfigurableProp[]>;
113204

packages/sdk/src/shared/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ export type App = AppInfo & {
9090
*/
9191
name: string;
9292

93+
/**
94+
* A short description of the app.
95+
*/
96+
description: string;
97+
9398
/**
9499
* The authentication type used by the app.
95100
*/
@@ -509,7 +514,9 @@ export type AccountsRequestResponse = GetAccountsResponse;
509514
/**
510515
* The response received when retrieving a list of apps.
511516
*/
512-
export type GetAppsResponse = { data: App[]; };
517+
export type GetAppsResponse = PaginationResponse & {
518+
data: App[];
519+
};
513520

514521
/**
515522
* @deprecated Use `GetAppsResponse` instead.

0 commit comments

Comments
 (0)