Skip to content

Commit 2fb9aee

Browse files
committed
fix: remove bignumber.js direct dependency to fix bundler conflict
1 parent 8e59d80 commit 2fb9aee

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change log
22

3-
## 0.21.1
3+
## 0.23.1
44

55
* Fix `bignumber.js` bundler conflict by removing direct dependency in favor of transitive dependency from `json-bigint`
66

package.json

Lines changed: 2 additions & 3 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.21.1",
5+
"version": "0.23.1",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {
@@ -36,8 +36,7 @@
3636
"dependencies": {
3737
"expo-file-system": "18.*.*",
3838
"json-bigint": "1.0.0",
39-
"react-native": ">=0.76.7 <1.0.0",
40-
"bignumber.js": "^9.0.0"
39+
"react-native": ">=0.76.7 <1.0.0"
4140
},
4241
"peerDependencies": {
4342
"expo": "*"

src/channel.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export class Channel<T> {
6868
return this.resolve("create");
6969
}
7070

71+
upsert(this: Channel<Document | Row>): Channel<Resolved> {
72+
return this.resolve("upsert");
73+
}
74+
7175
update(this: Channel<Actionable>): Channel<Resolved> {
7276
return this.resolve("update");
7377
}

src/client.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@ import { Service } from './service';
33
import { Platform } from 'react-native';
44
import { Query } from './query';
55
import JSONbigModule from 'json-bigint';
6-
import BigNumber from 'bignumber.js';
76
const JSONbigParser = JSONbigModule({ storeAsString: false });
87
const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true });
98

109
const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
1110
const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
1211

12+
function isBigNumber(value: any): boolean {
13+
return value !== null
14+
&& typeof value === 'object'
15+
&& value._isBigNumber === true
16+
&& typeof value.isInteger === 'function'
17+
&& typeof value.toFixed === 'function'
18+
&& typeof value.toNumber === 'function';
19+
}
20+
1321
function reviver(_key: string, value: any): any {
14-
if (BigNumber.isBigNumber(value)) {
22+
if (isBigNumber(value)) {
1523
if (value.isInteger()) {
1624
const str = value.toFixed();
1725
const bi = BigInt(str);
@@ -145,7 +153,7 @@ class Client {
145153
'x-sdk-name': 'React Native',
146154
'x-sdk-platform': 'client',
147155
'x-sdk-language': 'reactnative',
148-
'x-sdk-version': '0.21.1',
156+
'x-sdk-version': '0.23.1',
149157
'X-Appwrite-Response-Format': '1.8.0',
150158
};
151159

0 commit comments

Comments
 (0)