day 11
This commit is contained in:
Executable
Executable
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* activity_log Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.activity_log.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.activity_log.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((activity_log) => ({
|
||||
cursor: activity_log.id,
|
||||
node: activity_log,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('activity_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* calendar Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.calendar.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.calendar.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((calendar) => ({
|
||||
cursor: calendar.id,
|
||||
node: calendar,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges)?.cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('calendar -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* code Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.code.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.code.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((code) => ({
|
||||
cursor: code.id,
|
||||
node: code,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('code -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* credential Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.credential.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.credential.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((credential) => ({
|
||||
cursor: credential.id,
|
||||
node: credential,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('credential -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* image Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.image.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.image.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((image) => ({
|
||||
cursor: image.id,
|
||||
node: image,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('image -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* link Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.link.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.link.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((link) => ({
|
||||
cursor: link.id,
|
||||
node: link,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges)?.cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('link -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* links Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.links.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.links.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((links) => ({
|
||||
cursor: links.id,
|
||||
node: links,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('links -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* note Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.note.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.note.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((note) => ({
|
||||
cursor: note.id,
|
||||
node: note,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges)?.cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('note -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* notes Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
const { QueryTypes } = require('sequelize');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.notes.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
const users = await sequelize.query('SELECT * FROM `notes`', { type: QueryTypes.SELECT });
|
||||
console.log('Notes are: ' + users);
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.notes.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((notes) => ({
|
||||
cursor: notes.id,
|
||||
node: notes,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log('notes -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* profile Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.profile.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.profile.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((profile) => ({
|
||||
cursor: profile.id,
|
||||
node: profile,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('profile -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* refer_log Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.refer_log.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.refer_log.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((refer_log) => ({
|
||||
cursor: refer_log.id,
|
||||
node: refer_log,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('refer_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* user Resolve All
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const Sequelize = require('sequelize');
|
||||
const { last } = require('lodash');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, { first, after }, { db, credential }, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
const attributes = db.user.intersection(graphqlFields(info).edges.node);
|
||||
|
||||
const options = {
|
||||
where: {},
|
||||
limit: first,
|
||||
attributes,
|
||||
};
|
||||
|
||||
if (after) {
|
||||
options.where = {
|
||||
id: {
|
||||
[Sequelize.Op.gt]: after,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const { count, rows } = await db.user.findAndCountAll(options);
|
||||
|
||||
const edges = rows.map((user) => ({
|
||||
cursor: user.id,
|
||||
node: user,
|
||||
}));
|
||||
|
||||
const pageInfo = {
|
||||
endCursor: last(edges).cursor,
|
||||
hasNextPage: 0 < count - first,
|
||||
};
|
||||
|
||||
return {
|
||||
edges,
|
||||
pageInfo,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.log('user -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
Executable
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* activity_log Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { name } = args;
|
||||
const v = new Validator({ }, { });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.activity_log.insert({ name },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_activity_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* calendar Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { } = args;
|
||||
const v = new Validator({ }, { });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.calendar.insert({ },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_calendar -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* code Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { code } = args;
|
||||
const v = new Validator({ code: args.code}, { code: "required" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.code.insert({ code },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_code -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* credential Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { email,
|
||||
password } = args;
|
||||
const v = new Validator({ email: args.email,
|
||||
password: args.password}, { email: "required|valid_email",
|
||||
password: "required" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.credential.insert({ email,
|
||||
password },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_credential -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* image Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { url,
|
||||
caption } = args;
|
||||
const v = new Validator({ url: args.url}, { url: "required" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.image.insert({ url,
|
||||
caption },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_image -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* links Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const request = require('request-promise');
|
||||
|
||||
const { validateInputForGraphql } = require('../../services/ValidationService');
|
||||
const { formatError } = require('../../utils/formatError');
|
||||
const { errorCodes } = require('../../core/strings');
|
||||
|
||||
const inputValidations = {
|
||||
Mutation: {
|
||||
createLink: (resolver = () => null) => {
|
||||
return validateInputForGraphql(
|
||||
resolver,
|
||||
{
|
||||
link: 'required|string',
|
||||
},
|
||||
{
|
||||
'link.required': 'Link field is required.',
|
||||
'link.string': 'Link field should be a string.',
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = inputValidations.Mutation.createLink(async (_, { link }, { db, user }) => {
|
||||
try {
|
||||
const previousLinks = await db.link.getAll({ user_id: user.id, status: 1 });
|
||||
try {
|
||||
const urlResponse = await request({ uri: link, resolveWithFullResponse: true, method: 'GET' });
|
||||
const headers = urlResponse?.headers;
|
||||
const xFrameHeader = headers['x-frame-options'];
|
||||
if (xFrameHeader && (xFrameHeader === 'SAMEORIGIN' || xFrameHeader === 'DENY')) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'Iframe blocked to given link.',
|
||||
code: errorCodes.extra.IFRAME_BLOCKED,
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'Link invalid or not available at the moment.',
|
||||
code: errorCodes.extra.INVALID_URL,
|
||||
};
|
||||
}
|
||||
|
||||
if (previousLinks?.length) {
|
||||
await db.link.update(
|
||||
{ status: 0 },
|
||||
{
|
||||
where: { id: previousLinks?.map((link) => link.id) },
|
||||
},
|
||||
);
|
||||
}
|
||||
await db.link.insert({ link, user_id: user.id });
|
||||
return {
|
||||
success: true,
|
||||
message: 'Link inserted successfully.',
|
||||
};
|
||||
} catch (error) {
|
||||
return formatError(error);
|
||||
}
|
||||
});
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* note Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { } = args;
|
||||
const v = new Validator({ }, { });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.note.insert({ },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_note -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* profile Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { timezone,
|
||||
dashboard_code } = args;
|
||||
const v = new Validator({ timezone: args.timezone,
|
||||
dashboard_code: args.dashboard_code}, { timezone: "required",
|
||||
dashboard_code: "required" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.profile.insert({ timezone,
|
||||
dashboard_code },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_profile -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* refer_log Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { type,
|
||||
status } = args;
|
||||
const v = new Validator({ type: args.type,
|
||||
status: args.status}, { type: "required|integer",
|
||||
status: "required|integer" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return await db.refer_log.insert({ type,
|
||||
status },{returnAllFields: true});
|
||||
} catch (error) {
|
||||
console.log('create_refer_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* user Resolve Add
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError, UserInputError } = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, { db }, info) => {
|
||||
try {
|
||||
const { first_name, last_name, phone } = args;
|
||||
const v = new Validator(
|
||||
{
|
||||
first_name: args.first_name,
|
||||
last_name: args.last_name,
|
||||
},
|
||||
{ first_name: 'required', last_name: 'required' },
|
||||
);
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return await db.user.insert({ first_name, last_name, phone }, { returnAllFields: true });
|
||||
} catch (error) {
|
||||
console.log('create_user -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
Executable
Executable
+32
@@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* links Resolve Deactivate
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { formatError } = require('../../utils/formatError');
|
||||
|
||||
module.exports = async (_, __, { db, user }) => {
|
||||
try {
|
||||
const previousLinks = await db.link.getAll({ user_id: user.id, status: 1 });
|
||||
if (previousLinks?.length) {
|
||||
await db.link.update(
|
||||
{ status: 0 },
|
||||
{
|
||||
where: { id: previousLinks?.map((link) => link.id) },
|
||||
},
|
||||
);
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
message: 'All links deactivated successfully.',
|
||||
};
|
||||
} catch (error) {
|
||||
return formatError(error);
|
||||
}
|
||||
};
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* activity_log Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.activity_log.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_activity_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* calendar Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.calendar.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_calendar -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* code Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.code.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_code -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* credential Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.credential.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_credential -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* image Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.image.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_image -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* link Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.link.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_link -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* note Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.note.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_note -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* profile Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.profile.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_profile -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* refer_log Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.refer_log.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_refer_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* user Resolve Delete
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
//Check Auth if user allowed
|
||||
try {
|
||||
|
||||
return await db.user.realDelete(args.id);
|
||||
} catch (error) {
|
||||
console.log('delete_user -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: {{{year}}}*/
|
||||
/**
|
||||
* Resolve Index
|
||||
* @copyright {{{year}}} Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
const { GraphQLUpload } = require('graphql-upload');
|
||||
|
||||
const updateUserResolver = require('./update/updateUser');
|
||||
const singleUserResolver = require('./single/singleUser');
|
||||
const typeUserResolver = require('./type/typeUser');
|
||||
|
||||
const createLinkResolver = require('./create/createLink');
|
||||
const typeLinkResolver = require('./type/typeLink');
|
||||
const singleLinkResolver = require('./single/singleLink');
|
||||
const deactivateAllLinksResolver = require('./delete/deactivateAllLinks');
|
||||
|
||||
const calendarResolver = require('./custom/calendar');
|
||||
const noteResolver = require('./custom/note');
|
||||
const customImageResolver = require('./custom/image');
|
||||
const uploadFileMutationResolver = require('./custom/uploadFile');
|
||||
|
||||
const connectionStepsResolver = require('./custom/connectionSteps');
|
||||
|
||||
|
||||
module.exports = {
|
||||
Upload: GraphQLUpload,
|
||||
Query: {
|
||||
user: singleUserResolver,
|
||||
link: singleLinkResolver,
|
||||
...calendarResolver.Query,
|
||||
...customImageResolver.Query,
|
||||
...noteResolver.Query,
|
||||
...connectionStepsResolver.Query
|
||||
},
|
||||
Mutation: {
|
||||
updateUser: updateUserResolver,
|
||||
createLink: createLinkResolver,
|
||||
deactivateAllLinks: deactivateAllLinksResolver,
|
||||
uploadFile: uploadFileMutationResolver,
|
||||
...calendarResolver.Mutation,
|
||||
...customImageResolver.Mutation,
|
||||
...noteResolver.Mutation,
|
||||
},
|
||||
|
||||
...calendarResolver.Type,
|
||||
...noteResolver.Type,
|
||||
|
||||
User: typeUserResolver,
|
||||
Link: typeLinkResolver,
|
||||
};
|
||||
Executable
Executable
+8
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
module.exports = (parent, args, context, info) => {
|
||||
if (parent.event) {
|
||||
return parent.event;
|
||||
} else {
|
||||
return parent.getEvent();
|
||||
}
|
||||
};
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
module.exports = (parent, args, context, info) => {
|
||||
if (parent.image) {
|
||||
return parent.image;
|
||||
} else {
|
||||
return parent.getImage();
|
||||
}
|
||||
};
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
module.exports = (parent, args, context, info) => {
|
||||
if (parent.profile) {
|
||||
return parent.profile;
|
||||
} else {
|
||||
return parent.getProfile();
|
||||
}
|
||||
};
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
module.exports = (parent, args, context, info) => {
|
||||
if (parent.referrer_user) {
|
||||
return parent.referrer_user;
|
||||
} else {
|
||||
return parent.getReferrerUser();
|
||||
}
|
||||
};
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
module.exports = (parent, args, context, info) => {
|
||||
if (parent.role) {
|
||||
return parent.role;
|
||||
} else {
|
||||
return parent.getRole();
|
||||
}
|
||||
};
|
||||
Executable
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* activity_log Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.activity_log.intersection(graphqlFields(info));
|
||||
|
||||
return await db.activity_log.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_activity_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* calendar Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.calendar.intersection(graphqlFields(info));
|
||||
|
||||
return await db.calendar.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_calendar -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* code Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.code.intersection(graphqlFields(info));
|
||||
|
||||
return await db.code.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_code -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* credential Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.credential.intersection(graphqlFields(info));
|
||||
|
||||
return await db.credential.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_credential -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* image Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.image.intersection(graphqlFields(info));
|
||||
|
||||
return await db.image.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_image -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* Link Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { formatError } = require('../../utils/formatError');
|
||||
|
||||
module.exports = async (_, __, { db, user }) => {
|
||||
try {
|
||||
const link = await db.link.getByFields({
|
||||
status: 1,
|
||||
user_id: user.id,
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
data: link,
|
||||
};
|
||||
} catch (error) {
|
||||
return formatError(error);
|
||||
}
|
||||
};
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* note Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.note.intersection(graphqlFields(info));
|
||||
|
||||
return await db.note.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_note -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* profile Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.profile.intersection(graphqlFields(info));
|
||||
|
||||
return await db.profile.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_profile -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* refer_log Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = async (_, {id}, {db}, info) => {
|
||||
try {
|
||||
const attributes = db.refer_log.intersection(graphqlFields(info));
|
||||
|
||||
return await db.refer_log.getByPK(id);
|
||||
} catch (error) {
|
||||
console.log('single_refer_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* User Resolve Single
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
module.exports = async (_, __, { directives: { verifyUser } }) => {
|
||||
return {
|
||||
success: true,
|
||||
data: verifyUser?.user,
|
||||
};
|
||||
};
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
async event({ event_id }, _, { db }, info) {
|
||||
try {
|
||||
const attributes = db.event.intersection(graphqlFields(info));
|
||||
|
||||
return await db.event.getByPK(event_id, { attributes });
|
||||
} catch (error) {
|
||||
console.log('event -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
},
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
const { ApolloError } = require('apollo-server-express');
|
||||
const graphqlFields = require('graphql-fields');
|
||||
|
||||
module.exports = {
|
||||
|
||||
}
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
module.exports = {
|
||||
async sync_code(user, _, { db }) {
|
||||
try {
|
||||
const syncCode = await db.code.getByFields({
|
||||
user_id: user.id,
|
||||
})
|
||||
return syncCode?.code
|
||||
} catch (error) {
|
||||
return null
|
||||
}
|
||||
},
|
||||
}
|
||||
Executable
Executable
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* activity_log Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { name } = args;
|
||||
const v = new Validator({ }, { });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.activity_log.edit({ name }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_activity_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* calendar Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { } = args;
|
||||
const v = new Validator({ }, { });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.calendar.edit({ }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_calendar -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* code Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { code } = args;
|
||||
const v = new Validator({ code: args.code}, { code: "required" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.code.edit({ code }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_code -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* credential Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { email,
|
||||
password } = args;
|
||||
const v = new Validator({ email: args.email,
|
||||
password: args.password}, { email: "required|valid_email" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.credential.edit({ email,
|
||||
password }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_credential -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* image Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { url,
|
||||
caption } = args;
|
||||
const v = new Validator({ url: args.url}, { url: "required" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.image.edit({ url,
|
||||
caption }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_image -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* link Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { link,
|
||||
status } = args;
|
||||
const v = new Validator({ link: args.link,
|
||||
status: args.status}, { link: "required",
|
||||
status: "required|integer" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.link.edit({ link,
|
||||
status }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_link -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* note Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { } = args;
|
||||
const v = new Validator({ }, { });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.note.edit({ }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_note -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* profile Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { timezone,
|
||||
dashboard_code } = args;
|
||||
const v = new Validator({ timezone: args.timezone,
|
||||
dashboard_code: args.dashboard_code}, { timezone: "required",
|
||||
dashboard_code: "required" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.profile.edit({ timezone,
|
||||
dashboard_code }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_profile -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* refer_log Resolve Update
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const { ApolloError ,UserInputError} = require('apollo-server-express');
|
||||
const { Validator } = require('node-input-validator');
|
||||
|
||||
module.exports = async (parent, args, {db}, info) => {
|
||||
try {
|
||||
const { type,
|
||||
status } = args;
|
||||
const v = new Validator({ type: args.type,
|
||||
status: args.status}, { type: "required|integer" });
|
||||
|
||||
v.check().then(function (matched) {
|
||||
if (!matched) {
|
||||
Object.keys(v.errors).forEach((error) => {
|
||||
return new UserInputError(v.errors[error].message);
|
||||
});
|
||||
}
|
||||
});
|
||||
return await db.refer_log.edit({ type,
|
||||
status }, args.id);
|
||||
} catch (error) {
|
||||
console.log('update_refer_log -> error', error);
|
||||
return new ApolloError('InternalServerError');
|
||||
}
|
||||
};
|
||||
Executable
+127
@@ -0,0 +1,127 @@
|
||||
'use strict'
|
||||
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||
/**
|
||||
* Update User Resolver
|
||||
* @copyright 2021 Manaknightdigital Inc.
|
||||
* @link https://manaknightdigital.com
|
||||
* @license Proprietary Software licensing
|
||||
* @author Ryan Wong
|
||||
*
|
||||
*/
|
||||
|
||||
const TimezoneService = require('../../services/TimezoneService')
|
||||
|
||||
const { validateInputForGraphql } = require('../../services/ValidationService')
|
||||
const { formatError } = require('../../utils/formatError')
|
||||
const { errorCodes } = require('../../core/strings')
|
||||
|
||||
const timezoneService = new TimezoneService()
|
||||
|
||||
const inputValidations = {
|
||||
Mutation: {
|
||||
updateUser: (resolver = () => null) => {
|
||||
return validateInputForGraphql(
|
||||
resolver,
|
||||
{
|
||||
time_zone: 'string',
|
||||
time_format: 'integer|min:1|max:2',
|
||||
clock_format: 'integer|min:1|max:2',
|
||||
date_format: 'integer|min:1|max:2',
|
||||
location: 'string',
|
||||
lat: 'decimal',
|
||||
lng: 'decimal',
|
||||
},
|
||||
{
|
||||
'time_zone.string': 'Timezone should be a string.',
|
||||
'time_format.integer':
|
||||
'Time format field should be an integer. Can be 1 for `AM/PM format` and 2 for `24 hours format`.',
|
||||
'time_format.min':
|
||||
'Invalid value. Can be 1 for `AM/PM format` and 2 for `24 hours format`.',
|
||||
'time_format.max':
|
||||
'Invalid value.Can be 1 for `AM/PM format` and 2 for `24 hours format`.',
|
||||
|
||||
'clock_format.integer':
|
||||
'Clock format field should be an integer. Can be 1 for `Digital` and 2 for `Analog`.',
|
||||
'clock_format.min':
|
||||
'Invalid value. Can be 1 for `Digital` and 2 for `Analog`.',
|
||||
'clock_format.max':
|
||||
'Invalid value. Can be 1 for `Digital` and 2 for `Analog`.',
|
||||
|
||||
'date_format.integer':
|
||||
'Date format field should be an integer. Can be 1 for `Standard (dd-mm-yyyy)` and 2 for `Locale (1st April 2021)`.',
|
||||
'date_format.min':
|
||||
'Invalid value. Can be 1 for `Standard (dd-mm-yyyy)` and 2 for `Locale (1st April 2021)`.',
|
||||
'date_format.max':
|
||||
'Invalid value. Can be 1 for `Standard (dd-mm-yyyy)` and 2 for `Locale (1st April 2021)`.',
|
||||
}
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
module.exports = inputValidations.Mutation.updateUser(
|
||||
async (
|
||||
_,
|
||||
{
|
||||
sync_code,
|
||||
font_color,
|
||||
time_zone,
|
||||
time_format,
|
||||
clock_format,
|
||||
date_format,
|
||||
location,
|
||||
lat,
|
||||
lng,
|
||||
},
|
||||
{ db, user }
|
||||
) => {
|
||||
try {
|
||||
if (time_zone?.length) {
|
||||
const isValidTimezone = timezoneService.validateTimeZone(time_zone)
|
||||
if (!isValidTimezone) {
|
||||
return {
|
||||
success: false,
|
||||
message:
|
||||
'Invalid timezone. Pass the correct timezone abbreviation.',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sync_code?.length) {
|
||||
const syncCodeExists = await db.code.getByFields({
|
||||
code: sync_code,
|
||||
})
|
||||
if (syncCodeExists && +syncCodeExists.user_id !== +user.id) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'Sync code already exists.',
|
||||
code: errorCodes.extra.SYNC_CODE_ALREADY_EXISTS,
|
||||
}
|
||||
}
|
||||
await db.code.editByField({ code: sync_code }, { user_id: user.id })
|
||||
}
|
||||
|
||||
const fields = {
|
||||
...(font_color?.length ? { font_color } : {}),
|
||||
...(time_zone?.length ? { time_zone } : {}),
|
||||
...(time_format ? { time_format } : {}),
|
||||
...(clock_format ? { clock_format } : {}),
|
||||
...(date_format ? { date_format } : {}),
|
||||
...(location?.length ? { location } : {}),
|
||||
...((lat !== undefined || lat !== null) &&
|
||||
(lng !== undefined || lng !== null)
|
||||
? { lat, lng }
|
||||
: {}),
|
||||
}
|
||||
if (Object.entries(fields)?.length) {
|
||||
await db.user.edit(fields, user.id)
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
message: 'User settings updated successfully.',
|
||||
}
|
||||
} catch (error) {
|
||||
return formatError(error)
|
||||
}
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user