Skip to content

Commit 4697b48

Browse files
committed
fix: multipart testing
1 parent b8bd37b commit 4697b48

File tree

7 files changed

+30
-34
lines changed

7 files changed

+30
-34
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "node-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "15.0.0-rc1",
5+
"version": "14.1.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/index.js",
88
"type": "commonjs",

src/client.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { fetch, FormData, Blob } from 'node-fetch-native-with-agent';
2+
import { getBoundary, parse as parseMultipart} from 'parse-multipart-data';
23
import { createAgent } from 'node-fetch-native-with-agent/agent';
34
import { Models } from './models';
45
import { Payload } from './payload';
5-
import * as multipart from 'parse-multipart-data';
66

77
type Params = {
88
[key: string]: any;
@@ -35,7 +35,7 @@ class AppwriteException extends Error {
3535
}
3636

3737
function getUserAgent() {
38-
let ua = 'AppwriteNodeJSSDK/15.0.0-rc1';
38+
let ua = 'AppwriteNodeJSSDK/14.1.0';
3939

4040
// `process` is a global in Node.js, but not fully available in all runtimes.
4141
const platform: string[] = [];
@@ -84,7 +84,7 @@ class Client {
8484
'x-sdk-name': 'Node.js',
8585
'x-sdk-platform': 'server',
8686
'x-sdk-language': 'nodejs',
87-
'x-sdk-version': '15.0.0-rc1',
87+
'x-sdk-version': '14.1.0',
8888
'user-agent' : getUserAgent(),
8989
'X-Appwrite-Response-Format': '1.6.0',
9090
};
@@ -350,15 +350,11 @@ class Client {
350350
} else if (responseType === 'arrayBuffer') {
351351
data = await response.arrayBuffer();
352352
} else if (response.headers.get('content-type')?.includes('multipart/form-data')) {
353-
const chunks = [];
354-
for await (const chunk of (response.body as AsyncIterable<any>)) {
355-
chunks.push(chunk instanceof Buffer ? chunk : Buffer.from(chunk));
356-
}
357-
const body = Buffer.concat(chunks);
358-
const boundary = multipart.getBoundary(
353+
const body = await response.arrayBuffer();
354+
const boundary = getBoundary(
359355
response.headers.get("content-type") || ""
360356
);
361-
const parts = multipart.parse(body, boundary);
357+
const parts = parseMultipart(Buffer.from(body), boundary);
362358
const partsObject: { [key: string]: any } = {};
363359

364360
for (const part of parts) {

src/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ export namespace Models {
19241924
/**
19251925
* HTTP response body. This will return empty unless execution is created as synchronous.
19261926
*/
1927-
responseBody: string;
1927+
responseBody: Payload;
19281928
/**
19291929
* HTTP response headers as a key-value object. This will return only whitelisted headers. All headers are returned if execution is created as synchronous.
19301930
*/

src/services/account.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
126126
);
127127
}
128128
/**
129-
* List Identities
129+
* List identities
130130
*
131131
* Get the list of identities for the currently logged in user.
132132
*
@@ -265,7 +265,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
265265
);
266266
}
267267
/**
268-
* Create Authenticator
268+
* Create authenticator
269269
*
270270
* Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.
271271
*
@@ -293,7 +293,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
293293
);
294294
}
295295
/**
296-
* Verify Authenticator
296+
* Verify authenticator
297297
*
298298
* Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method.
299299
*
@@ -328,7 +328,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
328328
);
329329
}
330330
/**
331-
* Delete Authenticator
331+
* Delete authenticator
332332
*
333333
* Delete an authenticator for a user by ID.
334334
*
@@ -356,7 +356,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
356356
);
357357
}
358358
/**
359-
* Create MFA Challenge
359+
* Create MFA challenge
360360
*
361361
* Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.
362362
*
@@ -387,7 +387,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
387387
);
388388
}
389389
/**
390-
* Create MFA Challenge (confirmation)
390+
* Create MFA challenge (confirmation)
391391
*
392392
* Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
393393
*
@@ -425,7 +425,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
425425
);
426426
}
427427
/**
428-
* List Factors
428+
* List factors
429429
*
430430
* List the factors available on the account to be used as a MFA challange.
431431
*
@@ -449,7 +449,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
449449
);
450450
}
451451
/**
452-
* Get MFA Recovery Codes
452+
* Get MFA recovery codes
453453
*
454454
* Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.
455455
*
@@ -473,7 +473,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
473473
);
474474
}
475475
/**
476-
* Create MFA Recovery Codes
476+
* Create MFA recovery codes
477477
*
478478
* Generate recovery codes as backup for MFA flow. It&#039;s recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.
479479
*
@@ -497,7 +497,7 @@ This endpoint can also be used to convert an anonymous account to a normal one,
497497
);
498498
}
499499
/**
500-
* Regenerate MFA Recovery Codes
500+
* Regenerate MFA recovery codes
501501
*
502502
* Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.
503503
*

src/services/locale.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class Locale {
3636
);
3737
}
3838
/**
39-
* List Locale Codes
39+
* List locale codes
4040
*
4141
* List of all locale codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
4242
*

src/services/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ If you&#039;re creating a new file using one of the Appwrite SDKs, all the chunk
400400
);
401401
}
402402
/**
403-
* Delete File
403+
* Delete file
404404
*
405405
* Delete a file by its unique ID. Only users with write permissions have access to delete this resource.
406406
*

src/services/users.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export class Users {
190190
);
191191
}
192192
/**
193-
* List Identities
193+
* List identities
194194
*
195195
* Get identities for all users.
196196
*
@@ -814,7 +814,7 @@ Labels can be used to grant access to resources. While teams are a way for user&
814814
);
815815
}
816816
/**
817-
* Delete Authenticator
817+
* Delete authenticator
818818
*
819819
* Delete an authenticator app.
820820
*
@@ -846,7 +846,7 @@ Labels can be used to grant access to resources. While teams are a way for user&
846846
);
847847
}
848848
/**
849-
* List Factors
849+
* List factors
850850
*
851851
* List the factors available on the account to be used as a MFA challange.
852852
*
@@ -874,7 +874,7 @@ Labels can be used to grant access to resources. While teams are a way for user&
874874
);
875875
}
876876
/**
877-
* Get MFA Recovery Codes
877+
* Get MFA recovery codes
878878
*
879879
* Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method.
880880
*
@@ -902,7 +902,7 @@ Labels can be used to grant access to resources. While teams are a way for user&
902902
);
903903
}
904904
/**
905-
* Regenerate MFA Recovery Codes
905+
* Regenerate MFA recovery codes
906906
*
907907
* Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method.
908908
*
@@ -930,7 +930,7 @@ Labels can be used to grant access to resources. While teams are a way for user&
930930
);
931931
}
932932
/**
933-
* Create MFA Recovery Codes
933+
* Create MFA recovery codes
934934
*
935935
* Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK.
936936
*
@@ -1279,7 +1279,7 @@ If you want to generate a token for a custom authentication flow, use the [POST
12791279
);
12801280
}
12811281
/**
1282-
* List User Targets
1282+
* List user targets
12831283
*
12841284
* List the messaging targets that are associated with a user.
12851285
*
@@ -1311,7 +1311,7 @@ If you want to generate a token for a custom authentication flow, use the [POST
13111311
);
13121312
}
13131313
/**
1314-
* Create User Target
1314+
* Create user target
13151315
*
13161316
* Create a messaging target.
13171317
*
@@ -1368,7 +1368,7 @@ If you want to generate a token for a custom authentication flow, use the [POST
13681368
);
13691369
}
13701370
/**
1371-
* Get User Target
1371+
* Get user target
13721372
*
13731373
* Get a user&#039;s push notification target by ID.
13741374
*
@@ -1400,7 +1400,7 @@ If you want to generate a token for a custom authentication flow, use the [POST
14001400
);
14011401
}
14021402
/**
1403-
* Update User target
1403+
* Update user target
14041404
*
14051405
* Update a messaging target.
14061406
*

0 commit comments

Comments
 (0)