@itleanchatbot/shared-models-js-postgres 1.1.48 → 1.1.50
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/index.js +4 -2
- package/package.json +1 -1
- package/src/apis.js +17 -48
- package/src/attendanceScale.js +41 -0
- package/src/attendanceScaleOff.js +45 -0
- package/src/apiAuthentications.js +0 -57
package/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const attendances = require('./src/attendances')
|
|
2
|
+
const attendanceScale = require('./src/attendanceScale')
|
|
3
|
+
const attendanceScaleOff = require('./src/attendanceScaleOff')
|
|
2
4
|
const branches = require('./src/branches')
|
|
3
5
|
const channelConfigurations = require('./src/channelConfigurations')
|
|
4
6
|
const channels = require('./src/channels')
|
|
@@ -31,7 +33,6 @@ const lineConfigurations = require('./src/lineConfigurations')
|
|
|
31
33
|
const permissions = require('./src/permissions')
|
|
32
34
|
const apis = require('./src/apis')
|
|
33
35
|
const apiResources = require('./src/apiResources')
|
|
34
|
-
const apiAuthentications = require('./src/apiAuthentications')
|
|
35
36
|
const apiResourceBodies = require('./src/apiResourceBodies')
|
|
36
37
|
const apiResourceHeaders = require('./src/apiResourceHeaders')
|
|
37
38
|
const apiResourcePathParams = require('./src/apiResourcePathParams')
|
|
@@ -47,6 +48,8 @@ const transhipTriggers = require('./src/transhipTriggers')
|
|
|
47
48
|
|
|
48
49
|
module.exports = {
|
|
49
50
|
attendances,
|
|
51
|
+
attendanceScale,
|
|
52
|
+
attendanceScaleOff,
|
|
50
53
|
branches,
|
|
51
54
|
channelConfigurations,
|
|
52
55
|
channels,
|
|
@@ -79,7 +82,6 @@ module.exports = {
|
|
|
79
82
|
permissions,
|
|
80
83
|
apis,
|
|
81
84
|
apiResources,
|
|
82
|
-
apiAuthentications,
|
|
83
85
|
apiResourceBodies,
|
|
84
86
|
apiResourceHeaders,
|
|
85
87
|
apiResourcePathParams,
|
package/package.json
CHANGED
package/src/apis.js
CHANGED
|
@@ -3,45 +3,25 @@ const API_INTEGRATION_TYPES = {
|
|
|
3
3
|
XML: 'xml',
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const API_INTEGRATION_TYPE = [
|
|
7
|
+
API_INTEGRATION_TYPES.JSON,
|
|
8
|
+
API_INTEGRATION_TYPES.XML,
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const API_AUTHENTICATIONS_TYPES = {
|
|
13
|
+
BASIC_AUTH: 'basicAuth',
|
|
14
|
+
BEARER_TOKEN: 'bearerToken',
|
|
15
|
+
API_KEY: 'apyKey',
|
|
16
|
+
NO_AUTH: 'noAuth'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
11
20
|
const ApisModel = (sequelize, Sequelize) => {
|
|
12
21
|
const Api = sequelize.define('Apis', {
|
|
13
22
|
baseUrl: {
|
|
14
|
-
type: Sequelize.
|
|
23
|
+
type: Sequelize.JSON,
|
|
15
24
|
allowNull: false,
|
|
16
|
-
defaultValue: '[]',
|
|
17
|
-
get(field) {
|
|
18
|
-
try {
|
|
19
|
-
let value = this.getDataValue(field)
|
|
20
|
-
value = JSON.parse(value)
|
|
21
|
-
if (value.length) {
|
|
22
|
-
return value.map(item => {
|
|
23
|
-
try {
|
|
24
|
-
if(typeof item === 'string') {
|
|
25
|
-
return JSON.parse(item)
|
|
26
|
-
} else {
|
|
27
|
-
return item
|
|
28
|
-
}
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(error)
|
|
31
|
-
return item
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
return value
|
|
36
|
-
} catch (error) {
|
|
37
|
-
let value = this.getDataValue(field)
|
|
38
|
-
|
|
39
|
-
if(typeof value === 'string') {
|
|
40
|
-
value = []
|
|
41
|
-
}
|
|
42
|
-
return value
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
25
|
},
|
|
46
26
|
type: {
|
|
47
27
|
type: Sequelize.ENUM({
|
|
@@ -58,17 +38,6 @@ const API_INTEGRATION_TYPES = {
|
|
|
58
38
|
type: Sequelize.STRING,
|
|
59
39
|
allowNull: true,
|
|
60
40
|
},
|
|
61
|
-
ApiAuthenticationId: {
|
|
62
|
-
type: Sequelize.UUID,
|
|
63
|
-
defaultValue: null,
|
|
64
|
-
allowNull: true,
|
|
65
|
-
references: {
|
|
66
|
-
model: 'ApiAuthentications',
|
|
67
|
-
key: 'id',
|
|
68
|
-
},
|
|
69
|
-
onDelete: 'RESTRICT',
|
|
70
|
-
onUpdate: 'CASCADE',
|
|
71
|
-
},
|
|
72
41
|
EnterpriseId: {
|
|
73
42
|
type: Sequelize.UUID,
|
|
74
43
|
allowNull: true,
|
|
@@ -83,7 +52,6 @@ const API_INTEGRATION_TYPES = {
|
|
|
83
52
|
|
|
84
53
|
Api.associate = (models) => {
|
|
85
54
|
Api.hasMany(models.ApiResources)
|
|
86
|
-
Api.belongsTo(models.ApiAuthentications)
|
|
87
55
|
}
|
|
88
56
|
|
|
89
57
|
return Api
|
|
@@ -93,5 +61,6 @@ const API_INTEGRATION_TYPES = {
|
|
|
93
61
|
module.exports = {
|
|
94
62
|
ApisModel,
|
|
95
63
|
API_INTEGRATION_TYPE,
|
|
96
|
-
API_INTEGRATION_TYPES
|
|
64
|
+
API_INTEGRATION_TYPES,
|
|
65
|
+
API_AUTHENTICATIONS_TYPES
|
|
97
66
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
exports.AttendanceScalesModel = (sequelize, DataTypes) => {
|
|
2
|
+
const AttendanceScale = sequelize.define('AttendanceScales', {
|
|
3
|
+
LineConfigurationId: {
|
|
4
|
+
type: DataTypes.UUID,
|
|
5
|
+
allowNull: false,
|
|
6
|
+
references: {
|
|
7
|
+
model: 'LineConfigurations',
|
|
8
|
+
key: 'id',
|
|
9
|
+
},
|
|
10
|
+
onDelete: 'CASCADE',
|
|
11
|
+
onUpdate: 'CASCADE',
|
|
12
|
+
},
|
|
13
|
+
day: {
|
|
14
|
+
allowNull: false,
|
|
15
|
+
type: DataTypes.ENUM([0, 1, 2, 3, 4, 5, 6]),
|
|
16
|
+
unique: true,
|
|
17
|
+
},
|
|
18
|
+
hourInit: {
|
|
19
|
+
allowNull: false,
|
|
20
|
+
type: DataTypes.TIME,
|
|
21
|
+
get(field) {
|
|
22
|
+
const hourInit = this.getDataValue(field)
|
|
23
|
+
return hourInit.substring(0, 5)
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
hourFinish: {
|
|
27
|
+
allowNull: false,
|
|
28
|
+
type: DataTypes.TIME,
|
|
29
|
+
get(field) {
|
|
30
|
+
const hourInit = this.getDataValue(field)
|
|
31
|
+
return hourInit.substring(0, 5)
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
AttendanceScale.associate = (models) => {
|
|
37
|
+
AttendanceScale.belongsTo(models.LineConfigurations)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return AttendanceScale
|
|
41
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
exports.AttendanceScaleOffsModel = (sequelize, DataTypes) => {
|
|
2
|
+
const AttendanceScale = sequelize.define('AttendanceScaleOffs', {
|
|
3
|
+
LineConfigurationId: {
|
|
4
|
+
type: DataTypes.UUID,
|
|
5
|
+
allowNull: false,
|
|
6
|
+
references: {
|
|
7
|
+
model: 'LineConfigurations',
|
|
8
|
+
key: 'id',
|
|
9
|
+
},
|
|
10
|
+
onDelete: 'CASCADE',
|
|
11
|
+
onUpdate: 'CASCADE',
|
|
12
|
+
},
|
|
13
|
+
date: {
|
|
14
|
+
allowNull: false,
|
|
15
|
+
type: DataTypes.DATEONLY,
|
|
16
|
+
unique: true,
|
|
17
|
+
get(field) {
|
|
18
|
+
const date = this.getDataValue(field)
|
|
19
|
+
return new Date(date).toISOString().substring(0, 10)
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
hourInit: {
|
|
23
|
+
allowNull: false,
|
|
24
|
+
type: DataTypes.TIME,
|
|
25
|
+
get(field) {
|
|
26
|
+
const hourInit = this.getDataValue(field)
|
|
27
|
+
return hourInit.substring(0, 5)
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
hourFinish: {
|
|
31
|
+
allowNull: false,
|
|
32
|
+
type: DataTypes.TIME,
|
|
33
|
+
get(field) {
|
|
34
|
+
const hourFinish = this.getDataValue(field)
|
|
35
|
+
return hourFinish.substring(0, 5)
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
AttendanceScale.associate = (models) => {
|
|
41
|
+
AttendanceScale.belongsTo(models.LineConfigurations)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return AttendanceScale
|
|
45
|
+
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const { HTTP_METHODS } = require('./apiResources')
|
|
2
|
-
|
|
3
|
-
const API_AUTHENTICATIONS_TYPES = {
|
|
4
|
-
NO_AUTH: 'noAuth',
|
|
5
|
-
API_KEY: 'apiKey',
|
|
6
|
-
BEARER_TOKEN: 'bearerToken',
|
|
7
|
-
BASIC_AUTH: 'basicAuth',
|
|
8
|
-
}
|
|
9
|
-
const API_AUTHENTICATIONS_TYPE = [
|
|
10
|
-
API_AUTHENTICATIONS_TYPES.NO_AUTH,
|
|
11
|
-
API_AUTHENTICATIONS_TYPES.API_KEY,
|
|
12
|
-
API_AUTHENTICATIONS_TYPES.BEARER_TOKEN,
|
|
13
|
-
API_AUTHENTICATIONS_TYPES.BASIC_AUTH,
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const ApiAuthenticationsModel = (sequelize, Sequelize) => {
|
|
18
|
-
const ApiAuthentications = sequelize.define('ApiAuthentications', {
|
|
19
|
-
type: {
|
|
20
|
-
type: Sequelize.ENUM({
|
|
21
|
-
values: API_AUTHENTICATIONS_TYPE,
|
|
22
|
-
}),
|
|
23
|
-
allowNull: false,
|
|
24
|
-
},
|
|
25
|
-
method: {
|
|
26
|
-
type: Sequelize.ENUM({
|
|
27
|
-
values: HTTP_METHODS,
|
|
28
|
-
}),
|
|
29
|
-
allowNull: true,
|
|
30
|
-
},
|
|
31
|
-
value: {
|
|
32
|
-
type: Sequelize.STRING,
|
|
33
|
-
allowNull: true,
|
|
34
|
-
},
|
|
35
|
-
endpoint: {
|
|
36
|
-
type: Sequelize.STRING,
|
|
37
|
-
allowNull: true,
|
|
38
|
-
},
|
|
39
|
-
credentials: {
|
|
40
|
-
type: Sequelize.JSON,
|
|
41
|
-
allowNull: true,
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
ApiAuthentications.associate = (models) => {
|
|
46
|
-
ApiAuthentications.hasOne(models.Apis)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return ApiAuthentications
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
module.exports = {
|
|
54
|
-
ApiAuthenticationsModel,
|
|
55
|
-
API_AUTHENTICATIONS_TYPE,
|
|
56
|
-
API_AUTHENTICATIONS_TYPES
|
|
57
|
-
}
|