react-native-appwrite 0.9.0 → 0.9.1

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.1',
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
  *
@@ -2047,6 +2062,46 @@ class Databases extends Service {
2047
2062
  const uri = new URL(this.client.config.endpoint + apiPath);
2048
2063
  return this.client.call('get', uri, {}, payload);
2049
2064
  }
2065
+ /**
2066
+ * Create or update a Document. Before using this route, you should create a
2067
+ * new collection resource using either a [server
2068
+ * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection)
2069
+ * API or directly from your database console.
2070
+ *
2071
+ * @param {string} databaseId
2072
+ * @param {string} collectionId
2073
+ * @param {string} documentId
2074
+ * @param {object} data
2075
+ * @param {string[]} permissions
2076
+ * @throws {AppwriteException}
2077
+ * @returns {Promise}
2078
+ */
2079
+ upsertDocument(databaseId, collectionId, documentId, data, permissions) {
2080
+ if (typeof databaseId === 'undefined') {
2081
+ throw new AppwriteException('Missing required parameter: "databaseId"');
2082
+ }
2083
+ if (typeof collectionId === 'undefined') {
2084
+ throw new AppwriteException('Missing required parameter: "collectionId"');
2085
+ }
2086
+ if (typeof documentId === 'undefined') {
2087
+ throw new AppwriteException('Missing required parameter: "documentId"');
2088
+ }
2089
+ if (typeof data === 'undefined') {
2090
+ throw new AppwriteException('Missing required parameter: "data"');
2091
+ }
2092
+ const apiPath = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId);
2093
+ const payload = {};
2094
+ if (typeof data !== 'undefined') {
2095
+ payload['data'] = data;
2096
+ }
2097
+ if (typeof permissions !== 'undefined') {
2098
+ payload['permissions'] = permissions;
2099
+ }
2100
+ const uri = new URL(this.client.config.endpoint + apiPath);
2101
+ return this.client.call('put', uri, {
2102
+ 'content-type': 'application/json',
2103
+ }, payload);
2104
+ }
2050
2105
  /**
2051
2106
  * Update a document by its unique ID. Using the patch method you can pass
2052
2107
  * only specific fields that will get updated.