Skip to content
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

feat: support recursive auto-upload #62

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ Thumbs.db

# Next.js
.next
*.local
*.local
.vercel
2 changes: 1 addition & 1 deletion libs/client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@fal-ai/serverless-client",
"description": "The fal serverless JS/TS client",
"version": "0.9.1",
"version": "0.9.2",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions libs/client/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* @returns the file extension or `bin` if the content type is not recognized.
*/
function getExtensionFromContentType(contentType: string): string {
const [_, fileType] = contentType.split('/');

Check warning on line 62 in libs/client/src/storage.ts

View workflow job for this annotation

GitHub Actions / build

'_' is assigned a value but never used
return fileType.split(/[-;]/)[0] ?? 'bin';
}

Expand Down Expand Up @@ -121,6 +121,9 @@
if (isPlainObject(value)) {
return [key, await storageImpl.transformInput(value)];
}
if (Array.isArray(value)) {
return [key, await Promise.all(value.map(storageImpl.transformInput))];
}
return [key, value] as KeyValuePair;
});
const results = await Promise.all(promises);
Expand Down
5 changes: 2 additions & 3 deletions libs/client/src/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

type FalStreamEventType = 'message' | 'error' | 'done';

type EventHandler = (event: any) => void;

Check warning on line 33 in libs/client/src/streaming.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

/**
* The class representing a streaming response. With t
Expand Down Expand Up @@ -72,7 +72,7 @@
reject(error);
});
});
this.start();
this.start().catch(this.handleError);
}

private start = async () => {
Expand Down Expand Up @@ -145,8 +145,7 @@
this.emit(
'error',
new ApiError({
message:
'Event stream timed out after 15 seconds with no messages.',
message: `Event stream timed out after ${(timeout / 1000).toFixed(0)} seconds with no messages.`,
status: 408,
})
);
Expand All @@ -163,7 +162,7 @@
return;
};

private handleError = (error: any) => {

Check warning on line 165 in libs/client/src/streaming.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const apiError =
error instanceof ApiError
? error
Expand All @@ -182,7 +181,7 @@
this.listeners.get(type)?.push(listener);
};

private emit = (type: FalStreamEventType, event: any) => {

Check warning on line 184 in libs/client/src/streaming.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const listeners = this.listeners.get(type) || [];
for (const listener of listeners) {
listener(event);
Expand Down Expand Up @@ -228,7 +227,7 @@
* @param options the request options, including the input payload.
* @returns the `FalStream` instance.
*/
export async function stream<Input = Record<string, any>, Output = any>(

Check warning on line 230 in libs/client/src/streaming.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 230 in libs/client/src/streaming.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
appId: string,
options: StreamOptions<Input>
): Promise<FalStream<Input, Output>> {
Expand Down
Loading