-
-
Notifications
You must be signed in to change notification settings - Fork 877
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature Request] : Plugin Architecture for Server (#730)
* Test : lib/resolvers/group_chat_query/groupChatMessages.js * Add Test : Added Valid JSON Check * Create README.md * Create README.md * Update is-auth.js * AddedDocs Docs from withfilter pending * Update index.js * completed * sample * update/index.js * update/index.js * update/is-auth.js * Update/readme.md * update/image-readme * Add/query-schema * Update/Plugin-graphQL-schema * Add/Plugin-MongoDB-Model * Add/createPlugin-and-refractoring * Add/getPlugins * Add/Mutation/UpdatePluginStatus * Add/Mutation/updateTempPluginInstalledOrgs * Add/Mutation/Schema * Add/import/mutations * Add/plugins * Fix/path-err * Fix/Erros * update/lockfile * Add/plugin-model * Update is-auth.js * Removed extra queries * Documentation added for plugin queries and models * Fix/`delelte cr in prettier/prettier` * updated : mutation * Add/test `getPlugins` * Fix/`lint error` * test `updatePluginInstalledOrgs` * Test/ `updateInstallStatus` * Fix/Erros-1 * Fix/Erros-2 * Fix/Erros-3 * Test/`Queries.js` * Test/`Mutation.js` * remove extra `console.log` * Delete admin-plugin-query.js * Delete super-admin-plugin-query.js * Fix/Package-lock
- Loading branch information
1 parent
e1b6161
commit d56bd8c
Showing
23 changed files
with
358 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"singleQuote": true | ||
"singleQuote": true, | ||
"endOfLine": "auto" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,5 +77,4 @@ const isAuth = (req) => { | |
userId, | ||
}; | ||
}; | ||
|
||
module.exports = isAuth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const mongoose = require('mongoose'); | ||
const Schema = mongoose.Schema; | ||
/** | ||
* @name pluginSchema | ||
* @description Schema for MongoDB database | ||
* @param {string} pluginName Name of the plugin preferred having underscores "_" | ||
* @param {string} pluginCreatedBy name of the plugin creator ex.John Doe | ||
* @param {string} pluginDesc brief description of the plugin and it's features | ||
* @param {Boolean} pluginInstallStatus shows if the plugin is enabled or not | ||
* @param {String[]} installedOrgs list of orgIDs on which the plugin is enabled | ||
*/ | ||
const pluginSchema = new Schema({ | ||
pluginName: { | ||
type: String, | ||
required: true, | ||
}, | ||
pluginCreatedBy: { | ||
type: String, | ||
required: true, | ||
}, | ||
pluginDesc: { | ||
type: String, | ||
required: true, | ||
}, | ||
pluginInstallStatus: { | ||
type: Boolean, | ||
required: true, | ||
default: false, | ||
}, | ||
installedOrgs: [ | ||
{ type: Schema.Types.ObjectId, required: false, default: [] }, | ||
], | ||
}); | ||
|
||
module.exports = mongoose.model('PluginTemp', pluginSchema); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/resolvers/plugin_mutations/updatePluginInstalledOrgs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const Plugin = require('../../models/Plugin'); | ||
/** | ||
* @name updatePluginInstalledOrgs | ||
* @description updates the installedOrgs list of the specific plugin and adds or removes the current orgId from the list. | ||
* @param {any} parent parent of current request | ||
* @param {object} args payload provided with the request | ||
* @param {any} context context of entire application | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
module.exports = async (parent, args, context) => { | ||
let plug = await Plugin.findById(args.id); | ||
const plugOrgList = plug?.installedOrgs; | ||
const isDuplicate = plugOrgList?.includes(args.orgId); | ||
// remove the entry if duplicate | ||
if (isDuplicate) { | ||
// eslint-disable-next-line no-unused-vars | ||
const result = await Plugin.findByIdAndUpdate( | ||
args.id, | ||
{ $pull: { installedOrgs: args.orgId } }, | ||
{ new: true }, | ||
(err, res) => { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log('Updated Plugin with installed orgs : ', res); | ||
} | ||
} | ||
); | ||
} else { | ||
// eslint-disable-next-line no-unused-vars | ||
const result = await Plugin.findByIdAndUpdate( | ||
args.id, | ||
{ $push: { installedOrgs: args.orgId } }, | ||
{ new: true }, | ||
(err, res) => { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log('Updated Plugin with installed orgs : ', res); | ||
} | ||
} | ||
); | ||
} | ||
|
||
plug = await Plugin.findById(args.id); | ||
return plug; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const Plugin = require('../../models/Plugin'); | ||
/** | ||
* @name updatePluginStatus | ||
* @description toggles the installStatus of the plugin | ||
* @param {any} parent parent of current request | ||
* @param {object} args payload provided with the request | ||
* @param {any} context context of entire application | ||
*/ | ||
// eslint-disable-next-line no-unused-vars | ||
module.exports = async (parent, args, context) => { | ||
console.log('Argment s ', args); | ||
// eslint-disable-next-line no-unused-vars | ||
const result = await Plugin.findByIdAndUpdate( | ||
args.id, | ||
{ pluginInstallStatus: args.status }, | ||
{ new: true }, | ||
(err, res) => { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.log('Updated Plugin : ', res); | ||
} | ||
} | ||
); | ||
const plug = await Plugin.findById(args.id); | ||
return plug; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const Plugin = require('../../models/Plugin'); | ||
/** | ||
* @name getPlugins a GraphQL Query | ||
* @description returns list of plugin from database | ||
*/ | ||
module.exports = async () => { | ||
return await Plugin.find(); | ||
}; |
Oops, something went wrong.