@itleanchatbot/shared-models-js-postgres 1.1.29 → 1.1.31
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/package.json +2 -1
- package/src/dialogNodes.js +32 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itleanchatbot/shared-models-js-postgres",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.31",
|
|
4
4
|
"description": "Shared Models JS Postgres",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "ISC",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"commitizen": {
|
|
21
21
|
"path": "./node_modules/cz-conventional-changelog"
|
|
22
22
|
}
|
|
23
|
+
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
26
|
"@commitlint/cli": "^11.0.0",
|
package/src/dialogNodes.js
CHANGED
|
@@ -75,13 +75,41 @@ const DialogNodesModel = (sequelize, Sequelize) => {
|
|
|
75
75
|
defaultValue: true,
|
|
76
76
|
},
|
|
77
77
|
contexts: {
|
|
78
|
-
type: Sequelize.
|
|
78
|
+
type: Sequelize.TEXT,
|
|
79
79
|
allowNull: false,
|
|
80
|
-
defaultValue:
|
|
80
|
+
defaultValue: '',
|
|
81
|
+
set(value, field) {
|
|
82
|
+
try {
|
|
83
|
+
const string = JSON.stringify(value.map(item => {
|
|
84
|
+
if(typeof string === 'object') {
|
|
85
|
+
return JSON.stringify(item)
|
|
86
|
+
} else {
|
|
87
|
+
return JSON.stringify({ error: 'Parse error' })
|
|
88
|
+
}
|
|
89
|
+
}))
|
|
90
|
+
|
|
91
|
+
this.setDataValue(field, string)
|
|
92
|
+
} catch (error) {
|
|
93
|
+
this.setDataValue(field, '')
|
|
94
|
+
console.error(error)
|
|
95
|
+
}
|
|
96
|
+
},
|
|
81
97
|
get(field) {
|
|
82
|
-
|
|
98
|
+
let value = this.getDataValue(field)
|
|
99
|
+
value = JSON.parse(value)
|
|
83
100
|
if (value.length) {
|
|
84
|
-
return value.map(
|
|
101
|
+
return value.map(item => {
|
|
102
|
+
try {
|
|
103
|
+
if(typeof item === 'string') {
|
|
104
|
+
return JSON.parse(item)
|
|
105
|
+
} else {
|
|
106
|
+
return item
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error(error)
|
|
110
|
+
return item
|
|
111
|
+
}
|
|
112
|
+
})
|
|
85
113
|
}
|
|
86
114
|
return value
|
|
87
115
|
},
|