@itleanchatbot/shared-models-js-postgres 1.1.31 → 1.1.33
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 +1 -1
- package/src/dialogNodes.js +29 -21
package/package.json
CHANGED
package/src/dialogNodes.js
CHANGED
|
@@ -80,13 +80,17 @@ const DialogNodesModel = (sequelize, Sequelize) => {
|
|
|
80
80
|
defaultValue: '',
|
|
81
81
|
set(value, field) {
|
|
82
82
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
let string = JSON.stringify([])
|
|
84
|
+
|
|
85
|
+
if(Array.isArray(value) && value.length) {
|
|
86
|
+
string = JSON.stringify(value.map(item => {
|
|
87
|
+
if(typeof string === 'object') {
|
|
88
|
+
return JSON.stringify(item)
|
|
89
|
+
} else {
|
|
90
|
+
return JSON.stringify({ error: 'Parse error' })
|
|
91
|
+
}
|
|
92
|
+
}))
|
|
93
|
+
}
|
|
90
94
|
|
|
91
95
|
this.setDataValue(field, string)
|
|
92
96
|
} catch (error) {
|
|
@@ -95,23 +99,27 @@ const DialogNodesModel = (sequelize, Sequelize) => {
|
|
|
95
99
|
}
|
|
96
100
|
},
|
|
97
101
|
get(field) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
try {
|
|
103
|
+
let value = this.getDataValue(field)
|
|
104
|
+
value = JSON.parse(value)
|
|
105
|
+
if (value.length) {
|
|
106
|
+
return value.map(item => {
|
|
107
|
+
try {
|
|
108
|
+
if(typeof item === 'string') {
|
|
109
|
+
return JSON.parse(item)
|
|
110
|
+
} else {
|
|
111
|
+
return item
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error(error)
|
|
106
115
|
return item
|
|
107
116
|
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
return value
|
|
120
|
+
} catch (error) {
|
|
121
|
+
return this.getDataValue(field)
|
|
113
122
|
}
|
|
114
|
-
return value
|
|
115
123
|
},
|
|
116
124
|
},
|
|
117
125
|
})
|