Repository navigation
feat: SDK update for version 18.1.0 #115
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -413,7 +413,7 @@ class Client { | |
| 'x-sdk-name': 'Console', | ||
| 'x-sdk-platform': 'console', | ||
| 'x-sdk-language': 'web', | ||
| 'x-sdk-version': '18.0.0', | ||
| 'x-sdk-version': '18.1.0', | ||
| 'X-Appwrite-Response-Format': '2.3.0', | ||
| }; | ||
|
|
||
|
|
@@ -1171,6 +1171,11 @@ class Client { | |
| for (const nestedValue of value) { | ||
| formData.append(`${key}[]`, nestedValue); | ||
| } | ||
| } else if ( | ||
| value !== null && | ||
| typeof value === 'object' | ||
| ) { | ||
| formData.append(key, JSONbig.stringify(value)); | ||
| } else { | ||
| formData.append(key, value); | ||
| } | ||
|
|
@@ -1192,18 +1197,31 @@ class Client { | |
| headers: Headers = {}, | ||
| originalPayload: Payload = {}, | ||
| onProgress: (progress: UploadProgress) => void, | ||
| responseType = 'json', | ||
| ) { | ||
| const [fileParam, file] = | ||
| Object.entries(originalPayload).find( | ||
| ([_, value]) => value instanceof File, | ||
| ) ?? []; | ||
|
|
||
| if (!file || !fileParam) { | ||
| return await this.call(method, url, headers, originalPayload); | ||
| return await this.call( | ||
| method, | ||
| url, | ||
| headers, | ||
| originalPayload, | ||
| responseType, | ||
| ); | ||
| } | ||
|
|
||
| if (file.size <= Client.CHUNK_SIZE) { | ||
| return await this.call(method, url, headers, originalPayload); | ||
| if (file.size <= Client.CHUNK_SIZE || responseType === 'text') { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Knowledge Base Used: Client configuration and HTTP transport Prompt To Fix With AIThis is a comment left during a code review.
Path: src/client.ts
Line: 1217
Comment:
**Text uploads bypass chunking** If a caller uses the public `chunkedUpload` method with a text response and a file larger than 5 MB, this condition sends the whole file in one request. It also skips `onProgress`, so the caller loses progress updates and the upload may fail if the server limits single-request size. Keep large-file chunking independent of the response format.
**Knowledge Base Used:** [Client configuration and HTTP transport](https://app.greptile.com/appwrite/-/custom-context/knowledge-base/appwrite/sdk-for-console/-/docs/sdk-client-and-transport.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
| return await this.call( | ||
| method, | ||
| url, | ||
| headers, | ||
| originalPayload, | ||
| responseType, | ||
| ); | ||
| } | ||
|
|
||
| const totalChunks = Math.ceil(file.size / Client.CHUNK_SIZE); | ||
|
|
@@ -1223,6 +1241,7 @@ class Client { | |
| url, | ||
| firstChunkHeaders, | ||
| firstPayload, | ||
| responseType, | ||
| ); | ||
| const uploadId = response?.$id; | ||
|
|
||
|
|
@@ -1283,6 +1302,7 @@ class Client { | |
| url, | ||
| chunkHeaders, | ||
| chunkPayload, | ||
| responseType, | ||
| ); | ||
|
|
||
| if (rejected) { | ||
|
|
@@ -1392,7 +1412,9 @@ class Client { | |
| ); | ||
| } | ||
|
|
||
| if ( | ||
| if (responseType === 'text' && response.status < 400) { | ||
| data = await response.text(); | ||
| } else if ( | ||
| response.headers.get('content-type')?.includes('application/json') | ||
| ) { | ||
| data = JSONbig.parse(await response.text()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chatorgetZoneshould be checked through observable results; type-checking cannot catch a wrong field value or return value.Knowledge Base Used: Client configuration and HTTP transport
Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!