react-native-appwrite 0.9.0 → 0.9.2

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/dist/esm/sdk.js CHANGED
@@ -71,13 +71,14 @@ class Client {
71
71
  jwt: '',
72
72
  locale: '',
73
73
  session: '',
74
+ devkey: '',
74
75
  platform: '',
75
76
  };
76
77
  this.headers = {
77
78
  'x-sdk-name': 'React Native',
78
79
  'x-sdk-platform': 'client',
79
80
  'x-sdk-language': 'reactnative',
80
- 'x-sdk-version': '0.9.0',
81
+ 'x-sdk-version': '0.9.2',
81
82
  'X-Appwrite-Response-Format': '1.7.0',
82
83
  };
83
84
  this.realtime = {
@@ -314,6 +315,20 @@ class Client {
314
315
  this.config.session = value;
315
316
  return this;
316
317
  }
318
+ /**
319
+ * Set DevKey
320
+ *
321
+ * Your secret dev API key
322
+ *
323
+ * @param value string
324
+ *
325
+ * @return {this}
326
+ */
327
+ setDevKey(value) {
328
+ this.headers['X-Appwrite-Dev-Key'] = value;
329
+ this.config.devkey = value;
330
+ return this;
331
+ }
317
332
  /**
318
333
  * Subscribes to Appwrite events and passes you the payload in realtime.
319
334
  *
@@ -363,8 +378,10 @@ class Client {
363
378
  let options = {
364
379
  method,
365
380
  headers,
366
- credentials: 'include'
367
381
  };
382
+ if (headers['X-Appwrite-Dev-Key'] === undefined) {
383
+ options.credentials = 'include';
384
+ }
368
385
  if (method === 'GET') {
369
386
  for (const [key, value] of Object.entries(Service.flatten(params))) {
370
387
  url.searchParams.append(key, value);
@@ -2047,6 +2064,46 @@ class Databases extends Service {
2047
2064
  const uri = new URL(this.client.config.endpoint + apiPath);
2048
2065
  return this.client.call('get', uri, {}, payload);
2049
2066
  }
2067
+ /**
2068
+ * Create or update a Document. Before using this route, you should create a
2069
+ * new collection resource using either a [server
2070
+ * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
2071
+ * API or directly from your database console.
2072
+ *
2073
+ * @param {string} databaseId
2074
+ * @param {string} collectionId
2075
+ * @param {string} documentId
2076
+ * @param {object} data
2077
+ * @param {string[]} permissions
2078
+ * @throws {AppwriteException}
2079
+ * @returns {Promise}
2080
+ */
2081
+ upsertDocument(databaseId, collectionId, documentId, data, permissions) {
2082
+ if (typeof databaseId === 'undefined') {
2083
+ throw new AppwriteException('Missing required parameter: "databaseId"');
2084
+ }
2085
+ if (typeof collectionId === 'undefined') {
2086
+ throw new AppwriteException('Missing required parameter: "collectionId"');
2087
+ }
2088
+ if (typeof documentId === 'undefined') {
2089
+ throw new AppwriteException('Missing required parameter: "documentId"');
2090
+ }
2091
+ if (typeof data === 'undefined') {
2092
+ throw new AppwriteException('Missing required parameter: "data"');
2093
+ }
2094
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
2095
+ const payload = {};
2096
+ if (typeof data !== 'undefined') {
2097
+ payload['data'] = data;
2098
+ }
2099
+ if (typeof permissions !== 'undefined') {
2100
+ payload['permissions'] = permissions;
2101
+ }
2102
+ const uri = new URL(this.client.config.endpoint + apiPath);
2103
+ return this.client.call('put', uri, {
2104
+ 'content-type': 'application/json',
2105
+ }, payload);
2106
+ }
2050
2107
  /**
2051
2108
  * Update a document by its unique ID. Using the patch method you can pass
2052
2109
  * only specific fields that will get updated.