@mixd-id/web-scaffold 0.2.240705 → 0.2.250801009
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/docs/components/Dashboard.md +56 -0
- package/log.txt +7 -0
- package/package.json +27 -19
- package/src/components/404.vue +61 -0
- package/src/components/AccountIcon.vue +19 -0
- package/src/components/Ahref.vue +1 -1
- package/src/components/Alert.vue +4 -13
- package/src/components/ArrayList.vue +49 -0
- package/src/components/Article.vue +24 -30
- package/src/components/Button.vue +79 -167
- package/src/components/Card.vue +235 -0
- package/src/components/Carousel.vue +61 -60
- package/src/components/Cart.vue +192 -0
- package/src/components/CartIcon.vue +89 -0
- package/src/components/ChartBar.vue +2 -3
- package/src/components/Checkbox.vue +20 -11
- package/src/components/Checkout.vue +373 -0
- package/src/components/CheckoutDelivery.vue +267 -0
- package/src/components/CodeEditor.vue +5 -16
- package/src/components/CollapsiblePanel.vue +70 -0
- package/src/components/ColorPicker.vue +8 -3
- package/src/components/ColorPicker2.vue +41 -19
- package/src/components/ColorPicker3.vue +100 -0
- package/src/components/Confirm.vue +9 -7
- package/src/components/ContextMenu.vue +122 -206
- package/src/components/ContextMenuItem.vue +53 -0
- package/src/components/Dashboard.vue +243 -0
- package/src/components/Dashboard2.vue +118 -0
- package/src/components/DashboardComponentSelector.vue +96 -0
- package/src/components/DashboardConfigs.vue +202 -0
- package/src/components/Datepicker.vue +102 -41
- package/src/components/DayTimeRange.vue +3 -2
- package/src/components/Dropdown.vue +7 -4
- package/src/components/Flex.vue +14 -40
- package/src/components/GHeatMaps.vue +2 -2
- package/src/components/Grid.vue +6 -6
- package/src/components/HTMLEditor.vue +27 -14
- package/src/components/Image.vue +62 -108
- package/src/components/ImagePreview.vue +14 -4
- package/src/components/ImageUploader.vue +114 -0
- package/src/components/ImportModal.vue +3 -3
- package/src/components/Link.vue +62 -6
- package/src/components/List.vue +524 -402
- package/src/components/ListContextMenu.vue +88 -0
- package/src/components/ListItem.vue +5 -3
- package/src/components/ListPage1.vue +14 -15
- package/src/components/ListView.vue +5 -6
- package/src/components/ListViewSettings.vue +2 -2
- package/src/components/LogViewerItem.vue +1 -1
- package/src/components/MarkdownEdit.vue +128 -0
- package/src/components/MarkdownPreview.vue +102 -0
- package/src/components/MenuItem1.vue +36 -0
- package/src/components/Modal.vue +95 -43
- package/src/components/MultiDropdown.vue +124 -0
- package/src/components/MultilineText.vue +1 -4
- package/src/components/OTPField.vue +11 -17
- package/src/components/ObjectTree.vue +1 -1
- package/src/components/PageBuilder.vue +3 -3
- package/src/components/Paragraph.vue +1 -2
- package/src/components/PresetSelectorFilterItem.vue +107 -95
- package/src/components/Radio.vue +1 -1
- package/src/components/SearchModal.vue +153 -0
- package/src/components/Slider.vue +1 -1
- package/src/components/Svg.vue +1 -1
- package/src/components/SvgEditor.vue +173 -0
- package/src/components/Switch.vue +4 -5
- package/src/components/Table.vue +2 -2
- package/src/components/TableView.vue +2 -3
- package/src/components/TableViewHead.vue +2 -2
- package/src/components/Tabs.vue +1 -1
- package/src/components/Testimonial.vue +2 -2
- package/src/components/Text.vue +7 -22
- package/src/components/TextEditor.vue +3 -3
- package/src/components/TextWithTag.vue +61 -30
- package/src/components/Textarea.vue +11 -16
- package/src/components/Textbox.vue +9 -19
- package/src/components/Timepicker.vue +25 -15
- package/src/components/Toast.vue +5 -3
- package/src/components/TreeMenu.vue +122 -0
- package/src/components/TreeView.vue +15 -10
- package/src/components/TreeView2.vue +38 -0
- package/src/components/TreeViewItem.vue +58 -29
- package/src/components/TreeViewItem2.vue +55 -0
- package/src/components/Uploader.vue +45 -0
- package/src/components/Video.vue +119 -0
- package/src/components/VirtualGrid.vue +24 -7
- package/src/components/VirtualTable.vue +363 -128
- package/src/configs/dashboard/data-table.js +9 -0
- package/src/configs/web-page-builder.js +118 -0
- package/src/directives/intersect.js +26 -0
- package/src/hooks/device.js +14 -0
- package/src/index.js +62 -107
- package/src/mixin/component.js +147 -67
- package/src/themes/default/index.js +83 -155
- package/src/utils/dashboard.js +22 -962
- package/src/utils/helpers.cjs +635 -0
- package/src/utils/helpers.js +91 -60
- package/src/utils/helpers.mjs +245 -12
- package/src/utils/importer.js +22 -3
- package/src/utils/list.mjs +1509 -0
- package/src/utils/preset-selector.cjs +1455 -0
- package/src/utils/preset-selector.js +489 -95
- package/src/utils/preset-selector.mjs +59 -20
- package/src/utils/queue.js +63 -0
- package/src/utils/web.mjs +120 -0
- package/src/utils/wss.js +37 -29
- package/src/utils/wss.mjs +24 -19
- package/src/widgets/AhrefSetting.vue +16 -13
- package/src/widgets/ArticleSetting.vue +15 -27
- package/src/widgets/BackgroundColorSetting.vue +153 -0
- package/src/widgets/BorderColorSetting.vue +57 -0
- package/src/widgets/BotEditor/BotEditorActions.vue +3 -2
- package/src/widgets/BotEditor/BotEditorSettings.vue +21 -0
- package/src/widgets/BotEditor.vue +35 -15
- package/src/widgets/ButtonSetting.vue +12 -13
- package/src/widgets/CarouselSetting.vue +33 -45
- package/src/widgets/CartSetting.vue +46 -0
- package/src/widgets/CheckoutSetting.vue +46 -0
- package/src/widgets/CollapsiblePanelSetting.vue +46 -0
- package/src/widgets/ColumnSelector.vue +29 -5
- package/src/widgets/ComponentSetting.vue +1 -1
- package/src/widgets/ComponentSetting2.vue +112 -234
- package/src/widgets/ComponentSetting3.vue +1 -1
- package/src/widgets/ContactForm.vue +3 -3
- package/src/widgets/ContactFormSetting.vue +41 -30
- package/src/widgets/Dashboard/BarChart.vue +47 -11
- package/src/widgets/Dashboard/BarChartSetting.vue +1 -1
- package/src/widgets/Dashboard/DataTable.vue +125 -0
- package/src/widgets/Dashboard/DataTableSetting.vue +243 -0
- package/src/widgets/Dashboard/DatasourceSelector.vue +1 -1
- package/src/widgets/Dashboard/Doughnut.vue +49 -7
- package/src/widgets/Dashboard/DoughnutSetting.vue +2 -2
- package/src/widgets/Dashboard/Metric.vue +78 -19
- package/src/widgets/Dashboard/MetricSetting.vue +81 -28
- package/src/widgets/Dashboard/Pie.vue +55 -6
- package/src/widgets/Dashboard/PieSetting.vue +1 -1
- package/src/widgets/Dashboard/PolarArea.vue +49 -7
- package/src/widgets/Dashboard/PolarAreaSetting.vue +1 -1
- package/src/widgets/Dashboard/SharingModal.vue +4 -5
- package/src/widgets/Dashboard/ViewSelector.vue +2 -2
- package/src/widgets/Dashboard/VirtualTableSetting.vue +121 -184
- package/src/widgets/{Dashboard.vue → Dashboard0.vue} +426 -343
- package/src/widgets/EmbeddedVideoSetting.vue +7 -5
- package/src/widgets/FAQ.vue +16 -3
- package/src/widgets/FAQSetting.vue +53 -47
- package/src/widgets/FeatureList.vue +3 -0
- package/src/widgets/FeatureListSetting.vue +112 -102
- package/src/widgets/FlexSetting.vue +83 -106
- package/src/widgets/GridSetting.vue +71 -196
- package/src/widgets/Header2.vue +34 -71
- package/src/widgets/Header2Setting.vue +95 -179
- package/src/widgets/HeaderSetting.vue +16 -18
- package/src/widgets/IconListSetting.vue +69 -65
- package/src/widgets/ImageSetting.vue +33 -60
- package/src/widgets/LinkSetting.vue +60 -37
- package/src/widgets/LinkSettingModal.vue +173 -0
- package/src/widgets/LogViewer.vue +1 -1
- package/src/widgets/MarginSetting.vue +2 -2
- package/src/widgets/MenuEditor.vue +1 -1
- package/src/widgets/MenuItem1Setting.vue +78 -0
- package/src/widgets/ModalSetting.vue +42 -44
- package/src/widgets/MultiValueSetting.vue +2 -2
- package/src/widgets/MultiValueSetting2.vue +78 -45
- package/src/widgets/OGSettingModal.vue +103 -0
- package/src/widgets/PaddingSetting.vue +2 -2
- package/src/widgets/ParagraphSetting.vue +16 -13
- package/src/widgets/PositionSetting.vue +209 -0
- package/src/widgets/PresetBar.vue +359 -210
- package/src/widgets/PresetBarPivot.vue +31 -19
- package/src/widgets/PresetSelector.vue +29 -17
- package/src/widgets/SearchModalSetting.vue +70 -0
- package/src/widgets/Share.vue +1 -2
- package/src/widgets/ShareSetting.vue +67 -60
- package/src/widgets/StyleSetting.vue +227 -116
- package/src/widgets/TestimonialSetting.vue +97 -88
- package/src/widgets/TextBlockSetting.vue +16 -13
- package/src/widgets/UserActionBuilder/UserActionConsole.vue +30 -10
- package/src/widgets/UserActionBuilder/UserActionOutput.vue +2 -2
- package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +64 -87
- package/src/widgets/UserActionBuilder/UserActionProps.vue +3 -3
- package/src/widgets/UserActionBuilder.vue +4 -16
- package/src/widgets/WebComponentSelector.vue +15 -11
- package/src/widgets/WebLayoutSelector.vue +41 -270
- package/src/widgets/WebPageBuilder.vue +693 -704
- package/src/widgets/WebPageBuilder2.vue +7 -7
- package/src/widgets/WebPageBuilder4/ButtonSetting.vue +0 -8
- package/src/widgets/WebPageBuilder4/CarouselSetting.vue +63 -7
- package/src/widgets/WebPageBuilder4/FlexAlignSetting.vue +3 -3
- package/src/widgets/WebPageBuilder4/FlexSetting.vue +1 -10
- package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +2 -2
- package/src/widgets/WebPageBuilder4/PropertySetting.vue +0 -7
- package/src/widgets/WebPageBuilder4/WebPageComponentSelector.vue +1 -7
- package/src/widgets/WebPageBuilder4.vue +289 -575
- package/src/widgets/WebPageSelector.vue +1 -1
- package/src/widgets/YoutubeVideoSetting.vue +16 -13
- package/tailwind.config.js +3 -35
- package/docs/schema/user-action.json +0 -266
- package/src/App.vue +0 -25
- package/src/components/SearchButton.vue +0 -57
- package/src/entry-client.js +0 -27
- package/src/entry-server.js +0 -73
- package/src/events/event.js +0 -2
- package/src/main.js +0 -29
- package/src/mixin/website.js +0 -121
- package/src/router.js +0 -57
- package/src/widgets/MobileMenu.vue +0 -182
- package/src/widgets/WebPageBuilder4/ActionSetting.vue +0 -158
- package/src/widgets/WebPageBuilder4/ColorSetting.vue +0 -63
- package/src/widgets/WebPageBuilder4/DataSetting.vue +0 -92
- package/src/widgets/WebPageBuilder4/FontSizeSetting.vue +0 -76
- package/src/widgets/WebPageBuilder4/LinkSetting.vue +0 -68
- package/src/widgets/WebPageBuilder4/MobileMenuSetting.vue +0 -106
- package/src/widgets/WebPageBuilder4/Setting.vue +0 -73
- package/src/widgets/WebPageBuilder4/StyleSetting.vue +0 -77
- package/src/widgets/WebPageBuilder4/SvgSetting.vue +0 -207
- package/src/widgets/WebPageBuilder4/TextTransformSetting.vue +0 -70
- package/src/widgets/WebPageBuilder4/WebPageDataEdit.vue +0 -121
- package/test.json +0 -22
- /package/src/widgets/{Header1.vue → Header0.vue} +0 -0
- /package/src/widgets/{Header1Setting.vue → Header0Setting.vue} +0 -0
|
@@ -1,8 +1,366 @@
|
|
|
1
|
-
const groupBy = require("lodash/groupBy");
|
|
2
1
|
const dayjs = require("dayjs");
|
|
3
|
-
const {Op, literal, fn,
|
|
4
|
-
const {ftWildcard} = require("./helpers");
|
|
5
|
-
|
|
2
|
+
const {Op, literal, fn, DataTypes} = module.parent.require("sequelize");
|
|
3
|
+
const {ftWildcard, groupBy} = require("./helpers");
|
|
4
|
+
|
|
5
|
+
const getValue = (filter, opt) => {
|
|
6
|
+
|
|
7
|
+
const { columns, withoutKey = false } = opt
|
|
8
|
+
const { key, operator } = filter
|
|
9
|
+
const keyColumns = groupBy(columns, 'key')
|
|
10
|
+
const type = ((keyColumns[key] ?? [])[0] ?? {}).type
|
|
11
|
+
|
|
12
|
+
let whereObj = {}
|
|
13
|
+
|
|
14
|
+
switch(type){
|
|
15
|
+
|
|
16
|
+
case 'boolean':
|
|
17
|
+
withoutKey ? whereObj = { [Op.eq]:filter.value } : whereObj[key] = filter.value
|
|
18
|
+
break
|
|
19
|
+
|
|
20
|
+
case 'number':
|
|
21
|
+
switch(operator) {
|
|
22
|
+
case '=':
|
|
23
|
+
withoutKey ? whereObj = { [Op.eq]:filter.value } : whereObj[key] = filter.value
|
|
24
|
+
break
|
|
25
|
+
|
|
26
|
+
case '>':
|
|
27
|
+
case '>=':
|
|
28
|
+
case '<':
|
|
29
|
+
case '<=':
|
|
30
|
+
withoutKey ?
|
|
31
|
+
whereObj = { [Op[operator]]:filter.value } :
|
|
32
|
+
whereObj[key] = {
|
|
33
|
+
[Op[operator]]: filter.value
|
|
34
|
+
}
|
|
35
|
+
break
|
|
36
|
+
|
|
37
|
+
case 'in':
|
|
38
|
+
withoutKey ?
|
|
39
|
+
whereObj = { [Op.in]: (Array.isArray(filter.value) ? filter.value : filter.value.split(','))
|
|
40
|
+
.map(_ => parseInt(_))
|
|
41
|
+
.filter(_ => !isNaN(_)) } :
|
|
42
|
+
whereObj[key] = {
|
|
43
|
+
[Op.in]: filter.value.split(',')
|
|
44
|
+
.map(_ => parseInt(_))
|
|
45
|
+
.filter(_ => !isNaN(_))
|
|
46
|
+
}
|
|
47
|
+
break
|
|
48
|
+
|
|
49
|
+
case 'notIn':
|
|
50
|
+
withoutKey ?
|
|
51
|
+
whereObj = { [Op.notIn]: filter.value.split(',')
|
|
52
|
+
.map(_ => parseInt(_))
|
|
53
|
+
.filter(_ => !isNaN(_)) } :
|
|
54
|
+
whereObj[key] = {
|
|
55
|
+
[Op.notIn]: filter.value.split(',')
|
|
56
|
+
.map(_ => parseInt(_))
|
|
57
|
+
.filter(_ => !isNaN(_))
|
|
58
|
+
}
|
|
59
|
+
break
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
|
|
63
|
+
case 'date':
|
|
64
|
+
switch(operator) {
|
|
65
|
+
|
|
66
|
+
case 'thisWeek':
|
|
67
|
+
withoutKey ?
|
|
68
|
+
whereObj = {
|
|
69
|
+
[Op.between]: [
|
|
70
|
+
dayjs().startOf('week').format('YYYY-MM-DD 00:00:00'),
|
|
71
|
+
dayjs().endOf('week').format('YYYY-MM-DD 23:59:59'),
|
|
72
|
+
]
|
|
73
|
+
} :
|
|
74
|
+
whereObj[key] = {
|
|
75
|
+
[Op.between]: [
|
|
76
|
+
dayjs().startOf('week').format('YYYY-MM-DD 00:00:00'),
|
|
77
|
+
dayjs().endOf('week').format('YYYY-MM-DD 23:59:59'),
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
break
|
|
81
|
+
|
|
82
|
+
case 'thisMonth':
|
|
83
|
+
withoutKey ?
|
|
84
|
+
whereObj = {
|
|
85
|
+
[Op.between]: [
|
|
86
|
+
dayjs().startOf('month').format('YYYY-MM-DD 00:00:00'),
|
|
87
|
+
dayjs().endOf('month').format('YYYY-MM-DD 23:59:59'),
|
|
88
|
+
]
|
|
89
|
+
} :
|
|
90
|
+
whereObj[key] = {
|
|
91
|
+
[Op.between]: [
|
|
92
|
+
dayjs().startOf('month').format('YYYY-MM-DD 00:00:00'),
|
|
93
|
+
dayjs().endOf('month').format('YYYY-MM-DD 23:59:59'),
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
break
|
|
97
|
+
|
|
98
|
+
case 'thisYear':
|
|
99
|
+
withoutKey ?
|
|
100
|
+
whereObj = {
|
|
101
|
+
[Op.between]: [
|
|
102
|
+
dayjs().startOf('year').format('YYYY-MM-DD 00:00:00'),
|
|
103
|
+
dayjs().endOf('year').format('YYYY-MM-DD 23:59:59'),
|
|
104
|
+
]
|
|
105
|
+
} :
|
|
106
|
+
whereObj[key] = {
|
|
107
|
+
[Op.between]: [
|
|
108
|
+
dayjs().startOf('year').format('YYYY-MM-DD 00:00:00'),
|
|
109
|
+
dayjs().endOf('year').format('YYYY-MM-DD 23:59:59'),
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
break
|
|
113
|
+
|
|
114
|
+
case 'null':
|
|
115
|
+
withoutKey ?
|
|
116
|
+
whereObj = {
|
|
117
|
+
[Op.eq]: null
|
|
118
|
+
} :
|
|
119
|
+
whereObj[key] = {
|
|
120
|
+
[Op.eq]: null
|
|
121
|
+
}
|
|
122
|
+
break
|
|
123
|
+
|
|
124
|
+
case 'between':
|
|
125
|
+
withoutKey ?
|
|
126
|
+
whereObj = {
|
|
127
|
+
[Op.between]: [
|
|
128
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
129
|
+
dayjs(filter.value2).format('YYYY-MM-DD 23:59:59'),
|
|
130
|
+
]
|
|
131
|
+
} :
|
|
132
|
+
whereObj[key] = {
|
|
133
|
+
[Op.between]: [
|
|
134
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
135
|
+
dayjs(filter.value2).format('YYYY-MM-DD 23:59:59'),
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
break
|
|
139
|
+
|
|
140
|
+
case 'yesterday':
|
|
141
|
+
withoutKey ?
|
|
142
|
+
whereObj = {
|
|
143
|
+
[Op.between]: [
|
|
144
|
+
dayjs().subtract(1, 'day').startOf('day').format('YYYY-MM-DD 00:00:00'),
|
|
145
|
+
dayjs().subtract(1, 'day').endOf('day').format('YYYY-MM-DD 23:59:59'),
|
|
146
|
+
]
|
|
147
|
+
} :
|
|
148
|
+
whereObj[key] = {
|
|
149
|
+
[Op.between]: [
|
|
150
|
+
dayjs().subtract(1, 'day').startOf('day').format('YYYY-MM-DD 00:00:00'),
|
|
151
|
+
dayjs().subtract(1, 'day').endOf('day').format('YYYY-MM-DD 23:59:59'),
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
break
|
|
155
|
+
|
|
156
|
+
case 'today':
|
|
157
|
+
withoutKey ?
|
|
158
|
+
whereObj = {
|
|
159
|
+
[Op.between]: [
|
|
160
|
+
dayjs().startOf('day').format('YYYY-MM-DD 00:00:00'),
|
|
161
|
+
dayjs().endOf('day').format('YYYY-MM-DD 23:59:59'),
|
|
162
|
+
]
|
|
163
|
+
} :
|
|
164
|
+
whereObj[key] = {
|
|
165
|
+
[Op.between]: [
|
|
166
|
+
dayjs().startOf('day').format('YYYY-MM-DD 00:00:00'),
|
|
167
|
+
dayjs().endOf('day').format('YYYY-MM-DD 23:59:59'),
|
|
168
|
+
]
|
|
169
|
+
}
|
|
170
|
+
break
|
|
171
|
+
|
|
172
|
+
case '<':
|
|
173
|
+
withoutKey ?
|
|
174
|
+
whereObj = {
|
|
175
|
+
[Op.lt]: [
|
|
176
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
177
|
+
]
|
|
178
|
+
} :
|
|
179
|
+
whereObj[key] = {
|
|
180
|
+
[Op.lt]: [
|
|
181
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
break
|
|
185
|
+
|
|
186
|
+
case '<=':
|
|
187
|
+
withoutKey ?
|
|
188
|
+
whereObj = {
|
|
189
|
+
[Op.lte]: [
|
|
190
|
+
dayjs(filter.value).format('YYYY-MM-DD 23:59:59'),
|
|
191
|
+
]
|
|
192
|
+
} :
|
|
193
|
+
whereObj[key] = {
|
|
194
|
+
[Op.lte]: [
|
|
195
|
+
dayjs(filter.value).format('YYYY-MM-DD 23:59:59'),
|
|
196
|
+
]
|
|
197
|
+
}
|
|
198
|
+
break
|
|
199
|
+
|
|
200
|
+
case '=':
|
|
201
|
+
withoutKey ?
|
|
202
|
+
whereObj = {
|
|
203
|
+
[Op.between]: [
|
|
204
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
205
|
+
dayjs(filter.value).format('YYYY-MM-DD 23:59:59'),
|
|
206
|
+
]
|
|
207
|
+
} :
|
|
208
|
+
whereObj[key] = {
|
|
209
|
+
[Op.between]: [
|
|
210
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
211
|
+
dayjs(filter.value).format('YYYY-MM-DD 23:59:59'),
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
break
|
|
215
|
+
|
|
216
|
+
case '>':
|
|
217
|
+
withoutKey ?
|
|
218
|
+
whereObj = {
|
|
219
|
+
[Op.gt]: [
|
|
220
|
+
dayjs(filter.value).format('YYYY-MM-DD 23:59:59'),
|
|
221
|
+
]
|
|
222
|
+
} :
|
|
223
|
+
whereObj[key] = {
|
|
224
|
+
[Op.gt]: [
|
|
225
|
+
dayjs(filter.value).format('YYYY-MM-DD 23:59:59'),
|
|
226
|
+
]
|
|
227
|
+
}
|
|
228
|
+
break
|
|
229
|
+
|
|
230
|
+
case '>=':
|
|
231
|
+
withoutKey ?
|
|
232
|
+
whereObj = {
|
|
233
|
+
[Op.gte]: [
|
|
234
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
235
|
+
]
|
|
236
|
+
} :
|
|
237
|
+
whereObj[key] = {
|
|
238
|
+
[Op.gte]: [
|
|
239
|
+
dayjs(filter.value).format('YYYY-MM-DD 00:00:00'),
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
break
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
break
|
|
246
|
+
|
|
247
|
+
default:
|
|
248
|
+
switch(operator) {
|
|
249
|
+
case 'eq':
|
|
250
|
+
case '=':
|
|
251
|
+
withoutKey ?
|
|
252
|
+
whereObj = {
|
|
253
|
+
[Op.eq]: filter.value
|
|
254
|
+
} :
|
|
255
|
+
whereObj[key] = {
|
|
256
|
+
[Op.eq]: filter.value
|
|
257
|
+
}
|
|
258
|
+
break
|
|
259
|
+
|
|
260
|
+
case 'not':
|
|
261
|
+
withoutKey ?
|
|
262
|
+
whereObj = {
|
|
263
|
+
[Op[operator]]: filter.value
|
|
264
|
+
} :
|
|
265
|
+
whereObj[key] = {
|
|
266
|
+
[Op[operator]]: filter.value
|
|
267
|
+
}
|
|
268
|
+
break
|
|
269
|
+
|
|
270
|
+
case 'startsWith':
|
|
271
|
+
withoutKey ?
|
|
272
|
+
whereObj = {
|
|
273
|
+
[Op.like]: `${filter.value}%`
|
|
274
|
+
} :
|
|
275
|
+
whereObj[key] = {
|
|
276
|
+
[Op.like]: `${filter.value}%`
|
|
277
|
+
}
|
|
278
|
+
break
|
|
279
|
+
|
|
280
|
+
case 'endsWith':
|
|
281
|
+
withoutKey ?
|
|
282
|
+
whereObj = {
|
|
283
|
+
[Op.like]: `%${filter.value}`
|
|
284
|
+
} :
|
|
285
|
+
whereObj[key] = {
|
|
286
|
+
[Op.like]: `%${filter.value}`
|
|
287
|
+
}
|
|
288
|
+
break
|
|
289
|
+
|
|
290
|
+
case 'contains':
|
|
291
|
+
withoutKey ?
|
|
292
|
+
whereObj = {
|
|
293
|
+
[Op.like]: `%${filter.value}%`
|
|
294
|
+
} :
|
|
295
|
+
whereObj[key] = {
|
|
296
|
+
[Op.like]: `%${filter.value}%`
|
|
297
|
+
}
|
|
298
|
+
break
|
|
299
|
+
|
|
300
|
+
case 'notContains':
|
|
301
|
+
withoutKey ?
|
|
302
|
+
whereObj = {
|
|
303
|
+
[Op.notLike]: `%${filter.value}%`
|
|
304
|
+
} :
|
|
305
|
+
whereObj[key] = {
|
|
306
|
+
[Op.notLike]: `%${filter.value}%`
|
|
307
|
+
}
|
|
308
|
+
break
|
|
309
|
+
|
|
310
|
+
case 'notEmpty':
|
|
311
|
+
whereObj = {
|
|
312
|
+
[key]:{
|
|
313
|
+
[Op.or]: [
|
|
314
|
+
{ [Op.ne]: null },
|
|
315
|
+
{ [Op.ne]: '' }
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
break
|
|
320
|
+
|
|
321
|
+
case 'in':
|
|
322
|
+
withoutKey ?
|
|
323
|
+
whereObj = {
|
|
324
|
+
[Op.in]: (!Array.isArray(filter.value) ? filter.value.split(',') : filter.value)
|
|
325
|
+
.map(_ => parseInt(_))
|
|
326
|
+
.filter(_ => !isNaN(_))
|
|
327
|
+
} :
|
|
328
|
+
whereObj[key] = {
|
|
329
|
+
[Op.in]: (!Array.isArray(filter.value) ? filter.value.split(',') : filter.value)
|
|
330
|
+
.map(_ => parseInt(_))
|
|
331
|
+
.filter(_ => !isNaN(_))
|
|
332
|
+
}
|
|
333
|
+
break
|
|
334
|
+
|
|
335
|
+
case 'notIn':
|
|
336
|
+
withoutKey ?
|
|
337
|
+
whereObj = {
|
|
338
|
+
[Op.notIn]: filter.value.split(',')
|
|
339
|
+
.map(_ => parseInt(_))
|
|
340
|
+
.filter(_ => !isNaN(_))
|
|
341
|
+
} :
|
|
342
|
+
whereObj[key] = {
|
|
343
|
+
[Op.notIn]: filter.value.split(',')
|
|
344
|
+
.map(_ => parseInt(_))
|
|
345
|
+
.filter(_ => !isNaN(_))
|
|
346
|
+
}
|
|
347
|
+
break
|
|
348
|
+
|
|
349
|
+
case 'regex':
|
|
350
|
+
withoutKey ?
|
|
351
|
+
whereObj = {
|
|
352
|
+
[Op.regexp]: filter.value
|
|
353
|
+
} :
|
|
354
|
+
whereObj[key] = {
|
|
355
|
+
[Op.regexp]: filter.value
|
|
356
|
+
}
|
|
357
|
+
break
|
|
358
|
+
}
|
|
359
|
+
break
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return whereObj
|
|
363
|
+
}
|
|
6
364
|
|
|
7
365
|
const filtersToSequelizeWhere = async(filters, opt) => {
|
|
8
366
|
if(!Array.isArray(filters) || filters.length < 1){
|
|
@@ -23,8 +381,14 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
23
381
|
const type = ((keyColumns[key] ?? [])[0] ?? {}).type
|
|
24
382
|
|
|
25
383
|
let whereObj = {}
|
|
26
|
-
|
|
27
|
-
|
|
384
|
+
let Model, field
|
|
385
|
+
if(opt.model){
|
|
386
|
+
const modelAttributes = opt.model.getAttributes()
|
|
387
|
+
if(modelAttributes[key]){
|
|
388
|
+
Model = opt.model
|
|
389
|
+
field = modelAttributes[key].field
|
|
390
|
+
}
|
|
391
|
+
}
|
|
28
392
|
|
|
29
393
|
switch(type){
|
|
30
394
|
|
|
@@ -127,6 +491,12 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
127
491
|
}
|
|
128
492
|
break
|
|
129
493
|
|
|
494
|
+
case 'null':
|
|
495
|
+
whereObj = {
|
|
496
|
+
[key]: null
|
|
497
|
+
}
|
|
498
|
+
break
|
|
499
|
+
|
|
130
500
|
case 'between':
|
|
131
501
|
whereObj = {
|
|
132
502
|
[key]:{
|
|
@@ -268,6 +638,7 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
268
638
|
|
|
269
639
|
default:
|
|
270
640
|
switch(operator) {
|
|
641
|
+
case 'eq':
|
|
271
642
|
case '=':
|
|
272
643
|
whereObj = {
|
|
273
644
|
[key]:{
|
|
@@ -276,7 +647,6 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
276
647
|
}
|
|
277
648
|
break
|
|
278
649
|
|
|
279
|
-
case 'eq':
|
|
280
650
|
case 'not':
|
|
281
651
|
whereObj = {
|
|
282
652
|
[key]:{
|
|
@@ -317,6 +687,17 @@ const filtersToSequelizeWhere = async(filters, opt) => {
|
|
|
317
687
|
}
|
|
318
688
|
break
|
|
319
689
|
|
|
690
|
+
case 'notEmpty':
|
|
691
|
+
whereObj = {
|
|
692
|
+
[key]:{
|
|
693
|
+
[Op.or]: [
|
|
694
|
+
{ [Op.ne]: null },
|
|
695
|
+
{ [Op.ne]: '' }
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
break
|
|
700
|
+
|
|
320
701
|
case 'in':
|
|
321
702
|
whereObj = {
|
|
322
703
|
[key]:{
|
|
@@ -649,7 +1030,6 @@ const chartToSequelizeWhere = async (chart, opt) => {
|
|
|
649
1030
|
}
|
|
650
1031
|
|
|
651
1032
|
const pivotToSequelizeWhere = async (pivot, opt) => {
|
|
652
|
-
|
|
653
1033
|
const { model, sorts = [] } = opt
|
|
654
1034
|
|
|
655
1035
|
const attributes = []
|
|
@@ -657,120 +1037,131 @@ const pivotToSequelizeWhere = async (pivot, opt) => {
|
|
|
657
1037
|
const order = []
|
|
658
1038
|
const sortExists = sorts.length > 0
|
|
659
1039
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
for(let row of pivot.rows){
|
|
1040
|
+
if(Array.isArray(pivot.rows)){
|
|
1041
|
+
const groupedSorts = groupBy(sorts, 'key')
|
|
663
1042
|
|
|
664
|
-
|
|
1043
|
+
for(let row of pivot.rows){
|
|
1044
|
+
const field = model.rawAttributes[row.key].field
|
|
665
1045
|
|
|
666
|
-
|
|
1046
|
+
switch(row.aggregrate){
|
|
667
1047
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
1048
|
+
case 'date':
|
|
1049
|
+
attributes.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y-%m-%d'), row.key ])
|
|
1050
|
+
group.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y-%m-%d'), row.key ])
|
|
1051
|
+
if(!sortExists) order.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y-%m-%d'), 'asc' ])
|
|
1052
|
+
break
|
|
673
1053
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
1054
|
+
case 'month':
|
|
1055
|
+
attributes.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y-%m'), row.key ])
|
|
1056
|
+
group.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y-%m'), row.key ])
|
|
1057
|
+
if(!sortExists) order.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y-%m'), 'asc' ])
|
|
1058
|
+
break
|
|
679
1059
|
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
1060
|
+
case 'year':
|
|
1061
|
+
attributes.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y'), row.key ])
|
|
1062
|
+
group.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y'), row.key ])
|
|
1063
|
+
if(!sortExists) order.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%Y'), 'asc' ])
|
|
1064
|
+
break
|
|
685
1065
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
1066
|
+
case 'hour':
|
|
1067
|
+
attributes.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%H:00-%H:59'), row.key ])
|
|
1068
|
+
group.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%H:00-%H:59'), row.key ])
|
|
1069
|
+
if(!sortExists) order.push([ fn('DATE_FORMAT', literal(`${model.name}.${field}`), '%H:00-%H:59'), 'asc' ])
|
|
1070
|
+
break
|
|
691
1071
|
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
1072
|
+
default:
|
|
1073
|
+
attributes.push([ literal(`${model.name}.${field}`), row.key ])
|
|
1074
|
+
group.push(`${model.name}.${field}`)
|
|
1075
|
+
if(!sortExists) order.push([ row.key, groupedSorts[row.key] ? groupedSorts[row.key][0].type : 'asc' ])
|
|
1076
|
+
break
|
|
1077
|
+
}
|
|
697
1078
|
}
|
|
698
1079
|
}
|
|
699
1080
|
|
|
700
1081
|
const sortKeyToOrders = {} // Helper to determine group ordering
|
|
701
|
-
|
|
702
|
-
|
|
1082
|
+
if(Array.isArray(pivot.values)){
|
|
1083
|
+
for(let value of pivot.values){
|
|
1084
|
+
const valueKey = model.rawAttributes[value.key].field
|
|
703
1085
|
|
|
704
|
-
|
|
1086
|
+
switch(value.aggregrate){
|
|
705
1087
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
1088
|
+
case 'sum':
|
|
1089
|
+
attributes.push([ fn('SUM', literal(`${model.name}.${valueKey}`)), `_${value.key}-${value.aggregrate}` ])
|
|
1090
|
+
break
|
|
709
1091
|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
1092
|
+
case 'avg':
|
|
1093
|
+
attributes.push([ fn('AVG', literal(`${model.name}.${valueKey}`)), `_${value.key}-${value.aggregrate}` ])
|
|
1094
|
+
break
|
|
713
1095
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
1096
|
+
case 'min':
|
|
1097
|
+
attributes.push([ fn('MIN', literal(`${model.name}.${valueKey}`)), `_${value.key}-${value.aggregrate}` ])
|
|
1098
|
+
break
|
|
717
1099
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
1100
|
+
case 'max':
|
|
1101
|
+
attributes.push([ fn('MAX', literal(`${model.name}.${valueKey}`)), `_${value.key}-${value.aggregrate}` ])
|
|
1102
|
+
break
|
|
721
1103
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
1104
|
+
case 'countDistinct':
|
|
1105
|
+
attributes.push([ literal(`COUNT(DISTINCT ${model.name}.${valueKey})`), `_${value.key}-${value.aggregrate}` ])
|
|
1106
|
+
sortKeyToOrders[`_${value.key}-${value.aggregrate}`] = literal(`COUNT(DISTINCT ${model.name}.${valueKey})`)
|
|
1107
|
+
break
|
|
726
1108
|
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
break
|
|
1109
|
+
case 'first':
|
|
1110
|
+
attributes.push([ literal(`(SELECT ${valueKey} FROM ${model.tableName} WHERE id = MIN(${model.name}.id))`), `_${value.key}-${value.aggregrate}` ])
|
|
1111
|
+
break
|
|
731
1112
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
attributes: [ value.key ],
|
|
736
|
-
where: {
|
|
737
|
-
[Op.and]: [
|
|
738
|
-
where
|
|
739
|
-
]
|
|
740
|
-
},
|
|
741
|
-
group: [ value.key ],
|
|
742
|
-
replacements
|
|
743
|
-
})
|
|
1113
|
+
case 'last':
|
|
1114
|
+
attributes.push([ literal(`(SELECT ${valueKey} FROM ${model.tableName} WHERE id = MAX(${model.name}.id))`), `_${value.key}-${value.aggregrate}` ])
|
|
1115
|
+
break
|
|
744
1116
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
1117
|
+
case 'count':
|
|
1118
|
+
attributes.push([ fn('COUNT', literal(`${model.name}.${valueKey}`)), `_${value.key}-${value.aggregrate}` ])
|
|
1119
|
+
sortKeyToOrders[`_${value.key}-${value.aggregrate}`] = fn('COUNT', literal(`${model.name}.${valueKey}`))
|
|
1120
|
+
break
|
|
1121
|
+
|
|
1122
|
+
default:
|
|
1123
|
+
const { where, replacements } = opt
|
|
1124
|
+
const groups = await model.findAll({
|
|
1125
|
+
attributes: [ value.key ],
|
|
1126
|
+
where: {
|
|
1127
|
+
[Op.and]: [
|
|
1128
|
+
where
|
|
1129
|
+
]
|
|
1130
|
+
},
|
|
1131
|
+
group: [ value.key ],
|
|
1132
|
+
replacements
|
|
1133
|
+
})
|
|
1134
|
+
|
|
1135
|
+
if(groups.length > 50){
|
|
1136
|
+
throw new Error('Pivot value group is too large, max 50 items allowed.')
|
|
1137
|
+
}
|
|
748
1138
|
|
|
749
|
-
|
|
1139
|
+
const field = model.rawAttributes[value.key].field
|
|
750
1140
|
|
|
751
1141
|
|
|
752
|
-
|
|
1142
|
+
groups.forEach(group => {
|
|
753
1143
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
}
|
|
761
|
-
else{
|
|
762
|
-
if(model.rawAttributes[value.key].type instanceof DataTypes.BOOLEAN){
|
|
763
|
-
groupValue = group[value.key]
|
|
764
|
-
attributes.push([ literal(`SUM(CASE WHEN ${model.name}.${field} = ${groupValue === true ? 1 : 0} THEN 1 ELSE 0 END)`), `_${value.key}-${groupValue}` ])
|
|
1144
|
+
let groupValue
|
|
1145
|
+
if(group[value.key] === null){
|
|
1146
|
+
attributes.push([ literal(`SUM(CASE WHEN ${model.name}.${field} is null THEN 1 ELSE 0 END)`), `_${value.key}-(null)` ])
|
|
1147
|
+
}
|
|
1148
|
+
else if(group[value.key] === ''){
|
|
1149
|
+
attributes.push([ literal(`SUM(CASE WHEN ${model.name}.${field} = '' THEN 1 ELSE 0 END)`), `_${value.key}-(empty)` ])
|
|
765
1150
|
}
|
|
766
1151
|
else{
|
|
767
|
-
|
|
768
|
-
|
|
1152
|
+
if(model.rawAttributes[value.key].type instanceof DataTypes.BOOLEAN){
|
|
1153
|
+
groupValue = group[value.key]
|
|
1154
|
+
attributes.push([ literal(`SUM(CASE WHEN ${model.name}.${field} = ${groupValue === true ? 1 : 0} THEN 1 ELSE 0 END)`), `_${value.key}-${groupValue}` ])
|
|
1155
|
+
}
|
|
1156
|
+
else{
|
|
1157
|
+
groupValue = (group[value.key] ?? '').toString().replace(/\s/g, '_')
|
|
1158
|
+
attributes.push([ literal(`SUM(CASE WHEN ${model.name}.${field} = '${group[value.key]}' THEN 1 ELSE 0 END)`), `_${value.key}-${groupValue}` ])
|
|
1159
|
+
}
|
|
769
1160
|
}
|
|
770
|
-
}
|
|
771
|
-
})
|
|
1161
|
+
})
|
|
772
1162
|
|
|
773
|
-
|
|
1163
|
+
break
|
|
1164
|
+
}
|
|
774
1165
|
}
|
|
775
1166
|
}
|
|
776
1167
|
|
|
@@ -892,6 +1283,8 @@ const filtersToSequelizeInclude = async(filters, opt, includes) => {
|
|
|
892
1283
|
include.where = { [Op.and]: [] }
|
|
893
1284
|
}
|
|
894
1285
|
include.where[Op.and].push({ [currentKey]: whereObj[key] })
|
|
1286
|
+
|
|
1287
|
+
include.required = true
|
|
895
1288
|
}
|
|
896
1289
|
|
|
897
1290
|
//console.log('includes', util.inspect(includes, false, null, true /* enable colors */))
|
|
@@ -915,7 +1308,7 @@ const syntaxSearchToSequelizeOpt = async(search, opt) => {
|
|
|
915
1308
|
}
|
|
916
1309
|
}
|
|
917
1310
|
|
|
918
|
-
const presetToSequelizeList = async(preset
|
|
1311
|
+
const presetToSequelizeList = async(preset, {
|
|
919
1312
|
conn,
|
|
920
1313
|
model,
|
|
921
1314
|
config,
|
|
@@ -924,6 +1317,7 @@ const presetToSequelizeList = async(preset = {}, {
|
|
|
924
1317
|
include,
|
|
925
1318
|
order:initialOrder
|
|
926
1319
|
}) => {
|
|
1320
|
+
if(!model) return {}
|
|
927
1321
|
|
|
928
1322
|
const updatedAtField = model.rawAttributes['updatedAt'] ?? model.rawAttributes['updated_at']
|
|
929
1323
|
|