Skip to content

Commit f716c8d

Browse files
SDK regeneration
1 parent fd6995d commit f716c8d

File tree

81 files changed

+3879
-526
lines changed

Some content is hidden

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

81 files changed

+3879
-526
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Add the dependency in your `pom.xml` file:
2525
<dependency>
2626
<groupId>com.pipedream</groupId>
2727
<artifactId>pipedream</artifactId>
28-
<version>1.0.5</version>
28+
<version>1.0.6</version>
2929
</dependency>
3030
```
3131

@@ -45,10 +45,10 @@ public class Example {
4545
.builder()
4646
.clientId("<clientId>")
4747
.clientSecret("<clientSecret>")
48+
.projectId("YOUR_PROJECT_ID")
4849
.build();
4950

5051
client.actions().run(
51-
"project_id",
5252
RunActionOpts
5353
.builder()
5454
.id("id")
@@ -93,9 +93,9 @@ When the API returns a non-success status code (4xx or 5xx response), an API exc
9393
```java
9494
import com.pipedream.api.core.PipedreamApiApiException;
9595

96-
try {
96+
try{
9797
client.actions().run(...);
98-
} catch (PipedreamApiApiException e) {
98+
} catch (PipedreamApiApiException e){
9999
// Do something with the API exception...
100100
}
101101
```

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies {
2222
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
2323
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
2424
api 'org.apache.commons:commons-text:1.13.1'
25+
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
2526
}
2627

2728

@@ -48,7 +49,7 @@ java {
4849

4950
group = 'com.pipedream'
5051

51-
version = '1.0.5'
52+
version = '1.0.6'
5253

5354
jar {
5455
dependsOn(":generatePomFileForMavenPublication")
@@ -79,7 +80,7 @@ publishing {
7980
maven(MavenPublication) {
8081
groupId = 'com.pipedream'
8182
artifactId = 'pipedream'
82-
version = '1.0.5'
83+
version = '1.0.6'
8384
from components.java
8485
pom {
8586
name = 'pipedream'

src/main/java/com/pipedream/api/core/ClientOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ private ClientOptions(
3535
this.headers.putAll(headers);
3636
this.headers.putAll(new HashMap<String, String>() {
3737
{
38-
put("User-Agent", "com.pipedream:pipedream/1.0.5");
38+
put("User-Agent", "com.pipedream:pipedream/1.0.6");
3939
put("X-Fern-Language", "JAVA");
4040
put("X-Fern-SDK-Name", "com.pipedream.fern:api-sdk");
41-
put("X-Fern-SDK-Version", "1.0.5");
41+
put("X-Fern-SDK-Version", "1.0.6");
4242
}
4343
});
4444
this.headerSuppliers = headerSuppliers;

src/main/java/com/pipedream/api/core/Stream.java

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ private final class SSEIterator implements Iterator<T> {
174174
private T nextItem;
175175
private boolean hasNextItem = false;
176176
private boolean endOfStream = false;
177-
private StringBuilder buffer = new StringBuilder();
178-
private boolean prefixSeen = false;
177+
private StringBuilder eventDataBuffer = new StringBuilder();
178+
private String currentEventType = null;
179179

180180
private SSEIterator() {
181181
if (sseReader != null && !isStreamClosed()) {
@@ -223,39 +223,69 @@ private boolean readNextMessage() {
223223

224224
try {
225225
while (sseScanner.hasNextLine()) {
226-
String chunk = sseScanner.nextLine();
227-
buffer.append(chunk).append(NEWLINE);
228-
229-
int terminatorIndex;
230-
while ((terminatorIndex = buffer.indexOf(messageTerminator)) >= 0) {
231-
String line = buffer.substring(0, terminatorIndex + messageTerminator.length());
232-
buffer.delete(0, terminatorIndex + messageTerminator.length());
233-
234-
line = line.trim();
235-
if (line.isEmpty()) {
236-
continue;
226+
String line = sseScanner.nextLine();
227+
228+
if (line.trim().isEmpty()) {
229+
if (eventDataBuffer.length() > 0) {
230+
try {
231+
nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
232+
hasNextItem = true;
233+
eventDataBuffer.setLength(0);
234+
currentEventType = null;
235+
return true;
236+
} catch (Exception parseEx) {
237+
System.err.println("Failed to parse SSE event: " + parseEx.getMessage());
238+
eventDataBuffer.setLength(0);
239+
currentEventType = null;
240+
continue;
241+
}
237242
}
243+
continue;
244+
}
238245

239-
if (!prefixSeen && line.startsWith(DATA_PREFIX)) {
240-
prefixSeen = true;
241-
line = line.substring(DATA_PREFIX.length()).trim();
242-
} else if (!prefixSeen) {
243-
continue;
246+
if (line.startsWith(DATA_PREFIX)) {
247+
String dataContent = line.substring(DATA_PREFIX.length());
248+
if (dataContent.startsWith(" ")) {
249+
dataContent = dataContent.substring(1);
244250
}
245251

246-
if (streamTerminator != null && line.contains(streamTerminator)) {
252+
if (eventDataBuffer.length() == 0
253+
&& streamTerminator != null
254+
&& dataContent.trim().equals(streamTerminator)) {
247255
endOfStream = true;
248256
return false;
249257
}
250258

251-
try {
252-
nextItem = ObjectMappers.JSON_MAPPER.readValue(line, valueType);
253-
hasNextItem = true;
254-
prefixSeen = false;
255-
return true;
256-
} catch (Exception parseEx) {
257-
continue;
259+
if (eventDataBuffer.length() > 0) {
260+
eventDataBuffer.append('\n');
261+
}
262+
eventDataBuffer.append(dataContent);
263+
} else if (line.startsWith("event:")) {
264+
String eventValue = line.length() > 6 ? line.substring(6) : "";
265+
if (eventValue.startsWith(" ")) {
266+
eventValue = eventValue.substring(1);
258267
}
268+
currentEventType = eventValue;
269+
} else if (line.startsWith("id:")) {
270+
// Event ID field (ignored)
271+
} else if (line.startsWith("retry:")) {
272+
// Retry field (ignored)
273+
} else if (line.startsWith(":")) {
274+
// Comment line (ignored)
275+
}
276+
}
277+
278+
if (eventDataBuffer.length() > 0) {
279+
try {
280+
nextItem = ObjectMappers.JSON_MAPPER.readValue(eventDataBuffer.toString(), valueType);
281+
hasNextItem = true;
282+
eventDataBuffer.setLength(0);
283+
currentEventType = null;
284+
return true;
285+
} catch (Exception parseEx) {
286+
System.err.println("Failed to parse final SSE event: " + parseEx.getMessage());
287+
eventDataBuffer.setLength(0);
288+
currentEventType = null;
259289
}
260290
}
261291

src/main/java/com/pipedream/api/core/pagination/BasePage.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
package com.pipedream.api.core.pagination;
55

66
import java.util.List;
7+
import java.util.Optional;
78

89
public abstract class BasePage<T> {
910
private final boolean hasNext;
1011
private final List<T> items;
12+
private final Object response;
1113

12-
public BasePage(boolean hasNext, List<T> items) {
14+
public BasePage(boolean hasNext, List<T> items, Object response) {
1315
this.hasNext = hasNext;
1416
this.items = items;
17+
this.response = response;
1518
}
1619

1720
public boolean hasNext() {
@@ -21,4 +24,15 @@ public boolean hasNext() {
2124
public List<T> getItems() {
2225
return items;
2326
}
27+
28+
/**
29+
* Returns the full response object for accessing pagination metadata like cursor tokens.
30+
*
31+
* @return Optional containing the response, or empty if unavailable
32+
*/
33+
public <R> Optional<R> getResponse() {
34+
@SuppressWarnings("unchecked")
35+
R typedResponse = (R) response;
36+
return Optional.ofNullable(typedResponse);
37+
}
2438
}

src/main/java/com/pipedream/api/core/pagination/SyncPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
public class SyncPage<T> extends BasePage<T> {
1111
protected final Supplier<? extends SyncPage<T>> nextSupplier;
1212

13-
public SyncPage(boolean hasNext, List<T> items, Supplier<? extends SyncPage<T>> nextSupplier) {
14-
super(hasNext, items);
13+
public SyncPage(boolean hasNext, List<T> items, Object response, Supplier<? extends SyncPage<T>> nextSupplier) {
14+
super(hasNext, items, response);
1515
this.nextSupplier = nextSupplier;
1616
}
1717

src/main/java/com/pipedream/api/core/pagination/SyncPagingIterable.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
public class SyncPagingIterable<T> extends SyncPage<T> implements Iterable<T> {
1616

17-
public SyncPagingIterable(boolean hasNext, List<T> items, Supplier<? extends SyncPage<T>> getNext) {
18-
super(hasNext, items, getNext);
17+
public SyncPagingIterable(
18+
boolean hasNext, List<T> items, Object response, Supplier<? extends SyncPage<T>> getNext) {
19+
super(hasNext, items, response, getNext);
1920
}
2021

21-
public SyncPagingIterable(boolean hasNext, Optional<List<T>> items, Supplier<? extends SyncPage<T>> getNext) {
22-
super(hasNext, items.orElse(new ArrayList<>()), getNext);
22+
public SyncPagingIterable(
23+
boolean hasNext, Optional<List<T>> items, Object response, Supplier<? extends SyncPage<T>> getNext) {
24+
super(hasNext, items.orElse(new ArrayList<>()), response, getNext);
2325
}
2426

2527
public Stream<T> streamItems() {

src/main/java/com/pipedream/api/resources/accounts/AsyncRawAccountsClient.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ public CompletableFuture<BaseClientHttpResponse<SyncPagingIterable<Account>>> li
6868
.addPathSegments("v1/connect")
6969
.addPathSegment(clientOptions.projectId())
7070
.addPathSegments("accounts");
71-
if (request.getAppId().isPresent()) {
72-
QueryStringMapper.addQueryParameter(
73-
httpUrl, "app_id", request.getAppId().get(), false);
74-
}
7571
if (request.getExternalUserId().isPresent()) {
7672
QueryStringMapper.addQueryParameter(
7773
httpUrl, "external_user_id", request.getExternalUserId().get(), false);
@@ -92,6 +88,9 @@ public CompletableFuture<BaseClientHttpResponse<SyncPagingIterable<Account>>> li
9288
QueryStringMapper.addQueryParameter(
9389
httpUrl, "limit", request.getLimit().get(), false);
9490
}
91+
if (request.getApp().isPresent()) {
92+
QueryStringMapper.addQueryParameter(httpUrl, "app", request.getApp().get(), false);
93+
}
9594
if (request.getIncludeCredentials().isPresent()) {
9695
QueryStringMapper.addQueryParameter(
9796
httpUrl,
@@ -125,15 +124,16 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
125124
.build();
126125
List<Account> result = parsedResponse.getData();
127126
future.complete(new BaseClientHttpResponse<>(
128-
new SyncPagingIterable<Account>(startingAfter.isPresent(), result, () -> {
129-
try {
130-
return list(nextRequest, requestOptions)
131-
.get()
132-
.body();
133-
} catch (InterruptedException | ExecutionException e) {
134-
throw new RuntimeException(e);
135-
}
136-
}),
127+
new SyncPagingIterable<Account>(
128+
startingAfter.isPresent(), result, parsedResponse, () -> {
129+
try {
130+
return list(nextRequest, requestOptions)
131+
.get()
132+
.body();
133+
} catch (InterruptedException | ExecutionException e) {
134+
throw new RuntimeException(e);
135+
}
136+
}),
137137
response));
138138
return;
139139
}
@@ -183,10 +183,6 @@ public CompletableFuture<BaseClientHttpResponse<Account>> create(
183183
.addPathSegments("v1/connect")
184184
.addPathSegment(clientOptions.projectId())
185185
.addPathSegments("accounts");
186-
if (request.getAppId().isPresent()) {
187-
QueryStringMapper.addQueryParameter(
188-
httpUrl, "app_id", request.getAppId().get(), false);
189-
}
190186
if (request.getExternalUserId().isPresent()) {
191187
QueryStringMapper.addQueryParameter(
192188
httpUrl, "external_user_id", request.getExternalUserId().get(), false);

src/main/java/com/pipedream/api/resources/accounts/RawAccountsClient.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ public BaseClientHttpResponse<SyncPagingIterable<Account>> list(
6363
.addPathSegments("v1/connect")
6464
.addPathSegment(clientOptions.projectId())
6565
.addPathSegments("accounts");
66-
if (request.getAppId().isPresent()) {
67-
QueryStringMapper.addQueryParameter(
68-
httpUrl, "app_id", request.getAppId().get(), false);
69-
}
7066
if (request.getExternalUserId().isPresent()) {
7167
QueryStringMapper.addQueryParameter(
7268
httpUrl, "external_user_id", request.getExternalUserId().get(), false);
@@ -87,6 +83,9 @@ public BaseClientHttpResponse<SyncPagingIterable<Account>> list(
8783
QueryStringMapper.addQueryParameter(
8884
httpUrl, "limit", request.getLimit().get(), false);
8985
}
86+
if (request.getApp().isPresent()) {
87+
QueryStringMapper.addQueryParameter(httpUrl, "app", request.getApp().get(), false);
88+
}
9089
if (request.getIncludeCredentials().isPresent()) {
9190
QueryStringMapper.addQueryParameter(
9291
httpUrl,
@@ -116,9 +115,9 @@ public BaseClientHttpResponse<SyncPagingIterable<Account>> list(
116115
.build();
117116
List<Account> result = parsedResponse.getData();
118117
return new BaseClientHttpResponse<>(
119-
new SyncPagingIterable<Account>(
120-
startingAfter.isPresent(), result, () -> list(nextRequest, requestOptions)
121-
.body()),
118+
new SyncPagingIterable<Account>(startingAfter.isPresent(), result, parsedResponse, () -> list(
119+
nextRequest, requestOptions)
120+
.body()),
122121
response);
123122
}
124123
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
@@ -156,10 +155,6 @@ public BaseClientHttpResponse<Account> create(CreateAccountOpts request, Request
156155
.addPathSegments("v1/connect")
157156
.addPathSegment(clientOptions.projectId())
158157
.addPathSegments("accounts");
159-
if (request.getAppId().isPresent()) {
160-
QueryStringMapper.addQueryParameter(
161-
httpUrl, "app_id", request.getAppId().get(), false);
162-
}
163158
if (request.getExternalUserId().isPresent()) {
164159
QueryStringMapper.addQueryParameter(
165160
httpUrl, "external_user_id", request.getExternalUserId().get(), false);

0 commit comments

Comments
 (0)