node-appwrite
Advanced tools
Comparing version
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createBooleanAttribute('[COLLECTION_ID]', '', false); | ||
const promise = databases.createBooleanAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createCollection('[COLLECTION_ID]', '[NAME]', 'document', ["role:all"], ["role:all"]); | ||
const promise = databases.createCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createDocument('[COLLECTION_ID]', '[DOCUMENT_ID]', {}); | ||
const promise = databases.createDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]', {}); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createEmailAttribute('[COLLECTION_ID]', '', false); | ||
const promise = databases.createEmailAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createEnumAttribute('[COLLECTION_ID]', '', [], false); | ||
const promise = databases.createEnumAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', [], false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createFloatAttribute('[COLLECTION_ID]', '', false); | ||
const promise = databases.createFloatAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createIndex('[COLLECTION_ID]', '', 'key', []); | ||
const promise = databases.createIndex('[DATABASE_ID]', '[COLLECTION_ID]', '', 'key', []); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createIntegerAttribute('[COLLECTION_ID]', '', false); | ||
const promise = databases.createIntegerAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createIpAttribute('[COLLECTION_ID]', '', false); | ||
const promise = databases.createIpAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createStringAttribute('[COLLECTION_ID]', '', 1, false); | ||
const promise = databases.createStringAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', 1, false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.createUrlAttribute('[COLLECTION_ID]', '', false); | ||
const promise = databases.createUrlAttribute('[DATABASE_ID]', '[COLLECTION_ID]', '', false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.create('[NAME]'); | ||
const promise = databases.create('[DATABASE_ID]', '[NAME]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.deleteAttribute('[COLLECTION_ID]', ''); | ||
const promise = databases.deleteAttribute('[DATABASE_ID]', '[COLLECTION_ID]', ''); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.deleteCollection('[COLLECTION_ID]'); | ||
const promise = databases.deleteCollection('[DATABASE_ID]', '[COLLECTION_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.deleteDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); | ||
const promise = databases.deleteDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.deleteIndex('[COLLECTION_ID]', ''); | ||
const promise = databases.deleteIndex('[DATABASE_ID]', '[COLLECTION_ID]', ''); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.delete(); | ||
const promise = databases.delete('[DATABASE_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.getAttribute('[COLLECTION_ID]', ''); | ||
const promise = databases.getAttribute('[DATABASE_ID]', '[COLLECTION_ID]', ''); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.getCollection('[COLLECTION_ID]'); | ||
const promise = databases.getCollection('[DATABASE_ID]', '[COLLECTION_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.getDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); | ||
const promise = databases.getDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.getIndex('[COLLECTION_ID]', ''); | ||
const promise = databases.getIndex('[DATABASE_ID]', '[COLLECTION_ID]', ''); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.get(); | ||
const promise = databases.get('[DATABASE_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.listAttributes('[COLLECTION_ID]'); | ||
const promise = databases.listAttributes('[DATABASE_ID]', '[COLLECTION_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.listCollections(); | ||
const promise = databases.listCollections('[DATABASE_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.listDocuments('[COLLECTION_ID]'); | ||
const promise = databases.listDocuments('[DATABASE_ID]', '[COLLECTION_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.listIndexes('[COLLECTION_ID]'); | ||
const promise = databases.listIndexes('[DATABASE_ID]', '[COLLECTION_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -9,0 +9,0 @@ client |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.updateCollection('[COLLECTION_ID]', '[NAME]', 'document'); | ||
const promise = databases.updateCollection('[DATABASE_ID]', '[COLLECTION_ID]', '[NAME]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.updateDocument('[COLLECTION_ID]', '[DOCUMENT_ID]'); | ||
const promise = databases.updateDocument('[DATABASE_ID]', '[COLLECTION_ID]', '[DOCUMENT_ID]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -6,3 +6,3 @@ const sdk = require('node-appwrite'); | ||
const databases = new sdk.Databases(client, '[DATABASE_ID]'); | ||
const databases = new sdk.Databases(client); | ||
@@ -15,3 +15,3 @@ client | ||
const promise = databases.update('[NAME]'); | ||
const promise = databases.update('[DATABASE_ID]', '[NAME]'); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -15,3 +15,3 @@ const sdk = require('node-appwrite'); | ||
const promise = functions.createDeployment('[FUNCTION_ID]', '[ENTRYPOINT]', 'file.png', false); | ||
const promise = functions.createDeployment('[FUNCTION_ID]', '[ENTRYPOINT]', InputFile.fromPath('/path/to/file.png', 'file.png'), false); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -14,3 +14,3 @@ const sdk = require('node-appwrite'); | ||
const promise = functions.create('[FUNCTION_ID]', '[NAME]', [], 'node-14.5'); | ||
const promise = functions.create('[FUNCTION_ID]', '[NAME]', ["any"], 'node-14.5'); | ||
@@ -17,0 +17,0 @@ promise.then(function (response) { |
@@ -14,3 +14,3 @@ const sdk = require('node-appwrite'); | ||
const promise = functions.update('[FUNCTION_ID]', '[NAME]', []); | ||
const promise = functions.update('[FUNCTION_ID]', '[NAME]', ["any"]); | ||
@@ -17,0 +17,0 @@ promise.then(function (response) { |
@@ -14,3 +14,3 @@ const sdk = require('node-appwrite'); | ||
const promise = storage.createBucket('[BUCKET_ID]', '[NAME]', 'file'); | ||
const promise = storage.createBucket('[BUCKET_ID]', '[NAME]'); | ||
@@ -17,0 +17,0 @@ promise.then(function (response) { |
@@ -15,3 +15,3 @@ const sdk = require('node-appwrite'); | ||
const promise = storage.createFile('[BUCKET_ID]', '[FILE_ID]', 'file.png'); | ||
const promise = storage.createFile('[BUCKET_ID]', '[FILE_ID]', InputFile.fromPath('/path/to/file.png', 'file.png')); | ||
@@ -18,0 +18,0 @@ promise.then(function (response) { |
@@ -14,3 +14,3 @@ const sdk = require('node-appwrite'); | ||
const promise = storage.updateBucket('[BUCKET_ID]', '[NAME]', 'file'); | ||
const promise = storage.updateBucket('[BUCKET_ID]', '[NAME]'); | ||
@@ -17,0 +17,0 @@ promise.then(function (response) { |
@@ -14,3 +14,3 @@ const sdk = require('node-appwrite'); | ||
const promise = users.create('[USER_ID]', 'email@example.com', 'password'); | ||
const promise = users.create('[USER_ID]'); | ||
@@ -17,0 +17,0 @@ promise.then(function (response) { |
const Client = require('./lib/client.js'); | ||
const Query = require('./lib/query.js'); | ||
const Permission = require('./lib/permission.js'); | ||
const Role = require('./lib/role.js'); | ||
const ID = require('./lib/id.js'); | ||
const InputFile = require('./lib/inputFile.js'); | ||
@@ -18,2 +21,5 @@ const AppwriteException = require('./lib/exception.js'); | ||
Query, | ||
Permission, | ||
Role, | ||
ID, | ||
InputFile, | ||
@@ -20,0 +26,0 @@ AppwriteException, |
@@ -13,4 +13,7 @@ const URL = require('url').URL; | ||
'content-type': '', | ||
'x-sdk-version': 'appwrite:nodejs:7.0.2', | ||
'X-Appwrite-Response-Format' : '0.15.0', | ||
'x-sdk-name': 'Node.js', | ||
'x-sdk-platform': 'server', | ||
'x-sdk-language': 'nodejs', | ||
'x-sdk-version': '8.0.0-RC1', | ||
'X-Appwrite-Response-Format' : '1.0.0-RC1', | ||
}; | ||
@@ -17,0 +20,0 @@ this.selfSigned = false; |
@@ -8,13 +8,13 @@ class Query { | ||
static lesser = (attribute, value) => | ||
Query.addQuery(attribute, "lesser", value); | ||
static lessThan = (attribute, value) => | ||
Query.addQuery(attribute, "lessThan", value); | ||
static lesserEqual = (attribute, value) => | ||
Query.addQuery(attribute, "lesserEqual", value); | ||
static lessThanEqual = (attribute, value) => | ||
Query.addQuery(attribute, "lessThanEqual", value); | ||
static greater = (attribute, value) => | ||
Query.addQuery(attribute, "greater", value); | ||
static greaterThan = (attribute, value) => | ||
Query.addQuery(attribute, "greaterThan", value); | ||
static greaterEqual = (attribute, value) => | ||
Query.addQuery(attribute, "greaterEqual", value); | ||
static greaterThanEqual = (attribute, value) => | ||
Query.addQuery(attribute, "greaterThanEqual", value); | ||
@@ -24,8 +24,26 @@ static search = (attribute, value) => | ||
static addQuery = (attribute, oper, value) => | ||
static orderDesc = (attribute) => | ||
`orderDesc("${attribute}")`; | ||
static orderAsc = (attribute) => | ||
`orderAsc("${attribute}")`; | ||
static cursorAfter = (documentId) => | ||
`cursorAfter("${documentId}")`; | ||
static cursorBefore = (documentId) => | ||
`cursorBefore("${documentId}")`; | ||
static limit = (limit) => | ||
`limit(${limit})`; | ||
static offset = (offset) => | ||
`offset(${offset})`; | ||
static addQuery = (attribute, method, value) => | ||
value instanceof Array | ||
? `${attribute}.${oper}(${value | ||
? `${method}("${attribute}", [${value | ||
.map((v) => Query.parseValues(v)) | ||
.join(",")})` | ||
: `${attribute}.${oper}(${Query.parseValues(value)})`; | ||
.join(",")}])` | ||
: `${method}("${attribute}", [${Query.parseValues(value)}])`; | ||
@@ -32,0 +50,0 @@ static parseValues = (value) => |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -47,2 +53,4 @@ * Get Account | ||
async updateEmail(email, password) { | ||
let path = '/account/email'; | ||
let payload = {}; | ||
if (typeof email === 'undefined') { | ||
@@ -56,4 +64,2 @@ throw new AppwriteException('Missing required parameter: "email"'); | ||
let path = '/account/email'; | ||
let payload = {}; | ||
@@ -79,19 +85,14 @@ if (typeof email !== 'undefined') { | ||
* | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string[]} queries | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async getLogs(limit, offset) { | ||
async getLogs(queries) { | ||
let path = '/account/logs'; | ||
let payload = {}; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -112,2 +113,4 @@ 'content-type': 'application/json', | ||
async updateName(name) { | ||
let path = '/account/name'; | ||
let payload = {}; | ||
if (typeof name === 'undefined') { | ||
@@ -117,4 +120,2 @@ throw new AppwriteException('Missing required parameter: "name"'); | ||
let path = '/account/name'; | ||
let payload = {}; | ||
@@ -143,2 +144,4 @@ if (typeof name !== 'undefined') { | ||
async updatePassword(password, oldPassword) { | ||
let path = '/account/password'; | ||
let payload = {}; | ||
if (typeof password === 'undefined') { | ||
@@ -148,4 +151,2 @@ throw new AppwriteException('Missing required parameter: "password"'); | ||
let path = '/account/password'; | ||
let payload = {}; | ||
@@ -174,3 +175,3 @@ if (typeof password !== 'undefined') { | ||
* | ||
* @param {string} number | ||
* @param {string} phone | ||
* @param {string} password | ||
@@ -180,5 +181,7 @@ * @throws {AppwriteException} | ||
*/ | ||
async updatePhone(number, password) { | ||
if (typeof number === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "number"'); | ||
async updatePhone(phone, password) { | ||
let path = '/account/phone'; | ||
let payload = {}; | ||
if (typeof phone === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "phone"'); | ||
} | ||
@@ -190,7 +193,5 @@ | ||
let path = '/account/phone'; | ||
let payload = {}; | ||
if (typeof number !== 'undefined') { | ||
payload['number'] = number; | ||
if (typeof phone !== 'undefined') { | ||
payload['phone'] = phone; | ||
} | ||
@@ -236,2 +237,4 @@ | ||
async updatePrefs(prefs) { | ||
let path = '/account/prefs'; | ||
let payload = {}; | ||
if (typeof prefs === 'undefined') { | ||
@@ -241,4 +244,2 @@ throw new AppwriteException('Missing required parameter: "prefs"'); | ||
let path = '/account/prefs'; | ||
let payload = {}; | ||
@@ -272,2 +273,4 @@ if (typeof prefs !== 'undefined') { | ||
async createRecovery(email, url) { | ||
let path = '/account/recovery'; | ||
let payload = {}; | ||
if (typeof email === 'undefined') { | ||
@@ -281,4 +284,2 @@ throw new AppwriteException('Missing required parameter: "email"'); | ||
let path = '/account/recovery'; | ||
let payload = {}; | ||
@@ -319,2 +320,4 @@ if (typeof email !== 'undefined') { | ||
async updateRecovery(userId, secret, password, passwordAgain) { | ||
let path = '/account/recovery'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -336,4 +339,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/account/recovery'; | ||
let payload = {}; | ||
@@ -408,2 +409,4 @@ if (typeof userId !== 'undefined') { | ||
async getSession(sessionId) { | ||
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
if (typeof sessionId === 'undefined') { | ||
@@ -413,4 +416,2 @@ throw new AppwriteException('Missing required parameter: "sessionId"'); | ||
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
@@ -434,2 +435,4 @@ return await this.client.call('get', path, { | ||
async updateSession(sessionId) { | ||
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
if (typeof sessionId === 'undefined') { | ||
@@ -439,4 +442,2 @@ throw new AppwriteException('Missing required parameter: "sessionId"'); | ||
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
@@ -461,2 +462,4 @@ return await this.client.call('patch', path, { | ||
async deleteSession(sessionId) { | ||
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
if (typeof sessionId === 'undefined') { | ||
@@ -466,4 +469,2 @@ throw new AppwriteException('Missing required parameter: "sessionId"'); | ||
let path = '/account/sessions/{sessionId}'.replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
@@ -518,2 +519,4 @@ return await this.client.call('delete', path, { | ||
async createVerification(url) { | ||
let path = '/account/verification'; | ||
let payload = {}; | ||
if (typeof url === 'undefined') { | ||
@@ -523,4 +526,2 @@ throw new AppwriteException('Missing required parameter: "url"'); | ||
let path = '/account/verification'; | ||
let payload = {}; | ||
@@ -550,2 +551,4 @@ if (typeof url !== 'undefined') { | ||
async updateVerification(userId, secret) { | ||
let path = '/account/verification'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -559,4 +562,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/account/verification'; | ||
let payload = {}; | ||
@@ -612,2 +613,4 @@ if (typeof userId !== 'undefined') { | ||
async updatePhoneVerification(userId, secret) { | ||
let path = '/account/verification/phone'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -621,4 +624,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/account/verification/phone'; | ||
let payload = {}; | ||
@@ -639,2 +640,2 @@ if (typeof userId !== 'undefined') { | ||
module.exports = Account; | ||
module.exports = Account; |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -33,2 +39,4 @@ * Get Browser Icon | ||
async getBrowser(code, width, height, quality) { | ||
let path = '/avatars/browsers/{code}'.replace('{code}', code); | ||
let payload = {}; | ||
if (typeof code === 'undefined') { | ||
@@ -38,4 +46,2 @@ throw new AppwriteException('Missing required parameter: "code"'); | ||
let path = '/avatars/browsers/{code}'.replace('{code}', code); | ||
let payload = {}; | ||
@@ -80,2 +86,4 @@ if (typeof width !== 'undefined') { | ||
async getCreditCard(code, width, height, quality) { | ||
let path = '/avatars/credit-cards/{code}'.replace('{code}', code); | ||
let payload = {}; | ||
if (typeof code === 'undefined') { | ||
@@ -85,4 +93,2 @@ throw new AppwriteException('Missing required parameter: "code"'); | ||
let path = '/avatars/credit-cards/{code}'.replace('{code}', code); | ||
let payload = {}; | ||
@@ -118,2 +124,4 @@ if (typeof width !== 'undefined') { | ||
async getFavicon(url) { | ||
let path = '/avatars/favicon'; | ||
let payload = {}; | ||
if (typeof url === 'undefined') { | ||
@@ -123,4 +131,2 @@ throw new AppwriteException('Missing required parameter: "url"'); | ||
let path = '/avatars/favicon'; | ||
let payload = {}; | ||
@@ -141,3 +147,4 @@ if (typeof url !== 'undefined') { | ||
* users. The code argument receives the 2 letter country code. Use width, | ||
* height and quality arguments to change the output settings. | ||
* height and quality arguments to change the output settings. Country codes | ||
* follow the [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1) standard. | ||
* | ||
@@ -158,2 +165,4 @@ * When one dimension is specified and the other is 0, the image is scaled | ||
async getFlag(code, width, height, quality) { | ||
let path = '/avatars/flags/{code}'.replace('{code}', code); | ||
let payload = {}; | ||
if (typeof code === 'undefined') { | ||
@@ -163,4 +172,2 @@ throw new AppwriteException('Missing required parameter: "code"'); | ||
let path = '/avatars/flags/{code}'.replace('{code}', code); | ||
let payload = {}; | ||
@@ -205,2 +212,4 @@ if (typeof width !== 'undefined') { | ||
async getImage(url, width, height) { | ||
let path = '/avatars/image'; | ||
let payload = {}; | ||
if (typeof url === 'undefined') { | ||
@@ -210,4 +219,2 @@ throw new AppwriteException('Missing required parameter: "url"'); | ||
let path = '/avatars/image'; | ||
let payload = {}; | ||
@@ -254,3 +261,2 @@ if (typeof url !== 'undefined') { | ||
* @param {number} height | ||
* @param {string} color | ||
* @param {string} background | ||
@@ -260,3 +266,3 @@ * @throws {AppwriteException} | ||
*/ | ||
async getInitials(name, width, height, color, background) { | ||
async getInitials(name, width, height, background) { | ||
let path = '/avatars/initials'; | ||
@@ -277,6 +283,2 @@ let payload = {}; | ||
if (typeof color !== 'undefined') { | ||
payload['color'] = color; | ||
} | ||
if (typeof background !== 'undefined') { | ||
@@ -306,2 +308,4 @@ payload['background'] = background; | ||
async getQR(text, size, margin, download) { | ||
let path = '/avatars/qr'; | ||
let payload = {}; | ||
if (typeof text === 'undefined') { | ||
@@ -311,4 +315,2 @@ throw new AppwriteException('Missing required parameter: "text"'); | ||
let path = '/avatars/qr'; | ||
let payload = {}; | ||
@@ -337,2 +339,2 @@ if (typeof text !== 'undefined') { | ||
module.exports = Avatars; | ||
module.exports = Avatars; |
@@ -10,46 +10,28 @@ const Service = require('../service.js'); | ||
class Databases extends Service { | ||
databaseId; | ||
/** | ||
* Set databaseId. | ||
* | ||
* @param {string} databaseId | ||
* | ||
* @return void | ||
*/ | ||
setDatabaseId(databaseId) | ||
constructor(client) | ||
{ | ||
this.databaseId = databaseId; | ||
} | ||
/** | ||
* Get databaseId. | ||
* | ||
* @return string | ||
*/ | ||
getDatabaseId() | ||
{ | ||
return this.databaseId; | ||
} | ||
constructor(client, databaseId) | ||
{ | ||
super(client); | ||
this.databaseId = databaseId; | ||
} | ||
/** | ||
* List Databases | ||
* | ||
* Get a list of all databases from the current Appwrite project. You can use | ||
* the search parameter to filter your results. | ||
* | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async list(search, limit, offset, cursor, cursorDirection, orderType) { | ||
async list(queries, search) { | ||
let path = '/databases'; | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -59,22 +41,2 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -88,2 +50,6 @@ 'content-type': 'application/json', | ||
* | ||
* Create a new Database. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} name | ||
@@ -93,3 +59,9 @@ * @throws {AppwriteException} | ||
*/ | ||
async create(name) { | ||
async create(databaseId, name) { | ||
let path = '/databases'; | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof name === 'undefined') { | ||
@@ -99,7 +71,5 @@ throw new AppwriteException('Missing required parameter: "name"'); | ||
let path = '/databases'; | ||
let payload = {}; | ||
if (typeof this.databaseId !== 'undefined') { | ||
payload['databaseId'] = this.databaseId; | ||
if (typeof databaseId !== 'undefined') { | ||
payload['databaseId'] = databaseId; | ||
} | ||
@@ -119,9 +89,17 @@ | ||
* | ||
* Get a database by its unique ID. This endpoint response returns a JSON | ||
* object with the database metadata. | ||
* | ||
* @param {string} databaseId | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async get() { | ||
let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId); | ||
async get(databaseId) { | ||
let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -135,2 +113,5 @@ 'content-type': 'application/json', | ||
* | ||
* Update a database by its unique ID. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} name | ||
@@ -140,3 +121,9 @@ * @throws {AppwriteException} | ||
*/ | ||
async update(name) { | ||
async update(databaseId, name) { | ||
let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof name === 'undefined') { | ||
@@ -146,4 +133,2 @@ throw new AppwriteException('Missing required parameter: "name"'); | ||
let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId); | ||
let payload = {}; | ||
@@ -162,9 +147,17 @@ if (typeof name !== 'undefined') { | ||
* | ||
* Delete a database by its unique ID. Only API keys with with databases.write | ||
* scope can delete a database. | ||
* | ||
* @param {string} databaseId | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async delete() { | ||
let path = '/databases/{databaseId}'.replace('{databaseId}', this.databaseId); | ||
async delete(databaseId) { | ||
let path = '/databases/{databaseId}'.replace('{databaseId}', databaseId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
return await this.client.call('delete', path, { | ||
@@ -178,39 +171,27 @@ 'content-type': 'application/json', | ||
* | ||
* Get a list of all collections that belong to the provided databaseId. You | ||
* can use the search parameter to filter your results. | ||
* | ||
* @param {string} databaseId | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async listCollections(search, limit, offset, cursor, cursorDirection, orderType) { | ||
let path = '/databases/{databaseId}/collections'.replace('{databaseId}', this.databaseId); | ||
async listCollections(databaseId, queries, search) { | ||
let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); | ||
let payload = {}; | ||
if (typeof search !== 'undefined') { | ||
payload['search'] = search; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
if (typeof search !== 'undefined') { | ||
payload['search'] = search; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -224,11 +205,22 @@ 'content-type': 'application/json', | ||
* | ||
* Create a new Collection. Before using this route, you should create a new | ||
* database resource using either a [server | ||
* integration](/docs/server/databases#databasesCreateCollection) API or | ||
* directly from your database console. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
* @param {string} name | ||
* @param {string} permission | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @param {boolean} documentSecurity | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createCollection(collectionId, name, permission, read, write) { | ||
async createCollection(databaseId, collectionId, name, permissions, documentSecurity) { | ||
let path = '/databases/{databaseId}/collections'.replace('{databaseId}', databaseId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -242,17 +234,3 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
if (typeof permission === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "permission"'); | ||
} | ||
if (typeof read === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "read"'); | ||
} | ||
if (typeof write === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "write"'); | ||
} | ||
let path = '/databases/{databaseId}/collections'.replace('{databaseId}', this.databaseId); | ||
let payload = {}; | ||
if (typeof collectionId !== 'undefined') { | ||
@@ -266,14 +244,10 @@ payload['collectionId'] = collectionId; | ||
if (typeof permission !== 'undefined') { | ||
payload['permission'] = permission; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof documentSecurity !== 'undefined') { | ||
payload['documentSecurity'] = documentSecurity; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
return await this.client.call('post', path, { | ||
@@ -287,2 +261,6 @@ 'content-type': 'application/json', | ||
* | ||
* Get a collection by its unique ID. This endpoint response returns a JSON | ||
* object with the collection metadata. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -292,3 +270,9 @@ * @throws {AppwriteException} | ||
*/ | ||
async getCollection(collectionId) { | ||
async getCollection(databaseId, collectionId) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -298,4 +282,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -310,7 +292,9 @@ return await this.client.call('get', path, { | ||
* | ||
* Update a collection by its unique ID. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
* @param {string} name | ||
* @param {string} permission | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @param {boolean} documentSecurity | ||
* @param {boolean} enabled | ||
@@ -320,3 +304,9 @@ * @throws {AppwriteException} | ||
*/ | ||
async updateCollection(collectionId, name, permission, read, write, enabled) { | ||
async updateCollection(databaseId, collectionId, name, permissions, documentSecurity, enabled) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -330,9 +320,3 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
if (typeof permission === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "permission"'); | ||
} | ||
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof name !== 'undefined') { | ||
@@ -342,14 +326,10 @@ payload['name'] = name; | ||
if (typeof permission !== 'undefined') { | ||
payload['permission'] = permission; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof documentSecurity !== 'undefined') { | ||
payload['documentSecurity'] = documentSecurity; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
if (typeof enabled !== 'undefined') { | ||
@@ -367,2 +347,6 @@ payload['enabled'] = enabled; | ||
* | ||
* Delete a collection by its unique ID. Only users with write permissions | ||
* have access to delete this resource. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -372,3 +356,9 @@ * @throws {AppwriteException} | ||
*/ | ||
async deleteCollection(collectionId) { | ||
async deleteCollection(databaseId, collectionId) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -378,4 +368,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -390,2 +378,3 @@ return await this.client.call('delete', path, { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -395,3 +384,9 @@ * @throws {AppwriteException} | ||
*/ | ||
async listAttributes(collectionId) { | ||
async listAttributes(databaseId, collectionId) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -401,4 +396,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -413,2 +406,6 @@ return await this.client.call('get', path, { | ||
* | ||
* Create a boolean attribute. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -422,3 +419,9 @@ * @param {string} key | ||
*/ | ||
async createBooleanAttribute(collectionId, key, required, xdefault, array) { | ||
async createBooleanAttribute(databaseId, collectionId, key, required, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -436,5 +439,56 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/boolean'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
if (typeof key !== 'undefined') { | ||
payload['key'] = key; | ||
} | ||
if (typeof required !== 'undefined') { | ||
payload['required'] = required; | ||
} | ||
if (typeof xdefault !== 'undefined') { | ||
payload['default'] = xdefault; | ||
} | ||
if (typeof array !== 'undefined') { | ||
payload['array'] = array; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Create DateTime Attribute | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
* @param {string} key | ||
* @param {boolean} required | ||
* @param {string} xdefault | ||
* @param {boolean} array | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createDatetimeAttribute(databaseId, collectionId, key, required, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/datetime'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
} | ||
if (typeof key === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "key"'); | ||
} | ||
if (typeof required === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "required"'); | ||
} | ||
if (typeof key !== 'undefined') { | ||
@@ -464,2 +518,6 @@ payload['key'] = key; | ||
* | ||
* Create an email attribute. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -473,3 +531,9 @@ * @param {string} key | ||
*/ | ||
async createEmailAttribute(collectionId, key, required, xdefault, array) { | ||
async createEmailAttribute(databaseId, collectionId, key, required, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -487,4 +551,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/email'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -515,2 +577,3 @@ if (typeof key !== 'undefined') { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -525,3 +588,9 @@ * @param {string} key | ||
*/ | ||
async createEnumAttribute(collectionId, key, elements, required, xdefault, array) { | ||
async createEnumAttribute(databaseId, collectionId, key, elements, required, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -543,4 +612,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/enum'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -575,2 +642,7 @@ if (typeof key !== 'undefined') { | ||
* | ||
* Create a float attribute. Optionally, minimum and maximum values can be | ||
* provided. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -586,3 +658,9 @@ * @param {string} key | ||
*/ | ||
async createFloatAttribute(collectionId, key, required, min, max, xdefault, array) { | ||
async createFloatAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -600,4 +678,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/float'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -636,2 +712,7 @@ if (typeof key !== 'undefined') { | ||
* | ||
* Create an integer attribute. Optionally, minimum and maximum values can be | ||
* provided. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -647,3 +728,9 @@ * @param {string} key | ||
*/ | ||
async createIntegerAttribute(collectionId, key, required, min, max, xdefault, array) { | ||
async createIntegerAttribute(databaseId, collectionId, key, required, min, max, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -661,4 +748,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/integer'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -697,2 +782,6 @@ if (typeof key !== 'undefined') { | ||
* | ||
* Create IP address attribute. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -706,3 +795,9 @@ * @param {string} key | ||
*/ | ||
async createIpAttribute(collectionId, key, required, xdefault, array) { | ||
async createIpAttribute(databaseId, collectionId, key, required, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -720,4 +815,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/ip'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -748,2 +841,6 @@ if (typeof key !== 'undefined') { | ||
* | ||
* Create a string attribute. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -758,3 +855,9 @@ * @param {string} key | ||
*/ | ||
async createStringAttribute(collectionId, key, size, required, xdefault, array) { | ||
async createStringAttribute(databaseId, collectionId, key, size, required, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -776,4 +879,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/string'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -808,2 +909,6 @@ if (typeof key !== 'undefined') { | ||
* | ||
* Create a URL attribute. | ||
* | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -817,3 +922,9 @@ * @param {string} key | ||
*/ | ||
async createUrlAttribute(collectionId, key, required, xdefault, array) { | ||
async createUrlAttribute(databaseId, collectionId, key, required, xdefault, array) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -831,4 +942,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/url'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -859,2 +968,3 @@ if (typeof key !== 'undefined') { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -865,3 +975,9 @@ * @param {string} key | ||
*/ | ||
async getAttribute(collectionId, key) { | ||
async getAttribute(databaseId, collectionId, key) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -875,4 +991,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
@@ -887,2 +1001,3 @@ return await this.client.call('get', path, { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -893,3 +1008,9 @@ * @param {string} key | ||
*/ | ||
async deleteAttribute(collectionId, key) { | ||
async deleteAttribute(databaseId, collectionId, key) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -903,4 +1024,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/attributes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
@@ -915,14 +1034,20 @@ return await this.client.call('delete', path, { | ||
* | ||
* Get a list of all the user's documents in a given collection. You can use | ||
* the query params to filter your results. On admin mode, this endpoint will | ||
* return a list of all of documents belonging to the provided collectionId. | ||
* [Learn more about different API modes](/docs/admin). | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
* @param {string[]} queries | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string[]} orderAttributes | ||
* @param {string[]} orderTypes | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async listDocuments(collectionId, queries, limit, offset, cursor, cursorDirection, orderAttributes, orderTypes) { | ||
async listDocuments(databaseId, collectionId, queries) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -932,4 +1057,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -940,26 +1063,2 @@ if (typeof queries !== 'undefined') { | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderAttributes !== 'undefined') { | ||
payload['orderAttributes'] = orderAttributes; | ||
} | ||
if (typeof orderTypes !== 'undefined') { | ||
payload['orderTypes'] = orderTypes; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -973,11 +1072,22 @@ 'content-type': 'application/json', | ||
* | ||
* Create a new Document. Before using this route, you should create a new | ||
* collection resource using either a [server | ||
* integration](/docs/server/databases#databasesCreateCollection) API or | ||
* directly from your database console. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
* @param {string} documentId | ||
* @param {object} data | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createDocument(collectionId, documentId, data, read, write) { | ||
async createDocument(databaseId, collectionId, documentId, data, permissions) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -995,4 +1105,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -1007,10 +1115,6 @@ if (typeof documentId !== 'undefined') { | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
return await this.client.call('post', path, { | ||
@@ -1024,2 +1128,6 @@ 'content-type': 'application/json', | ||
* | ||
* Get a document by its unique ID. This endpoint response returns a JSON | ||
* object with the document data. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -1030,3 +1138,9 @@ * @param {string} documentId | ||
*/ | ||
async getDocument(collectionId, documentId) { | ||
async getDocument(databaseId, collectionId, documentId) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -1040,4 +1154,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); | ||
let payload = {}; | ||
@@ -1052,11 +1164,20 @@ return await this.client.call('get', path, { | ||
* | ||
* Update a document by its unique ID. Using the patch method you can pass | ||
* only specific fields that will get updated. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
* @param {string} documentId | ||
* @param {object} data | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async updateDocument(collectionId, documentId, data, read, write) { | ||
async updateDocument(databaseId, collectionId, documentId, data, permissions) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -1070,4 +1191,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); | ||
let payload = {}; | ||
@@ -1078,10 +1197,6 @@ if (typeof data !== 'undefined') { | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
return await this.client.call('patch', path, { | ||
@@ -1095,2 +1210,5 @@ 'content-type': 'application/json', | ||
* | ||
* Delete a document by its unique ID. | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -1101,3 +1219,9 @@ * @param {string} documentId | ||
*/ | ||
async deleteDocument(collectionId, documentId) { | ||
async deleteDocument(databaseId, collectionId, documentId) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -1111,4 +1235,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{documentId}', documentId); | ||
let payload = {}; | ||
@@ -1123,2 +1245,3 @@ return await this.client.call('delete', path, { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -1128,3 +1251,9 @@ * @throws {AppwriteException} | ||
*/ | ||
async listIndexes(collectionId) { | ||
async listIndexes(databaseId, collectionId) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -1134,4 +1263,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -1146,2 +1273,3 @@ return await this.client.call('get', path, { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -1155,3 +1283,9 @@ * @param {string} key | ||
*/ | ||
async createIndex(collectionId, key, type, attributes, orders) { | ||
async createIndex(databaseId, collectionId, key, type, attributes, orders) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -1173,4 +1307,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId); | ||
let payload = {}; | ||
@@ -1201,2 +1333,3 @@ if (typeof key !== 'undefined') { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -1207,3 +1340,9 @@ * @param {string} key | ||
*/ | ||
async getIndex(collectionId, key) { | ||
async getIndex(databaseId, collectionId, key) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -1217,4 +1356,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
@@ -1229,2 +1366,3 @@ return await this.client.call('get', path, { | ||
* | ||
* @param {string} databaseId | ||
* @param {string} collectionId | ||
@@ -1235,3 +1373,9 @@ * @param {string} key | ||
*/ | ||
async deleteIndex(collectionId, key) { | ||
async deleteIndex(databaseId, collectionId, key) { | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
if (typeof databaseId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "databaseId"'); | ||
} | ||
if (typeof collectionId === 'undefined') { | ||
@@ -1245,4 +1389,2 @@ throw new AppwriteException('Missing required parameter: "collectionId"'); | ||
let path = '/databases/{databaseId}/collections/{collectionId}/indexes/{key}'.replace('{databaseId}', this.databaseId).replace('{collectionId}', collectionId).replace('{key}', key); | ||
let payload = {}; | ||
@@ -1255,2 +1397,2 @@ return await this.client.call('delete', path, { | ||
module.exports = Databases; | ||
module.exports = Databases; |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -18,15 +24,15 @@ * List Functions | ||
* | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async list(search, limit, offset, cursor, cursorDirection, orderType) { | ||
async list(queries, search) { | ||
let path = '/functions'; | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -36,22 +42,2 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -73,3 +59,2 @@ 'content-type': 'application/json', | ||
* @param {string} runtime | ||
* @param {object} vars | ||
* @param {string[]} events | ||
@@ -81,3 +66,5 @@ * @param {string} schedule | ||
*/ | ||
async create(functionId, name, execute, runtime, vars, events, schedule, timeout) { | ||
async create(functionId, name, execute, runtime, events, schedule, timeout) { | ||
let path = '/functions'; | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -99,4 +86,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions'; | ||
let payload = {}; | ||
@@ -119,6 +104,2 @@ if (typeof functionId !== 'undefined') { | ||
if (typeof vars !== 'undefined') { | ||
payload['vars'] = vars; | ||
} | ||
if (typeof events !== 'undefined') { | ||
@@ -168,2 +149,4 @@ payload['events'] = events; | ||
async get(functionId) { | ||
let path = '/functions/{functionId}'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -173,4 +156,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
@@ -190,3 +171,2 @@ return await this.client.call('get', path, { | ||
* @param {string[]} execute | ||
* @param {object} vars | ||
* @param {string[]} events | ||
@@ -198,3 +178,5 @@ * @param {string} schedule | ||
*/ | ||
async update(functionId, name, execute, vars, events, schedule, timeout) { | ||
async update(functionId, name, execute, events, schedule, timeout) { | ||
let path = '/functions/{functionId}'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -212,4 +194,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
@@ -224,6 +204,2 @@ if (typeof name !== 'undefined') { | ||
if (typeof vars !== 'undefined') { | ||
payload['vars'] = vars; | ||
} | ||
if (typeof events !== 'undefined') { | ||
@@ -256,2 +232,4 @@ payload['events'] = events; | ||
async delete(functionId) { | ||
let path = '/functions/{functionId}'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -261,4 +239,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
@@ -277,12 +253,10 @@ return await this.client.call('delete', path, { | ||
* @param {string} functionId | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async listDeployments(functionId, search, limit, offset, cursor, cursorDirection, orderType) { | ||
async listDeployments(functionId, queries, search) { | ||
let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -292,5 +266,7 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -300,22 +276,2 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -348,2 +304,4 @@ 'content-type': 'application/json', | ||
async createDeployment(functionId, entrypoint, code, activate, onProgress = () => {}) { | ||
let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -365,4 +323,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/deployments'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
@@ -492,2 +448,3 @@ if (typeof entrypoint !== 'undefined') { | ||
}); | ||
} | ||
@@ -506,2 +463,4 @@ | ||
async getDeployment(functionId, deploymentId) { | ||
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -515,4 +474,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); | ||
let payload = {}; | ||
@@ -537,2 +494,4 @@ return await this.client.call('get', path, { | ||
async updateDeployment(functionId, deploymentId) { | ||
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -546,4 +505,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); | ||
let payload = {}; | ||
@@ -566,2 +523,4 @@ return await this.client.call('patch', path, { | ||
async deleteDeployment(functionId, deploymentId) { | ||
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -575,4 +534,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId); | ||
let payload = {}; | ||
@@ -594,2 +551,4 @@ return await this.client.call('delete', path, { | ||
async retryBuild(functionId, deploymentId, buildId) { | ||
let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -607,4 +566,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId); | ||
let payload = {}; | ||
@@ -625,11 +582,10 @@ return await this.client.call('post', path, { | ||
* @param {string} functionId | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async listExecutions(functionId, limit, offset, search, cursor, cursorDirection) { | ||
async listExecutions(functionId, queries, search) { | ||
let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -639,13 +595,7 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -655,10 +605,2 @@ payload['search'] = search; | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -684,2 +626,4 @@ 'content-type': 'application/json', | ||
async createExecution(functionId, data, async) { | ||
let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -689,4 +633,2 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/executions'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
@@ -717,2 +659,4 @@ if (typeof data !== 'undefined') { | ||
async getExecution(functionId, executionId) { | ||
let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
@@ -726,5 +670,35 @@ throw new AppwriteException('Missing required parameter: "functionId"'); | ||
let path = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId); | ||
return await this.client.call('get', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* List Variables | ||
* | ||
* Get a list of all variables of a specific function. | ||
* | ||
* @param {string} functionId | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async listVariables(functionId, queries, search) { | ||
let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "functionId"'); | ||
} | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
payload['search'] = search; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -734,4 +708,140 @@ 'content-type': 'application/json', | ||
} | ||
/** | ||
* Create Variable | ||
* | ||
* Create a new function variable. These variables can be accessed within | ||
* function in the `env` object under the request variable. | ||
* | ||
* @param {string} functionId | ||
* @param {string} key | ||
* @param {string} value | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createVariable(functionId, key, value) { | ||
let path = '/functions/{functionId}/variables'.replace('{functionId}', functionId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "functionId"'); | ||
} | ||
if (typeof key === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "key"'); | ||
} | ||
if (typeof value === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "value"'); | ||
} | ||
if (typeof key !== 'undefined') { | ||
payload['key'] = key; | ||
} | ||
if (typeof value !== 'undefined') { | ||
payload['value'] = value; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Get Variable | ||
* | ||
* Get a variable by its unique ID. | ||
* | ||
* @param {string} functionId | ||
* @param {string} variableId | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async getVariable(functionId, variableId) { | ||
let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "functionId"'); | ||
} | ||
if (typeof variableId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "variableId"'); | ||
} | ||
return await this.client.call('get', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Update Variable | ||
* | ||
* Update variable by its unique ID. | ||
* | ||
* @param {string} functionId | ||
* @param {string} variableId | ||
* @param {string} key | ||
* @param {string} value | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async updateVariable(functionId, variableId, key, value) { | ||
let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "functionId"'); | ||
} | ||
if (typeof variableId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "variableId"'); | ||
} | ||
if (typeof key === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "key"'); | ||
} | ||
if (typeof key !== 'undefined') { | ||
payload['key'] = key; | ||
} | ||
if (typeof value !== 'undefined') { | ||
payload['value'] = value; | ||
} | ||
return await this.client.call('put', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Delete Variable | ||
* | ||
* Delete a variable by its unique ID. | ||
* | ||
* @param {string} functionId | ||
* @param {string} variableId | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async deleteVariable(functionId, variableId) { | ||
let path = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId); | ||
let payload = {}; | ||
if (typeof functionId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "functionId"'); | ||
} | ||
if (typeof variableId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "variableId"'); | ||
} | ||
return await this.client.call('delete', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
} | ||
module.exports = Functions; | ||
module.exports = Functions; |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -192,2 +198,2 @@ * Get HTTP | ||
module.exports = Health; | ||
module.exports = Health; |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -144,2 +150,2 @@ * Get User Locale | ||
module.exports = Locale; | ||
module.exports = Locale; |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -18,15 +24,15 @@ * List buckets | ||
* | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async listBuckets(search, limit, offset, cursor, cursorDirection, orderType) { | ||
async listBuckets(queries, search) { | ||
let path = '/storage/buckets'; | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -36,22 +42,2 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -69,8 +55,8 @@ 'content-type': 'application/json', | ||
* @param {string} name | ||
* @param {string} permission | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @param {boolean} fileSecurity | ||
* @param {boolean} enabled | ||
* @param {number} maximumFileSize | ||
* @param {string[]} allowedFileExtensions | ||
* @param {string} compression | ||
* @param {boolean} encryption | ||
@@ -81,3 +67,5 @@ * @param {boolean} antivirus | ||
*/ | ||
async createBucket(bucketId, name, permission, read, write, enabled, maximumFileSize, allowedFileExtensions, encryption, antivirus) { | ||
async createBucket(bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus) { | ||
let path = '/storage/buckets'; | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -91,9 +79,3 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
if (typeof permission === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "permission"'); | ||
} | ||
let path = '/storage/buckets'; | ||
let payload = {}; | ||
if (typeof bucketId !== 'undefined') { | ||
@@ -107,14 +89,10 @@ payload['bucketId'] = bucketId; | ||
if (typeof permission !== 'undefined') { | ||
payload['permission'] = permission; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof fileSecurity !== 'undefined') { | ||
payload['fileSecurity'] = fileSecurity; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
if (typeof enabled !== 'undefined') { | ||
@@ -132,2 +110,6 @@ payload['enabled'] = enabled; | ||
if (typeof compression !== 'undefined') { | ||
payload['compression'] = compression; | ||
} | ||
if (typeof encryption !== 'undefined') { | ||
@@ -157,2 +139,4 @@ payload['encryption'] = encryption; | ||
async getBucket(bucketId) { | ||
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -162,4 +146,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
@@ -178,8 +160,8 @@ return await this.client.call('get', path, { | ||
* @param {string} name | ||
* @param {string} permission | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @param {boolean} fileSecurity | ||
* @param {boolean} enabled | ||
* @param {number} maximumFileSize | ||
* @param {string[]} allowedFileExtensions | ||
* @param {string} compression | ||
* @param {boolean} encryption | ||
@@ -190,3 +172,5 @@ * @param {boolean} antivirus | ||
*/ | ||
async updateBucket(bucketId, name, permission, read, write, enabled, maximumFileSize, allowedFileExtensions, encryption, antivirus) { | ||
async updateBucket(bucketId, name, permissions, fileSecurity, enabled, maximumFileSize, allowedFileExtensions, compression, encryption, antivirus) { | ||
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -200,9 +184,3 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
if (typeof permission === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "permission"'); | ||
} | ||
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
if (typeof name !== 'undefined') { | ||
@@ -212,14 +190,10 @@ payload['name'] = name; | ||
if (typeof permission !== 'undefined') { | ||
payload['permission'] = permission; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof fileSecurity !== 'undefined') { | ||
payload['fileSecurity'] = fileSecurity; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
if (typeof enabled !== 'undefined') { | ||
@@ -237,2 +211,6 @@ payload['enabled'] = enabled; | ||
if (typeof compression !== 'undefined') { | ||
payload['compression'] = compression; | ||
} | ||
if (typeof encryption !== 'undefined') { | ||
@@ -261,2 +239,4 @@ payload['encryption'] = encryption; | ||
async deleteBucket(bucketId) { | ||
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -266,4 +246,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
@@ -283,12 +261,10 @@ return await this.client.call('delete', path, { | ||
* @param {string} bucketId | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async listFiles(bucketId, search, limit, offset, cursor, cursorDirection, orderType) { | ||
async listFiles(bucketId, queries, search) { | ||
let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -298,5 +274,7 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -306,22 +284,2 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -337,4 +295,4 @@ 'content-type': 'application/json', | ||
* resource using either a [server | ||
* integration](/docs/server/database#storageCreateBucket) API or directly | ||
* from your Appwrite console. | ||
* integration](/docs/server/storage#storageCreateBucket) API or directly from | ||
* your Appwrite console. | ||
* | ||
@@ -358,8 +316,9 @@ * Larger files should be uploaded using multiple requests with the | ||
* @param {InputFile} file | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createFile(bucketId, fileId, file, read, write, onProgress = () => {}) { | ||
async createFile(bucketId, fileId, file, permissions, onProgress = () => {}) { | ||
let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -377,4 +336,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); | ||
let payload = {}; | ||
@@ -389,10 +346,6 @@ if (typeof fileId !== 'undefined') { | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
const size = file.size; | ||
@@ -516,2 +469,3 @@ | ||
}); | ||
} | ||
@@ -531,2 +485,4 @@ | ||
async getFile(bucketId, fileId) { | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -540,4 +496,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
@@ -557,8 +511,9 @@ return await this.client.call('get', path, { | ||
* @param {string} fileId | ||
* @param {string[]} read | ||
* @param {string[]} write | ||
* @param {string[]} permissions | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async updateFile(bucketId, fileId, read, write) { | ||
async updateFile(bucketId, fileId, permissions) { | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -572,13 +527,7 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
if (typeof read !== 'undefined') { | ||
payload['read'] = read; | ||
if (typeof permissions !== 'undefined') { | ||
payload['permissions'] = permissions; | ||
} | ||
if (typeof write !== 'undefined') { | ||
payload['write'] = write; | ||
} | ||
return await this.client.call('put', path, { | ||
@@ -601,2 +550,4 @@ 'content-type': 'application/json', | ||
async deleteFile(bucketId, fileId) { | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -610,4 +561,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
@@ -632,2 +581,4 @@ return await this.client.call('delete', path, { | ||
async getFileDownload(bucketId, fileId) { | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -641,4 +592,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}/download'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
@@ -676,2 +625,4 @@ return await this.client.call('get', path, { | ||
async getFilePreview(bucketId, fileId, width, height, gravity, quality, borderWidth, borderColor, borderRadius, opacity, rotation, background, output) { | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -685,4 +636,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}/preview'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
@@ -751,2 +700,4 @@ if (typeof width !== 'undefined') { | ||
async getFileView(bucketId, fileId) { | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
if (typeof bucketId === 'undefined') { | ||
@@ -760,4 +711,2 @@ throw new AppwriteException('Missing required parameter: "bucketId"'); | ||
let path = '/storage/buckets/{bucketId}/files/{fileId}/view'.replace('{bucketId}', bucketId).replace('{fileId}', fileId); | ||
let payload = {}; | ||
@@ -770,2 +719,2 @@ return await this.client.call('get', path, { | ||
module.exports = Storage; | ||
module.exports = Storage; |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -21,15 +27,15 @@ * List Teams | ||
* | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async list(search, limit, offset, cursor, cursorDirection, orderType) { | ||
async list(queries, search) { | ||
let path = '/teams'; | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -39,22 +45,2 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -79,2 +65,4 @@ 'content-type': 'application/json', | ||
async create(teamId, name, roles) { | ||
let path = '/teams'; | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -88,4 +76,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams'; | ||
let payload = {}; | ||
@@ -119,2 +105,4 @@ if (typeof teamId !== 'undefined') { | ||
async get(teamId) { | ||
let path = '/teams/{teamId}'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -124,4 +112,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
@@ -145,2 +131,4 @@ return await this.client.call('get', path, { | ||
async update(teamId, name) { | ||
let path = '/teams/{teamId}'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -154,4 +142,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
@@ -178,2 +164,4 @@ if (typeof name !== 'undefined') { | ||
async delete(teamId) { | ||
let path = '/teams/{teamId}'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -183,4 +171,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
@@ -199,12 +185,10 @@ return await this.client.call('delete', path, { | ||
* @param {string} teamId | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async getMemberships(teamId, search, limit, offset, cursor, cursorDirection, orderType) { | ||
async getMemberships(teamId, queries, search) { | ||
let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -214,5 +198,7 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -222,22 +208,2 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -276,2 +242,4 @@ 'content-type': 'application/json', | ||
async createMembership(teamId, email, roles, url, name) { | ||
let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -293,4 +261,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}/memberships'.replace('{teamId}', teamId); | ||
let payload = {}; | ||
@@ -330,2 +296,4 @@ if (typeof email !== 'undefined') { | ||
async getMembership(teamId, membershipId) { | ||
let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -339,4 +307,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
@@ -362,2 +328,4 @@ return await this.client.call('get', path, { | ||
async updateMembershipRoles(teamId, membershipId, roles) { | ||
let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -375,4 +343,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
@@ -401,2 +367,4 @@ if (typeof roles !== 'undefined') { | ||
async deleteMembership(teamId, membershipId) { | ||
let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -410,4 +378,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
@@ -438,2 +404,4 @@ return await this.client.call('delete', path, { | ||
async updateMembershipStatus(teamId, membershipId, userId, secret) { | ||
let path = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
if (typeof teamId === 'undefined') { | ||
@@ -455,4 +423,2 @@ throw new AppwriteException('Missing required parameter: "teamId"'); | ||
let path = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId); | ||
let payload = {}; | ||
@@ -473,2 +439,2 @@ if (typeof userId !== 'undefined') { | ||
module.exports = Teams; | ||
module.exports = Teams; |
@@ -11,2 +11,8 @@ const Service = require('../service.js'); | ||
constructor(client) | ||
{ | ||
super(client); | ||
} | ||
/** | ||
@@ -18,15 +24,15 @@ * List Users | ||
* | ||
* @param {string[]} queries | ||
* @param {string} search | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string} cursor | ||
* @param {string} cursorDirection | ||
* @param {string} orderType | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async list(search, limit, offset, cursor, cursorDirection, orderType) { | ||
async list(queries, search) { | ||
let path = '/users'; | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
@@ -36,23 +42,49 @@ payload['search'] = search; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
return await this.client.call('get', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Create User | ||
* | ||
* Create a new user. | ||
* | ||
* @param {string} userId | ||
* @param {string} email | ||
* @param {string} phone | ||
* @param {string} password | ||
* @param {string} name | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async create(userId, email, phone, password, name) { | ||
let path = '/users'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "userId"'); | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
if (typeof userId !== 'undefined') { | ||
payload['userId'] = userId; | ||
} | ||
if (typeof cursor !== 'undefined') { | ||
payload['cursor'] = cursor; | ||
if (typeof email !== 'undefined') { | ||
payload['email'] = email; | ||
} | ||
if (typeof cursorDirection !== 'undefined') { | ||
payload['cursorDirection'] = cursorDirection; | ||
if (typeof phone !== 'undefined') { | ||
payload['phone'] = phone; | ||
} | ||
if (typeof orderType !== 'undefined') { | ||
payload['orderType'] = orderType; | ||
if (typeof password !== 'undefined') { | ||
payload['password'] = password; | ||
} | ||
return await this.client.call('get', path, { | ||
if (typeof name !== 'undefined') { | ||
payload['name'] = name; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
@@ -63,5 +95,8 @@ }, payload); | ||
/** | ||
* Create User | ||
* Create User with Argon2 Password | ||
* | ||
* Create a new user. | ||
* Create a new user. Password provided must be hashed with the | ||
* [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST | ||
* /users](/docs/server/users#usersCreate) endpoint to create users with a | ||
* plain text password. | ||
* | ||
@@ -75,3 +110,5 @@ * @param {string} userId | ||
*/ | ||
async create(userId, email, password, name) { | ||
async createArgon2User(userId, email, password, name) { | ||
let path = '/users/argon2'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -89,5 +126,55 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users'; | ||
if (typeof userId !== 'undefined') { | ||
payload['userId'] = userId; | ||
} | ||
if (typeof email !== 'undefined') { | ||
payload['email'] = email; | ||
} | ||
if (typeof password !== 'undefined') { | ||
payload['password'] = password; | ||
} | ||
if (typeof name !== 'undefined') { | ||
payload['name'] = name; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Create User with Bcrypt Password | ||
* | ||
* Create a new user. Password provided must be hashed with the | ||
* [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST | ||
* /users](/docs/server/users#usersCreate) endpoint to create users with a | ||
* plain text password. | ||
* | ||
* @param {string} userId | ||
* @param {string} email | ||
* @param {string} password | ||
* @param {string} name | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createBcryptUser(userId, email, password, name) { | ||
let path = '/users/bcrypt'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "userId"'); | ||
} | ||
if (typeof email === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "email"'); | ||
} | ||
if (typeof password === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "password"'); | ||
} | ||
if (typeof userId !== 'undefined') { | ||
@@ -115,2 +202,339 @@ payload['userId'] = userId; | ||
/** | ||
* Create User with MD5 Password | ||
* | ||
* Create a new user. Password provided must be hashed with the | ||
* [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST | ||
* /users](/docs/server/users#usersCreate) endpoint to create users with a | ||
* plain text password. | ||
* | ||
* @param {string} userId | ||
* @param {string} email | ||
* @param {string} password | ||
* @param {string} name | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createMD5User(userId, email, password, name) { | ||
let path = '/users/md5'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "userId"'); | ||
} | ||
if (typeof email === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "email"'); | ||
} | ||
if (typeof password === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "password"'); | ||
} | ||
if (typeof userId !== 'undefined') { | ||
payload['userId'] = userId; | ||
} | ||
if (typeof email !== 'undefined') { | ||
payload['email'] = email; | ||
} | ||
if (typeof password !== 'undefined') { | ||
payload['password'] = password; | ||
} | ||
if (typeof name !== 'undefined') { | ||
payload['name'] = name; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Create User with PHPass Password | ||
* | ||
* Create a new user. Password provided must be hashed with the | ||
* [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST | ||
* /users](/docs/server/users#usersCreate) endpoint to create users with a | ||
* plain text password. | ||
* | ||
* @param {string} userId | ||
* @param {string} email | ||
* @param {string} password | ||
* @param {string} name | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createPHPassUser(userId, email, password, name) { | ||
let path = '/users/phpass'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "userId"'); | ||
} | ||
if (typeof email === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "email"'); | ||
} | ||
if (typeof password === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "password"'); | ||
} | ||
if (typeof userId !== 'undefined') { | ||
payload['userId'] = userId; | ||
} | ||
if (typeof email !== 'undefined') { | ||
payload['email'] = email; | ||
} | ||
if (typeof password !== 'undefined') { | ||
payload['password'] = password; | ||
} | ||
if (typeof name !== 'undefined') { | ||
payload['name'] = name; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Create User with Scrypt Password | ||
* | ||
* Create a new user. Password provided must be hashed with the | ||
* [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST | ||
* /users](/docs/server/users#usersCreate) endpoint to create users with a | ||
* plain text password. | ||
* | ||
* @param {string} userId | ||
* @param {string} email | ||
* @param {string} password | ||
* @param {string} passwordSalt | ||
* @param {number} passwordCpu | ||
* @param {number} passwordMemory | ||
* @param {number} passwordParallel | ||
* @param {number} passwordLength | ||
* @param {string} name | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createScryptUser(userId, email, password, passwordSalt, passwordCpu, passwordMemory, passwordParallel, passwordLength, name) { | ||
let path = '/users/scrypt'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "userId"'); | ||
} | ||
if (typeof email === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "email"'); | ||
} | ||
if (typeof password === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "password"'); | ||
} | ||
if (typeof passwordSalt === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordSalt"'); | ||
} | ||
if (typeof passwordCpu === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordCpu"'); | ||
} | ||
if (typeof passwordMemory === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordMemory"'); | ||
} | ||
if (typeof passwordParallel === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordParallel"'); | ||
} | ||
if (typeof passwordLength === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordLength"'); | ||
} | ||
if (typeof userId !== 'undefined') { | ||
payload['userId'] = userId; | ||
} | ||
if (typeof email !== 'undefined') { | ||
payload['email'] = email; | ||
} | ||
if (typeof password !== 'undefined') { | ||
payload['password'] = password; | ||
} | ||
if (typeof passwordSalt !== 'undefined') { | ||
payload['passwordSalt'] = passwordSalt; | ||
} | ||
if (typeof passwordCpu !== 'undefined') { | ||
payload['passwordCpu'] = passwordCpu; | ||
} | ||
if (typeof passwordMemory !== 'undefined') { | ||
payload['passwordMemory'] = passwordMemory; | ||
} | ||
if (typeof passwordParallel !== 'undefined') { | ||
payload['passwordParallel'] = passwordParallel; | ||
} | ||
if (typeof passwordLength !== 'undefined') { | ||
payload['passwordLength'] = passwordLength; | ||
} | ||
if (typeof name !== 'undefined') { | ||
payload['name'] = name; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Create User with Scrypt Modified Password | ||
* | ||
* Create a new user. Password provided must be hashed with the [Scrypt | ||
* Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) | ||
* algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint | ||
* to create users with a plain text password. | ||
* | ||
* @param {string} userId | ||
* @param {string} email | ||
* @param {string} password | ||
* @param {string} passwordSalt | ||
* @param {string} passwordSaltSeparator | ||
* @param {string} passwordSignerKey | ||
* @param {string} name | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createScryptModifiedUser(userId, email, password, passwordSalt, passwordSaltSeparator, passwordSignerKey, name) { | ||
let path = '/users/scrypt-modified'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "userId"'); | ||
} | ||
if (typeof email === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "email"'); | ||
} | ||
if (typeof password === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "password"'); | ||
} | ||
if (typeof passwordSalt === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordSalt"'); | ||
} | ||
if (typeof passwordSaltSeparator === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"'); | ||
} | ||
if (typeof passwordSignerKey === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "passwordSignerKey"'); | ||
} | ||
if (typeof userId !== 'undefined') { | ||
payload['userId'] = userId; | ||
} | ||
if (typeof email !== 'undefined') { | ||
payload['email'] = email; | ||
} | ||
if (typeof password !== 'undefined') { | ||
payload['password'] = password; | ||
} | ||
if (typeof passwordSalt !== 'undefined') { | ||
payload['passwordSalt'] = passwordSalt; | ||
} | ||
if (typeof passwordSaltSeparator !== 'undefined') { | ||
payload['passwordSaltSeparator'] = passwordSaltSeparator; | ||
} | ||
if (typeof passwordSignerKey !== 'undefined') { | ||
payload['passwordSignerKey'] = passwordSignerKey; | ||
} | ||
if (typeof name !== 'undefined') { | ||
payload['name'] = name; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Create User with SHA Password | ||
* | ||
* Create a new user. Password provided must be hashed with the | ||
* [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use | ||
* the [POST /users](/docs/server/users#usersCreate) endpoint to create users | ||
* with a plain text password. | ||
* | ||
* @param {string} userId | ||
* @param {string} email | ||
* @param {string} password | ||
* @param {string} passwordVersion | ||
* @param {string} name | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async createSHAUser(userId, email, password, passwordVersion, name) { | ||
let path = '/users/sha'; | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "userId"'); | ||
} | ||
if (typeof email === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "email"'); | ||
} | ||
if (typeof password === 'undefined') { | ||
throw new AppwriteException('Missing required parameter: "password"'); | ||
} | ||
if (typeof userId !== 'undefined') { | ||
payload['userId'] = userId; | ||
} | ||
if (typeof email !== 'undefined') { | ||
payload['email'] = email; | ||
} | ||
if (typeof password !== 'undefined') { | ||
payload['password'] = password; | ||
} | ||
if (typeof passwordVersion !== 'undefined') { | ||
payload['passwordVersion'] = passwordVersion; | ||
} | ||
if (typeof name !== 'undefined') { | ||
payload['name'] = name; | ||
} | ||
return await this.client.call('post', path, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
} | ||
/** | ||
* Get User | ||
@@ -125,2 +549,4 @@ * | ||
async get(userId) { | ||
let path = '/users/{userId}'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -130,4 +556,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -153,2 +577,4 @@ return await this.client.call('get', path, { | ||
async delete(userId) { | ||
let path = '/users/{userId}'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -158,4 +584,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -178,2 +602,4 @@ return await this.client.call('delete', path, { | ||
async updateEmail(userId, email) { | ||
let path = '/users/{userId}/email'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -187,4 +613,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/email'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -206,8 +630,9 @@ if (typeof email !== 'undefined') { | ||
* @param {string} userId | ||
* @param {number} limit | ||
* @param {number} offset | ||
* @param {string[]} queries | ||
* @throws {AppwriteException} | ||
* @returns {Promise} | ||
*/ | ||
async getLogs(userId, limit, offset) { | ||
async getLogs(userId, queries) { | ||
let path = '/users/{userId}/logs'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -217,13 +642,7 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/logs'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof limit !== 'undefined') { | ||
payload['limit'] = limit; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof offset !== 'undefined') { | ||
payload['offset'] = offset; | ||
} | ||
return await this.client.call('get', path, { | ||
@@ -244,2 +663,4 @@ 'content-type': 'application/json', | ||
async getMemberships(userId) { | ||
let path = '/users/{userId}/memberships'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -249,4 +670,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/memberships'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -269,2 +688,4 @@ return await this.client.call('get', path, { | ||
async updateName(userId, name) { | ||
let path = '/users/{userId}/name'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -278,4 +699,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/name'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -302,2 +721,4 @@ if (typeof name !== 'undefined') { | ||
async updatePassword(userId, password) { | ||
let path = '/users/{userId}/password'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -311,4 +732,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/password'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -335,2 +754,4 @@ if (typeof password !== 'undefined') { | ||
async updatePhone(userId, number) { | ||
let path = '/users/{userId}/phone'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -344,4 +765,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/phone'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -367,2 +786,4 @@ if (typeof number !== 'undefined') { | ||
async getPrefs(userId) { | ||
let path = '/users/{userId}/prefs'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -372,4 +793,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/prefs'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -394,2 +813,4 @@ return await this.client.call('get', path, { | ||
async updatePrefs(userId, prefs) { | ||
let path = '/users/{userId}/prefs'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -403,4 +824,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/prefs'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -426,2 +845,4 @@ if (typeof prefs !== 'undefined') { | ||
async getSessions(userId) { | ||
let path = '/users/{userId}/sessions'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -431,4 +852,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/sessions'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -450,2 +869,4 @@ return await this.client.call('get', path, { | ||
async deleteSessions(userId) { | ||
let path = '/users/{userId}/sessions'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -455,4 +876,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/sessions'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -475,2 +894,4 @@ return await this.client.call('delete', path, { | ||
async deleteSession(userId, sessionId) { | ||
let path = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -484,4 +905,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId); | ||
let payload = {}; | ||
@@ -505,2 +924,4 @@ return await this.client.call('delete', path, { | ||
async updateStatus(userId, status) { | ||
let path = '/users/{userId}/status'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -514,4 +935,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/status'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -538,2 +957,4 @@ if (typeof status !== 'undefined') { | ||
async updateEmailVerification(userId, emailVerification) { | ||
let path = '/users/{userId}/verification'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -547,4 +968,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/verification'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -571,2 +990,4 @@ if (typeof emailVerification !== 'undefined') { | ||
async updatePhoneVerification(userId, phoneVerification) { | ||
let path = '/users/{userId}/verification/phone'.replace('{userId}', userId); | ||
let payload = {}; | ||
if (typeof userId === 'undefined') { | ||
@@ -580,4 +1001,2 @@ throw new AppwriteException('Missing required parameter: "userId"'); | ||
let path = '/users/{userId}/verification/phone'.replace('{userId}', userId); | ||
let payload = {}; | ||
@@ -594,2 +1013,2 @@ if (typeof phoneVerification !== 'undefined') { | ||
module.exports = Users; | ||
module.exports = Users; |
@@ -5,3 +5,3 @@ { | ||
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", | ||
"version": "7.0.2", | ||
"version": "8.0.0-RC1", | ||
"license": "BSD-3-Clause", | ||
@@ -8,0 +8,0 @@ "main": "./index.js", |
# Appwrite Node.js SDK | ||
 | ||
 | ||
 | ||
[](https://travis-ci.com/appwrite/sdk-generator) | ||
@@ -9,3 +9,3 @@ [](https://twitter.com/appwrite) | ||
**This SDK is compatible with Appwrite server version 0.15.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** | ||
**This SDK is compatible with Appwrite server version 1.0.0-RC1. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-node/releases).** | ||
@@ -12,0 +12,0 @@ > This is the Node.js SDK for integrating with Appwrite from your Node.js server-side code. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
379622
13.05%171
10.32%8722
13.35%1
Infinity%