Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-born-module-a-base-sync

Package Overview
Dependencies
Maintainers
1
Versions
354
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-born-module-a-base-sync - npm Package Compare versions

Comparing version 1.1.9 to 1.1.12

backend/src/config/validation/keywords.js

16

backend/src/config/config.js

@@ -48,2 +48,5 @@ // eslint-disable-next-line

},
registerAuthProvider: {
path: 'auth/register',
},
};

@@ -62,10 +65,19 @@

config.registered = {
maxAge: 1 * 24 * 3600 * 1000, // 1 天
maxAge: 30 * 24 * 3600 * 1000, // 30 天
};
// checkUserName
config.checkUserName = false;
config.checkUserName = true;
// signupRoleName
config.signupRoleName = 'registered';
// comment
config.comment = {
trim: {
limit: 100,
wordBreak: false,
preserveTags: false,
},
};
return config;
};

6

backend/src/config/constants.js

@@ -15,4 +15,4 @@ module.exports = {

create: { title: 'Create', actionComponent: 'action' },
read: { title: 'View', actionPath: 'atom/view?atomId={{atomId}}&itemId={{itemId}}&atomClassId={{atomClassId}}&atomClassName={{atomClassName}}&atomClassIdParent={{atomClassIdParent}}' },
write: { title: 'Edit', actionPath: 'atom/edit?atomId={{atomId}}&itemId={{itemId}}&atomClassId={{atomClassId}}&atomClassName={{atomClassName}}&atomClassIdParent={{atomClassIdParent}}' },
read: { title: 'View', actionPath: 'atom/view?atomId={{atomId}}&itemId={{itemId}}&atomClassId={{atomClassId}}&module={{module}}&atomClassName={{atomClassName}}&atomClassIdParent={{atomClassIdParent}}' },
write: { title: 'Edit', actionPath: 'atom/edit?atomId={{atomId}}&itemId={{itemId}}&atomClassId={{atomClassId}}&module={{module}}&atomClassName={{atomClassName}}&atomClassIdParent={{atomClassIdParent}}' },
delete: { title: 'Delete', actionComponent: 'action' },

@@ -29,3 +29,3 @@ save: { title: 'Save', actionComponent: 'action', authorize: false },

list: 2,
statistics: 20,
report: 20,
tools: 50,

@@ -32,0 +32,0 @@ custom: 100,

module.exports = {
'Comment List': '评论列表',
'Element exists': '元素已存在',

@@ -10,2 +11,3 @@ 'Element does not exist': '元素不存在',

'Should delete children first': '应该先删除子角色',
'Cannot contain __': '不能包含__',
Draft: '草稿',

@@ -12,0 +14,0 @@ Base: '基本',

@@ -97,3 +97,3 @@ const require3 = require('require3');

if (!atomName) {
// sequence
// sequence
const sequence = await this.sequence.next('draft');

@@ -221,2 +221,3 @@ atomName = `${ctx.text('Draft')}-${sequence}`;

if (item.atomName !== undefined) atom.atomName = item.atomName;
if (item.allowComment !== undefined) atom.allowComment = item.allowComment;
if (Object.keys(atom).length > 0) {

@@ -331,9 +332,17 @@ atom.id = key.atomId;

async star({ key, atom: { star = 1 }, user }) {
// force delete
await this.modelAtomStar.delete({
let diff = 0;
// check if exists
const _star = await this.modelAtomStar.get({
userId: user.id,
atomId: key.atomId,
});
// new
if (star) {
if (_star && !star) {
diff = -1;
// delete
await this.modelAtomStar.delete({
id: _star.id,
});
} else if (!_star && star) {
diff = 1;
// new
await this.modelAtomStar.insert({

@@ -345,4 +354,32 @@ userId: user.id,

}
// get
const atom = await this.get({ atomId: key.atomId });
let starCount = atom.starCount;
if (diff !== 0) {
starCount += diff;
await this.modelAtom.update({
id: key.atomId,
starCount,
// userIdUpdated: user.id,
});
}
// ok
return { star, starCount };
}
async readCount({ key, atom: { readCount = 1 }, user }) {
await this.modelAtom.query('update aAtom set readCount = readCount + ? where iid=? and id=?',
[ readCount, ctx.instance.id, key.atomId ]);
}
async comment({ key, atom: { comment = 1 }, user }) {
await this.modelAtom.query('update aAtom set commentCount = commentCount + ? where iid=? and id=?',
[ comment, ctx.instance.id, key.atomId ]);
}
async attachment({ key, atom: { attachment = 1 }, user }) {
await this.modelAtom.query('update aAtom set attachmentCount = attachmentCount + ? where iid=? and id=?',
[ attachment, ctx.instance.id, key.atomId ]);
}
async labels({ key, atom: { labels = null }, user }) {

@@ -442,3 +479,3 @@ // force delete

async _update({
atom: { id, atomName, atomFlow, itemId },
atom: { id, atomName, allowComment, atomFlow, itemId },
user,

@@ -448,4 +485,6 @@ }) {

if (atomName !== undefined) params.atomName = atomName;
if (allowComment !== undefined) params.allowComment = allowComment;
if (atomFlow !== undefined) params.atomFlow = atomFlow;
if (itemId !== undefined) params.itemId = itemId;
params.updatedAt = new Date();
const res = await this.modelAtom.update(params);

@@ -473,3 +512,3 @@ if (res.affectedRows !== 1) ctx.throw(1003);

async _list({ tableName = '', options: { where, orders, page, star = 0, label = 0 }, user, pageForce = true }) {
async _list({ tableName = '', options: { where, orders, page, star = 0, label = 0, comment = 0, file = 0 }, user, pageForce = true }) {
page = ctx.meta.util.page(page, pageForce);

@@ -481,4 +520,4 @@

const res = await ctx.model.query('call aSelectAtoms(?,?,?,?,?,?,?,?)',
[ tableName, _where, _orders, _limit, ctx.instance.id, user.id, star, label ]
const res = await ctx.model.query('call aSelectAtoms(?,?,?,?,?,?,?,?,?,?)',
[ tableName, _where, _orders, _limit, ctx.instance.id, user.id, star, label, comment, file ]
);

@@ -485,0 +524,0 @@ return res[0];

@@ -318,3 +318,3 @@ const _modulesLocales = {};

func.actionComponent = 'action';
func.actionPath = '/a/base/atom/edit?atomId={{atomId}}&itemId={{itemId}}&atomClassId={{atomClassId}}&atomClassName={{atomClassName}}&atomClassIdParent={{atomClassIdParent}}';
// func.actionPath = '/a/base/atom/edit?atomId={{atomId}}&itemId={{itemId}}&atomClassId={{atomClassId}}&atomClassName={{atomClassName}}&atomClassIdParent={{atomClassIdParent}}';
}

@@ -321,0 +321,0 @@ // list

@@ -39,3 +39,3 @@ const modelFn = require('../../../model/function.js');

async list({ options: { where, orders, page, star = 0, locale = '' }, user }) {
page = ctx.meta.util.page(page);
// page = ctx.meta.util.page(page); // has set in controller

@@ -42,0 +42,0 @@ const _where = ctx.model._where2(where);

@@ -17,2 +17,3 @@ const modelFn = require('../../../model/user.js');

this._modelAuthProvider = null;
this._sequence = null;
}

@@ -40,2 +41,7 @@

get sequence() {
if (!this._sequence) this._sequence = ctx.meta.sequence.module(moduleInfo.relativeName);
return this._sequence;
}
async anonymous() {

@@ -111,3 +117,3 @@ // new

return await this.model.queryOne(
`select * from aUser
`select * from aUser
where iid=? and deleted=0 and ((?<>'' and userName=?) or (?<>'' and email=?) or (?<>'' and mobile=?))`,

@@ -117,3 +123,3 @@ [ ctx.instance.id, userName, userName, email, email, mobile, mobile ]);

return await this.model.queryOne(
`select * from aUser
`select * from aUser
where iid=? and deleted=0 and ((?<>'' and email=?) or (?<>'' and mobile=?))`,

@@ -163,4 +169,4 @@ [ ctx.instance.id, email, email, mobile, mobile ]);

const sql = `
select a.* from aUser a
left join aUserAgent b on a.id=b.userIdAgent
select a.* from aUser a
left join aUserAgent b on a.id=b.userIdAgent
where a.iid=? and a.deleted=0 and b.userId=?

@@ -173,3 +179,3 @@ `;

const sql = `
select a.* from aUser a
select a.* from aUser a
left join aUserAgent b on a.id=b.userId

@@ -221,6 +227,6 @@ where a.iid=? and a.deleted=0 and b.userIdAgent=?

select a.* from aUser a
${roleJoin}
${roleJoin}
where a.iid=? and a.deleted=0
${anonymousWhere}
${roleWhere}
${roleWhere}
${queryWhere}

@@ -262,3 +268,3 @@ ${_limit}

// provider
const providerItem = await this.modelAuthProvider.get({
const providerItem = await this.getAuthProvider({
module: profileUser.module,

@@ -361,3 +367,3 @@ providerName: profileUser.provider,

for (const column of columns) {
user[column] = profile[column];
await this._setUserInfoColumn(user, column, profile[column]);
}

@@ -373,3 +379,3 @@ return await this.signup(user, { addRole });

for (const column of columns) {
if (!user[column] && profile[column]) user[column] = profile[column];
await this._setUserInfoColumn(user, column, profile[column]);
}

@@ -380,2 +386,64 @@ user.id = userId;

async _setUserInfoColumn(user, column, value) {
if (user[column] || !value) return;
// userName
if (column === 'userName') {
const res = await this.exists({ [column]: value });
if (res) {
// sequence
const sequence = await this.sequence.next('userName');
value = `${value}__${sequence}`;
}
} else if (column === 'email' || column === 'mobile') {
const res = await this.exists({ [column]: value });
if (res) {
value = '';
}
}
if (value) {
user[column] = value;
}
}
async getAuthProvider({ subdomain, iid, id, module, providerName }) {
// ctx.instance maybe not exists
const data = id ? {
iid: iid || ctx.instance.id,
id,
} : {
iid: iid || ctx.instance.id,
module,
providerName,
};
const res = await ctx.db.get('aAuthProvider', data);
if (res) return res;
if (!module || !providerName) throw new Error('Invalid arguments');
// queue
return await ctx.app.meta.queue.pushAsync({
subdomain: subdomain || ctx.subdomain,
module: moduleInfo.relativeName,
queueName: 'registerAuthProvider',
data: { module, providerName },
});
}
async registerAuthProvider({ module, providerName }) {
// get
const res = await this.modelAuthProvider.get({ module, providerName });
if (res) return res;
// data
const _module = ctx.app.meta.modules[module];
const _provider = _module.main.meta.auth.providers[providerName];
if (!_provider) throw new Error(`authProvider ${module}:${providerName} not found!`);
const data = {
module,
providerName,
config: JSON.stringify(_provider.config),
};
// insert
const res2 = await this.modelAuthProvider.insert(data);
data.id = res2.insertId;
return data;
}
}

@@ -382,0 +450,0 @@

@@ -11,3 +11,3 @@ const require3 = require('require3');

}
if (force || _page.size === undefined) _page.size = ctx.app.config.pageSize;
if (_page.size === undefined || (force && (_page.size === 0 || _page.size === -1 || _page.size > ctx.app.config.pageSize))) _page.size = ctx.app.config.pageSize;
return _page;

@@ -14,0 +14,0 @@ }

@@ -12,2 +12,3 @@ module.exports = app => {

notEmpty: true,
'x-exists': true,
},

@@ -26,2 +27,3 @@ realName: {

format: 'email',
'x-exists': true,
},

@@ -33,2 +35,3 @@ mobile: {

notEmpty: true,
'x-exists': true,
},

@@ -35,0 +38,0 @@ motto: {

@@ -91,2 +91,50 @@ module.exports = app => {

async starP() {
// data
const data = JSON.parse(this.ctx.request.query.data);
// select
const res = await this.ctx.performAction({
method: 'post',
url: 'atom/star',
body: data,
});
this.ctx.success(res);
}
async readCount() {
const res = await this.ctx.service.atom.readCount({
key: this.ctx.request.body.key,
atom: this.ctx.request.body.atom,
user: this.ctx.user.op,
});
this.ctx.success(res);
}
async readCountP() {
// data
const data = JSON.parse(this.ctx.request.query.data);
// select
const res = await this.ctx.performAction({
method: 'post',
url: 'atom/readCount',
body: data,
});
this.ctx.success(res);
}
async statsP() {
// atomIds
const atomIds = JSON.parse(this.ctx.request.query.data);
const options = {
where: {
'a.id': { op: 'in', val: atomIds },
},
};
// select
const res = await this.ctx.meta.atom.select({
options, user: this.ctx.user.op, pageForce: false,
});
this.ctx.success(res);
}
async labels() {

@@ -93,0 +141,0 @@ const res = await this.ctx.service.atom.labels({

@@ -22,2 +22,10 @@ module.exports = app => {

async checkRightCreate() {
const res = await this.ctx.service.atomClass.checkRightCreate({
atomClass: this.ctx.request.body.atomClass,
user: this.ctx.user.op,
});
this.ctx.success(res);
}
}

@@ -24,0 +32,0 @@

@@ -44,2 +44,10 @@ module.exports = app => {

async register() {
const res = await this.ctx.service.auth.register({
module: this.ctx.request.body.module,
providerName: this.ctx.request.body.providerName,
});
this.ctx.success(res);
}
}

@@ -46,0 +54,0 @@

@@ -9,3 +9,3 @@ module.exports = app => {

const options = this.ctx.request.body.options || {};
options.page = this.ctx.meta.util.page(options.page);
options.page = this.ctx.meta.util.page(options.page, false); // false
// locale maybe '' for selectAllFunctions

@@ -12,0 +12,0 @@ if (options.locale === undefined) options.locale = this.ctx.locale;

module.exports = app => {
// keywords
const keywords = require('./config/validation/keywords.js')(app);
// schemas

@@ -6,2 +8,13 @@ const schemas = require('./config/validation/schemas.js')(app);

const meta = {
base: {
functions: {
listComment: {
title: 'Comment List',
scene: 'list',
sorting: 1,
menu: 1,
actionPath: 'comment/all',
},
},
},
sequence: {

@@ -15,2 +28,8 @@ providers: {

},
userName: {
start: 0,
expression({ ctx, value }) {
return ++value;
},
},
},

@@ -24,3 +43,5 @@ },

},
keywords: {},
keywords: {
'x-exists': keywords.exists,
},
schemas: {

@@ -27,0 +48,0 @@ user: schemas.user,

@@ -23,2 +23,5 @@ const atom = require('./model/atom.js');

const roleFunction = require('./model/roleFunction.js');
const comment = require('./model/comment.js');
const commentView = require('./model/commentView.js');
const commentHeart = require('./model/commentHeart.js');

@@ -49,4 +52,7 @@ module.exports = app => {

roleFunction,
comment,
commentView,
commentHeart,
};
return models;
};

@@ -9,2 +9,3 @@ const version = require('./controller/version.js');

const auth = require('./controller/auth.js');
const comment = require('./controller/comment.js');

@@ -57,2 +58,8 @@ module.exports = app => {

},
{ method: 'get', path: 'atom/star', controller: atom, action: 'starP', middlewares: 'jsonp' },
{ method: 'post', path: 'atom/readCount', controller: atom,
meta: { right: { type: 'atom', action: 2 } },
},
{ method: 'get', path: 'atom/readCount', controller: atom, action: 'readCountP', middlewares: 'jsonp' },
{ method: 'get', path: 'atom/stats', controller: atom, action: 'statsP', middlewares: 'jsonp' },
{ method: 'post', path: 'atom/labels', controller: atom,

@@ -64,2 +71,29 @@ meta: { right: { type: 'atom', action: 2 } },

{ method: 'post', path: 'atom/validator', controller: atom },
// comment
{ method: 'post', path: 'comment/all', controller: comment },
{ method: 'get', path: 'comment/all', controller: comment, action: 'allP', middlewares: 'jsonp' },
{ method: 'post', path: 'comment/list', controller: comment,
meta: { right: { type: 'atom', action: 2 } },
},
{ method: 'get', path: 'comment/list', controller: comment, action: 'listP', middlewares: 'jsonp' },
{ method: 'post', path: 'comment/item', controller: comment,
meta: { right: { type: 'atom', action: 2 } },
},
{ method: 'post', path: 'comment/save', controller: comment, middlewares: 'transaction',
meta: {
auth: { user: true },
right: { type: 'atom', action: 2 },
},
},
{ method: 'post', path: 'comment/delete', controller: comment, middlewares: 'transaction',
meta: {
auth: { user: true },
right: { type: 'atom', action: 2 },
},
},
{ method: 'get', path: 'comment/delete', controller: comment, action: 'deleteP', middlewares: 'jsonp' },
{ method: 'post', path: 'comment/heart', controller: comment, middlewares: 'transaction',
meta: { right: { type: 'atom', action: 2 } },
},
{ method: 'get', path: 'comment/heart', controller: comment, action: 'heartP', middlewares: 'jsonp' },
// user

@@ -88,4 +122,6 @@ { method: 'post', path: 'user/getLabels', controller: user },

{ method: 'post', path: 'atomClass/validatorSearch', controller: atomClass },
{ method: 'post', path: 'atomClass/checkRightCreate', controller: atomClass },
// auth
{ method: 'post', path: 'auth/echo', controller: auth, meta: { auth: { enable: false } } },
{ method: 'get', path: 'auth/echo', controller: auth, middlewares: 'jsonp', meta: { auth: { enable: false } } },
{ method: 'post', path: 'auth/check', controller: auth, meta: { auth: { user: true } } },

@@ -96,4 +132,7 @@ { method: 'post', path: 'auth/logout', controller: auth, meta: { auth: { enable: false } } },

},
{ method: 'post', path: 'auth/register', controller: auth, middlewares: 'inner',
meta: { auth: { enable: false } },
},
];
return routes;
};

@@ -37,2 +37,6 @@ module.exports = app => {

async readCount({ key, atom, user }) {
return await this.ctx.meta.atom.readCount({ key, atom, user });
}
async labels({ key, atom, user }) {

@@ -39,0 +43,0 @@ return await this.ctx.meta.atom.labels({ key, atom, user });

@@ -13,2 +13,6 @@ module.exports = app => {

async checkRightCreate({ atomClass, user }) {
return await this.ctx.meta.atom.checkRightCreate({ atomClass, user });
}
}

@@ -15,0 +19,0 @@

const require3 = require('require3');
const mparse = require3('egg-born-mparse').default;
const UserFn = require('../config/middleware/adapter/user.js');

@@ -24,3 +25,3 @@ module.exports = app => {

for (const instance of instances) {
await this.registerProviderInstance(instance.id, moduleRelativeName, providerName);
await this.registerProviderInstance(instance.name, instance.id, moduleRelativeName, providerName);
}

@@ -48,5 +49,7 @@ // config

async registerProviderInstance(iid, moduleRelativeName, providerName) {
async registerProviderInstance(subdomain, iid, moduleRelativeName, providerName) {
// provider of db
const providerItem = await this.ctx.db.get('aAuthProvider', {
const user = new (UserFn(this.ctx))();
const providerItem = await user.getAuthProvider({
subdomain,
iid,

@@ -64,3 +67,3 @@ module: moduleRelativeName,

// provider
const provider = module.main.meta.auth.providers[providerName](this.app);
const provider = module.main.meta.auth.providers[providerName].handler(this.app);
// install strategy

@@ -73,2 +76,6 @@ const strategyName = `${iid}:${moduleRelativeName}:${providerName}`;

async register({ module, providerName }) {
return await this.ctx.meta.user.registerAuthProvider({ module, providerName });
}
}

@@ -82,3 +89,3 @@

// provider of db
const providerItem = await ctx.model.authProvider.get({
const providerItem = await ctx.meta.user.getAuthProvider({
module: moduleRelativeName,

@@ -85,0 +92,0 @@ providerName,

const VersionUpdate1Fn = require('./version/update1.js');
const VersionUpdate2Fn = require('./version/update2.js');
const VersionUpdate3Fn = require('./version/update3.js');
const VersionInitFn = require('./version/init.js');
const VersionUpdate4Fn = require('./version/update4.js');
const VersionInit2Fn = require('./version/init2.js');
const VersionInit4Fn = require('./version/init4.js');

@@ -12,2 +14,7 @@ module.exports = app => {

if (options.version === 4) {
const versionUpdate4 = new (VersionUpdate4Fn(this.ctx))();
await versionUpdate4.run();
}
if (options.version === 3) {

@@ -31,5 +38,9 @@ const versionUpdate3 = new (VersionUpdate3Fn(this.ctx))();

if (options.version === 2) {
const versionInit = new (VersionInitFn(this.ctx))();
await versionInit.run(options);
const versionInit2 = new (VersionInit2Fn(this.ctx))();
await versionInit2.run(options);
}
if (options.version === 4) {
const versionInit4 = new (VersionInit4Fn(this.ctx))();
await versionInit4.run(options);
}
}

@@ -36,0 +47,0 @@

@@ -9,2 +9,3 @@ const version = require('./service/version.js');

const func = require('./service/function.js');
const comment = require('./service/comment.js');

@@ -21,4 +22,5 @@ module.exports = app => {

function: func,
comment,
};
return services;
};

@@ -13,3 +13,10 @@ export default {

if (!this.menusAll) return null;
return this.menusAll[menu.module][menu.name];
const menus = this.menusAll[menu.module];
// by name
if (menu.name) return menus[ menu.name ];
// by action
for (const key in menus) {
if (menus[key].action === menu.action) return menus[key];
}
return null;
},

@@ -16,0 +23,0 @@ getMenuTitle(menu) {

@@ -10,3 +10,7 @@ export default {

return ctx.$api.post('/a/base/atom/create', {
atomClass: { id: item.atomClassId },
atomClass: {
id: item.atomClassId,
module: item.module,
atomClassName: item.atomClassName,
},
}).then(key => {

@@ -13,0 +17,0 @@ ctx.$utils.extend(item, key);

@@ -8,3 +8,2 @@ export default {

Close: '关闭',
'Search menu': '搜索菜单',
Create: '新建',

@@ -22,3 +21,2 @@ Others: '其他',

Delete: '删除',
'Atom Name': '原子名称',
Red: '红色',

@@ -30,4 +28,9 @@ Orange: '橘色',

Purple: '紫色',
Label: '标签',
Comment: '评论',
'Atom Name': '原子名称',
'Modification time': '修改时间',
'Comment List': '评论列表',
'Created time': '创建时间',
'Search Menu': '搜索菜单',
'Search Atom': '搜索原子',

@@ -40,3 +43,4 @@ 'Search Result': '搜索结果',

'Atom class': '原子类型',
Label: '标签',
'Allow Comment': '允许评论',
'Attachment List': '附件列表',
};
let Vue;
import './assets/css/module.css';
import './assets/css/module.less';

@@ -5,0 +5,0 @@ // install

@@ -16,2 +16,6 @@ function load(name) {

{ path: 'atom/selectAtomClass', component: load('atom/selectAtomClass') },
{ path: 'comment/list', component: load('comment/list') },
{ path: 'comment/item', component: load('comment/item') },
{ path: 'comment/all', component: load('comment/all') },
{ path: 'attachment/list', component: load('attachment/list') },
];
{
"name": "egg-born-module-a-base-sync",
"version": "1.1.9",
"version": "1.1.12",
"title": "Base",
"eggBornModule": {
"fileVersion": 3,
"fileVersion": 4,
"dependencies": {

@@ -61,4 +61,6 @@ "a-instance": "1.0.0",

"require3": "^1.0.1",
"moment": "^2.22.2"
"moment": "^2.22.2",
"@zhennann/markdown": "^1.0.0",
"trim-html": "^0.1.9"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc