day 11
This commit is contained in:
Vendored
BIN
Binary file not shown.
Regular → Executable
+55
@@ -0,0 +1,55 @@
|
|||||||
|
# day 11
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
- setup project
|
||||||
|
- clone to your github
|
||||||
|
- Read the documentation https://www.apollographql.com/docs/
|
||||||
|
- Create the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
Create model
|
||||||
|
|
||||||
|
movies
|
||||||
|
- id
|
||||||
|
- title
|
||||||
|
- director_id
|
||||||
|
- main_genre
|
||||||
|
- status
|
||||||
|
- review
|
||||||
|
|
||||||
|
review
|
||||||
|
- id
|
||||||
|
- notes
|
||||||
|
- movie_id
|
||||||
|
|
||||||
|
director
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
|
||||||
|
actors
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
|
||||||
|
movie_actor
|
||||||
|
- id
|
||||||
|
- actor_id
|
||||||
|
- movie_id
|
||||||
|
|
||||||
|
genre
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
|
||||||
|
genre_movie
|
||||||
|
- id
|
||||||
|
- movie_id
|
||||||
|
- genre_id
|
||||||
|
```
|
||||||
|
|
||||||
|
- Create resolvers and make query for the 4 tables. Inside movies, we can get all actors in that movie
|
||||||
|
|
||||||
|
- Create a query in apollo to get all movies with reviews > # provided by user
|
||||||
|
|
||||||
|
- Create a mutation to add an actor to every movie for given genre
|
||||||
|
|
||||||
|
- Everything must be done by end of date
|
||||||
|
|||||||
Executable
+158
@@ -0,0 +1,158 @@
|
|||||||
|
'use strict'
|
||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2020*/
|
||||||
|
/**
|
||||||
|
* App
|
||||||
|
* @copyright 2020 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
require('dotenv').config()
|
||||||
|
const express = require('express')
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const logger = require('morgan')
|
||||||
|
const helmet = require('helmet')
|
||||||
|
const cookieParser = require('cookie-parser')
|
||||||
|
const cors = require('cors')
|
||||||
|
const { ApolloServer } = require('apollo-server-express')
|
||||||
|
const { graphqlUploadExpress } = require('graphql-upload')
|
||||||
|
const body_parser = require('body-parser')
|
||||||
|
|
||||||
|
const db = require('./models')
|
||||||
|
const typeDefs = fs.readFileSync(
|
||||||
|
path.join(__dirname, '/types/schema.graphql'),
|
||||||
|
'utf8'
|
||||||
|
)
|
||||||
|
const jwtService = require('./services/JwtService')
|
||||||
|
const resolvers = require('./resolvers')
|
||||||
|
const schemaDirectives = require('./directives')
|
||||||
|
const { AuthenticationError } = require('./services/ErrorService')
|
||||||
|
const { errorCodes } = require('./core/strings')
|
||||||
|
const { formatGraphqlError } = require('./utils/formatError')
|
||||||
|
|
||||||
|
const GRAPHQL_PATH = '/graphql'
|
||||||
|
const ALLOWED_ROLE_IDS = [2]
|
||||||
|
|
||||||
|
let app = express()
|
||||||
|
|
||||||
|
app.use(logger('dev'))
|
||||||
|
|
||||||
|
if (process.env.MODE === 'development') {
|
||||||
|
logger.token('graphql-query', (req) => {
|
||||||
|
const disallowedLogs = ['IntrospectionQuery']
|
||||||
|
|
||||||
|
if (req.method === 'POST' && req.originalUrl === GRAPHQL_PATH) {
|
||||||
|
const { query, variables, operationName } = req.body
|
||||||
|
return !disallowedLogs.includes(operationName)
|
||||||
|
? `GRAPHQL: \nOperation Name: ${operationName} \nQuery: ${query} \nVariables: ${JSON.stringify(
|
||||||
|
variables
|
||||||
|
)}`
|
||||||
|
: ''
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
})
|
||||||
|
app.use(logger(':graphql-query'))
|
||||||
|
}
|
||||||
|
|
||||||
|
const server = new ApolloServer({
|
||||||
|
uploads: false,
|
||||||
|
typeDefs,
|
||||||
|
resolvers,
|
||||||
|
schemaDirectives,
|
||||||
|
context: async ({ req }) => {
|
||||||
|
const token = req.headers.authorization
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
throw new AuthenticationError(
|
||||||
|
'Invalid token',
|
||||||
|
errorCodes.token.INVALID_TOKEN
|
||||||
|
)
|
||||||
|
}
|
||||||
|
const cleanToken = token.replace('Bearer ', '')
|
||||||
|
const verify = jwtService.verifyAccessToken(cleanToken)
|
||||||
|
|
||||||
|
const roleId = verify?.role_id
|
||||||
|
const user = verify?.user
|
||||||
|
const credentialId = verify?.credential_id
|
||||||
|
|
||||||
|
if (!verify || !roleId || !user || !credentialId) {
|
||||||
|
throw new AuthenticationError(
|
||||||
|
'Invalid token',
|
||||||
|
errorCodes.token.INVALID_TOKEN
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ALLOWED_ROLE_IDS.includes(+roleId)) {
|
||||||
|
throw new AuthenticationError(
|
||||||
|
'Access Denied',
|
||||||
|
errorCodes.account.UNAUTHORIZED
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
credentialId,
|
||||||
|
user,
|
||||||
|
db,
|
||||||
|
role: {
|
||||||
|
roleId,
|
||||||
|
allowedRoleIds: ALLOWED_ROLE_IDS,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
formatError: formatGraphqlError,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (process.NODE_ENV === 'maintenance') {
|
||||||
|
app.all('*', (req, res) => {
|
||||||
|
res.status(503).json({ message: 'website under maintenance' })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
app.set('iocContainer', process.env)
|
||||||
|
app.set('db', db)
|
||||||
|
app.use(body_parser.json({ limit: '50mb' }))
|
||||||
|
|
||||||
|
app.use(express.json())
|
||||||
|
app.use(
|
||||||
|
express.urlencoded({
|
||||||
|
extended: false,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
app.use(cors())
|
||||||
|
app.set('view engine', 'eta')
|
||||||
|
app.set('views', path.join(__dirname, '/views'))
|
||||||
|
app.use(cookieParser())
|
||||||
|
app.use(helmet())
|
||||||
|
|
||||||
|
app.use(express.static(path.join(__dirname, '/public')))
|
||||||
|
app.use(express.static(path.join(__dirname, '/uploads')))
|
||||||
|
app.use(express.static(path.join(__dirname)));
|
||||||
|
|
||||||
|
app.use(graphqlUploadExpress({ maxFileSize: 1000000000, maxFiles: 10 }))
|
||||||
|
|
||||||
|
server.applyMiddleware({ app, path: GRAPHQL_PATH })
|
||||||
|
|
||||||
|
|
||||||
|
app.use((err, req, res, next) => {
|
||||||
|
res.locals.message = err.message
|
||||||
|
res.locals.error = req.app.get('env') === 'development' ? err : {}
|
||||||
|
|
||||||
|
// render the error page
|
||||||
|
res.status(err.status || 500)
|
||||||
|
res.json({
|
||||||
|
message: err.message,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.use((_, res, next) => {
|
||||||
|
return res
|
||||||
|
.status(400)
|
||||||
|
.send("<h3 style='text-align:center';>404: Page Not Found!</h3>")
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
app,
|
||||||
|
apollo: server,
|
||||||
|
}
|
||||||
Executable
+67
@@ -0,0 +1,67 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
const sanitizeHtml = require('sanitize-html')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
filterEmptyFields(object) {
|
||||||
|
Object.keys(object).forEach((key) => {
|
||||||
|
if (this.empty(object[key])) {
|
||||||
|
delete object[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return object
|
||||||
|
},
|
||||||
|
empty(value) {
|
||||||
|
return value === ''
|
||||||
|
},
|
||||||
|
getMappingKey(mappingFunction, value) {
|
||||||
|
return Object.keys(mappingFunction()).find(
|
||||||
|
(key) => mappingFunction()[key].toLowerCase() === value.toLowerCase()
|
||||||
|
)
|
||||||
|
},
|
||||||
|
checkFor(requiredFields) {
|
||||||
|
for (const [key, value] of Object.entries(requiredFields)) {
|
||||||
|
if (!value) {
|
||||||
|
throw new Error(`Must provide ${key}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
convertToCents(amount) {
|
||||||
|
return parseFloat(amount) * 100
|
||||||
|
},
|
||||||
|
convertFromCents(amount) {
|
||||||
|
return parseFloat(amount) / 100
|
||||||
|
},
|
||||||
|
inject_substitute(text, normalKey, value) {
|
||||||
|
text = text.replace(new RegExp('{{{' + normalKey + '}}}', 'g'), value)
|
||||||
|
return text
|
||||||
|
},
|
||||||
|
createDirectoriesRecursive(filePath) {
|
||||||
|
let fileDirectoryPath = path.dirname(filePath)
|
||||||
|
if (!fs.existsSync(fileDirectoryPath)) {
|
||||||
|
fs.mkdirSync(fileDirectoryPath, { recursive: true })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sanitizeInputs(body) {
|
||||||
|
if (Array.isArray(body)) {
|
||||||
|
body.forEach((item) => {
|
||||||
|
item = sanitizeHtml(item)
|
||||||
|
})
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
if (this.isObject(body)) {
|
||||||
|
Object.keys(body).forEach((key) => {
|
||||||
|
body[key] = sanitizeHtml(body[key])
|
||||||
|
})
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
return sanitizeHtml(body)
|
||||||
|
},
|
||||||
|
isObject(obj) {
|
||||||
|
return obj === Object(obj)
|
||||||
|
},
|
||||||
|
ucFirst(string) {
|
||||||
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
||||||
|
},
|
||||||
|
}
|
||||||
Executable
+259
@@ -0,0 +1,259 @@
|
|||||||
|
const { isInteger } = require('lodash');
|
||||||
|
|
||||||
|
module.exports = async function (Table) {
|
||||||
|
Table._primaryKey = function () {
|
||||||
|
return 'id';
|
||||||
|
};
|
||||||
|
Table.getLast = async function (parameters) {
|
||||||
|
let where = parameters;
|
||||||
|
if (!where) {
|
||||||
|
where = {};
|
||||||
|
}
|
||||||
|
for (const key in where) {
|
||||||
|
const element = where[key];
|
||||||
|
if (element == undefined || element == null) {
|
||||||
|
delete where.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = await Table.findAll({
|
||||||
|
limit: 1,
|
||||||
|
where: where,
|
||||||
|
order: [['id', 'DESC']],
|
||||||
|
});
|
||||||
|
return result[0];
|
||||||
|
};
|
||||||
|
Table.getAll = function (parameters) {
|
||||||
|
let where = parameters;
|
||||||
|
if (!where) {
|
||||||
|
where = {};
|
||||||
|
}
|
||||||
|
for (const key in where) {
|
||||||
|
const element = where[key];
|
||||||
|
if (element == undefined || element == null) {
|
||||||
|
delete where.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Table.findAll({
|
||||||
|
where: where,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Table._count = function (parameters, include = []) {
|
||||||
|
let where = parameters;
|
||||||
|
if (!where) {
|
||||||
|
where = {};
|
||||||
|
}
|
||||||
|
for (const key in where) {
|
||||||
|
const element = where[key];
|
||||||
|
if (element == undefined || element == null) {
|
||||||
|
delete where.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Table._customCountingConditions(where);
|
||||||
|
|
||||||
|
return Table.count({
|
||||||
|
where: where,
|
||||||
|
include: include,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.getPaginated = function (page, limit, parameters, orderBy, direction, include = []) {
|
||||||
|
let where = parameters;
|
||||||
|
|
||||||
|
// for (const key in where) {
|
||||||
|
// if (where.hasOwnProperty.call(where, key)) {
|
||||||
|
// const element = where[key];
|
||||||
|
// if (element.length || isInteger(element)) {
|
||||||
|
// where[key] = element;
|
||||||
|
// } else {
|
||||||
|
// delete where[key];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (!page) {
|
||||||
|
page = 0;
|
||||||
|
}
|
||||||
|
if (!limit) {
|
||||||
|
limit = 10;
|
||||||
|
}
|
||||||
|
if (!where) {
|
||||||
|
where = {};
|
||||||
|
}
|
||||||
|
if (!orderBy) {
|
||||||
|
orderBy = Table._primaryKey();
|
||||||
|
}
|
||||||
|
if (!direction) {
|
||||||
|
direction = 'ASC';
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key in where) {
|
||||||
|
const element = where[key];
|
||||||
|
if (element == undefined || element == null) {
|
||||||
|
delete where.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Where down', where);
|
||||||
|
|
||||||
|
console.log('[[[[[[[', {
|
||||||
|
where: where,
|
||||||
|
offset: page * limit,
|
||||||
|
limit: limit,
|
||||||
|
order: [[orderBy, direction]],
|
||||||
|
include: include,
|
||||||
|
});
|
||||||
|
|
||||||
|
return Table.findAll({
|
||||||
|
where: where,
|
||||||
|
offset: page * limit,
|
||||||
|
limit: limit,
|
||||||
|
order: [[orderBy, direction]],
|
||||||
|
include: include,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.getAllByStatus = function (status) {
|
||||||
|
return Table.findAll({
|
||||||
|
where: {
|
||||||
|
status: status,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.getByField = function (field, value) {
|
||||||
|
return Table.findOne({
|
||||||
|
where: {
|
||||||
|
[field]: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.getByPK = async function (id, options) {
|
||||||
|
return await Table.findByPk(id, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.getByFields = function (parameters) {
|
||||||
|
let where = parameters;
|
||||||
|
if (!where) {
|
||||||
|
where = {};
|
||||||
|
}
|
||||||
|
for (const key in where) {
|
||||||
|
const element = where[key];
|
||||||
|
if (element == undefined || element == null) {
|
||||||
|
delete where.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Table.findOne({
|
||||||
|
where: where,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.getAllByKeyValue = async function (field, parameters) {
|
||||||
|
let where = parameters;
|
||||||
|
if (!where) {
|
||||||
|
where = {};
|
||||||
|
}
|
||||||
|
let data = [];
|
||||||
|
const results = await Table.findAll({
|
||||||
|
where: where,
|
||||||
|
});
|
||||||
|
|
||||||
|
for (let i = 0; i < results.length; i++) {
|
||||||
|
const element = results[i];
|
||||||
|
let singleField = element[field];
|
||||||
|
data.push({ [element.id]: singleField });
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.insert = async function (data, { returnAllFields = false } = {}) {
|
||||||
|
data = Table._preCreateProcessing(data);
|
||||||
|
const insertedRow = await Table.create(Table._filterAllowKeys(data));
|
||||||
|
if (returnAllFields === true) {
|
||||||
|
return insertedRow;
|
||||||
|
}
|
||||||
|
if (insertedRow) {
|
||||||
|
return insertedRow.id;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.batchInsert = async function (data) {
|
||||||
|
const insertedRow = await Table.bulkCreate(data, { returning: true });
|
||||||
|
|
||||||
|
if (insertedRow) {
|
||||||
|
return insertedRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.edit = async function (data, id) {
|
||||||
|
data = Table._postCreateProcessing(data);
|
||||||
|
const updateRow = await Table.update(Table._filterAllowKeys(data), {
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
}).catch((error) => {
|
||||||
|
throw new Error(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
return updateRow;
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.editByField = async function (data, where) {
|
||||||
|
data = Table._postCreateProcessing(data);
|
||||||
|
|
||||||
|
const updateRow = await Table.update(Table._filterAllowKeys(data), {
|
||||||
|
where,
|
||||||
|
});
|
||||||
|
|
||||||
|
return updateRow;
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.delete = async function (id) {
|
||||||
|
const updateRow = await Table.update(
|
||||||
|
{
|
||||||
|
status: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return updateRow;
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.realDelete = async function (id) {
|
||||||
|
return Table.destroy({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.realDeleteByFields = async function (parameters, id) {
|
||||||
|
let where = parameters;
|
||||||
|
if (!where) {
|
||||||
|
where = {
|
||||||
|
id: id,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
where['id'] = id;
|
||||||
|
}
|
||||||
|
return Table.destroy({
|
||||||
|
where: where,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Table.realDeleteByUniqueField = async function (field, value) {
|
||||||
|
let where = {};
|
||||||
|
where[field] = value;
|
||||||
|
return Table.destroy({
|
||||||
|
where: where,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
Executable
+45
@@ -0,0 +1,45 @@
|
|||||||
|
const translation = require('./translation.json')
|
||||||
|
|
||||||
|
exports.errors = {
|
||||||
|
EMAIL_ADDRESS_NOT_FOUND: translation.xyzAccountDoesntExists,
|
||||||
|
EMAIL_ADDRESS_ALREADY_EXIST: translation.xyzAccount_Already_Exists,
|
||||||
|
PASSWORD_NOT_MATCH: translation.xyzPasswordsDoNotMatch,
|
||||||
|
INVALID_EMAIL_CONFIRMATION_CODE: translation.xyzInvalidEmailConfirmationCode,
|
||||||
|
INVALID_EMAIL_OR_PASSWORD: translation.xyzWrongEmailOrPassword,
|
||||||
|
ACCOUNT_IS_REGISTERED_WITH_GOOGLE:
|
||||||
|
translation.xyzAccountIsRegisteredUsingGoogle,
|
||||||
|
ACCOUNT_IS_REGISTERED_WITH_FACEBOOK:
|
||||||
|
translation.xyzAccountIsRegisteredUsingFacebook,
|
||||||
|
ACCOUNT_IS_REGISTERED_WITH_EMAIL_AND_PASSWORD:
|
||||||
|
translation.xyzAccountIsRegisteredUsingEmailAndPassword,
|
||||||
|
ACCOUNT_DOES_NOT_EXISTS: translation.xyzAccountDoesntExists,
|
||||||
|
CODE_DOES_NOT_EXIST: translation.xyzCodeInvalidOrExpired,
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.errorCodes = {
|
||||||
|
token: {
|
||||||
|
INVALID_TOKEN: 'INVALID_TOKEN',
|
||||||
|
},
|
||||||
|
account: {
|
||||||
|
ACCOUNT_DOES_NOT_EXISTS: 'ACCOUNT_DOES_NOT_EXISTS',
|
||||||
|
ACCOUNT_NOT_VERIFIED: 'ACCOUNT_NOT_VERIFIED',
|
||||||
|
ACCOUNT_ALREADY_VERIFIED: 'ACCOUNT_ALREADY_VERIFIED',
|
||||||
|
UNAUTHORIZED: 'UNAUTHORIZED',
|
||||||
|
},
|
||||||
|
calendar: {
|
||||||
|
CALENDAR_EVENT_DOES_NOT_EXISTS: 'CALENDAR_EVENT_DOES_NOT_EXISTS',
|
||||||
|
},
|
||||||
|
note: {
|
||||||
|
NOTE_DOES_NOT_EXISTS: 'NOTE_DOES_NOT_EXISTS',
|
||||||
|
},
|
||||||
|
extra: {
|
||||||
|
CUSTOM_IMAGE_OR_VIDEO_ALREADY_EXISTS:
|
||||||
|
'CUSTOM_IMAGE_OR_VIDEO_ALREADY_EXISTS',
|
||||||
|
CUSTOM_IMAGE_OR_VIDEO_DOES_NOT_EXISTS:
|
||||||
|
'CUSTOM_IMAGE_OR_VIDEO_DOES_NOT_EXISTS',
|
||||||
|
INVALID_SYNC_CODE: 'INVALID_SYNC_CODE',
|
||||||
|
IFRAME_BLOCKED: 'IFRAME_BLOCKED',
|
||||||
|
INVALID_URL: 'INVALID_URL',
|
||||||
|
SYNC_CODE_ALREADY_EXISTS: 'SYNC_CODE_ALREADY_EXISTS',
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,384 @@
|
|||||||
|
{
|
||||||
|
"xyzTitle": "Title",
|
||||||
|
"xyzDate": "Date",
|
||||||
|
"xyzIs Used": "Is Used",
|
||||||
|
"xyzVersion #": "Version #",
|
||||||
|
"xyzTime zone": "Time zone",
|
||||||
|
"xyzTime format": "Time format",
|
||||||
|
"xyzClock format": "Clock format",
|
||||||
|
"xyzDate format": "Date format",
|
||||||
|
"xyzEmails": "Emails",
|
||||||
|
"xyzTimes": "Times",
|
||||||
|
"xyzConfiguration": "Configuration",
|
||||||
|
"xyzEmail": "Email",
|
||||||
|
"xyzFirst Name": "First Name",
|
||||||
|
"xyzLast Name": "Last Name",
|
||||||
|
"xyzPassword": "Password",
|
||||||
|
"xyzEdit": "Edit",
|
||||||
|
"xyzDates": "Date",
|
||||||
|
"xyzFullDates": "Full Date",
|
||||||
|
"xyzAdd": "Add",
|
||||||
|
"xyzCode": "Code",
|
||||||
|
"xyzLink": "Link",
|
||||||
|
"xyzTitles": "Title",
|
||||||
|
"xyzReferree User": "Referree User",
|
||||||
|
"xyzReferrer User": "Referrer User",
|
||||||
|
"xyxType": "Type",
|
||||||
|
"xyzPhone": "Phone",
|
||||||
|
"xyzProfile Type": "Profile Type",
|
||||||
|
"xyzPaid": "Paid",
|
||||||
|
"xyzImage": "Image",
|
||||||
|
"xyzImage ID": "Image ID",
|
||||||
|
"xyzRefer Code": "Refer Code",
|
||||||
|
"xyzProfile": "Profile",
|
||||||
|
"xyzVerified": "Verified",
|
||||||
|
"xyzRole": "Role",
|
||||||
|
"xyzConfirmed": "Confirmed",
|
||||||
|
"xyzDashboard": "Dashboard",
|
||||||
|
"xyzPending": "Pending",
|
||||||
|
"xyzResult": "Result",
|
||||||
|
"xyzTokken": "Tokken",
|
||||||
|
"xyzData": "Data",
|
||||||
|
"xyzTime To Live": "Time To Live",
|
||||||
|
"xyzFullDate": "Full Date",
|
||||||
|
"xyzIssue at": "Issue at",
|
||||||
|
"xyzExpire at": "Expire at",
|
||||||
|
"xyzToken Type": "Token Type",
|
||||||
|
"xyzUser": "xUser",
|
||||||
|
"xyzFilter": "Filter",
|
||||||
|
"xyzSearch": "Search",
|
||||||
|
"xyzStripe Id": "Stripe Id",
|
||||||
|
"xyzAdmin": "Admin",
|
||||||
|
"xyzSystem": "Systems",
|
||||||
|
"xyzMedia Gallery": "Media Gallery",
|
||||||
|
"xyzSaved": "Saved",
|
||||||
|
"xyzLoad More": "Load More",
|
||||||
|
"xyzUpload": "Upload",
|
||||||
|
"xyzClose": "Close",
|
||||||
|
"xyzChoose": "Choose",
|
||||||
|
"xyzCrop & Upload": "Crop & Upload",
|
||||||
|
"xyzDetails": "Details",
|
||||||
|
"xyzView": "View",
|
||||||
|
"xyzSubmit": "Submit",
|
||||||
|
"xyzError": "Error",
|
||||||
|
"xyzBack": "Back",
|
||||||
|
"xyzAction": "Action",
|
||||||
|
"xyzStatus": "Status",
|
||||||
|
"xyzName": "Name",
|
||||||
|
"xyzMessage": "Message",
|
||||||
|
"xyzOR": "OR",
|
||||||
|
"xyzURL": "URL",
|
||||||
|
"xyzCaption": "Caption",
|
||||||
|
"xyzWidth": "Width",
|
||||||
|
"xyzHeight": "Height",
|
||||||
|
"xyzSMS Type": "SMS Type",
|
||||||
|
"xyzImage Type": "Image Type",
|
||||||
|
"xyzReplacement Tags": "Replacement Tags",
|
||||||
|
"xyzSMS Body": "SMS Body",
|
||||||
|
"xyzEmail Type": "Email Type",
|
||||||
|
"xyzSubject": "xyzSubject",
|
||||||
|
"xyzForgot_token": "Forgot_token",
|
||||||
|
"xyzAccess_token": "Access token",
|
||||||
|
"xyzEmail Body": "Email Body",
|
||||||
|
"xyzEdit Profile": "Edit Profile",
|
||||||
|
"xyzRefresh_token": "Refresh_token",
|
||||||
|
"xyzOther": "Other",
|
||||||
|
"xyzApi_key": "Api Key",
|
||||||
|
"xyzApi_secret": "Api Secret",
|
||||||
|
"xyzVerify": "Verify",
|
||||||
|
"xyzSign Up": "Sign Up",
|
||||||
|
"xyzRepeat Password": "Repeat Password",
|
||||||
|
"xyzRegister": "Register",
|
||||||
|
"xyzSign in with Google+": "Sign in with Google+",
|
||||||
|
"xyzSign in with Facebook": "Sign in with Facebook",
|
||||||
|
"xyzSign up New Account": "Sign up New Account",
|
||||||
|
"xyzForgot password?": "Forgot password?",
|
||||||
|
"xyzSign in": "Sign in",
|
||||||
|
"xyzReset Password": "Reset Password",
|
||||||
|
"xyzEmail address": "Email address",
|
||||||
|
"xyzForgot Password": "Forgot Password",
|
||||||
|
"xyzUpload a file": "Upload a file",
|
||||||
|
"xyzChoose Image": "Choose Image",
|
||||||
|
"xyzID": "ID",
|
||||||
|
"xyzPhoto": "Photo",
|
||||||
|
"xyzYes": "Yes",
|
||||||
|
"xyzNo": "No",
|
||||||
|
"xyzPersonal Information": "Personal Information",
|
||||||
|
"xyzUpload file size too big": "Upload file size too big",
|
||||||
|
"xyzUpload to S3 Failed": "xyzUpload to S3 Failed",
|
||||||
|
"xyzWrong email or password.": "Wrong email or password.",
|
||||||
|
"xyzUpload file missing": "xyzUpload file missing",
|
||||||
|
"xyzUpload file failed": "xyzUpload file failed",
|
||||||
|
"xyzSorry, your email is not a google email in our system.": "Sorry, your email is not a google email in our system.",
|
||||||
|
"xyzSorry, google cannot find your email.": "Sorry, google cannot find your email.",
|
||||||
|
"xyzSorry, facebook cannot find your email.": "Sorry, facebook cannot find your email.",
|
||||||
|
"xyzSorry, your email is not a facebook email in our system.": "Sorry, your email is not a facebook email in our system.",
|
||||||
|
"xyzThere was a problem creating your new account. Please try again.": "There was a problem creating your new account. Please try again.",
|
||||||
|
"xyzUser creation failed. Please try again.": "User creation failed. Please try again.",
|
||||||
|
"xyzYour Reset email was sent. Check your email.": "Your Reset email was sent. Check your email.",
|
||||||
|
"xyzEmail does not exist in our system.": "Email does not exist in our system.",
|
||||||
|
"xyzYour password was reset. Try to login now": "Your password was reset. Try to login now",
|
||||||
|
"xyzInvalid reset token to reset password.": "Invalid reset token to reset password.",
|
||||||
|
"xyzinvalid credentials": "invalid credentials",
|
||||||
|
"xyzUpload CSV File missing": "Upload CSV File missing",
|
||||||
|
"xyzNot CSV File": "Not CSV File",
|
||||||
|
"xyzGenerating SQL worked but insert error to the database": "Generating SQL worked but insert error to the database",
|
||||||
|
"xyzImport": "Import",
|
||||||
|
"xyzExport": "Export",
|
||||||
|
"xyzActive": "Active",
|
||||||
|
"xyzInactive": "Inactive",
|
||||||
|
"xyzAll": "All",
|
||||||
|
"xyzSuspend": "Suspend",
|
||||||
|
"xyzMember": "Member",
|
||||||
|
"xyzRemove": "Remove",
|
||||||
|
"xyzCreated At": "Created At",
|
||||||
|
"xyzUpdated At": "Updated At",
|
||||||
|
"xyzNot verified": "Not verified",
|
||||||
|
"xyzType": "Type",
|
||||||
|
"xyzis_required": "is required",
|
||||||
|
"xyzInvalid_email": "Invalid email",
|
||||||
|
"xyzshould_contain_at_least": "should contain at least",
|
||||||
|
"xyzcharacters": "characters",
|
||||||
|
"xyzshould_not_exceed": "should not exceed",
|
||||||
|
"xyzshould_be_unique": "should be unique",
|
||||||
|
"xyzvalue_cannot_be_less_than": "value cannot be less than",
|
||||||
|
"xyzvalue_cannot_be_greater_than": "value cannot be greater than",
|
||||||
|
"xyzSomething_went_wrong": "Something went wrong",
|
||||||
|
"xyzNew": "New",
|
||||||
|
"xyzcreated_successfully": "created successfully",
|
||||||
|
"xyzedited_successFully": "edited successfully",
|
||||||
|
"xyznot_found": "not found",
|
||||||
|
"xyzdeleted_successfully": "deleted successfully",
|
||||||
|
"xyzEmailIsRequired": "Email is required",
|
||||||
|
"xyzPasswordShouldBeAtLeastSixCharacters": "Password should be at least 6 characters long.",
|
||||||
|
"xyzInvalidEmailOrPassword": "Invalid email or password",
|
||||||
|
"xyzWrongEmailOrPassword": "Wrong email or password",
|
||||||
|
"xyzLogin": "Login",
|
||||||
|
"xyzForgot_password": "Forgot Password",
|
||||||
|
"xyzAccount_Already_Exists": "Account already exists",
|
||||||
|
"xyzLogin_with_Google": "Login with Google",
|
||||||
|
"xyzSignup_with_Google": "Login with Google",
|
||||||
|
"xyzLogin_with_Facebook": "Login with Facebook",
|
||||||
|
"xyzSignup_with_Facebook": "Login with Facebook",
|
||||||
|
"xyzPasswordIsRequired": "Password is required.",
|
||||||
|
"xyzPasswordsDoNotMatch": "Passwords do not match",
|
||||||
|
"xyzDontHaveAnAccount": "Don't have an account yet?",
|
||||||
|
"xyzAlreadyHaveAnAccount": "Already have an account?",
|
||||||
|
"xyzAccountDoesntExists": "Account doesn't exists.",
|
||||||
|
"xyzInvalid_token": "Invalid token",
|
||||||
|
"xyzBackToLogin": "Back to Login",
|
||||||
|
"xyzResetPassword": "Reset Password",
|
||||||
|
"xyzPasswordResetSuccessful": "Password reset successful",
|
||||||
|
"xyzlisted_successfully": "listed successfully",
|
||||||
|
"xyzFirstNameIsRequired": "First name is required",
|
||||||
|
"xyzLastNameIsRequired": "Last name is required",
|
||||||
|
"xyzVerificationCodeIsRequired": "Verification Code is re required.",
|
||||||
|
"xyzPasswordResetLinkIsSentToYourInbox": "A password reset link is sent to your inbox.",
|
||||||
|
"xyzReset": "Reset",
|
||||||
|
"xyzshould_be_equal_to": "should be equal to",
|
||||||
|
"xyzshould_be_greater_than_or_equal_to": "should be greater than or equal to",
|
||||||
|
"xyzshould_be_greater_than": "should be greater than",
|
||||||
|
"xyzshould_be_less_than_or_equal_to": "should be less than or equal to",
|
||||||
|
"xyzshould_be_less_than_to": "should be less than to",
|
||||||
|
"xyzshould_be_exist_in_the_list": "should be exist in the list",
|
||||||
|
"xyzshould_only_contain_alphabetic_characters": "should only contain alphabetic characters",
|
||||||
|
"xyzshould_only_contain_contains_letters_and_numbers": "should only contain contains letters and numbers",
|
||||||
|
"xyzshould_have_have_alpha-numeric_characters,_as_well_as_dashes_and_underscores": "should have have alpha-numeric characters, as well as dashes and underscores",
|
||||||
|
"xyzmust_be_numeric": "must be numeric",
|
||||||
|
"xyzmust_be_integer": "must be integer",
|
||||||
|
"xyzmust_be_decimal": "must be decimal",
|
||||||
|
"xyzmust_be_is_natural": "must be is natural",
|
||||||
|
"xyzmust_be_is_natural_no_zero": "must be is natural without zero",
|
||||||
|
"xyzmust_be_valid_url": "must be valid url",
|
||||||
|
"xyzmust_be_valid_ip": "must be valid ip",
|
||||||
|
"xyzmust_be_valid_base64_string": "must be valid base64 string",
|
||||||
|
"xyzshould_be_between": "should be between",
|
||||||
|
"xyzshould_be_digits_between": "should be digits between",
|
||||||
|
"xyzshould_be_date": "should be date",
|
||||||
|
"xyzshould_be_datetime": "should be datetime",
|
||||||
|
"xyzshould_be_contains": "should be contains",
|
||||||
|
"xyzshould_be": "should be",
|
||||||
|
"xyzshould_be_equals": "should be equals",
|
||||||
|
"xyzBulk_Delete": "Bulk Delete",
|
||||||
|
"xyzBulk_Edit": "Bulk Edit",
|
||||||
|
"xyzBulkDeleteSuccessful": "Bulk Delete Successful",
|
||||||
|
"xyzItemsWereDeleted": "item(s) were deleted.",
|
||||||
|
"xyzThankYouForContacting": "Thank your for contacting",
|
||||||
|
"xyzContact": "Contact",
|
||||||
|
"xyzMessageIsRequired": "Message is required",
|
||||||
|
"xyzFullNameIsRequired": "Full name is required",
|
||||||
|
"xyzFullName": "Full Name",
|
||||||
|
"xyzContactNotFound": "Contact not found",
|
||||||
|
"xyzContactDeletedSuccessfully": "Contact deleted successfully",
|
||||||
|
"xyzContactDetails": "Contact Details",
|
||||||
|
"xyzInvalidEmail": "Invalid email",
|
||||||
|
"xyzContactCreatedSuccessfully": "Contact created successfully",
|
||||||
|
"xyzRewriteURL": "Rewrite URL",
|
||||||
|
"xyzTwoFactorAuthentication": "Two factor authentication",
|
||||||
|
"xyzfor": "for",
|
||||||
|
"xyzis": "is",
|
||||||
|
"xyzcode": "code",
|
||||||
|
"xyzYourVerificationCodeIs": "Your verification code is",
|
||||||
|
"xyzAccountVerification": "Account Verification",
|
||||||
|
"xyzInvalidVerificationCode": "Invalid Verification Code",
|
||||||
|
"xyzNewVerificationCodeSent": "New verification code sent",
|
||||||
|
"xyzResendTheCode": "Resent the code",
|
||||||
|
"xyzVerificationCode": "Verification code",
|
||||||
|
"xyzUserID": "User ID",
|
||||||
|
"xyzOrganizationID": "Organization ID",
|
||||||
|
"xyzPermission": "Permission",
|
||||||
|
"xyzOrganizationName": "Organization name",
|
||||||
|
"xyzOrganizationStatus": "Organization status",
|
||||||
|
"xyzUserPermissions": "User permissions",
|
||||||
|
"xyzOrganizationPermissions": "Organization permissions",
|
||||||
|
"xyxRoute": "Route",
|
||||||
|
"xyzSave Data": "Save Data",
|
||||||
|
"xyzAllRightsReserved": "All Rights Reserved.",
|
||||||
|
"xyzInvalidEmailConfirmationCode": "Invalid email confirmation code",
|
||||||
|
"xyzImageId": "Image Id",
|
||||||
|
"xyzInvalidRefreshToken": "Invalid refresh token",
|
||||||
|
"xyzTokenIDIsRequired": "Token ID is required",
|
||||||
|
"xyzRefreshTokenIsRequired": "Refresh token is required",
|
||||||
|
"xyzGoogleTokenIDIsRequired": "Google token ID token is required",
|
||||||
|
"xyzGoogleAccessTokenIsRequired": "Google access token is required",
|
||||||
|
"xyzFacebookAccessTokenIsRequired": "Facebook access token is required",
|
||||||
|
"xyzAccountIsRegisteredUsingGoogle": "Account is registered using Google. Use that instead.",
|
||||||
|
"xyzAccountIsRegisteredUsingFacebook": "Account is registered using Facebook. Use that instead.",
|
||||||
|
"xyzAccountIsRegisteredUsingEmailAndPassword": "Account is registered using Facebook. Use that instead.",
|
||||||
|
"xyzEmailAssociatedWithFacebookCouldntBeFound": "Email associated with facebook couldn't be found",
|
||||||
|
"xyzConfirm_Password": "Confirm Password",
|
||||||
|
"xyzPage Title": "Page Title",
|
||||||
|
"xyzPage slug": "Page slug",
|
||||||
|
"xyzPage Link": "Page Link",
|
||||||
|
"xyzLayout": "Layout",
|
||||||
|
"xyzContent Template Path": "Content Template Path",
|
||||||
|
"xyzHeader Template Path": "Header Template Path",
|
||||||
|
"xyzFooter Template Path": "Footer Template Path",
|
||||||
|
"xyzPage Content": "Page Content",
|
||||||
|
"xyzMarketing Title": "Marketing Title",
|
||||||
|
"xyzMarketing Slug": "Marketing Slug",
|
||||||
|
"xyzExpire At": "Expire At",
|
||||||
|
"xyzPassword Protected": "Password Protected",
|
||||||
|
"xyzStripe Cards": "Stripe Cards",
|
||||||
|
"xyzStripe Checkout": "Stripe Checkout",
|
||||||
|
"xyzPayPal Subscriptions": "PayPal Subscriptions",
|
||||||
|
"xyzPayPal Plans": "PayPal Plans",
|
||||||
|
"xyzPayPal Services": "PayPal Services",
|
||||||
|
"xyzPayPal Products": "PayPal Products",
|
||||||
|
"xyzStripe Disputes": "Stripe Disputes",
|
||||||
|
"xyzStripe Invoices": "Stripe Invoices",
|
||||||
|
"xyzStripe Payments": "Stripe Payments",
|
||||||
|
"xyzStripe Coupons": "Stripe Coupons",
|
||||||
|
"xyzStripe Subscriptions": "Stripe Subscriptions",
|
||||||
|
"xyzStripe Plans": "Stripe Plans",
|
||||||
|
"xyzStripe Services": "Stripe Services",
|
||||||
|
"xyzStripe Products": "Stripe Products",
|
||||||
|
"xyzSchedule": "Schedule",
|
||||||
|
"xyzStripe Checkout Sessions": "Stripe Checkout Sessions",
|
||||||
|
"xyzService Stripe ID": "Service Stripe ID",
|
||||||
|
"xyzCategory": "Category",
|
||||||
|
"xyzCredential ID": "Credential ID",
|
||||||
|
"xyzPlan Interval": "Plan Interval",
|
||||||
|
"xyzBilling Info": "Billing Info",
|
||||||
|
"xyzPayPal ID": "PayPal ID",
|
||||||
|
"xyzPaypal ID": "Paypal ID",
|
||||||
|
"xyzPayment Plans": "Payment Plans",
|
||||||
|
"xyzPayment Services": "Payment Services",
|
||||||
|
"xyzPayer ID": "Payer ID",
|
||||||
|
"xyzPayment Product ID": "Payment Product ID",
|
||||||
|
"xyzPayment": "Payment",
|
||||||
|
"xyzService ID": "Service ID",
|
||||||
|
"xyzService": "Service",
|
||||||
|
"xyzPaypal Product ID": "Paypal Product ID",
|
||||||
|
"xyzPayPal Product ID": "PayPal Product ID",
|
||||||
|
"xyzCustomer Stripe ID": "Customer Stripe ID",
|
||||||
|
"xyzCustomer Paypal ID": "Customer Paypal ID",
|
||||||
|
"xyzStripe": "Stripe",
|
||||||
|
"xyzPayPal": "PayPal",
|
||||||
|
"xyzRegular": "Regular",
|
||||||
|
"xyzUser Details": "User Details",
|
||||||
|
"xyzLife Time Paid": "Life Time Paid",
|
||||||
|
"xyzLife Time Free": "Life Time Free",
|
||||||
|
"xyzTrial Paid": "Trial Paid",
|
||||||
|
"xyzTrial Free": "Trial Free",
|
||||||
|
"xyzInterval": "Interval",
|
||||||
|
"xyzCoupon Stripe ID": "Coupon Stripe ID",
|
||||||
|
"xyzProduct Name": "Product Name",
|
||||||
|
"xyzDescription": "Description",
|
||||||
|
"xyzStatement descriptor": "Statement descriptor",
|
||||||
|
"xyzUnit Label": "Unit Label",
|
||||||
|
"xyzShippable": "Shippable",
|
||||||
|
"xyzPricing": "Pricing",
|
||||||
|
"xyzAmount": "Amount",
|
||||||
|
"xyzDisplay Name": "Display Name",
|
||||||
|
"xyzincomplete": "incomplete",
|
||||||
|
"xyzincomplete_expired": "incomplete_expired",
|
||||||
|
"xyztrialing": "trialing",
|
||||||
|
"xyzpast_due": "past_due",
|
||||||
|
"xyzactive": "active",
|
||||||
|
"xyzcanceled": "canceled",
|
||||||
|
"xyzunpaid": "unpaid",
|
||||||
|
"xyzrefunded": "refunded",
|
||||||
|
"xyzday": "day",
|
||||||
|
"xyzweek": "week",
|
||||||
|
"xyzmonth": "month",
|
||||||
|
"xyzyear": "year",
|
||||||
|
"xyzStripe Customer ID": "Stripe Customer ID",
|
||||||
|
"xyzCurrent Period Start": "Current Period Start",
|
||||||
|
"xyzCurrent Period End": "Current Period End",
|
||||||
|
"xyzCurrent Period Start Date": "Current Period Start Date",
|
||||||
|
"xyzCurrent Period End Date": "Current Period End Date",
|
||||||
|
"xyzCancel At Period End": "Cancel At Period End",
|
||||||
|
"xyzPlan Object": "Plan Object",
|
||||||
|
"xyzOrder ID": "Order ID",
|
||||||
|
"xyzStripe ID": "Stripe ID",
|
||||||
|
"xyzCoupon ID": "Coupon ID",
|
||||||
|
"xyzSubscription Interval": "Subscription Interval",
|
||||||
|
"xyzInterval Count": "Interval Count",
|
||||||
|
"xyzTrial Period Days": "Trial Period Days",
|
||||||
|
"xyzTrial Start": "Trial Start",
|
||||||
|
"xyzTrial End": "Trial End",
|
||||||
|
"xyzCollection Method": "Collection Method",
|
||||||
|
"xyzUser ID": "User ID",
|
||||||
|
"xyzRole ID": "Role ID",
|
||||||
|
"xyzPlan ID": "Plan ID",
|
||||||
|
"xyzSettings": "Settings",
|
||||||
|
"xyzdetails": "details",
|
||||||
|
"xyzedited_successfully": "edited successfully",
|
||||||
|
"xyzname": "name",
|
||||||
|
"xyz": "",
|
||||||
|
"xyzbadge": "Badge",
|
||||||
|
"xyzbadge_id": "Badge ID",
|
||||||
|
"xyzuser": "User",
|
||||||
|
"xyzmessage": "Message",
|
||||||
|
"xyzstatus": "Status",
|
||||||
|
"xyztitle": "Title",
|
||||||
|
"xyzdate": "Date",
|
||||||
|
"xyztime": "Time",
|
||||||
|
"xyztimezone": "Timezone",
|
||||||
|
"xyzdashboard_code": "Dashboard Code",
|
||||||
|
"xyzlink": "link",
|
||||||
|
"xyzPost": "Post",
|
||||||
|
"xyzUserDoesNotExists": "User does not exists.",
|
||||||
|
"xyzSyncCode": "Sync Code",
|
||||||
|
"xyzFontColor": "Font Color",
|
||||||
|
"xyzTimezone": "Timezone",
|
||||||
|
"xyzPacific": "Pacific",
|
||||||
|
"xyzEastern": "Eastern",
|
||||||
|
"xyzTimeFormat": "Time Format",
|
||||||
|
"xyzAM/PM": "AM/PM",
|
||||||
|
"xyz24Hours": "24 hours",
|
||||||
|
"xyzClockFormat": "Clock Format",
|
||||||
|
"xyzDigital": "Digital",
|
||||||
|
"xyzAnalog": "Analog",
|
||||||
|
"xyzDateFormat": "Date Format",
|
||||||
|
"xyzStandard": "Standard",
|
||||||
|
"xyzLocale": "Locale",
|
||||||
|
"xyzLocation": "Location",
|
||||||
|
"xyzCodeInvalidOrExpired": "Code invalid or already expired",
|
||||||
|
"xyzLatitude": "Latitude",
|
||||||
|
"xyzLongitude": "Longitude",
|
||||||
|
"xyzStartDate": "Start Date",
|
||||||
|
"xyzEndDate": "End Date",
|
||||||
|
"xyzEventId": "Event Id"
|
||||||
|
}
|
||||||
Executable
+11
@@ -0,0 +1,11 @@
|
|||||||
|
exports.validateEmail = (email) => {
|
||||||
|
const re =
|
||||||
|
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||||
|
|
||||||
|
const reStartAndEnd = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}/g
|
||||||
|
|
||||||
|
if (re.test(email) && reStartAndEnd.test(email)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
Executable
+48
@@ -0,0 +1,48 @@
|
|||||||
|
const { SchemaDirectiveVisitor, ApolloError } = require('apollo-server-express');
|
||||||
|
const { defaultFieldResolver } = require('graphql');
|
||||||
|
|
||||||
|
const { errorCodes, errors } = require('../core/strings');
|
||||||
|
const { GraphqlError, AuthenticationError } = require('../services/ErrorService');
|
||||||
|
|
||||||
|
class VerifyUser extends SchemaDirectiveVisitor {
|
||||||
|
visitFieldDefinition(field) {
|
||||||
|
const resolver = field.resolve || defaultFieldResolver;
|
||||||
|
|
||||||
|
let User;
|
||||||
|
let Credential;
|
||||||
|
|
||||||
|
field.resolve = async (root, args, context, info) => {
|
||||||
|
const { user, credentialId, db, role } = context;
|
||||||
|
Credential = await db.credential.getByFields({
|
||||||
|
status: 1,
|
||||||
|
id: credentialId,
|
||||||
|
role_id: role.roleId,
|
||||||
|
});
|
||||||
|
if (!Credential) {
|
||||||
|
throw new ApolloError(errors.ACCOUNT_DOES_NOT_EXISTS, errorCodes.account.ACCOUNT_DOES_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
User = await db.user.getByFields({
|
||||||
|
status: 1,
|
||||||
|
id: user.id,
|
||||||
|
});
|
||||||
|
if (!User) {
|
||||||
|
throw new ApolloError(errors.ACCOUNT_DOES_NOT_EXISTS, errorCodes.account.ACCOUNT_DOES_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resolver(
|
||||||
|
root,
|
||||||
|
args,
|
||||||
|
{
|
||||||
|
...context,
|
||||||
|
directives: {
|
||||||
|
...(context.directives || {}),
|
||||||
|
...(User && Credential ? { verifyUser: { user: JSON.parse(JSON.stringify(User)), credential: JSON.parse(JSON.stringify(Credential)) } } : {}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
info,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = VerifyUser;
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
const VerifyUser = require('./VerifyUser');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
verifyUser: VerifyUser,
|
||||||
|
};
|
||||||
Executable
+143
@@ -0,0 +1,143 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* activity_log Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Activity_log = sequelize.define(
|
||||||
|
"activity_log",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
name: DataTypes.STRING,
|
||||||
|
action: { type: DataTypes.STRING, validate: {} },
|
||||||
|
data: DataTypes.STRING,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "activity_log",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Activity_log);
|
||||||
|
|
||||||
|
Activity_log._preCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Activity_log._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Activity_log._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Activity_log._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Activity_log.allowFields();
|
||||||
|
allowedFields.push(Activity_log._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Activity_log.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Activity_log.associate = function (models) { };
|
||||||
|
|
||||||
|
|
||||||
|
Activity_log.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active", "2": "Suspend" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Activity_log.allowFields = function () {
|
||||||
|
return ['id', 'name', 'action', 'data', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Activity_log.labels = function () {
|
||||||
|
return ['ID', 'Name', 'Action', 'Data', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Activity_log.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['name', 'Name', ''],
|
||||||
|
['action', 'Action', 'required'],
|
||||||
|
['data', 'Data', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Activity_log.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['name', 'Name', ''],
|
||||||
|
['action', 'Action', 'required'],
|
||||||
|
['data', 'Data', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Activity_log.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'name', 'action', 'data', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Activity_log;
|
||||||
|
};
|
||||||
Executable
+156
@@ -0,0 +1,156 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* admin_operation Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Admin_operation = sequelize.define(
|
||||||
|
"admin_operation",
|
||||||
|
{
|
||||||
|
user_id: DataTypes.INTEGER,
|
||||||
|
action: DataTypes.STRING,
|
||||||
|
detail: DataTypes.TEXT,
|
||||||
|
last_ip: { type: DataTypes.STRING, validate: {} },
|
||||||
|
user_agent: { type: DataTypes.STRING, validate: {} },
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "admin_operation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Admin_operation);
|
||||||
|
|
||||||
|
Admin_operation._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Admin_operation._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Admin_operation._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Admin_operation._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Admin_operation.allowFields();
|
||||||
|
allowedFields.push(Admin_operation._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Admin_operation.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Admin_operation.associate = function (models) {
|
||||||
|
Admin_operation.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Admin_operation.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Admin_operation.allowFields = function () {
|
||||||
|
return ['user_id', 'action', 'detail', 'last_ip', 'user_agent', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Admin_operation.labels = function () {
|
||||||
|
return ['User', 'Action', 'Detail', 'Last IP', 'User Agent', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Admin_operation.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['user_id', 'User', 'required|integer'],
|
||||||
|
['action', 'Action', 'required|max[50]'],
|
||||||
|
['detail', 'Detail', 'required'],
|
||||||
|
['last_ip', 'Last IP', 'required'],
|
||||||
|
['user_agent', 'User Agent', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Admin_operation.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['user_id', 'User', ''],
|
||||||
|
['action', 'Action', ''],
|
||||||
|
['detail', 'Detail', ''],
|
||||||
|
['last_ip', 'Last IP', ''],
|
||||||
|
['user_agent', 'User Agent', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Admin_operation.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Admin_operation.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Admin_operation.get_admin_operation_user = (id, db) => {
|
||||||
|
return Admin_operation.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Admin_operation.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'user_id', 'action', 'detail', 'last_ip', 'user_agent', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Admin_operation;
|
||||||
|
};
|
||||||
Executable
+164
@@ -0,0 +1,164 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* calendar Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Calendar = sequelize.define(
|
||||||
|
"calendar",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
event_id: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
unique: true
|
||||||
|
},
|
||||||
|
title: DataTypes.STRING,
|
||||||
|
start_date: DataTypes.DATE,
|
||||||
|
end_date: DataTypes.DATE,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "calendar",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Calendar);
|
||||||
|
|
||||||
|
Calendar._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Calendar._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Calendar._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Calendar._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Calendar.allowFields();
|
||||||
|
allowedFields.push(Calendar._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Calendar.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Calendar.associate = function (models) {
|
||||||
|
Calendar.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Calendar.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Calendar.allowFields = function () {
|
||||||
|
return ["user_id", 'id', 'event_id', 'title', 'start_date', 'end_date', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Calendar.labels = function () {
|
||||||
|
return ['ID', 'Event Id', 'Title', 'Start Date', 'End Date', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Calendar.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['event_id', 'Event Id', ''],
|
||||||
|
['title', 'Title', 'required'],
|
||||||
|
['start_date', 'Start Date', 'required'],
|
||||||
|
['end_date', 'End Date', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Calendar.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['event_id', 'Event Id', ''],
|
||||||
|
['title', 'Title', 'required'],
|
||||||
|
['start_date', 'Start Date', 'required'],
|
||||||
|
['end_date', 'End Date', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Calendar.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Calendar.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Calendar.get_calendar_user = (id, db) => {
|
||||||
|
return Calendar.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Calendar.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'event_id', 'title', 'start_date', 'end_date', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Calendar;
|
||||||
|
};
|
||||||
Executable
+152
@@ -0,0 +1,152 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* code Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require('moment')
|
||||||
|
|
||||||
|
const { Op } = require('sequelize')
|
||||||
|
const { intersection } = require('lodash')
|
||||||
|
const coreModel = require('./../core/models')
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Code = sequelize.define(
|
||||||
|
'code',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
code: { type: DataTypes.STRING, unique: true },
|
||||||
|
is_used: DataTypes.INTEGER,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: 'code',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
coreModel.call(this, Code)
|
||||||
|
|
||||||
|
Code._preCreateProcessing = function (data) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
Code._postCreateProcessing = function (data) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
Code._customCountingConditions = function (data) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
Code._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {}
|
||||||
|
let allowedFields = Code.allowFields()
|
||||||
|
allowedFields.push(Code._primaryKey())
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.timeDefaultMapping = function () {
|
||||||
|
let results = []
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? '0'.i : i
|
||||||
|
let min = j < 10 ? '0'.j : j
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.associate = function (models) {
|
||||||
|
Code.belongsTo(models.user, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
as: 'user',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.is_used_mapping = function (is_used) {
|
||||||
|
const mapping = { 0: 'No', 1: 'Yes' }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping
|
||||||
|
else return mapping[is_used]
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.status_mapping = function (status) {
|
||||||
|
const mapping = { 0: 'Inactive', 1: 'Active', 2: 'Suspend' }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping
|
||||||
|
else return mapping[status]
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.allowFields = function () {
|
||||||
|
return ['user_id', 'id', 'code', 'is_used', 'status']
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.labels = function () {
|
||||||
|
return ['ID', 'Code', 'Is Used', 'Status']
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['code', 'Code', 'required'],
|
||||||
|
['is_used', 'Is Used', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['code', 'Code', 'required'],
|
||||||
|
['is_used', 'Is Used', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Code.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.user,
|
||||||
|
as: 'user',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
Code.get_code_user = (id, db) => {
|
||||||
|
return Code.findByPk(id, { include: [{ model: db.user, as: 'user' }] })
|
||||||
|
}
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Code.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
['id', 'code', 'is_used', 'status', 'created_at', 'updated_at'],
|
||||||
|
Object.keys(fields)
|
||||||
|
)
|
||||||
|
} else return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return Code
|
||||||
|
}
|
||||||
Executable
+198
@@ -0,0 +1,198 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* credential Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Credential = sequelize.define(
|
||||||
|
"credential",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
unique: true
|
||||||
|
},
|
||||||
|
password: DataTypes.STRING,
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
verify: DataTypes.INTEGER,
|
||||||
|
role_id: DataTypes.INTEGER,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
two_factor_authentication: DataTypes.INTEGER,
|
||||||
|
force_password_change: DataTypes.BOOLEAN,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "credential",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Credential);
|
||||||
|
|
||||||
|
Credential._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
data.two_factor_authentication = 0;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Credential._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Credential._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Credential._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Credential.allowFields();
|
||||||
|
allowedFields.push(Credential._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Credential.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Credential.associate = function (models) {
|
||||||
|
Credential.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Credential.verify_mapping = function (verify) {
|
||||||
|
const mapping = { "0": "Not verified", "1": "Verified" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[verify];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Credential.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active", "2": "Suspend" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Credential.role_id_mapping = function (role_id) {
|
||||||
|
const mapping = { "1": "Member", "2": "Admin" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[role_id];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Credential.two_factor_authentication_mapping = function (two_factor_authentication) {
|
||||||
|
const mapping = { "0": "No", "1": "Yes" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[two_factor_authentication];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Credential.allowFields = function () {
|
||||||
|
return ["user_id", 'id', 'email', 'password', 'type', 'verify', 'role_id', 'status', 'two_factor_authentication', 'force_password_change',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Credential.labels = function () {
|
||||||
|
return ['ID', 'Email', 'Password', 'Type', 'Verified', 'Role', 'Status', 'Two factor authentication', '',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Credential.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['email', 'Email', 'required|valid_email'],
|
||||||
|
['password', 'Password', 'required'],
|
||||||
|
['type', 'Type', ''],
|
||||||
|
['verify', 'Verified', ''],
|
||||||
|
['role_id', 'Role', ''],
|
||||||
|
['status', 'Status', ''],
|
||||||
|
['two_factor_authentication', 'Two factor authentication', ''],
|
||||||
|
['force_password_change', '', ''],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Credential.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['email', 'Email', 'required|valid_email'],
|
||||||
|
['password', 'Password', ''],
|
||||||
|
['type', 'Type', ''],
|
||||||
|
['verify', 'Verified', ''],
|
||||||
|
['role_id', 'Role', ''],
|
||||||
|
['status', 'Status', 'required|in_list[0,1,2]'],
|
||||||
|
['two_factor_authentication', 'Two factor authentication', ''],
|
||||||
|
['force_password_change', '', ''],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Credential.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Credential.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Credential.get_credential_user = (id, db) => {
|
||||||
|
return Credential.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Credential.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'email', 'password', 'type', 'verify', 'role_id', 'status', 'two_factor_authentication', 'force_password_change', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Credential;
|
||||||
|
};
|
||||||
Executable
+149
@@ -0,0 +1,149 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* email Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Email = sequelize.define(
|
||||||
|
"email",
|
||||||
|
{
|
||||||
|
slug: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
unique: true
|
||||||
|
},
|
||||||
|
subject: DataTypes.TEXT,
|
||||||
|
tag: DataTypes.TEXT,
|
||||||
|
html: DataTypes.TEXT,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "email",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Email);
|
||||||
|
|
||||||
|
Email._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Email._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Email._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Email._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Email.allowFields();
|
||||||
|
allowedFields.push(Email._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Email.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Email.associate = function (models) { };
|
||||||
|
|
||||||
|
|
||||||
|
Email.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Email.type_mapping = function (type) {
|
||||||
|
const mapping = { "0": "Forgot_token", "1": "Access token", "2": "Refresh_token", "3": "Other", "4": "Api Key", "5": "Api Secret", "6": "Verify" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[type];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Email.allowFields = function () {
|
||||||
|
return ['slug', 'subject', 'tag', 'html', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Email.labels = function () {
|
||||||
|
return ['Email Type', 'Subject', 'Replacement Tags', 'Email Body', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Email.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['slug', 'Email Type', 'required|is_unique[email.slug]'],
|
||||||
|
['subject', 'Subject', 'required'],
|
||||||
|
['tag', 'Replacement Tags', 'required'],
|
||||||
|
['html', 'Email Body', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Email.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['slug', 'Email Type', ''],
|
||||||
|
['subject', 'Subject', 'required'],
|
||||||
|
['tag', 'Replacement Tags', ''],
|
||||||
|
['html', 'Email Body', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Email.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'slug', 'subject', 'tag', 'html', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Email;
|
||||||
|
};
|
||||||
Executable
+173
@@ -0,0 +1,173 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* image Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Image = sequelize.define(
|
||||||
|
"image",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
url: DataTypes.TEXT,
|
||||||
|
caption: DataTypes.TEXT,
|
||||||
|
width: DataTypes.INTEGER,
|
||||||
|
height: DataTypes.INTEGER,
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "image",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Image);
|
||||||
|
|
||||||
|
Image._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
data.refer = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Image._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Image._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Image._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Image.allowFields();
|
||||||
|
allowedFields.push(Image._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Image.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Image.associate = function (models) {
|
||||||
|
Image.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Image.type_mapping = function (type) {
|
||||||
|
const mapping = { "0": "Server Hosted", "1": "External Link", "2": "S3", "3": "Cloudinary", "4": "File", "5": "External File", "6": "Custom" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[type];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Image.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Image.allowFields = function () {
|
||||||
|
return ["user_id", 'id', 'url', 'caption', 'width', 'height', 'type', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Image.labels = function () {
|
||||||
|
return ['ID', 'URL', 'Caption', 'Width', 'Height', 'Image Type', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Image.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['url', 'URL', 'required'],
|
||||||
|
['caption', 'Caption', ''],
|
||||||
|
['width', 'Width', ''],
|
||||||
|
['height', 'Height', ''],
|
||||||
|
['type', 'Image Type', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Image.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['url', 'URL', 'required'],
|
||||||
|
['caption', 'Caption', ''],
|
||||||
|
['width', 'Width', ''],
|
||||||
|
['height', 'Height', ''],
|
||||||
|
['type', 'Image Type', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Image.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Image.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Image.get_image_user = (id, db) => {
|
||||||
|
return Image.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Image.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'url', 'caption', 'width', 'height', 'type', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Image;
|
||||||
|
};
|
||||||
Executable
+69
@@ -0,0 +1,69 @@
|
|||||||
|
'use strict';
|
||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2020*/
|
||||||
|
/**
|
||||||
|
* Sequelize File
|
||||||
|
* @copyright 2020 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
let Sequelize = require('sequelize');
|
||||||
|
const { DataTypes } = require('sequelize');
|
||||||
|
const basename = path.basename(__filename);
|
||||||
|
const config = {
|
||||||
|
DB_DATABASE: 'mysql',
|
||||||
|
DB_USERNAME: 'root',
|
||||||
|
DB_PASSWORD: 'root',
|
||||||
|
DB_ADAPTER: 'mysql',
|
||||||
|
DB_NAME: 'day_1',
|
||||||
|
DB_HOSTNAME: 'localhost',
|
||||||
|
DB_PORT: 3306,
|
||||||
|
};
|
||||||
|
|
||||||
|
let db = {};
|
||||||
|
|
||||||
|
let sequelize = new Sequelize(config.DB_DATABASE, config.DB_USERNAME, config.DB_PASSWORD, {
|
||||||
|
dialect: config.DB_ADAPTER,
|
||||||
|
username: config.DB_USERNAME,
|
||||||
|
password: config.DB_PASSWORD,
|
||||||
|
database: config.DB_NAME,
|
||||||
|
host: config.DB_HOSTNAME,
|
||||||
|
port: config.DB_PORT,
|
||||||
|
logging: console.log,
|
||||||
|
timezone: '-04:00',
|
||||||
|
pool: {
|
||||||
|
maxConnections: 1,
|
||||||
|
minConnections: 0,
|
||||||
|
maxIdleTime: 100,
|
||||||
|
},
|
||||||
|
define: {
|
||||||
|
timestamps: false,
|
||||||
|
underscoredAll: true,
|
||||||
|
underscored: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// sequelize.sync({ force: true });
|
||||||
|
|
||||||
|
fs.readdirSync(__dirname)
|
||||||
|
.filter((file) => {
|
||||||
|
return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js';
|
||||||
|
})
|
||||||
|
.forEach((file) => {
|
||||||
|
var model = require(path.join(__dirname, file))(sequelize, DataTypes);
|
||||||
|
db[model.name] = model;
|
||||||
|
});
|
||||||
|
|
||||||
|
Object.keys(db).forEach((modelName) => {
|
||||||
|
if (db[modelName].associate) {
|
||||||
|
db[modelName].associate(db);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
db.sequelize = sequelize;
|
||||||
|
db.Sequelize = Sequelize;
|
||||||
|
|
||||||
|
module.exports = db;
|
||||||
Executable
+152
@@ -0,0 +1,152 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* link Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Link = sequelize.define(
|
||||||
|
"link",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
link: DataTypes.STRING,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "link",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Link);
|
||||||
|
|
||||||
|
Link._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Link._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Link._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Link._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Link.allowFields();
|
||||||
|
allowedFields.push(Link._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Link.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Link.associate = function (models) {
|
||||||
|
Link.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Link.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Link.allowFields = function () {
|
||||||
|
return ["user_id", 'id', 'link', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Link.labels = function () {
|
||||||
|
return ['ID', 'Link', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Link.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['link', 'Link', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Link.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['link', 'Link', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Link.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Link.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Link.get_link_user = (id, db) => {
|
||||||
|
return Link.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Link.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'link', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Link;
|
||||||
|
};
|
||||||
Executable
+153
@@ -0,0 +1,153 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* member_operation Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Member_operation = sequelize.define(
|
||||||
|
"member_operation",
|
||||||
|
{
|
||||||
|
action: DataTypes.STRING,
|
||||||
|
detail: DataTypes.TEXT,
|
||||||
|
last_ip: { type: DataTypes.STRING, validate: {} },
|
||||||
|
user_agent: { type: DataTypes.STRING, validate: {} },
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "member_operation",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Member_operation);
|
||||||
|
|
||||||
|
Member_operation._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Member_operation._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Member_operation._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Member_operation._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Member_operation.allowFields();
|
||||||
|
allowedFields.push(Member_operation._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Member_operation.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Member_operation.associate = function (models) {
|
||||||
|
Member_operation.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Member_operation.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Member_operation.allowFields = function () {
|
||||||
|
return ["user_id", 'action', 'detail', 'last_ip', 'user_agent', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Member_operation.labels = function () {
|
||||||
|
return ['Action', 'Detail', 'Last IP', 'User Agent', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Member_operation.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['action', 'Action', 'required|max[50]'],
|
||||||
|
['detail', 'Detail', 'required'],
|
||||||
|
['last_ip', 'Last IP', 'required'],
|
||||||
|
['user_agent', 'User Agent', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Member_operation.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['action', 'Action', ''],
|
||||||
|
['detail', 'Detail', ''],
|
||||||
|
['last_ip', 'Last IP', ''],
|
||||||
|
['user_agent', 'User Agent', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Member_operation.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Member_operation.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Member_operation.get_member_operation_user = (id, db) => {
|
||||||
|
return Member_operation.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Member_operation.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'action', 'detail', 'last_ip', 'user_agent', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Member_operation;
|
||||||
|
};
|
||||||
Executable
+152
@@ -0,0 +1,152 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* note Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Note = sequelize.define(
|
||||||
|
"note",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
message: DataTypes.STRING,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "note",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Note);
|
||||||
|
|
||||||
|
Note._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Note._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Note._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Note._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Note.allowFields();
|
||||||
|
allowedFields.push(Note._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Note.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Note.associate = function (models) {
|
||||||
|
Note.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Note.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Note.allowFields = function () {
|
||||||
|
return ["user_id", 'id', 'message', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Note.labels = function () {
|
||||||
|
return ['ID', 'Message', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Note.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['message', 'Message', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Note.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['message', 'Message', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Note.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Note.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Note.get_note_user = (id, db) => {
|
||||||
|
return Note.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Note.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'message', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Note;
|
||||||
|
};
|
||||||
Executable
+158
@@ -0,0 +1,158 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* profile Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Profile = sequelize.define(
|
||||||
|
"profile",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
timezone: DataTypes.STRING,
|
||||||
|
dashboard_code: DataTypes.STRING,
|
||||||
|
code: DataTypes.STRING,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "profile",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Profile);
|
||||||
|
|
||||||
|
Profile._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Profile._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Profile._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Profile._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Profile.allowFields();
|
||||||
|
allowedFields.push(Profile._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Profile.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Profile.associate = function (models) {
|
||||||
|
Profile.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "profile",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Profile.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Profile.allowFields = function () {
|
||||||
|
return ["user_id", 'id', 'timezone', 'dashboard_code', 'code', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Profile.labels = function () {
|
||||||
|
return ['ID', 'Timezone', 'Dashboard Code', 'Code', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Profile.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['timezone', 'Timezone', 'required'],
|
||||||
|
['dashboard_code', 'Dashboard Code', 'required'],
|
||||||
|
['code', 'Code', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Profile.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['timezone', 'Timezone', 'required'],
|
||||||
|
['dashboard_code', 'Dashboard Code', 'required'],
|
||||||
|
['code', 'Code', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Profile.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Profile.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "profile"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Profile.get_profile_user = (id, db) => {
|
||||||
|
return Profile.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Profile.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'timezone', 'dashboard_code', 'code', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Profile;
|
||||||
|
};
|
||||||
Executable
+163
@@ -0,0 +1,163 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* refer_log Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Refer_log = sequelize.define(
|
||||||
|
"refer_log",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
referrer_user_id: DataTypes.INTEGER,
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "refer_log",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Refer_log);
|
||||||
|
|
||||||
|
Refer_log._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Refer_log._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Refer_log._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Refer_log._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Refer_log.allowFields();
|
||||||
|
allowedFields.push(Refer_log._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Refer_log.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Refer_log.associate = function (models) {
|
||||||
|
Refer_log.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Refer_log.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Pending", "1": "Confirmed", "2": "Paid" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Refer_log.type_mapping = function (type) {
|
||||||
|
const mapping = { "0": "user" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[type];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Refer_log.allowFields = function () {
|
||||||
|
return ['id', 'referrer_user_id', 'type', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Refer_log.labels = function () {
|
||||||
|
return ['ID', 'Referrer User', 'Type', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Refer_log.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['referrer_user_id', 'Referrer User', 'required|integer'],
|
||||||
|
['type', 'Type', 'required|integer'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Refer_log.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['referrer_user_id', 'Referrer User', ''],
|
||||||
|
['type', 'Type', 'required|integer'],
|
||||||
|
['status', 'Status', ''],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Refer_log.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Refer_log.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Refer_log.get_refer_log_user = (id, db) => {
|
||||||
|
return Refer_log.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Refer_log.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'referrer_user_id', 'type', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Refer_log;
|
||||||
|
};
|
||||||
Executable
+137
@@ -0,0 +1,137 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* role Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Role = sequelize.define(
|
||||||
|
"role",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
name: { type: DataTypes.STRING, validate: {} },
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "role",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Role);
|
||||||
|
|
||||||
|
Role._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Role._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Role._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Role._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Role.allowFields();
|
||||||
|
allowedFields.push(Role._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Role.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Role.associate = function (models) { };
|
||||||
|
|
||||||
|
|
||||||
|
Role.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Pending", "1": "Confirmed", "2": "Paid" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Role.allowFields = function () {
|
||||||
|
return ['id', 'name', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Role.labels = function () {
|
||||||
|
return ['ID', 'Role Name', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Role.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['name', 'Role Name', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Role.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['name', 'Role Name', 'required'],
|
||||||
|
['status', 'Status', ''],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Role.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'name', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Role;
|
||||||
|
};
|
||||||
Executable
+165
@@ -0,0 +1,165 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* setting Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Setting = sequelize.define(
|
||||||
|
"setting",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
key: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
unique: true
|
||||||
|
},
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
value: DataTypes.TEXT,
|
||||||
|
maintenance: DataTypes.INTEGER,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "setting",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Setting);
|
||||||
|
|
||||||
|
Setting._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Setting._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Setting._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Setting._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Setting.allowFields();
|
||||||
|
allowedFields.push(Setting._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Setting.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Setting.associate = function (models) { };
|
||||||
|
|
||||||
|
|
||||||
|
Setting.type_mapping = function (type) {
|
||||||
|
const mapping = { "0": "text", "1": "select", "2": "number", "3": "image", "4": "read_only" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[type];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Setting.maintenance_mapping = function (maintenance) {
|
||||||
|
const mapping = { "0": "No", "1": "Yes" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[maintenance];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Setting.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Pending", "1": "Confirmed", "2": "Paid" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Setting.allowFields = function () {
|
||||||
|
return ['id', 'key', 'type', 'value', 'maintenance', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Setting.labels = function () {
|
||||||
|
return ['ID', 'Setting Field', 'Setting Type', 'Setting Value', 'Setting Type', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Setting.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['key', 'Setting Field', 'required'],
|
||||||
|
['type', 'Setting Type', 'required'],
|
||||||
|
['value', 'Setting Value', 'required'],
|
||||||
|
['maintenance', 'Setting Type', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Setting.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['key', 'Setting Field', ''],
|
||||||
|
['type', 'Setting Type', ''],
|
||||||
|
['value', 'Setting Value', 'required'],
|
||||||
|
['maintenance', 'Setting Type', ''],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Setting.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'key', 'type', 'value', 'maintenance', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Setting;
|
||||||
|
};
|
||||||
Executable
+135
@@ -0,0 +1,135 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* sms Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Sms = sequelize.define(
|
||||||
|
"sms",
|
||||||
|
{
|
||||||
|
slug: { type: DataTypes.STRING, validate: {} },
|
||||||
|
tag: DataTypes.TEXT,
|
||||||
|
content: DataTypes.TEXT,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "sms",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Sms);
|
||||||
|
|
||||||
|
Sms._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Sms._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Sms._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Sms._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Sms.allowFields();
|
||||||
|
allowedFields.push(Sms._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Sms.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Sms.associate = function (models) { };
|
||||||
|
|
||||||
|
|
||||||
|
Sms.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Sms.allowFields = function () {
|
||||||
|
return ['slug', 'tag', 'content', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Sms.labels = function () {
|
||||||
|
return ['SMS Slug', 'Replacement Tags', 'SMS Body', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Sms.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['slug', 'SMS Slug', 'required|is_unique[sms.slug]'],
|
||||||
|
['tag', 'Replacement Tags', 'required'],
|
||||||
|
['content', 'SMS Body', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Sms.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['slug', 'SMS Slug', ''],
|
||||||
|
['tag', 'Replacement Tags', ''],
|
||||||
|
['content', 'SMS Body', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Sms.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'slug', 'tag', 'content', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Sms;
|
||||||
|
};
|
||||||
Executable
+174
@@ -0,0 +1,174 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* token Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require("moment");
|
||||||
|
;
|
||||||
|
const { Op } = require("sequelize");
|
||||||
|
const { intersection } = require('lodash');
|
||||||
|
const coreModel = require('./../core/models');
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const Token = sequelize.define(
|
||||||
|
"token",
|
||||||
|
{
|
||||||
|
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
token: DataTypes.TEXT,
|
||||||
|
data: DataTypes.TEXT,
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
ttl: DataTypes.INTEGER,
|
||||||
|
issue_at: DataTypes.DATE,
|
||||||
|
expire_at: DataTypes.DATE,
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: false,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: "token",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
coreModel.call(this, Token);
|
||||||
|
|
||||||
|
Token._preCreateProcessing = function (data) {
|
||||||
|
data.status = 1;
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Token._postCreateProcessing = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
Token._customCountingConditions = function (data) {
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
Token._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {};
|
||||||
|
let allowedFields = Token.allowFields();
|
||||||
|
allowedFields.push(Token._primaryKey());
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData;
|
||||||
|
};
|
||||||
|
|
||||||
|
Token.timeDefaultMapping = function () {
|
||||||
|
let results = [];
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? "0".i : i;
|
||||||
|
let min = j < 10 ? "0".j : j;
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
};
|
||||||
|
|
||||||
|
Token.associate = function (models) {
|
||||||
|
Token.belongsTo(models.user, {
|
||||||
|
foreignKey: "user_id",
|
||||||
|
as: "user",
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Token.status_mapping = function (status) {
|
||||||
|
const mapping = { "0": "Inactive", "1": "Active" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[status];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Token.type_mapping = function (type) {
|
||||||
|
const mapping = { "0": "Forgot_token", "1": "Access token", "2": "Refresh_token", "3": "Other", "4": "Api Key", "5": "Api Secret", "6": "Verify" }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping;
|
||||||
|
else return mapping[type];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Token.allowFields = function () {
|
||||||
|
return ["user_id", 'id', 'token', 'data', 'type', 'ttl', 'issue_at', 'expire_at', 'status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Token.labels = function () {
|
||||||
|
return ['ID', 'Token', 'Data', 'Token Type', 'Time To Live', 'Issue at', 'Expire at', 'Status',];
|
||||||
|
};
|
||||||
|
|
||||||
|
Token.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['token', 'Token', 'required'],
|
||||||
|
['data', 'Data', 'required'],
|
||||||
|
['type', 'Token Type', 'required|integer'],
|
||||||
|
['ttl', 'Time To Live', 'required|integer'],
|
||||||
|
['issue_at', 'Issue at', 'required'],
|
||||||
|
['expire_at', 'Expire at', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
Token.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['token', 'Token', 'required'],
|
||||||
|
['data', 'Data', 'required'],
|
||||||
|
['type', 'Token Type', 'required|integer'],
|
||||||
|
['ttl', 'Time To Live', 'required|integer'],
|
||||||
|
['issue_at', 'Issue at', 'required'],
|
||||||
|
['expire_at', 'Expire at', 'required'],
|
||||||
|
['status', 'Status', 'required|integer'],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Token.get_user_paginated = function (db, ...rest) {
|
||||||
|
return Token.getPaginated(...rest, [{
|
||||||
|
model: db.user,
|
||||||
|
as: "user"
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Token.get_token_user = (id, db) => {
|
||||||
|
return Token.findByPk(id, { include: [{ model: db.user, as: "user" }] });
|
||||||
|
};
|
||||||
|
|
||||||
|
// ex
|
||||||
|
Token.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id', 'token', 'data', 'type', 'ttl', 'issue_at', 'expire_at', 'status', 'created_at', 'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields),
|
||||||
|
);
|
||||||
|
} else return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Token;
|
||||||
|
};
|
||||||
Executable
+482
@@ -0,0 +1,482 @@
|
|||||||
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||||||
|
/**
|
||||||
|
* user Model
|
||||||
|
* @copyright 2021 Manaknightdigital Inc.
|
||||||
|
* @link https://manaknightdigital.com
|
||||||
|
* @license Proprietary Software licensing
|
||||||
|
* @author Ryan Wong
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
const moment = require('moment')
|
||||||
|
|
||||||
|
const { Op } = require('sequelize')
|
||||||
|
const { intersection } = require('lodash')
|
||||||
|
const coreModel = require('./../core/models')
|
||||||
|
|
||||||
|
module.exports = (sequelize, DataTypes) => {
|
||||||
|
const User = sequelize.define(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true,
|
||||||
|
},
|
||||||
|
status: DataTypes.INTEGER,
|
||||||
|
first_name: DataTypes.STRING,
|
||||||
|
last_name: DataTypes.STRING,
|
||||||
|
phone: DataTypes.STRING,
|
||||||
|
image: DataTypes.TEXT,
|
||||||
|
image_id: DataTypes.INTEGER,
|
||||||
|
refer: DataTypes.STRING,
|
||||||
|
profile_id: DataTypes.INTEGER,
|
||||||
|
role_id: DataTypes.INTEGER,
|
||||||
|
stripe_uid: DataTypes.STRING,
|
||||||
|
paypal_uid: DataTypes.STRING,
|
||||||
|
font_color: DataTypes.STRING,
|
||||||
|
time_zone: DataTypes.STRING,
|
||||||
|
time_format: DataTypes.INTEGER,
|
||||||
|
clock_format: DataTypes.INTEGER,
|
||||||
|
date_format: DataTypes.INTEGER,
|
||||||
|
location: DataTypes.STRING,
|
||||||
|
lat: DataTypes.FLOAT,
|
||||||
|
lng: DataTypes.FLOAT,
|
||||||
|
expire_at: DataTypes.DATEONLY,
|
||||||
|
created_at: DataTypes.DATEONLY,
|
||||||
|
updated_at: DataTypes.DATE,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true,
|
||||||
|
freezeTableName: true,
|
||||||
|
tableName: 'user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
underscoredAll: false,
|
||||||
|
underscored: false,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
coreModel.call(this, User)
|
||||||
|
|
||||||
|
User._preCreateProcessing = function (data) {
|
||||||
|
data.image = 'https://i.imgur.com/AzJ7DRw.png'
|
||||||
|
data.refer = Math.round(Math.random() * 1000000000000, 0)
|
||||||
|
data.status = 1
|
||||||
|
data.verify = 0
|
||||||
|
data.font_color = '#ffffff'
|
||||||
|
data.time_zone = 'UTC'
|
||||||
|
data.time_format = 1
|
||||||
|
data.clock_format = 1
|
||||||
|
data.date_format = 1
|
||||||
|
data.location = ''
|
||||||
|
if (!data.profile_id) {
|
||||||
|
data.profile_id = 0
|
||||||
|
}
|
||||||
|
if (data.type) {
|
||||||
|
data.type = 'n'
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
User._postCreateProcessing = function (data) {
|
||||||
|
if (data.password && data.password.length < 1) {
|
||||||
|
delete data.password
|
||||||
|
}
|
||||||
|
if (data.image && data.image.length < 1) {
|
||||||
|
delete data.image
|
||||||
|
}
|
||||||
|
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
User._customCountingConditions = function (data) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
User._filterAllowKeys = function (data) {
|
||||||
|
let cleanData = {}
|
||||||
|
let allowedFields = User.allowFields()
|
||||||
|
allowedFields.push(User._primaryKey())
|
||||||
|
|
||||||
|
for (const key in data) {
|
||||||
|
if (allowedFields.includes(key)) {
|
||||||
|
cleanData[key] = data[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cleanData
|
||||||
|
}
|
||||||
|
|
||||||
|
User.timeDefaultMapping = function () {
|
||||||
|
let results = []
|
||||||
|
for (let i = 0; i < 24; i++) {
|
||||||
|
for (let j = 0; j < 60; j++) {
|
||||||
|
let hour = i < 10 ? '0'.i : i
|
||||||
|
let min = j < 10 ? '0'.j : j
|
||||||
|
results[i * 60 + j] = `${hour}:${min}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
User.associate = function (models) {
|
||||||
|
User.hasMany(models.refer_log, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasOne(models.credential, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasMany(models.token, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasOne(models.code, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasMany(models.admin_operation, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasMany(models.member_operation, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasMany(models.image, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasMany(models.note, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasMany(models.calendar, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasOne(models.profile, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
User.hasMany(models.link, {
|
||||||
|
foreignKey: 'user_id',
|
||||||
|
constraints: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
User.status_mapping = function (status) {
|
||||||
|
const mapping = { 0: 'Inactive', 1: 'Active', 2: 'Suspend' }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping
|
||||||
|
else return mapping[status]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.time_format_mapping = function (time_format) {
|
||||||
|
const mapping = { 1: 'AM/PM', 2: '24 hours' }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping
|
||||||
|
else return mapping[time_format]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.clock_format_mapping = function (clock_format) {
|
||||||
|
const mapping = { 1: 'Digital', 2: 'Analog' }
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping
|
||||||
|
else return mapping[clock_format]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.date_format_mapping = function (date_format) {
|
||||||
|
const mapping = {
|
||||||
|
1: 'Standard (dd/mm/yyyy)',
|
||||||
|
2: 'Locale (Wed, April 1, 2021)',
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arguments.length === 0) return mapping
|
||||||
|
else return mapping[date_format]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.allowFields = function () {
|
||||||
|
return [
|
||||||
|
'id',
|
||||||
|
'status',
|
||||||
|
'first_name',
|
||||||
|
'last_name',
|
||||||
|
'phone',
|
||||||
|
'image',
|
||||||
|
'image_id',
|
||||||
|
'refer',
|
||||||
|
'profile_id',
|
||||||
|
'role_id',
|
||||||
|
'stripe_uid',
|
||||||
|
'paypal_uid',
|
||||||
|
'font_color',
|
||||||
|
'time_zone',
|
||||||
|
'time_format',
|
||||||
|
'clock_format',
|
||||||
|
'date_format',
|
||||||
|
'location',
|
||||||
|
'lat',
|
||||||
|
'lng',
|
||||||
|
'expire_at',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.labels = function () {
|
||||||
|
return [
|
||||||
|
'ID',
|
||||||
|
'Status',
|
||||||
|
'First Name',
|
||||||
|
'Last Name',
|
||||||
|
'Phone #',
|
||||||
|
'Image',
|
||||||
|
'Image ID',
|
||||||
|
'Refer Code',
|
||||||
|
'Profile ID',
|
||||||
|
'Role ID',
|
||||||
|
'Stripe ID',
|
||||||
|
'PayPal ID',
|
||||||
|
'Font Color',
|
||||||
|
'Timezone',
|
||||||
|
'Time Format',
|
||||||
|
'Clock Format',
|
||||||
|
'Date Format',
|
||||||
|
'Location',
|
||||||
|
'Latitude',
|
||||||
|
'Longitude',
|
||||||
|
'Expire At',
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.validationRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['status', 'Status', ''],
|
||||||
|
['first_name', 'First Name', 'required'],
|
||||||
|
['last_name', 'Last Name', 'required'],
|
||||||
|
['phone', 'Phone #', ''],
|
||||||
|
['image', 'Image', ''],
|
||||||
|
['image_id', 'Image ID', ''],
|
||||||
|
['refer', 'Refer Code', ''],
|
||||||
|
['profile_id', 'Profile ID', ''],
|
||||||
|
['role_id', 'Role ID', ''],
|
||||||
|
['stripe_uid', 'Stripe ID', ''],
|
||||||
|
['paypal_uid', 'PayPal ID', ''],
|
||||||
|
['font_color', 'Font Color', ''],
|
||||||
|
['time_zone', 'Timezone', 'required'],
|
||||||
|
['time_format', 'Time Format', 'required|integer'],
|
||||||
|
['clock_format', 'Clock Format', 'required|integer'],
|
||||||
|
['date_format', 'Date Format', 'required|integer'],
|
||||||
|
['location', 'Location', ''],
|
||||||
|
['lat', 'Latitude', 'required|integer'],
|
||||||
|
['lng', 'Longitude', ''],
|
||||||
|
['expire_at', 'Expire At', ''],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.validationEditRules = function () {
|
||||||
|
return [
|
||||||
|
['id', 'ID', ''],
|
||||||
|
['status', 'Status', ''],
|
||||||
|
['first_name', 'First Name', ''],
|
||||||
|
['last_name', 'Last Name', ''],
|
||||||
|
['phone', 'Phone #', ''],
|
||||||
|
['image', 'Image', ''],
|
||||||
|
['image_id', 'Image ID', ''],
|
||||||
|
['refer', 'Refer Code', ''],
|
||||||
|
['profile_id', 'Profile ID', ''],
|
||||||
|
['role_id', 'Role ID', ''],
|
||||||
|
['stripe_uid', 'Stripe ID', ''],
|
||||||
|
['paypal_uid', 'PayPal ID', ''],
|
||||||
|
['font_color', 'Font Color', ''],
|
||||||
|
['time_zone', 'Timezone', 'required'],
|
||||||
|
['time_format', 'Time Format', 'required|integer'],
|
||||||
|
['clock_format', 'Clock Format', 'required|integer'],
|
||||||
|
['date_format', 'Date Format', 'required|integer'],
|
||||||
|
['location', 'Location', ''],
|
||||||
|
['lat', 'Latitude', ''],
|
||||||
|
['lng', 'Longitude', ''],
|
||||||
|
['expire_at', 'Expire At', ''],
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_refer_log_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.refer_log,
|
||||||
|
as: 'refer_log',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_credential_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.credential,
|
||||||
|
as: 'credential',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_token_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.token,
|
||||||
|
as: 'token',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_code_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.code,
|
||||||
|
as: 'code',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_admin_operation_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.admin_operation,
|
||||||
|
as: 'admin_operation',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_member_operation_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.member_operation,
|
||||||
|
as: 'member_operation',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_image_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.image,
|
||||||
|
as: 'image',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_note_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.note,
|
||||||
|
as: 'note',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_calendar_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.calendar,
|
||||||
|
as: 'calendar',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_profile_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.profile,
|
||||||
|
as: 'profile',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_link_paginated = function (db, ...rest) {
|
||||||
|
return User.getPaginated(...rest, [
|
||||||
|
{
|
||||||
|
model: db.link,
|
||||||
|
as: 'link',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
User.get_user_refer_log = (id, db) => {
|
||||||
|
return User.findByPk(id, {
|
||||||
|
include: [{ model: db.refer_log, as: 'refer_log' }],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
User.get_user_credential = (id, db) => {
|
||||||
|
return User.findByPk(id, {
|
||||||
|
include: [{ model: db.credential, as: 'credential' }],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
User.get_user_token = (id, db) => {
|
||||||
|
return User.findByPk(id, { include: [{ model: db.token, as: 'token' }] })
|
||||||
|
}
|
||||||
|
User.get_user_code = (id, db) => {
|
||||||
|
return User.findByPk(id, { include: [{ model: db.code, as: 'code' }] })
|
||||||
|
}
|
||||||
|
User.get_user_admin_operation = (id, db) => {
|
||||||
|
return User.findByPk(id, {
|
||||||
|
include: [{ model: db.admin_operation, as: 'admin_operation' }],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
User.get_user_member_operation = (id, db) => {
|
||||||
|
return User.findByPk(id, {
|
||||||
|
include: [{ model: db.member_operation, as: 'member_operation' }],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
User.get_user_image = (id, db) => {
|
||||||
|
return User.findByPk(id, { include: [{ model: db.image, as: 'image' }] })
|
||||||
|
}
|
||||||
|
User.get_user_note = (id, db) => {
|
||||||
|
return User.findByPk(id, { include: [{ model: db.note, as: 'note' }] })
|
||||||
|
}
|
||||||
|
User.get_user_calendar = (id, db) => {
|
||||||
|
return User.findByPk(id, {
|
||||||
|
include: [{ model: db.calendar, as: 'calendar' }],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
User.get_user_profile = (id, db) => {
|
||||||
|
return User.findByPk(id, {
|
||||||
|
include: [{ model: db.profile, as: 'profile' }],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
User.get_user_link = (id, db) => {
|
||||||
|
return User.findByPk(id, { include: [{ model: db.link, as: 'link' }] })
|
||||||
|
}
|
||||||
|
|
||||||
|
// ex
|
||||||
|
User.intersection = function (fields) {
|
||||||
|
if (fields) {
|
||||||
|
return intersection(
|
||||||
|
[
|
||||||
|
'id',
|
||||||
|
'status',
|
||||||
|
'first_name',
|
||||||
|
'last_name',
|
||||||
|
'phone',
|
||||||
|
'image',
|
||||||
|
'image_id',
|
||||||
|
'refer',
|
||||||
|
'profile_id',
|
||||||
|
'role_id',
|
||||||
|
'stripe_uid',
|
||||||
|
'paypal_uid',
|
||||||
|
'font_color',
|
||||||
|
'time_zone',
|
||||||
|
'time_format',
|
||||||
|
'clock_format',
|
||||||
|
'date_format',
|
||||||
|
'location',
|
||||||
|
'lat',
|
||||||
|
'lng',
|
||||||
|
'expire_at',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
],
|
||||||
|
Object.keys(fields)
|
||||||
|
)
|
||||||
|
} else return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return User
|
||||||
|
}
|
||||||
Executable
+41
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"name": "day11",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"scripts": {},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "Ryan Wong",
|
||||||
|
"private": true,
|
||||||
|
"license": "Private",
|
||||||
|
"dependencies": {
|
||||||
|
"apollo-server-express": "^2.11.0",
|
||||||
|
"axios": "^0.19.2",
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
|
"cookie-parser": "~1.4.4",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"dateformat": "^4.5.1",
|
||||||
|
"dotenv": "^8.2.0",
|
||||||
|
"eta": "^1.12",
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"express-session": "^1.17.1",
|
||||||
|
"fast-csv": "^4.3.6",
|
||||||
|
"firebase-admin": "^8.12.1",
|
||||||
|
"fs-extra": "^9.1.0",
|
||||||
|
"graphql": "^15.5.1",
|
||||||
|
"graphql-fields": "^2.0.3",
|
||||||
|
"graphql-upload": "^12.0.0",
|
||||||
|
"helmet": "^3.19.0",
|
||||||
|
"jsonwebtoken": "^8.5.1",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"moment": "^2.26.0",
|
||||||
|
"morgan": "~1.9.1",
|
||||||
|
"mysql2": "^2.2.5",
|
||||||
|
"nanoid": "^3.2.0",
|
||||||
|
"node-input-validator": "^4.3.2",
|
||||||
|
"nodemailer": "^6.4.11",
|
||||||
|
"path": "^0.12.7",
|
||||||
|
"request-promise": "^4.2.6",
|
||||||
|
"sequelize": "^6.15.1",
|
||||||
|
"winston": "^3.3.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
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');
|
||||||
|
}
|
||||||
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user