Skip to content

Commit 7def0c8

Browse files
authored
Merge pull request #94 from appwrite/dev
2 parents 8a92442 + ea7d053 commit 7def0c8

File tree

6 files changed

+104
-15
lines changed

6 files changed

+104
-15
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change log
22

3+
## 0.26.0
4+
5+
* [BREAKING] Changed `$sequence` type from `number` to `string` for `Row` and `Document` models
6+
* Added impersonation support: `setImpersonateUserId()`, `setImpersonateUserEmail()`, `setImpersonateUserPhone()` on `Client`
7+
* Added `impersonator` and `impersonatorUserId` optional fields to `User` model
8+
* Added custom `toString()` on response data objects using `JSONbig.stringify` to fix BigInt serialization
9+
* Updated `Log` model field descriptions to clarify impersonation behavior for `userId`, `userEmail`, `userName`
10+
* Updated `X-Appwrite-Response-Format` header to `1.9.0`
11+
* Updated devDependencies: Rollup 2→3, TypeScript pinned to 5.7.3, and related plugin upgrades
12+
313
## 0.24.1
414

515
* Fix very large double values (for example 1.7976931348623157e+308) from being expanded into giant integer literals.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Appwrite React Native SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-react-native.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.9.0-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)
88

9-
**This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).**
9+
**This SDK is compatible with Appwrite server version 1.9.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-react-native/releases).**
1010

