react-native-appwrite 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/cjs/sdk.js +53 -25
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +53 -25
- package/dist/esm/sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +29 -3
- package/src/enums/image-format.ts +2 -0
- package/src/models.ts +7 -3
- package/src/services/account.ts +25 -14
- package/src/services/locale.ts +1 -1
- package/src/services/storage.ts +5 -7
- package/src/services/teams.ts +4 -2
- package/types/enums/image-format.d.ts +3 -1
- package/types/models.d.ts +7 -3
- package/types/services/account.d.ts +25 -14
- package/types/services/locale.d.ts +1 -1
- package/types/services/storage.d.ts +1 -1
- package/types/services/teams.d.ts +4 -2
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors.
|
|
2
2
|
All rights reserved.
|
|
3
3
|
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Appwrite React Native SDK
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

|
|
5
5
|
[](https://travis-ci.com/appwrite/sdk-generator)
|
|
6
6
|
[](https://twitter.com/appwrite)
|
|
7
7
|
[](https://appwrite.io/discord)
|
package/dist/cjs/sdk.js
CHANGED
|
@@ -99,12 +99,13 @@ class Client {
|
|
|
99
99
|
'x-sdk-name': 'React Native',
|
|
100
100
|
'x-sdk-platform': 'client',
|
|
101
101
|
'x-sdk-language': 'reactnative',
|
|
102
|
-
'x-sdk-version': '0.
|
|
102
|
+
'x-sdk-version': '0.7.0',
|
|
103
103
|
'X-Appwrite-Response-Format': '1.6.0',
|
|
104
104
|
};
|
|
105
105
|
this.realtime = {
|
|
106
106
|
socket: undefined,
|
|
107
107
|
timeout: undefined,
|
|
108
|
+
heartbeat: undefined,
|
|
108
109
|
url: '',
|
|
109
110
|
channels: new Set(),
|
|
110
111
|
subscriptions: new Map(),
|
|
@@ -130,6 +131,17 @@ class Client {
|
|
|
130
131
|
return 60000;
|
|
131
132
|
}
|
|
132
133
|
},
|
|
134
|
+
createHeartbeat: () => {
|
|
135
|
+
if (this.realtime.heartbeat) {
|
|
136
|
+
clearTimeout(this.realtime.heartbeat);
|
|
137
|
+
}
|
|
138
|
+
this.realtime.heartbeat = window === null || window === void 0 ? void 0 : window.setInterval(() => {
|
|
139
|
+
var _a;
|
|
140
|
+
(_a = this.realtime.socket) === null || _a === void 0 ? void 0 : _a.send(JSON.stringify({
|
|
141
|
+
type: 'ping'
|
|
142
|
+
}));
|
|
143
|
+
}, 20000);
|
|
144
|
+
},
|
|
133
145
|
createSocket: () => {
|
|
134
146
|
var _a, _b, _c;
|
|
135
147
|
if (this.realtime.channels.size < 1) {
|
|
@@ -163,6 +175,7 @@ class Client {
|
|
|
163
175
|
this.realtime.socket.addEventListener('message', this.realtime.onMessage);
|
|
164
176
|
this.realtime.socket.addEventListener('open', _event => {
|
|
165
177
|
this.realtime.reconnectAttempts = 0;
|
|
178
|
+
this.realtime.createHeartbeat();
|
|
166
179
|
});
|
|
167
180
|
this.realtime.socket.addEventListener('close', event => {
|
|
168
181
|
var _a, _b, _c;
|
|
@@ -200,6 +213,8 @@ class Client {
|
|
|
200
213
|
});
|
|
201
214
|
}
|
|
202
215
|
break;
|
|
216
|
+
case 'pong':
|
|
217
|
+
break; // Handle pong response if needed
|
|
203
218
|
case 'error':
|
|
204
219
|
throw message.data;
|
|
205
220
|
default:
|
|
@@ -539,7 +554,7 @@ class Account extends Service {
|
|
|
539
554
|
});
|
|
540
555
|
}
|
|
541
556
|
/**
|
|
542
|
-
* List
|
|
557
|
+
* List identities
|
|
543
558
|
*
|
|
544
559
|
* Get the list of identities for the currently logged in user.
|
|
545
560
|
*
|
|
@@ -653,7 +668,7 @@ class Account extends Service {
|
|
|
653
668
|
});
|
|
654
669
|
}
|
|
655
670
|
/**
|
|
656
|
-
* Create
|
|
671
|
+
* Create authenticator
|
|
657
672
|
*
|
|
658
673
|
* Add an authenticator app to be used as an MFA factor. Verify the
|
|
659
674
|
* authenticator using the [verify
|
|
@@ -678,7 +693,7 @@ class Account extends Service {
|
|
|
678
693
|
});
|
|
679
694
|
}
|
|
680
695
|
/**
|
|
681
|
-
* Verify
|
|
696
|
+
* Verify authenticator
|
|
682
697
|
*
|
|
683
698
|
* Verify an authenticator app after adding it using the [add
|
|
684
699
|
* authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator)
|
|
@@ -709,7 +724,7 @@ class Account extends Service {
|
|
|
709
724
|
});
|
|
710
725
|
}
|
|
711
726
|
/**
|
|
712
|
-
* Delete
|
|
727
|
+
* Delete authenticator
|
|
713
728
|
*
|
|
714
729
|
* Delete an authenticator for a user by ID.
|
|
715
730
|
*
|
|
@@ -731,7 +746,7 @@ class Account extends Service {
|
|
|
731
746
|
});
|
|
732
747
|
}
|
|
733
748
|
/**
|
|
734
|
-
* Create MFA
|
|
749
|
+
* Create MFA challenge
|
|
735
750
|
*
|
|
736
751
|
* Begin the process of MFA verification after sign-in. Finish the flow with
|
|
737
752
|
* [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge)
|
|
@@ -758,7 +773,7 @@ class Account extends Service {
|
|
|
758
773
|
});
|
|
759
774
|
}
|
|
760
775
|
/**
|
|
761
|
-
* Create MFA
|
|
776
|
+
* Create MFA challenge (confirmation)
|
|
762
777
|
*
|
|
763
778
|
* Complete the MFA challenge by providing the one-time password. Finish the
|
|
764
779
|
* process of MFA verification by providing the one-time password. To begin
|
|
@@ -794,7 +809,7 @@ class Account extends Service {
|
|
|
794
809
|
});
|
|
795
810
|
}
|
|
796
811
|
/**
|
|
797
|
-
* List
|
|
812
|
+
* List factors
|
|
798
813
|
*
|
|
799
814
|
* List the factors available on the account to be used as a MFA challange.
|
|
800
815
|
*
|
|
@@ -812,7 +827,7 @@ class Account extends Service {
|
|
|
812
827
|
});
|
|
813
828
|
}
|
|
814
829
|
/**
|
|
815
|
-
* Get MFA
|
|
830
|
+
* Get MFA recovery codes
|
|
816
831
|
*
|
|
817
832
|
* Get recovery codes that can be used as backup for MFA flow. Before getting
|
|
818
833
|
* codes, they must be generated using
|
|
@@ -833,7 +848,7 @@ class Account extends Service {
|
|
|
833
848
|
});
|
|
834
849
|
}
|
|
835
850
|
/**
|
|
836
|
-
* Create MFA
|
|
851
|
+
* Create MFA recovery codes
|
|
837
852
|
*
|
|
838
853
|
* Generate recovery codes as backup for MFA flow. It's recommended to
|
|
839
854
|
* generate and show then immediately after user successfully adds their
|
|
@@ -855,7 +870,7 @@ class Account extends Service {
|
|
|
855
870
|
});
|
|
856
871
|
}
|
|
857
872
|
/**
|
|
858
|
-
* Regenerate MFA
|
|
873
|
+
* Regenerate MFA recovery codes
|
|
859
874
|
*
|
|
860
875
|
* Regenerate recovery codes that can be used as backup for MFA flow. Before
|
|
861
876
|
* regenerating codes, they must be first generated using
|
|
@@ -1445,6 +1460,11 @@ class Account extends Service {
|
|
|
1445
1460
|
/**
|
|
1446
1461
|
* Create push target
|
|
1447
1462
|
*
|
|
1463
|
+
* Use this endpoint to register a device for push notifications. Provide a
|
|
1464
|
+
* target ID (custom or generated using ID.unique()), a device identifier
|
|
1465
|
+
* (usually a device token), and optionally specify which provider should send
|
|
1466
|
+
* notifications to this target. The target is automatically linked to the
|
|
1467
|
+
* current session and includes device information like brand and model.
|
|
1448
1468
|
*
|
|
1449
1469
|
* @param {string} targetId
|
|
1450
1470
|
* @param {string} identifier
|
|
@@ -1480,6 +1500,11 @@ class Account extends Service {
|
|
|
1480
1500
|
/**
|
|
1481
1501
|
* Update push target
|
|
1482
1502
|
*
|
|
1503
|
+
* Update the currently logged in user's push notification target. You can
|
|
1504
|
+
* modify the target's identifier (device token) and provider ID (token,
|
|
1505
|
+
* email, phone etc.). The target must exist and belong to the current user.
|
|
1506
|
+
* If you change the provider ID, notifications will be sent through the new
|
|
1507
|
+
* messaging provider instead.
|
|
1483
1508
|
*
|
|
1484
1509
|
* @param {string} targetId
|
|
1485
1510
|
* @param {string} identifier
|
|
@@ -1508,6 +1533,9 @@ class Account extends Service {
|
|
|
1508
1533
|
/**
|
|
1509
1534
|
* Delete push target
|
|
1510
1535
|
*
|
|
1536
|
+
* Delete a push notification target for the currently logged in user. After
|
|
1537
|
+
* deletion, the device will no longer receive push notifications. The target
|
|
1538
|
+
* must exist and belong to the current user.
|
|
1511
1539
|
*
|
|
1512
1540
|
* @param {string} targetId
|
|
1513
1541
|
* @throws {AppwriteException}
|
|
@@ -1582,9 +1610,7 @@ class Account extends Service {
|
|
|
1582
1610
|
* [POST
|
|
1583
1611
|
* /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession)
|
|
1584
1612
|
* endpoint to complete the login process. The link sent to the user's email
|
|
1585
|
-
* address is valid for 1 hour.
|
|
1586
|
-
* the URL parameter empty, so that the login completion will be handled by
|
|
1587
|
-
* your Appwrite instance by default.
|
|
1613
|
+
* address is valid for 1 hour.
|
|
1588
1614
|
*
|
|
1589
1615
|
* A user is limited to 10 active sessions at a time by default. [Learn more
|
|
1590
1616
|
* about session
|
|
@@ -2529,7 +2555,7 @@ class Locale extends Service {
|
|
|
2529
2555
|
});
|
|
2530
2556
|
}
|
|
2531
2557
|
/**
|
|
2532
|
-
* List
|
|
2558
|
+
* List locale codes
|
|
2533
2559
|
*
|
|
2534
2560
|
* List of all locale codes in [ISO
|
|
2535
2561
|
* 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).
|
|
@@ -2830,13 +2856,11 @@ class Storage extends Service {
|
|
|
2830
2856
|
};
|
|
2831
2857
|
let offset = 0;
|
|
2832
2858
|
let response = undefined;
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
catch (e) {
|
|
2839
|
-
}
|
|
2859
|
+
try {
|
|
2860
|
+
response = yield this.client.call('GET', new URL(this.client.config.endpoint + apiPath + '/' + fileId), apiHeaders);
|
|
2861
|
+
offset = response.chunksUploaded * Service.CHUNK_SIZE;
|
|
2862
|
+
}
|
|
2863
|
+
catch (e) {
|
|
2840
2864
|
}
|
|
2841
2865
|
let timestamp = new Date().getTime();
|
|
2842
2866
|
while (offset < size) {
|
|
@@ -2934,7 +2958,7 @@ class Storage extends Service {
|
|
|
2934
2958
|
});
|
|
2935
2959
|
}
|
|
2936
2960
|
/**
|
|
2937
|
-
* Delete
|
|
2961
|
+
* Delete file
|
|
2938
2962
|
*
|
|
2939
2963
|
* Delete a file by its unique ID. Only users with write permissions have
|
|
2940
2964
|
* access to delete this resource.
|
|
@@ -3239,7 +3263,8 @@ class Teams extends Service {
|
|
|
3239
3263
|
* List team memberships
|
|
3240
3264
|
*
|
|
3241
3265
|
* Use this endpoint to list a team's members using the team's ID. All team
|
|
3242
|
-
* members have read access to this endpoint.
|
|
3266
|
+
* members have read access to this endpoint. Hide sensitive attributes from
|
|
3267
|
+
* the response by toggling membership privacy in the Console.
|
|
3243
3268
|
*
|
|
3244
3269
|
* @param {string} teamId
|
|
3245
3270
|
* @param {string[]} queries
|
|
@@ -3339,7 +3364,8 @@ class Teams extends Service {
|
|
|
3339
3364
|
* Get team membership
|
|
3340
3365
|
*
|
|
3341
3366
|
* Get a team member by the membership unique id. All team members have read
|
|
3342
|
-
* access for this resource.
|
|
3367
|
+
* access for this resource. Hide sensitive attributes from the response by
|
|
3368
|
+
* toggling membership privacy in the Console.
|
|
3343
3369
|
*
|
|
3344
3370
|
* @param {string} teamId
|
|
3345
3371
|
* @param {string} membershipId
|
|
@@ -4033,6 +4059,8 @@ exports.ImageFormat = void 0;
|
|
|
4033
4059
|
ImageFormat["Gif"] = "gif";
|
|
4034
4060
|
ImageFormat["Png"] = "png";
|
|
4035
4061
|
ImageFormat["Webp"] = "webp";
|
|
4062
|
+
ImageFormat["Heic"] = "heic";
|
|
4063
|
+
ImageFormat["Avif"] = "avif";
|
|
4036
4064
|
})(exports.ImageFormat || (exports.ImageFormat = {}));
|
|
4037
4065
|
|
|
4038
4066
|
exports.Account = Account;
|