@xeplr/auth 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/bin/migrate.js +95 -0
- package/bin/server.js +35 -0
- package/index.js +165 -0
- package/lib/accessMiddleware.js +79 -0
- package/lib/accessService.js +188 -0
- package/lib/adminRouter.js +387 -0
- package/lib/authHelper.js +63 -0
- package/lib/authMiddleware.js +31 -0
- package/lib/authRouter.js +192 -0
- package/lib/authService.js +194 -0
- package/lib/sessionService.js +210 -0
- package/migrations/0001_users.js +22 -0
- package/migrations/0002_menus.js +16 -0
- package/migrations/0003_apis.js +16 -0
- package/migrations/0004_uiPages.js +16 -0
- package/migrations/0005_uiElements.js +16 -0
- package/migrations/0006_roles.js +15 -0
- package/migrations/0007_apisRolesMapping.js +16 -0
- package/migrations/0008_uiPagesRolesMapping.js +16 -0
- package/migrations/0009_uiElementsRolesMapping.js +16 -0
- package/migrations/0010_menuRolesMapping.js +16 -0
- package/migrations/0011_userRolesMapping.js +16 -0
- package/migrations/0012_users_add_reset_token.js +13 -0
- package/migrations/0013_add_isPublic.js +27 -0
- package/migrations/0014_users_add_activation_token.js +13 -0
- package/migrations/0015_add_mt_columns.js +41 -0
- package/migrations/0016_tenants.js +23 -0
- package/migrations/0017_userTenantsMapping.js +20 -0
- package/models/Api.js +45 -0
- package/models/ApisRolesMapping.js +29 -0
- package/models/Menu.js +45 -0
- package/models/MenuRolesMapping.js +29 -0
- package/models/Role.js +89 -0
- package/models/Tenant.js +63 -0
- package/models/UiElement.js +44 -0
- package/models/UiElementsRolesMapping.js +29 -0
- package/models/UiPage.js +45 -0
- package/models/UiPagesRolesMapping.js +29 -0
- package/models/User.js +76 -0
- package/models/UserRolesMapping.js +29 -0
- package/models/UserTenantsMapping.js +30 -0
- package/models/index.js +29 -0
- package/package.json +31 -0
- package/seeds/001_roles.js +26 -0
- package/seeds/002_apis.js +70 -0
- package/seeds/003_pages.js +41 -0
- package/seeds/004_elements.js +46 -0
- package/seeds/005_menus.js +35 -0
- package/seeds/006_default_tenant.js +50 -0
- package/seeds/zzz_admin_access.js +49 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var TABLES = [
|
|
2
|
+
'users',
|
|
3
|
+
'roles',
|
|
4
|
+
'apis',
|
|
5
|
+
'uiPages',
|
|
6
|
+
'uiElements',
|
|
7
|
+
'menus',
|
|
8
|
+
'userRolesMapping',
|
|
9
|
+
'apisRolesMapping',
|
|
10
|
+
'uiPagesRolesMapping',
|
|
11
|
+
'uiElementsRolesMapping',
|
|
12
|
+
'menuRolesMapping'
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
exports.up = async function(knex) {
|
|
16
|
+
for (var i = 0; i < TABLES.length; i++) {
|
|
17
|
+
var exists = await knex.schema.hasColumn(TABLES[i], 'mtId1');
|
|
18
|
+
if (!exists) {
|
|
19
|
+
await knex.schema.alterTable(TABLES[i], function(table) {
|
|
20
|
+
table.string('mtId1', 25);
|
|
21
|
+
table.string('mtId2', 25);
|
|
22
|
+
table.string('mtId3', 25);
|
|
23
|
+
table.string('mtId4', 25);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.down = async function(knex) {
|
|
30
|
+
for (var i = 0; i < TABLES.length; i++) {
|
|
31
|
+
var exists = await knex.schema.hasColumn(TABLES[i], 'mtId1');
|
|
32
|
+
if (exists) {
|
|
33
|
+
await knex.schema.alterTable(TABLES[i], function(table) {
|
|
34
|
+
table.dropColumn('mtId1');
|
|
35
|
+
table.dropColumn('mtId2');
|
|
36
|
+
table.dropColumn('mtId3');
|
|
37
|
+
table.dropColumn('mtId4');
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
exports.up = function(knex) {
|
|
2
|
+
return knex.schema.createTable('tenants', function(table) {
|
|
3
|
+
table.string('id', 25).primary();
|
|
4
|
+
table.string('name', 255).notNullable();
|
|
5
|
+
table.string('code', 50);
|
|
6
|
+
table.integer('level').defaultTo(1);
|
|
7
|
+
table.string('parentId', 25);
|
|
8
|
+
table.string('description', 500);
|
|
9
|
+
table.string('mtId1', 25);
|
|
10
|
+
table.string('mtId2', 25);
|
|
11
|
+
table.string('mtId3', 25);
|
|
12
|
+
table.string('mtId4', 25);
|
|
13
|
+
table.boolean('isActive').defaultTo(true);
|
|
14
|
+
table.timestamp('recordCreatedDate');
|
|
15
|
+
table.timestamp('recordModifiedDate');
|
|
16
|
+
table.string('recordCreatedBy', 25);
|
|
17
|
+
table.string('recordModifiedBy', 25);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.down = function(knex) {
|
|
22
|
+
return knex.schema.dropTableIfExists('tenants');
|
|
23
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
exports.up = function(knex) {
|
|
2
|
+
return knex.schema.createTable('userTenantsMapping', function(table) {
|
|
3
|
+
table.string('id', 25).primary();
|
|
4
|
+
table.string('userId', 25).notNullable().references('id').inTable('users');
|
|
5
|
+
table.string('tenantId', 25).notNullable().references('id').inTable('tenants');
|
|
6
|
+
table.string('mtId1', 25);
|
|
7
|
+
table.string('mtId2', 25);
|
|
8
|
+
table.string('mtId3', 25);
|
|
9
|
+
table.string('mtId4', 25);
|
|
10
|
+
table.boolean('isActive').defaultTo(true);
|
|
11
|
+
table.timestamp('recordCreatedDate');
|
|
12
|
+
table.timestamp('recordModifiedDate');
|
|
13
|
+
table.string('recordCreatedBy', 25);
|
|
14
|
+
table.string('recordModifiedBy', 25);
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.down = function(knex) {
|
|
19
|
+
return knex.schema.dropTableIfExists('userTenantsMapping');
|
|
20
|
+
};
|
package/models/Api.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class Api extends BaseModel {
|
|
4
|
+
static get tableName() { return 'apis'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
name: { type: ['string', 'null'], maxLength: 255 },
|
|
14
|
+
apiGroup: { type: ['string', 'null'], maxLength: 255 },
|
|
15
|
+
isPublic: { type: 'integer' },
|
|
16
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
18
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
20
|
+
isActive: { type: 'boolean' },
|
|
21
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
24
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static get relationMappings() {
|
|
30
|
+
const Role = require('./Role');
|
|
31
|
+
return {
|
|
32
|
+
roles: {
|
|
33
|
+
relation: BaseModel.ManyToManyRelation,
|
|
34
|
+
modelClass: Role,
|
|
35
|
+
join: {
|
|
36
|
+
from: 'apis.id',
|
|
37
|
+
through: { from: 'apisRolesMapping.apiId', to: 'apisRolesMapping.roleId' },
|
|
38
|
+
to: 'roles.id'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = Api;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class ApisRolesMapping extends BaseModel {
|
|
4
|
+
static get tableName() { return 'apisRolesMapping'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
roleId: { type: ['string', 'null'], maxLength: 25 },
|
|
14
|
+
apiId: { type: ['string', 'null'], maxLength: 25 },
|
|
15
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
16
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
18
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
isActive: { type: 'boolean' },
|
|
20
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
21
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = ApisRolesMapping;
|
package/models/Menu.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class Menu extends BaseModel {
|
|
4
|
+
static get tableName() { return 'menus'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
name: { type: ['string', 'null'], maxLength: 255 },
|
|
14
|
+
menuGroup: { type: ['string', 'null'], maxLength: 255 },
|
|
15
|
+
isPublic: { type: 'integer' },
|
|
16
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
18
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
20
|
+
isActive: { type: 'boolean' },
|
|
21
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
24
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static get relationMappings() {
|
|
30
|
+
const Role = require('./Role');
|
|
31
|
+
return {
|
|
32
|
+
roles: {
|
|
33
|
+
relation: BaseModel.ManyToManyRelation,
|
|
34
|
+
modelClass: Role,
|
|
35
|
+
join: {
|
|
36
|
+
from: 'menus.id',
|
|
37
|
+
through: { from: 'menuRolesMapping.menuId', to: 'menuRolesMapping.roleId' },
|
|
38
|
+
to: 'roles.id'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = Menu;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class MenuRolesMapping extends BaseModel {
|
|
4
|
+
static get tableName() { return 'menuRolesMapping'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
menuId: { type: ['string', 'null'], maxLength: 25 },
|
|
14
|
+
roleId: { type: ['string', 'null'], maxLength: 25 },
|
|
15
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
16
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
18
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
isActive: { type: 'boolean' },
|
|
20
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
21
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = MenuRolesMapping;
|
package/models/Role.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class Role extends BaseModel {
|
|
4
|
+
static get tableName() {
|
|
5
|
+
return 'roles';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
static get idColumn() {
|
|
9
|
+
return 'id';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static get jsonSchema() {
|
|
13
|
+
return {
|
|
14
|
+
type: 'object',
|
|
15
|
+
required: ['id'],
|
|
16
|
+
properties: {
|
|
17
|
+
id: { type: 'string', maxLength: 25 },
|
|
18
|
+
name: { type: ['string', 'null'], maxLength: 255 },
|
|
19
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
20
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
21
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
isActive: { type: 'boolean' },
|
|
24
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
25
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
26
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
27
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static get relationMappings() {
|
|
33
|
+
const User = require('./User');
|
|
34
|
+
const Api = require('./Api');
|
|
35
|
+
const UiPage = require('./UiPage');
|
|
36
|
+
const UiElement = require('./UiElement');
|
|
37
|
+
const Menu = require('./Menu');
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
users: {
|
|
41
|
+
relation: BaseModel.ManyToManyRelation,
|
|
42
|
+
modelClass: User,
|
|
43
|
+
join: {
|
|
44
|
+
from: 'roles.id',
|
|
45
|
+
through: { from: 'userRolesMapping.roleId', to: 'userRolesMapping.userId' },
|
|
46
|
+
to: 'users.id'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
apis: {
|
|
50
|
+
relation: BaseModel.ManyToManyRelation,
|
|
51
|
+
modelClass: Api,
|
|
52
|
+
join: {
|
|
53
|
+
from: 'roles.id',
|
|
54
|
+
through: { from: 'apisRolesMapping.roleId', to: 'apisRolesMapping.apiId' },
|
|
55
|
+
to: 'apis.id'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
uiPages: {
|
|
59
|
+
relation: BaseModel.ManyToManyRelation,
|
|
60
|
+
modelClass: UiPage,
|
|
61
|
+
join: {
|
|
62
|
+
from: 'roles.id',
|
|
63
|
+
through: { from: 'uiPagesRolesMapping.roleId', to: 'uiPagesRolesMapping.uiPageId' },
|
|
64
|
+
to: 'uiPages.id'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
uiElements: {
|
|
68
|
+
relation: BaseModel.ManyToManyRelation,
|
|
69
|
+
modelClass: UiElement,
|
|
70
|
+
join: {
|
|
71
|
+
from: 'roles.id',
|
|
72
|
+
through: { from: 'uiElementsRolesMapping.roleId', to: 'uiElementsRolesMapping.uiElementId' },
|
|
73
|
+
to: 'uiElements.id'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
menus: {
|
|
77
|
+
relation: BaseModel.ManyToManyRelation,
|
|
78
|
+
modelClass: Menu,
|
|
79
|
+
join: {
|
|
80
|
+
from: 'roles.id',
|
|
81
|
+
through: { from: 'menuRolesMapping.roleId', to: 'menuRolesMapping.menuId' },
|
|
82
|
+
to: 'menus.id'
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports = Role;
|
package/models/Tenant.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class Tenant extends BaseModel {
|
|
4
|
+
static get tableName() {
|
|
5
|
+
return 'tenants';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
static get idColumn() {
|
|
9
|
+
return 'id';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Tenants are global — not filtered by tenant context
|
|
13
|
+
static get multiTenant() {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static get jsonSchema() {
|
|
18
|
+
return {
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: ['id', 'name'],
|
|
21
|
+
properties: {
|
|
22
|
+
id: { type: 'string', maxLength: 25 },
|
|
23
|
+
name: { type: 'string', maxLength: 255 },
|
|
24
|
+
code: { type: ['string', 'null'], maxLength: 50 },
|
|
25
|
+
level: { type: 'integer' },
|
|
26
|
+
parentId: { type: ['string', 'null'], maxLength: 25 },
|
|
27
|
+
description: { type: ['string', 'null'], maxLength: 500 },
|
|
28
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
29
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
30
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
31
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 },
|
|
32
|
+
isActive: { type: 'boolean' },
|
|
33
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
34
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
35
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
36
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 }
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get relationMappings() {
|
|
42
|
+
return {
|
|
43
|
+
children: {
|
|
44
|
+
relation: BaseModel.HasManyRelation,
|
|
45
|
+
modelClass: Tenant,
|
|
46
|
+
join: {
|
|
47
|
+
from: 'tenants.id',
|
|
48
|
+
to: 'tenants.parentId'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
parent: {
|
|
52
|
+
relation: BaseModel.BelongsToOneRelation,
|
|
53
|
+
modelClass: Tenant,
|
|
54
|
+
join: {
|
|
55
|
+
from: 'tenants.parentId',
|
|
56
|
+
to: 'tenants.id'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = Tenant;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class UiElement extends BaseModel {
|
|
4
|
+
static get tableName() { return 'uiElements'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
name: { type: ['string', 'null'], maxLength: 255 },
|
|
14
|
+
uiElementsGroup: { type: ['string', 'null'], maxLength: 255 },
|
|
15
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
16
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
18
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
isActive: { type: 'boolean' },
|
|
20
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
21
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static get relationMappings() {
|
|
29
|
+
const Role = require('./Role');
|
|
30
|
+
return {
|
|
31
|
+
roles: {
|
|
32
|
+
relation: BaseModel.ManyToManyRelation,
|
|
33
|
+
modelClass: Role,
|
|
34
|
+
join: {
|
|
35
|
+
from: 'uiElements.id',
|
|
36
|
+
through: { from: 'uiElementsRolesMapping.uiElementId', to: 'uiElementsRolesMapping.roleId' },
|
|
37
|
+
to: 'roles.id'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
module.exports = UiElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class UiElementsRolesMapping extends BaseModel {
|
|
4
|
+
static get tableName() { return 'uiElementsRolesMapping'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
roleId: { type: ['string', 'null'], maxLength: 25 },
|
|
14
|
+
uiElementId: { type: ['string', 'null'], maxLength: 25 },
|
|
15
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
16
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
18
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
isActive: { type: 'boolean' },
|
|
20
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
21
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = UiElementsRolesMapping;
|
package/models/UiPage.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class UiPage extends BaseModel {
|
|
4
|
+
static get tableName() { return 'uiPages'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
name: { type: ['string', 'null'], maxLength: 255 },
|
|
14
|
+
uiPagesGroup: { type: ['string', 'null'], maxLength: 255 },
|
|
15
|
+
isPublic: { type: 'integer' },
|
|
16
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
18
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
20
|
+
isActive: { type: 'boolean' },
|
|
21
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
24
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static get relationMappings() {
|
|
30
|
+
const Role = require('./Role');
|
|
31
|
+
return {
|
|
32
|
+
roles: {
|
|
33
|
+
relation: BaseModel.ManyToManyRelation,
|
|
34
|
+
modelClass: Role,
|
|
35
|
+
join: {
|
|
36
|
+
from: 'uiPages.id',
|
|
37
|
+
through: { from: 'uiPagesRolesMapping.uiPageId', to: 'uiPagesRolesMapping.roleId' },
|
|
38
|
+
to: 'roles.id'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = UiPage;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class UiPagesRolesMapping extends BaseModel {
|
|
4
|
+
static get tableName() { return 'uiPagesRolesMapping'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
roleId: { type: ['string', 'null'], maxLength: 25 },
|
|
14
|
+
uiPageId: { type: ['string', 'null'], maxLength: 25 },
|
|
15
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
16
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
18
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
isActive: { type: 'boolean' },
|
|
20
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
21
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = UiPagesRolesMapping;
|
package/models/User.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class User extends BaseModel {
|
|
4
|
+
static get multiTenant() { return false; }
|
|
5
|
+
static get tableName() {
|
|
6
|
+
return 'users';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static get idColumn() {
|
|
10
|
+
return 'id';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static get jsonSchema() {
|
|
14
|
+
return {
|
|
15
|
+
type: 'object',
|
|
16
|
+
required: ['id', 'email'],
|
|
17
|
+
properties: {
|
|
18
|
+
id: { type: 'string', maxLength: 25 },
|
|
19
|
+
email: { type: 'string', maxLength: 255 },
|
|
20
|
+
phoneNumber: { type: ['string', 'null'], maxLength: 255 },
|
|
21
|
+
name: { type: ['string', 'null'], maxLength: 255 },
|
|
22
|
+
pwd: { type: ['string', 'null'], maxLength: 255 },
|
|
23
|
+
pwdSalt: { type: ['string', 'null'], maxLength: 100 },
|
|
24
|
+
isActive: { type: 'boolean' },
|
|
25
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
26
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
27
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
28
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 },
|
|
29
|
+
isActivated: { type: 'boolean' },
|
|
30
|
+
activatedOn: { type: ['string', 'null'] },
|
|
31
|
+
activatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
32
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
33
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
34
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
35
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
36
|
+
resetToken: { type: ['string', 'null'], maxLength: 255 },
|
|
37
|
+
resetTokenExpiry: { type: ['string', 'null'] },
|
|
38
|
+
activationToken: { type: ['string', 'null'], maxLength: 255 },
|
|
39
|
+
normalizedEmail: { type: ['string', 'null'], maxLength: 255 }
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static get relationMappings() {
|
|
45
|
+
const Role = require('./Role');
|
|
46
|
+
const Tenant = require('./Tenant');
|
|
47
|
+
return {
|
|
48
|
+
roles: {
|
|
49
|
+
relation: BaseModel.ManyToManyRelation,
|
|
50
|
+
modelClass: Role,
|
|
51
|
+
join: {
|
|
52
|
+
from: 'users.id',
|
|
53
|
+
through: {
|
|
54
|
+
from: 'userRolesMapping.userId',
|
|
55
|
+
to: 'userRolesMapping.roleId'
|
|
56
|
+
},
|
|
57
|
+
to: 'roles.id'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
tenants: {
|
|
61
|
+
relation: BaseModel.ManyToManyRelation,
|
|
62
|
+
modelClass: Tenant,
|
|
63
|
+
join: {
|
|
64
|
+
from: 'users.id',
|
|
65
|
+
through: {
|
|
66
|
+
from: 'userTenantsMapping.userId',
|
|
67
|
+
to: 'userTenantsMapping.tenantId'
|
|
68
|
+
},
|
|
69
|
+
to: 'tenants.id'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = User;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class UserRolesMapping extends BaseModel {
|
|
4
|
+
static get tableName() { return 'userRolesMapping'; }
|
|
5
|
+
static get idColumn() { return 'id'; }
|
|
6
|
+
|
|
7
|
+
static get jsonSchema() {
|
|
8
|
+
return {
|
|
9
|
+
type: 'object',
|
|
10
|
+
required: ['id'],
|
|
11
|
+
properties: {
|
|
12
|
+
id: { type: 'string', maxLength: 25 },
|
|
13
|
+
userId: { type: ['string', 'null'], maxLength: 25 },
|
|
14
|
+
roleId: { type: ['string', 'null'], maxLength: 25 },
|
|
15
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
16
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
17
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
18
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
isActive: { type: 'boolean' },
|
|
20
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
21
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
22
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
23
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 }
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = UserRolesMapping;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { BaseModel } = require('@xeplr/db');
|
|
2
|
+
|
|
3
|
+
class UserTenantsMapping extends BaseModel {
|
|
4
|
+
static get multiTenant() { return false; }
|
|
5
|
+
static get tableName() { return 'userTenantsMapping'; }
|
|
6
|
+
static get idColumn() { return 'id'; }
|
|
7
|
+
|
|
8
|
+
static get jsonSchema() {
|
|
9
|
+
return {
|
|
10
|
+
type: 'object',
|
|
11
|
+
required: ['id', 'userId', 'tenantId'],
|
|
12
|
+
properties: {
|
|
13
|
+
id: { type: 'string', maxLength: 25 },
|
|
14
|
+
userId: { type: 'string', maxLength: 25 },
|
|
15
|
+
tenantId: { type: 'string', maxLength: 25 },
|
|
16
|
+
mtId1: { type: ['string', 'null'], maxLength: 25 },
|
|
17
|
+
mtId2: { type: ['string', 'null'], maxLength: 25 },
|
|
18
|
+
mtId3: { type: ['string', 'null'], maxLength: 25 },
|
|
19
|
+
mtId4: { type: ['string', 'null'], maxLength: 25 },
|
|
20
|
+
isActive: { type: 'boolean' },
|
|
21
|
+
recordCreatedDate: { type: ['string', 'null'] },
|
|
22
|
+
recordModifiedDate: { type: ['string', 'null'] },
|
|
23
|
+
recordCreatedBy: { type: ['string', 'null'], maxLength: 25 },
|
|
24
|
+
recordModifiedBy: { type: ['string', 'null'], maxLength: 25 }
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = UserTenantsMapping;
|