1111
Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the React Native SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1212

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "react-native-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
5-
"version": "0.25.0",
5+
"version": "0.26.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {
@@ -25,13 +25,13 @@
2525
"build:libs": "rollup -c"
2626
},
2727
"devDependencies": {
28-
"@rollup/plugin-typescript": "8.3.2",
28+
"@rollup/plugin-typescript": "11.1.6",
2929
"@types/json-bigint": "1.0.4",
3030
"playwright": "1.56.1",
31-
"rollup": "2.75.4",
31+
"rollup": "3.29.5",
3232
"serve-handler": "6.1.0",
33-
"tslib": "2.4.0",
34-
"typescript": "^5.3.3"
33+
"tslib": "2.8.1",
34+
"typescript": "5.7.3"
3535
},
3636
"dependencies": {
3737
"expo-file-system": "18.*.*",

rollup.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import pkg from "./package.json";
1+
import { readFileSync } from "fs";
2+
const pkg = JSON.parse(readFileSync("./package.json", "utf8"));
23
import typescript from "@rollup/plugin-typescript";
34

45
const external = Object.keys(pkg.dependencies ?? {});

src/client.ts

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,17 @@ class Client {
152152
locale: '',
153153
session: '',
154154
devkey: '',
155+
impersonateuserid: '',
156+
impersonateuseremail: '',
157+
impersonateuserphone: '',
155158
platform: '',
156159
};
157160
headers: Headers = {
158161
'x-sdk-name': 'React Native',
159162
'x-sdk-platform': 'client',
160163
'x-sdk-language': 'reactnative',
161-
'x-sdk-version': '0.25.0',
162-
'X-Appwrite-Response-Format': '1.8.0',
164+
'x-sdk-version': '0.26.0',
165+
'X-Appwrite-Response-Format': '1.9.0',
163166
};
164167

165168
/**
@@ -293,6 +296,69 @@ class Client {
293296
return this;
294297
}
295298

299+
/**
300+
* Set ImpersonateUserId
301+
*
302+
* Impersonate a user by ID on an already user-authenticated request. Requires
303+
* the current request to be authenticated as a user with impersonator
304+
* capability; X-Appwrite-Key alone is not sufficient. Impersonator users are
305+
* intentionally granted users.read so they can discover a target before
306+
* impersonation begins. Internal audit logs still attribute actions to the
307+
* original impersonator and record the impersonated target only in internal
308+
* audit payload data.
309+
*
310+
* @param value string
311+
*
312+
* @return {this}
313+
*/
314+
setImpersonateUserId(value: string): this {
315+
this.headers['X-Appwrite-Impersonate-User-Id'] = value;
316+
this.config.impersonateuserid = value;
317+
return this;
318+
}
319+
320+
/**
321+
* Set ImpersonateUserEmail
322+
*
323+
* Impersonate a user by email on an already user-authenticated request.
324+
* Requires the current request to be authenticated as a user with
325+
* impersonator capability; X-Appwrite-Key alone is not sufficient.
326+
* Impersonator users are intentionally granted users.read so they can
327+
* discover a target before impersonation begins. Internal audit logs still
328+
* attribute actions to the original impersonator and record the impersonated
329+
* target only in internal audit payload data.
330+
*
331+
* @param value string
332+
*
333+
* @return {this}
334+
*/
335+
setImpersonateUserEmail(value: string): this {
336+
this.headers['X-Appwrite-Impersonate-User-Email'] = value;
337+
this.config.impersonateuseremail = value;
338+
return this;
339+
}
340+
341+
/**
342+
* Set ImpersonateUserPhone
343+
*
344+
* Impersonate a user by phone on an already user-authenticated request.
345+
* Requires the current request to be authenticated as a user with
346+
* impersonator capability; X-Appwrite-Key alone is not sufficient.
347+
* Impersonator users are intentionally granted users.read so they can
348+
* discover a target before impersonation begins. Internal audit logs still
349+
* attribute actions to the original impersonator and record the impersonated
350+
* target only in internal audit payload data.
351+
*
352+
* @param value string
353+
*
354+
* @return {this}
355+
*/
356+
setImpersonateUserPhone(value: string): this {
357+
this.headers['X-Appwrite-Impersonate-User-Phone'] = value;
358+
this.config.impersonateuserphone = value;
359+
return this;
360+
}
361+
296362

297363
private realtime: Realtime = {
298364
socket: undefined,
@@ -588,6 +654,10 @@ class Client {
588654
window.localStorage.setItem('cookieFallback', cookieFallback);
589655
}
590656

657+
if (data && typeof data === 'object') {
658+
data.toString = () => JSONbig.stringify(data);
659+
}
660+
591661
return data;
592662
} catch (e) {
593663
if (e instanceof AppwriteException) {

src/models.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export namespace Models {
240240
/**
241241
* Row sequence ID.
242242
*/
243-
$sequence: number;
243+
$sequence: string;
244244
/**
245245
* Table ID.
246246
*/
@@ -279,7 +279,7 @@ export namespace Models {
279279
/**
280280
* Document sequence ID.
281281
*/
282-
$sequence: number;
282+
$sequence: string;
283283
/**
284284
* Collection ID.
285285
*/
@@ -316,15 +316,15 @@ export namespace Models {
316316
*/
317317
event: string;
318318
/**
319-
* User ID.
319+
* User ID of the actor recorded for this log. During impersonation, this is the original impersonator, not the impersonated target user.
320320
*/
321321
userId: string;
322322
/**
323-
* User Email.
323+
* User email of the actor recorded for this log. During impersonation, this is the original impersonator.
324324
*/
325325
userEmail: string;
326326
/**
327-
* User Name.
327+
* User name of the actor recorded for this log. During impersonation, this is the original impersonator.
328328
*/
329329
userName: string;
330330
/**
@@ -477,6 +477,14 @@ export namespace Models {
477477
* Most recent access date in ISO 8601 format. This attribute is only updated again after 24 hours.
478478
*/
479479
accessedAt: string;
480+
/**
481+
* Whether the user can impersonate other users.
482+
*/
483+
impersonator?: boolean;
484+
/**
485+
* ID of the original actor performing the impersonation. Present only when the current request is impersonating another user. Internal audit logs attribute the action to this user, while the impersonated target is recorded only in internal audit payload data.
486+
*/
487+
impersonatorUserId?: string;
480488
}
481489

482490
/**

0 commit comments

Comments
 (0)