n8n-nodes-appwriten8n
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -1,4 +0,17 @@ | ||
import { Client, Databases, InputFile, Models } from 'node-appwrite'; | ||
import { Client, Databases, InputFile, Models, Users } from 'node-appwrite'; | ||
export declare function getAppwriteClient(endpoint: string, projectId: string, apiKey: string): Promise<Client>; | ||
export declare function getAppwriteDatabase(client: Client, databaseId?: string): Promise<Databases>; | ||
export declare function getAppwriteUsers(client: Client): Promise<Users>; | ||
export declare function listAppwriteUsers(client: Client, queries?: string[]): Promise<Models.UserList<Models.Preferences>>; | ||
export declare function createAppwriteUser(client: Client, id: string | undefined, email: string, password: string, name?: string, phone?: string, userType?: 'AlgoArgon2' | 'AlgoBcrypt' | 'AlgoMd5' | 'AlgoPhpass' | 'AlgoScryptModified' | 'AlgoSha'): Promise<Models.User<Models.Preferences>>; | ||
export declare function getAppwriteUser(client: Client, userId: string): Promise<Models.User<Models.Preferences>>; | ||
export declare function updateAppwriteUser(client: Client, userId: string, email?: string, emailVerification?: boolean, name?: string, password?: string, newPassword?: string, prefs?: Models.Preferences, phone?: string, phoneVerification?: boolean, labels?: string[], status?: boolean): Promise<Models.User<Models.Preferences>>; | ||
export declare function deleteAppwriteUser(client: Client, userId: string): Promise<string>; | ||
export declare function deleteAppwriteUserSession(client: Client, userId: string, sessionId: string): Promise<string>; | ||
export declare function deleteAppwriteUserSessions(client: Client, userId: string): Promise<string>; | ||
export declare function getAppwriteUserPrefs(client: Client, userId: string): Promise<Models.Preferences>; | ||
export declare function listAppwriteUserSessions(client: Client, userId: string): Promise<Models.SessionList>; | ||
export declare function listAppwriteUserIdentities(client: Client, userId: string): Promise<Models.IdentityList>; | ||
export declare function listAppwriteUserLogs(client: Client, userId: string): Promise<Models.LogList>; | ||
export declare function listAppwriteUserMemberships(client: Client, userId: string): Promise<Models.MembershipList>; | ||
export declare function listAppwriteDatabases(client: Client): Promise<Models.DatabaseList>; | ||
@@ -5,0 +18,0 @@ export declare function getAppwriteCollection(client: Client, databaseId: string, collectionId: string): Promise<Models.Collection>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.convertStringToQuery = exports.deleteAppwriteStorageBucket = exports.deleteAppwriteStorageFile = exports.createAppwriteStorageBucket = exports.createAppwriteStorageFile = exports.listAppwriteStorage = exports.listAppwriteBuckets = exports.getAppwriteStorageFile = exports.runAppwriteFunction = exports.listAppwriteFunctions = exports.getAppwriteFunction = exports.deleteAppwriteDocument = exports.updateAppwriteDocument = exports.createAppwriteDocument = exports.listAppwriteDocuments = exports.getAppwriteDocument = exports.listAppwriteCollections = exports.getAppwriteCollectionIndices = exports.getAppwriteCollection = exports.listAppwriteDatabases = exports.getAppwriteDatabase = exports.getAppwriteClient = void 0; | ||
exports.convertStringToQuery = exports.deleteAppwriteStorageBucket = exports.deleteAppwriteStorageFile = exports.createAppwriteStorageBucket = exports.createAppwriteStorageFile = exports.listAppwriteStorage = exports.listAppwriteBuckets = exports.getAppwriteStorageFile = exports.runAppwriteFunction = exports.listAppwriteFunctions = exports.getAppwriteFunction = exports.deleteAppwriteDocument = exports.updateAppwriteDocument = exports.createAppwriteDocument = exports.listAppwriteDocuments = exports.getAppwriteDocument = exports.listAppwriteCollections = exports.getAppwriteCollectionIndices = exports.getAppwriteCollection = exports.listAppwriteDatabases = exports.listAppwriteUserMemberships = exports.listAppwriteUserLogs = exports.listAppwriteUserIdentities = exports.listAppwriteUserSessions = exports.getAppwriteUserPrefs = exports.deleteAppwriteUserSessions = exports.deleteAppwriteUserSession = exports.deleteAppwriteUser = exports.updateAppwriteUser = exports.getAppwriteUser = exports.createAppwriteUser = exports.listAppwriteUsers = exports.getAppwriteUsers = exports.getAppwriteDatabase = exports.getAppwriteClient = void 0; | ||
const node_appwrite_1 = require("node-appwrite"); | ||
@@ -16,2 +16,145 @@ async function getAppwriteClient(endpoint, projectId, apiKey) { | ||
exports.getAppwriteDatabase = getAppwriteDatabase; | ||
async function getAppwriteUsers(client) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users; | ||
} | ||
exports.getAppwriteUsers = getAppwriteUsers; | ||
async function listAppwriteUsers(client, queries) { | ||
const users = new node_appwrite_1.Users(client); | ||
if (queries) { | ||
return users.list(queries); | ||
} | ||
return users.list(); | ||
} | ||
exports.listAppwriteUsers = listAppwriteUsers; | ||
async function createAppwriteUser(client, id = node_appwrite_1.ID.unique(), email, password, name, phone, userType) { | ||
const users = new node_appwrite_1.Users(client); | ||
if (userType) { | ||
let user; | ||
switch (userType) { | ||
case 'AlgoArgon2': | ||
user = await users.createArgon2User(id, email, password, name); | ||
if (phone) { | ||
await users.updatePhone(user.$id, phone); | ||
} | ||
break; | ||
case 'AlgoBcrypt': | ||
user = await users.createBcryptUser(id, email, password, name); | ||
if (phone) { | ||
await users.updatePhone(user.$id, phone); | ||
} | ||
break; | ||
case 'AlgoMd5': | ||
user = await users.createMD5User(id, email, password, name); | ||
if (phone) { | ||
await users.updatePhone(user.$id, phone); | ||
} | ||
break; | ||
case 'AlgoPhpass': | ||
user = await users.createPHPassUser(id, email, password, name); | ||
if (phone) { | ||
await users.updatePhone(user.$id, phone); | ||
} | ||
break; | ||
case 'AlgoSha': | ||
user = await users.createSHAUser(id, email, password, name, phone); | ||
if (phone) { | ||
await users.updatePhone(user.$id, phone); | ||
} | ||
break; | ||
default: | ||
user = await users.create(id, email, password, name, phone); | ||
if (phone) { | ||
await users.updatePhone(user.$id, phone); | ||
} | ||
break; | ||
} | ||
return user; | ||
} | ||
else { | ||
const user = await users.create(id, email, password, name); | ||
if (phone) { | ||
await users.updatePhone(user.$id, phone); | ||
} | ||
return user; | ||
} | ||
} | ||
exports.createAppwriteUser = createAppwriteUser; | ||
async function getAppwriteUser(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.get(userId); | ||
} | ||
exports.getAppwriteUser = getAppwriteUser; | ||
async function updateAppwriteUser(client, userId, email, emailVerification, name, password, newPassword, prefs, phone, phoneVerification, labels, status) { | ||
const users = new node_appwrite_1.Users(client); | ||
if (email) { | ||
await users.updateEmail(userId, email); | ||
} | ||
if (name) { | ||
await users.updateName(userId, name); | ||
} | ||
if (password && newPassword) { | ||
await users.updatePassword(userId, newPassword); | ||
} | ||
if (prefs) { | ||
await users.updatePrefs(userId, prefs); | ||
} | ||
if (phone) { | ||
await users.updatePhone(userId, phone); | ||
} | ||
if (phoneVerification) { | ||
await users.updatePhoneVerification(userId, phoneVerification); | ||
} | ||
if (emailVerification) { | ||
await users.updateEmailVerification(userId, emailVerification); | ||
} | ||
if (labels) { | ||
await users.updateLabels(userId, labels); | ||
} | ||
if (status) { | ||
await users.updateStatus(userId, status); | ||
} | ||
return getAppwriteUser(client, userId); | ||
} | ||
exports.updateAppwriteUser = updateAppwriteUser; | ||
async function deleteAppwriteUser(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.delete(userId); | ||
} | ||
exports.deleteAppwriteUser = deleteAppwriteUser; | ||
async function deleteAppwriteUserSession(client, userId, sessionId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.deleteSession(userId, sessionId); | ||
} | ||
exports.deleteAppwriteUserSession = deleteAppwriteUserSession; | ||
async function deleteAppwriteUserSessions(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.deleteSessions(userId); | ||
} | ||
exports.deleteAppwriteUserSessions = deleteAppwriteUserSessions; | ||
async function getAppwriteUserPrefs(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.getPrefs(userId); | ||
} | ||
exports.getAppwriteUserPrefs = getAppwriteUserPrefs; | ||
async function listAppwriteUserSessions(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.listSessions(userId); | ||
} | ||
exports.listAppwriteUserSessions = listAppwriteUserSessions; | ||
async function listAppwriteUserIdentities(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.listIdentities(userId); | ||
} | ||
exports.listAppwriteUserIdentities = listAppwriteUserIdentities; | ||
async function listAppwriteUserLogs(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.listLogs(userId); | ||
} | ||
exports.listAppwriteUserLogs = listAppwriteUserLogs; | ||
async function listAppwriteUserMemberships(client, userId) { | ||
const users = new node_appwrite_1.Users(client); | ||
return users.listMemberships(userId); | ||
} | ||
exports.listAppwriteUserMemberships = listAppwriteUserMemberships; | ||
async function listAppwriteDatabases(client) { | ||
@@ -55,2 +198,3 @@ const database = await getAppwriteDatabase(client); | ||
const database = await getAppwriteDatabase(client); | ||
console.log("Inside creation function, function data received: ", data); | ||
return database.createDocument(databaseId, collectionId, documentId, data); | ||
@@ -57,0 +201,0 @@ } |
@@ -8,2 +8,3 @@ "use strict"; | ||
const FunctionDescription_1 = require("./FunctionDescription"); | ||
const UsersDescription_1 = require("./UsersDescription"); | ||
const AppwriteFunctions_1 = require("./AppwriteFunctions"); | ||
@@ -51,2 +52,6 @@ const node_appwrite_1 = require("node-appwrite"); | ||
}, | ||
{ | ||
name: 'Users', | ||
value: 'users', | ||
}, | ||
], | ||
@@ -62,2 +67,4 @@ default: 'document', | ||
...FunctionDescription_1.functionFields, | ||
...UsersDescription_1.usersOperations, | ||
...UsersDescription_1.usersFields, | ||
], | ||
@@ -67,3 +74,3 @@ }; | ||
async execute() { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; | ||
const returnData = []; | ||
@@ -208,2 +215,106 @@ console.log("INSIDE EXECUTE!"); | ||
} | ||
else if (resource === 'users') { | ||
if (operation === 'createUser') { | ||
let userId = this.getNodeParameter('userIdOptional', 0); | ||
if (!userId) { | ||
userId = node_appwrite_1.ID.unique(); | ||
} | ||
const email = this.getNodeParameter('email', 0); | ||
const verifyEmail = this.getNodeParameter('verifyEmail', 0); | ||
const name = this.getNodeParameter('name', 0); | ||
const phone = this.getNodeParameter('phone', 0); | ||
const verifyPhone = this.getNodeParameter('verifyPhone', 0); | ||
const password = this.getNodeParameter('password', 0); | ||
responseData = await (0, AppwriteFunctions_1.createAppwriteUser)(appwriteClient, userId, email, password, phone, name); | ||
if (verifyEmail || verifyPhone) { | ||
if (verifyEmail && verifyPhone) { | ||
await (0, AppwriteFunctions_1.updateAppwriteUser)(appwriteClient, responseData.$id, undefined, verifyEmail, undefined, undefined, undefined, undefined, undefined, verifyPhone); | ||
} | ||
else if (verifyEmail) { | ||
await (0, AppwriteFunctions_1.updateAppwriteUser)(appwriteClient, responseData.$id, undefined, verifyEmail); | ||
} | ||
else if (verifyPhone) { | ||
await (0, AppwriteFunctions_1.updateAppwriteUser)(appwriteClient, responseData.$id, undefined, undefined, undefined, undefined, undefined, undefined, undefined, verifyPhone); | ||
} | ||
} | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'deleteUser') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.deleteAppwriteUser)(appwriteClient, userId); | ||
returnData.push({ "success": responseData }); | ||
} | ||
else if (operation === 'deleteUserSession') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
const sessionId = this.getNodeParameter('sessionId', 0); | ||
responseData = await (0, AppwriteFunctions_1.deleteAppwriteUserSession)(appwriteClient, userId, sessionId); | ||
returnData.push({ "success": responseData }); | ||
} | ||
else if (operation === 'deleteUserSessions') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.deleteAppwriteUserSessions)(appwriteClient, userId); | ||
returnData.push({ "success": responseData }); | ||
} | ||
else if (operation === 'getUser') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.getAppwriteUser)(appwriteClient, userId); | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'getUserPreferences') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.getAppwriteUserPrefs)(appwriteClient, userId); | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'listUserIdentities') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.listAppwriteUserIdentities)(appwriteClient, userId); | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'listUserLogs') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.listAppwriteUserLogs)(appwriteClient, userId); | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'listUserMemberships') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.listAppwriteUserMemberships)(appwriteClient, userId); | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'listUserSessions') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
responseData = await (0, AppwriteFunctions_1.listAppwriteUserSessions)(appwriteClient, userId); | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'listUsers') { | ||
const optionalFields = this.getNodeParameter('additionalFields', 0); | ||
const queriesToSend = []; | ||
if (optionalFields.options) { | ||
const queries = optionalFields.query; | ||
console.log("Inside optional fields, options value: ", optionalFields.options); | ||
console.log("Queries found: ", queries); | ||
if (queries) { | ||
for (const query of queries) { | ||
queriesToSend.push((0, AppwriteFunctions_1.convertStringToQuery)(`${query.index}`, query.value, (_c = query.value2) !== null && _c !== void 0 ? _c : undefined)); | ||
} | ||
} | ||
} | ||
responseData = await (0, AppwriteFunctions_1.listAppwriteUsers)(appwriteClient, queriesToSend); | ||
returnData.push(responseData); | ||
} | ||
else if (operation === 'updateUser') { | ||
const userId = this.getNodeParameter('userId', 0); | ||
const email = (_d = this.getNodeParameter('email', 0)) !== null && _d !== void 0 ? _d : undefined; | ||
const verifyEmail = (_e = this.getNodeParameter('verifyEmail', 0)) !== null && _e !== void 0 ? _e : undefined; | ||
const name = (_f = this.getNodeParameter('name', 0)) !== null && _f !== void 0 ? _f : undefined; | ||
const phone = (_g = this.getNodeParameter('phone', 0)) !== null && _g !== void 0 ? _g : undefined; | ||
const verifyPhone = (_h = this.getNodeParameter('verifyPhone', 0)) !== null && _h !== void 0 ? _h : undefined; | ||
const password = (_j = this.getNodeParameter('password', 0)) !== null && _j !== void 0 ? _j : undefined; | ||
const newPassword = (_k = this.getNodeParameter('newPassword', 0)) !== null && _k !== void 0 ? _k : undefined; | ||
const prefs = (_l = this.getNodeParameter('preferences', 0)) !== null && _l !== void 0 ? _l : undefined; | ||
const labels = (_m = this.getNodeParameter('labels', 0)) !== null && _m !== void 0 ? _m : undefined; | ||
const status = (_o = this.getNodeParameter('status', 0)) !== null && _o !== void 0 ? _o : undefined; | ||
responseData = await (0, AppwriteFunctions_1.updateAppwriteUser)(appwriteClient, userId, email, verifyEmail, name, phone, password, newPassword, prefs, verifyPhone, labels, status); | ||
returnData.push(responseData); | ||
} | ||
} | ||
else { | ||
@@ -210,0 +321,0 @@ throw new n8n_workflow_1.NodeApiError(this.getNode(), { "Error": "Resource not found" }); |
{ | ||
"name": "n8n-nodes-appwriten8n", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "N8N Nodes for Appwrite starting at 1.4.X and up, will be updated.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
{ | ||
"name": "n8n-nodes-appwriten8n", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "N8N Nodes for Appwrite starting at 1.4.X and up, will be updated.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -58,2 +58,27 @@ # n8n-nodes-appwrite | ||
- Delete File | ||
- Users | ||
- Get User | ||
- Create User | ||
- I will implement the hashing algorithms soon, but for now hashed users are disabled | ||
- Update User | ||
- Can update the following | ||
- Name | ||
- Email Verification Status (true or false) | ||
- Password | ||
- Phone | ||
- Phone Verification Status (true or false) | ||
- Labels | ||
- Status | ||
- Get User Prefs | ||
- Update User Prefs | ||
- List Users | ||
- Filterable with Queries | ||
- Delete User | ||
- List User Sessions | ||
- Delete User Sessions | ||
- Delete User Session | ||
- List User Memberships | ||
- List User Logs | ||
- List User Identities | ||
@@ -60,0 +85,0 @@ ## Credentials |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
208013
30
2102
107