Skip to content

Commit 631f3d5

Browse files
authored
Merge pull request #15 from appwrite/dev
fix: patch updates for appwrite 1.4.1
2 parents 37abd13 + 5162d6b commit 631f3d5

File tree

5 files changed

+84
-18
lines changed

5 files changed

+84
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite Deno SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-deno.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.4.0-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.4.1-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export class Client {
1111
endpoint: string = 'https://HOSTNAME/v1';
1212
headers: Payload = {
1313
'content-type': '',
14-
'user-agent' : `AppwriteDenoSDK/8.0.0 (${Deno.build.os}; ${Deno.build.arch})`,
14+
'user-agent' : `AppwriteDenoSDK/8.0.1 (${Deno.build.os}; ${Deno.build.arch})`,
1515
'x-sdk-name': 'Deno',
1616
'x-sdk-platform': 'server',
1717
'x-sdk-language': 'deno',
18-
'x-sdk-version': '8.0.0',
18+
'x-sdk-version': '8.0.1',
1919
'X-Appwrite-Response-Format':'1.4.0',
2020
};
2121

src/role.ts

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,100 @@
1+
/**
2+
* Helper class to generate role strings for `Permission`.
3+
*/
14
export class Role {
5+
6+
/**
7+
* Grants access to anyone.
8+
*
9+
* This includes authenticated and unauthenticated users.
10+
*
11+
* @returns {string}
12+
*/
213
public static any(): string {
314
return 'any'
415
}
516

17+
/**
18+
* Grants access to a specific user by user ID.
19+
*
20+
* You can optionally pass verified or unverified for
21+
* `status` to target specific types of users.
22+
*
23+
* @param {string} id
24+
* @param {string} status
25+
* @returns {string}
26+
*/
627
public static user(id: string, status: string = ''): string {
7-
if(status === '') {
28+
if (status === '') {
829
return `user:${id}`
930
}
1031
return `user:${id}/${status}`
1132
}
12-
33+
34+
/**
35+
* Grants access to any authenticated or anonymous user.
36+
*
37+
* You can optionally pass verified or unverified for
38+
* `status` to target specific types of users.
39+
*
40+
* @param {string} status
41+
* @returns {string}
42+
*/
1343
public static users(status: string = ''): string {
14-
if(status === '') {
44+
if (status === '') {
1545
return 'users'
1646
}
1747
return `users/${status}`
1848
}
19-
49+
50+
/**
51+
* Grants access to any guest user without a session.
52+
*
53+
* Authenticated users don't have access to this role.
54+
*
55+
* @returns {string}
56+
*/
2057
public static guests(): string {
2158
return 'guests'
2259
}
23-
60+
61+
/**
62+
* Grants access to a team by team ID.
63+
*
64+
* You can optionally pass a role for `role` to target
65+
* team members with the specified role.
66+
*
67+
* @param {string} id
68+
* @param {string} role
69+
* @returns {string}
70+
*/
2471
public static team(id: string, role: string = ''): string {
25-
if(role === '') {
72+
if (role === '') {
2673
return `team:${id}`
2774
}
2875
return `team:${id}/${role}`
2976
}
3077

78+
/**
79+
* Grants access to a specific member of a team.
80+
*
81+
* When the member is removed from the team, they will
82+
* no longer have access.
83+
*
84+
* @param {string} id
85+
* @returns {string}
86+
*/
3187
public static member(id: string): string {
3288
return `member:${id}`
3389
}
90+
91+
/**
92+
* Grants access to a user with the specified label.
93+
*
94+
* @param {string} name
95+
* @returns {string}
96+
*/
97+
public static label(name: string): string {
98+
return `label:${name}`
99+
}
34100
}

src/services/functions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ export class Functions extends Service {
389389

390390
const size = code.size;
391391

392-
const headers: { [header: string]: string } = {
392+
const apiHeaders: { [header: string]: string } = {
393393
'content-type': 'multipart/form-data',
394394
};
395395

@@ -412,7 +412,7 @@ export class Functions extends Service {
412412
const end = start + currentPosition;
413413

414414
if(!lastUpload || currentChunk !== 1) {
415-
headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
415+
apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
416416
}
417417

418418
let uploadableChunkTrimmed: Uint8Array;
@@ -427,12 +427,12 @@ export class Functions extends Service {
427427
}
428428

429429
if (id) {
430-
headers['x-appwrite-id'] = id;
430+
apiHeaders['x-appwrite-id'] = id;
431431
}
432432

433433
payload['code'] = { type: 'file', file: new File([uploadableChunkTrimmed], code.filename), filename: code.filename };
434434

435-
response = await this.client.call('post', apiPath, headers, payload);
435+
response = await this.client.call('post', apiPath, apiHeaders, payload);
436436

437437
if (!id) {
438438
id = response['$id'];

src/services/storage.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export class Storage extends Service {
304304

305305
const size = file.size;
306306

307-
const headers: { [header: string]: string } = {
307+
const apiHeaders: { [header: string]: string } = {
308308
'content-type': 'multipart/form-data',
309309
};
310310

@@ -315,7 +315,7 @@ export class Storage extends Service {
315315

316316
if(fileId != 'unique()') {
317317
try {
318-
response = await this.client.call('get', apiPath + '/' + fileId, headers);
318+
response = await this.client.call('get', apiPath + '/' + fileId, apiHeaders);
319319
chunksUploaded = response.chunksUploaded;
320320
} catch(e) {
321321
}
@@ -334,7 +334,7 @@ export class Storage extends Service {
334334
const end = start + currentPosition;
335335

336336
if(!lastUpload || currentChunk !== 1) {
337-
headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
337+
apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
338338
}
339339

340340
let uploadableChunkTrimmed: Uint8Array;
@@ -349,12 +349,12 @@ export class Storage extends Service {
349349
}
350350

351351
if (id) {
352-
headers['x-appwrite-id'] = id;
352+
apiHeaders['x-appwrite-id'] = id;
353353
}
354354

355355
payload['file'] = { type: 'file', file: new File([uploadableChunkTrimmed], file.filename), filename: file.filename };
356356

357-
response = await this.client.call('post', apiPath, headers, payload);
357+
response = await this.client.call('post', apiPath, apiHeaders, payload);
358358

359359
if (!id) {
360360
id = response['$id'];

0 commit comments

Comments
 (0)