@mixd-id/web-scaffold 0.2.250801010 → 0.2.250801012
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/AccountIcon.md +16 -0
- package/docs/components/Ahref.md +35 -0
- package/docs/components/Alert.md +72 -0
- package/docs/components/ArrayList.md +39 -0
- package/docs/components/Article.md +28 -0
- package/docs/components/BarChart.md +81 -0
- package/docs/components/Block.md +23 -0
- package/docs/components/Box.md +15 -0
- package/docs/components/Button.md +68 -0
- package/docs/components/Card.md +67 -0
- package/docs/components/Carousel.md +70 -0
- package/docs/components/Cart.md +20 -0
- package/docs/components/CartIcon.md +29 -0
- package/docs/components/Chart.md +53 -0
- package/docs/components/ChartBar.md +34 -0
- package/docs/components/ChatTyping.md +21 -0
- package/docs/components/Checkbox.md +63 -0
- package/docs/components/CodeEditor.md +25 -0
- package/docs/components/CollapsiblePanel.md +41 -0
- package/docs/components/ColorPicker.md +52 -0
- package/docs/components/Confirm.md +62 -0
- package/docs/components/ContextMenu.md +76 -0
- package/docs/components/ContextMenuItem.md +29 -0
- package/docs/components/CopyToClipboard.md +43 -0
- package/docs/components/Countdown.md +47 -0
- package/docs/components/Datepicker.md +61 -0
- package/docs/components/Datetimepicker.md +57 -0
- package/docs/components/DayTimeRange.md +20 -0
- package/docs/components/Dropdown.md +65 -0
- package/docs/components/ErrorText.md +15 -0
- package/docs/components/FBLogin.md +21 -0
- package/docs/components/Flex.md +44 -0
- package/docs/components/GHeatMaps.md +16 -0
- package/docs/components/GSignIn.md +21 -0
- package/docs/components/Gmaps.md +16 -0
- package/docs/components/GmapsDirection.md +20 -0
- package/docs/components/Grid.md +36 -0
- package/docs/components/HTMLEditor.md +26 -0
- package/docs/components/IconMenu.md +20 -0
- package/docs/components/Image.md +78 -0
- package/docs/components/Link.md +33 -0
- package/docs/components/MultiDropdown.md +46 -0
- package/docs/components/Radio.md +55 -0
- package/docs/components/Slider.md +47 -0
- package/docs/components/Switch.md +43 -0
- package/docs/components/Table.md +31 -0
- package/docs/components/Tabs.md +65 -0
- package/docs/components/Text.md +30 -0
- package/docs/components/Textarea.md +66 -0
- package/docs/components/Textbox.md +97 -0
- package/docs/components/Timepicker.md +62 -0
- package/docs/components/Toast.md +59 -0
- package/docs/components/Uploader.md +51 -0
- package/docs/components/Video.md +54 -0
- package/package.json +65 -2
- package/docs/components/Dashboard.md +0 -56
- package/docs/components/Header2.md +0 -16
- package/log.txt +0 -7
- package/public/assets/dashboard/bar.png +0 -0
- package/public/assets/dashboard/doughnut.png +0 -0
- package/public/assets/dashboard/metric.png +0 -0
- package/public/assets/dashboard/pie.png +0 -0
- package/public/assets/dashboard/polar-area.png +0 -0
- package/public/assets/dashboard/virtual-table.png +0 -0
- package/public/static/dashboard/bar.png +0 -0
- package/public/static/dashboard/doughnut.png +0 -0
- package/public/static/dashboard/metric.png +0 -0
- package/public/static/dashboard/pie.png +0 -0
- package/public/static/dashboard/polar-area.png +0 -0
- package/public/static/dashboard/virtual-table.png +0 -0
- package/src/components/404.vue +0 -61
- package/src/components/AccountIcon.vue +0 -19
- package/src/components/Ahref.vue +0 -200
- package/src/components/Alert.vue +0 -257
- package/src/components/ArrayList.vue +0 -49
- package/src/components/Article.vue +0 -387
- package/src/components/Block.vue +0 -31
- package/src/components/Box.vue +0 -34
- package/src/components/Button.vue +0 -258
- package/src/components/Card.vue +0 -257
- package/src/components/Carousel.vue +0 -364
- package/src/components/Cart.vue +0 -192
- package/src/components/CartIcon.vue +0 -89
- package/src/components/Chart.vue +0 -485
- package/src/components/ChartBar.vue +0 -192
- package/src/components/ChatTyping.vue +0 -69
- package/src/components/Checkbox.vue +0 -200
- package/src/components/Checkout.vue +0 -373
- package/src/components/CheckoutDelivery.vue +0 -267
- package/src/components/CodeEditor.vue +0 -50
- package/src/components/CollapsiblePanel.vue +0 -70
- package/src/components/ColorPicker.vue +0 -165
- package/src/components/ColorPicker2.vue +0 -186
- package/src/components/ColorPicker3.vue +0 -100
- package/src/components/Confirm.vue +0 -180
- package/src/components/ContextMenu.vue +0 -265
- package/src/components/ContextMenuItem.vue +0 -53
- package/src/components/ConversationBuilder.vue +0 -161
- package/src/components/CopyToClipboard.vue +0 -34
- package/src/components/Countdown.vue +0 -264
- package/src/components/DGrid.vue +0 -21
- package/src/components/DGridItem.vue +0 -263
- package/src/components/Dashboard.vue +0 -243
- package/src/components/Dashboard2.vue +0 -118
- package/src/components/DashboardComponentSelector.vue +0 -96
- package/src/components/DashboardConfigs.vue +0 -202
- package/src/components/DataList.vue +0 -92
- package/src/components/Datepicker.vue +0 -399
- package/src/components/DayTimeRange.vue +0 -126
- package/src/components/Dropdown.vue +0 -224
- package/src/components/ErrorText.vue +0 -57
- package/src/components/FBLogin.vue +0 -194
- package/src/components/Feed.vue +0 -118
- package/src/components/Flex.vue +0 -44
- package/src/components/GHeatMaps.vue +0 -317
- package/src/components/GSignIn.vue +0 -166
- package/src/components/Gmaps.vue +0 -251
- package/src/components/GmapsDirection.vue +0 -191
- package/src/components/Grid.vue +0 -35
- package/src/components/HTMLEditor.vue +0 -588
- package/src/components/IconMenu.vue +0 -95
- package/src/components/IconMenu2.vue +0 -89
- package/src/components/IconPlus.vue +0 -89
- package/src/components/Image.vue +0 -263
- package/src/components/Image360.vue +0 -140
- package/src/components/ImageFullScreen.vue +0 -101
- package/src/components/ImagePreview.vue +0 -93
- package/src/components/ImageUploader.vue +0 -114
- package/src/components/ImportModal.vue +0 -260
- package/src/components/Link.vue +0 -95
- package/src/components/List.vue +0 -1381
- package/src/components/ListContextMenu.vue +0 -88
- package/src/components/ListItem.vue +0 -160
- package/src/components/ListPage1.vue +0 -1401
- package/src/components/ListPage1Filter.vue +0 -170
- package/src/components/ListView.vue +0 -961
- package/src/components/ListViewBarSummary.vue +0 -81
- package/src/components/ListViewLineSummary.vue +0 -75
- package/src/components/ListViewLiveBarSummary.vue +0 -52
- package/src/components/ListViewMapSummary.vue +0 -56
- package/src/components/ListViewSettings.vue +0 -514
- package/src/components/ListViewTableSummary.vue +0 -77
- package/src/components/LogViewerItem.vue +0 -116
- package/src/components/MarkdownEdit.vue +0 -128
- package/src/components/MarkdownPreview.vue +0 -102
- package/src/components/MenuItem1.vue +0 -36
- package/src/components/Modal.vue +0 -456
- package/src/components/MultiDropdown.vue +0 -124
- package/src/components/MultilineText.vue +0 -174
- package/src/components/OTPField.vue +0 -139
- package/src/components/ObjectTree.vue +0 -105
- package/src/components/PageBuilder.vue +0 -449
- package/src/components/Paragraph.vue +0 -40
- package/src/components/PresetSelectorFilterItem.vue +0 -203
- package/src/components/Radio.vue +0 -109
- package/src/components/SearchModal.vue +0 -153
- package/src/components/Slider.vue +0 -317
- package/src/components/SplitPane.vue +0 -129
- package/src/components/Svg.vue +0 -33
- package/src/components/SvgEditor.vue +0 -173
- package/src/components/Switch.vue +0 -101
- package/src/components/TabView.vue +0 -105
- package/src/components/Table.vue +0 -56
- package/src/components/TableView.vue +0 -200
- package/src/components/TableViewHead.vue +0 -159
- package/src/components/Tabs.vue +0 -131
- package/src/components/Test.vue +0 -23
- package/src/components/Testimonial.vue +0 -86
- package/src/components/Text.vue +0 -34
- package/src/components/TextBlock.vue +0 -50
- package/src/components/TextEditor.vue +0 -85
- package/src/components/TextWithTag.vue +0 -298
- package/src/components/Textarea.vue +0 -184
- package/src/components/Textbox.vue +0 -216
- package/src/components/Thumbnail.vue +0 -27
- package/src/components/Timepicker.vue +0 -125
- package/src/components/Toast.vue +0 -117
- package/src/components/TreeMenu.vue +0 -122
- package/src/components/TreeView.vue +0 -106
- package/src/components/TreeView2.vue +0 -38
- package/src/components/TreeViewItem.vue +0 -453
- package/src/components/TreeViewItem1.vue +0 -282
- package/src/components/TreeViewItem2.vue +0 -55
- package/src/components/Uploader.vue +0 -45
- package/src/components/Video.vue +0 -119
- package/src/components/VirtualGrid.vue +0 -297
- package/src/components/VirtualScroll.vue +0 -282
- package/src/components/VirtualTable.vue +0 -956
- package/src/components/YoutubeVideo.vue +0 -196
- package/src/configs/dashboard/bar.js +0 -10
- package/src/configs/dashboard/collection-1.js +0 -5
- package/src/configs/dashboard/data-table.js +0 -9
- package/src/configs/dashboard/doughnut.js +0 -7
- package/src/configs/dashboard/gheatmaps.js +0 -9
- package/src/configs/dashboard/grid-2.js +0 -34
- package/src/configs/dashboard/grid-3.js +0 -34
- package/src/configs/dashboard/grid-4.js +0 -34
- package/src/configs/dashboard/grid.js +0 -15
- package/src/configs/dashboard/metric.js +0 -10
- package/src/configs/dashboard/pie.js +0 -7
- package/src/configs/dashboard/polar-area.js +0 -7
- package/src/configs/dashboard/virtual-table.js +0 -9
- package/src/configs/icons-fa.json +0 -12
- package/src/configs/web-page-builder.js +0 -118
- package/src/defs/dashboard-preset.js +0 -22
- package/src/directives/intersect.js +0 -26
- package/src/hooks/device.js +0 -14
- package/src/index.css +0 -3
- package/src/index.js +0 -648
- package/src/middleware/http/trim-string.js +0 -20
- package/src/mixin/component.js +0 -306
- package/src/mixin/ready-state.js +0 -37
- package/src/stores/components.js +0 -36
- package/src/stores/datasource.js +0 -11
- package/src/themes/default/index.js +0 -303
- package/src/utils/dashboard.js +0 -140
- package/src/utils/event-bus.js +0 -8
- package/src/utils/helpers.cjs +0 -635
- package/src/utils/helpers.js +0 -635
- package/src/utils/helpers.mjs +0 -722
- package/src/utils/importer.js +0 -209
- package/src/utils/list.mjs +0 -1509
- package/src/utils/listpage1.js +0 -1507
- package/src/utils/listview.js +0 -1287
- package/src/utils/preset-selector.cjs +0 -1455
- package/src/utils/preset-selector.js +0 -1452
- package/src/utils/preset-selector.mjs +0 -234
- package/src/utils/queue.js +0 -63
- package/src/utils/selection.js +0 -43
- package/src/utils/web.js +0 -50
- package/src/utils/web.mjs +0 -120
- package/src/utils/wss.js +0 -296
- package/src/utils/wss.mjs +0 -285
- package/src/widgets/AhrefSetting.vue +0 -97
- package/src/widgets/ArticleSetting.vue +0 -457
- package/src/widgets/BackgroundColorSetting.vue +0 -153
- package/src/widgets/BackgroundSetting.vue +0 -132
- package/src/widgets/BlockSetting.vue +0 -49
- package/src/widgets/BorderColorSetting.vue +0 -57
- package/src/widgets/BorderSetting.vue +0 -201
- package/src/widgets/BotEditor/BotEditorActions.vue +0 -163
- package/src/widgets/BotEditor/BotEditorSettings.vue +0 -21
- package/src/widgets/BotEditor.vue +0 -248
- package/src/widgets/BoxSetting.vue +0 -53
- package/src/widgets/ButtonSetting.vue +0 -113
- package/src/widgets/CarouselSetting.vue +0 -181
- package/src/widgets/CartSetting.vue +0 -46
- package/src/widgets/CheckoutSetting.vue +0 -46
- package/src/widgets/CollapsiblePanelSetting.vue +0 -46
- package/src/widgets/ColumnSelector.vue +0 -104
- package/src/widgets/ComponentPropertyLabel.vue +0 -35
- package/src/widgets/ComponentPropertySelector.vue +0 -115
- package/src/widgets/ComponentSetting.vue +0 -2220
- package/src/widgets/ComponentSetting2.vue +0 -927
- package/src/widgets/ComponentSetting3.vue +0 -231
- package/src/widgets/ContactForm.vue +0 -193
- package/src/widgets/ContactFormSetting.vue +0 -395
- package/src/widgets/CountdownSetting.vue +0 -76
- package/src/widgets/Dashboard/BarChart.vue +0 -366
- package/src/widgets/Dashboard/BarChartSetting.vue +0 -317
- package/src/widgets/Dashboard/DataTable.vue +0 -125
- package/src/widgets/Dashboard/DataTableSetting.vue +0 -243
- package/src/widgets/Dashboard/DatasourceFilterSharing.vue +0 -93
- package/src/widgets/Dashboard/DatasourcePreview.vue +0 -93
- package/src/widgets/Dashboard/DatasourceSelector.vue +0 -122
- package/src/widgets/Dashboard/Doughnut.vue +0 -199
- package/src/widgets/Dashboard/DoughnutSetting.vue +0 -196
- package/src/widgets/Dashboard/GHeatMapsSetting.vue +0 -108
- package/src/widgets/Dashboard/InteractionEdit.vue +0 -228
- package/src/widgets/Dashboard/Metric.vue +0 -135
- package/src/widgets/Dashboard/MetricSetting.vue +0 -227
- package/src/widgets/Dashboard/Pie.vue +0 -188
- package/src/widgets/Dashboard/PieSetting.vue +0 -247
- package/src/widgets/Dashboard/PolarArea.vue +0 -201
- package/src/widgets/Dashboard/PolarAreaSetting.vue +0 -195
- package/src/widgets/Dashboard/SharingModal.vue +0 -115
- package/src/widgets/Dashboard/ViewSelector.vue +0 -183
- package/src/widgets/Dashboard/VirtualColumnEdit.vue +0 -97
- package/src/widgets/Dashboard/VirtualTableSetting.vue +0 -171
- package/src/widgets/Dashboard0.vue +0 -1856
- package/src/widgets/DataListSetting.vue +0 -102
- package/src/widgets/EffectSetting.vue +0 -94
- package/src/widgets/EmbeddedVideo.vue +0 -60
- package/src/widgets/EmbeddedVideoSetting.vue +0 -50
- package/src/widgets/FAQ.vue +0 -98
- package/src/widgets/FAQSetting.vue +0 -94
- package/src/widgets/FeatureList.vue +0 -131
- package/src/widgets/FeatureListSetting.vue +0 -233
- package/src/widgets/FiltersSetting.vue +0 -88
- package/src/widgets/FlexSetting.vue +0 -174
- package/src/widgets/GridSetting.vue +0 -165
- package/src/widgets/Header.vue +0 -15
- package/src/widgets/Header0.vue +0 -41
- package/src/widgets/Header0Setting.vue +0 -75
- package/src/widgets/Header2.vue +0 -65
- package/src/widgets/Header2Setting.vue +0 -193
- package/src/widgets/HeaderSetting.vue +0 -102
- package/src/widgets/IconList.vue +0 -51
- package/src/widgets/IconListSetting.vue +0 -188
- package/src/widgets/ImageSetting.vue +0 -119
- package/src/widgets/LayoutSetting.vue +0 -251
- package/src/widgets/LinkSetting.vue +0 -209
- package/src/widgets/LinkSettingModal.vue +0 -173
- package/src/widgets/LogViewer.vue +0 -85
- package/src/widgets/MarginPaddingSetting.vue +0 -58
- package/src/widgets/MarginSetting.vue +0 -142
- package/src/widgets/MenuEditor.vue +0 -256
- package/src/widgets/MenuItem1Setting.vue +0 -78
- package/src/widgets/ModalSetting.vue +0 -94
- package/src/widgets/MultiValueSetting.vue +0 -121
- package/src/widgets/MultiValueSetting2.vue +0 -147
- package/src/widgets/OGSettingModal.vue +0 -103
- package/src/widgets/PaddingSetting.vue +0 -142
- package/src/widgets/ParagraphSetting.vue +0 -89
- package/src/widgets/PositionSetting.vue +0 -209
- package/src/widgets/PresetBar.vue +0 -990
- package/src/widgets/PresetBarPivot.vue +0 -198
- package/src/widgets/PresetBarPivotColumnEdit.vue +0 -197
- package/src/widgets/PresetSelector.vue +0 -685
- package/src/widgets/Review.vue +0 -131
- package/src/widgets/ReviewSetting.vue +0 -201
- package/src/widgets/SearchModalSetting.vue +0 -70
- package/src/widgets/Share.vue +0 -164
- package/src/widgets/ShareSetting.vue +0 -99
- package/src/widgets/SizingSetting.vue +0 -306
- package/src/widgets/SpacingSetting.vue +0 -77
- package/src/widgets/StyleSetting.vue +0 -543
- package/src/widgets/StyleSetting2.vue +0 -90
- package/src/widgets/SvgSetting.vue +0 -133
- package/src/widgets/TableSetting.vue +0 -172
- package/src/widgets/TestimonialSetting.vue +0 -161
- package/src/widgets/TextBlockSetting.vue +0 -81
- package/src/widgets/ThumbnailSetting.vue +0 -49
- package/src/widgets/TransitionSetting.vue +0 -64
- package/src/widgets/TypographySetting.vue +0 -334
- package/src/widgets/UserActionBuilder/UserActionCondition.vue +0 -99
- package/src/widgets/UserActionBuilder/UserActionConsole.vue +0 -97
- package/src/widgets/UserActionBuilder/UserActionItem.vue +0 -273
- package/src/widgets/UserActionBuilder/UserActionOutput.vue +0 -152
- package/src/widgets/UserActionBuilder/UserActionOutputDelay.vue +0 -27
- package/src/widgets/UserActionBuilder/UserActionOutputLog.vue +0 -28
- package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +0 -112
- package/src/widgets/UserActionBuilder/UserActionProps.vue +0 -213
- package/src/widgets/UserActionBuilder.vue +0 -314
- package/src/widgets/WebComponentSelector.vue +0 -205
- package/src/widgets/WebDatasourceSelector.vue +0 -153
- package/src/widgets/WebLayoutSelector.vue +0 -147
- package/src/widgets/WebPageBuilder.vue +0 -2161
- package/src/widgets/WebPageBuilder2.vue +0 -1091
- package/src/widgets/WebPageBuilder3.vue +0 -411
- package/src/widgets/WebPageBuilder4/BackgroundColorSetting.vue +0 -54
- package/src/widgets/WebPageBuilder4/BackgroundPositionSetting.vue +0 -75
- package/src/widgets/WebPageBuilder4/BackgroundRepeatSetting.vue +0 -72
- package/src/widgets/WebPageBuilder4/BackgroundSizeSetting.vue +0 -72
- package/src/widgets/WebPageBuilder4/BlurSetting.vue +0 -72
- package/src/widgets/WebPageBuilder4/BorderColorSetting.vue +0 -64
- package/src/widgets/WebPageBuilder4/BorderRadiusSetting.vue +0 -75
- package/src/widgets/WebPageBuilder4/BorderSizeSetting.vue +0 -69
- package/src/widgets/WebPageBuilder4/BorderStyleSetting.vue +0 -72
- package/src/widgets/WebPageBuilder4/BoxShadowSetting.vue +0 -73
- package/src/widgets/WebPageBuilder4/ButtonSetting.vue +0 -65
- package/src/widgets/WebPageBuilder4/CarouselSetting.vue +0 -178
- package/src/widgets/WebPageBuilder4/DisplaySetting.vue +0 -76
- package/src/widgets/WebPageBuilder4/FlexAlignSetting.vue +0 -71
- package/src/widgets/WebPageBuilder4/FlexDirectionSetting.vue +0 -70
- package/src/widgets/WebPageBuilder4/FlexJustifySetting.vue +0 -74
- package/src/widgets/WebPageBuilder4/FlexPropertySetting.vue +0 -71
- package/src/widgets/WebPageBuilder4/FlexSetting.vue +0 -96
- package/src/widgets/WebPageBuilder4/FlexWrapSetting.vue +0 -69
- package/src/widgets/WebPageBuilder4/GapSetting.vue +0 -75
- package/src/widgets/WebPageBuilder4/GrayscaleSetting.vue +0 -68
- package/src/widgets/WebPageBuilder4/GridSetting.vue +0 -216
- package/src/widgets/WebPageBuilder4/HeightSetting.vue +0 -98
- package/src/widgets/WebPageBuilder4/ImageSetting.vue +0 -102
- package/src/widgets/WebPageBuilder4/MarginSetting.vue +0 -73
- package/src/widgets/WebPageBuilder4/MaxHeightSetting.vue +0 -82
- package/src/widgets/WebPageBuilder4/MaxWidthSetting.vue +0 -90
- package/src/widgets/WebPageBuilder4/MinHeightSetting.vue +0 -81
- package/src/widgets/WebPageBuilder4/MinWidthSetting.vue +0 -101
- package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +0 -163
- package/src/widgets/WebPageBuilder4/OpacitySetting.vue +0 -77
- package/src/widgets/WebPageBuilder4/OverflowSetting.vue +0 -81
- package/src/widgets/WebPageBuilder4/PaddingSetting.vue +0 -57
- package/src/widgets/WebPageBuilder4/PositionSetting.vue +0 -191
- package/src/widgets/WebPageBuilder4/PropertySetting.vue +0 -176
- package/src/widgets/WebPageBuilder4/TextSetting.vue +0 -72
- package/src/widgets/WebPageBuilder4/TreeView.vue +0 -46
- package/src/widgets/WebPageBuilder4/TreeViewItem.vue +0 -303
- package/src/widgets/WebPageBuilder4/WebPageComponentSelector.vue +0 -141
- package/src/widgets/WebPageBuilder4/WebPagePropertySelector.vue +0 -172
- package/src/widgets/WebPageBuilder4/WidthSetting.vue +0 -105
- package/src/widgets/WebPageBuilder4/ZIndexSetting.vue +0 -72
- package/src/widgets/WebPageBuilder4.vue +0 -798
- package/src/widgets/WebPagePreview.vue +0 -295
- package/src/widgets/WebPageSelector.vue +0 -173
- package/src/widgets/WebTemplateCreator.vue +0 -156
- package/src/widgets/YoutubeVideoSetting.vue +0 -68
- package/tailwind.config.js +0 -481
package/src/utils/helpers.js
DELETED
|
@@ -1,635 +0,0 @@
|
|
|
1
|
-
const ceil = (num, precision = 0) => {
|
|
2
|
-
var p = Math.pow(10, precision)
|
|
3
|
-
var n = (num * p) * (1 + Number.EPSILON)
|
|
4
|
-
return Math.ceil(n) / p
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const floor = (num, precision = 0) => {
|
|
8
|
-
var p = Math.pow(10, precision)
|
|
9
|
-
var n = (num * p) * (1 + Number.EPSILON)
|
|
10
|
-
return Math.floor(n) / p
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const ftWildcard = (key) => {
|
|
14
|
-
if(key.indexOf('/') >= 0) return key
|
|
15
|
-
|
|
16
|
-
const term = key.replace(/[\-\+\*\<\>\@\(\)\~]/, ' ', 'gi')
|
|
17
|
-
|
|
18
|
-
const searchTerms = []
|
|
19
|
-
term.split(' ').forEach((txt) => {
|
|
20
|
-
if(txt.length >= 3){
|
|
21
|
-
searchTerms.push(`+${txt}*`)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
return searchTerms.join(' ')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const moveFile = function(oldPath, newPath, callback) {
|
|
28
|
-
const fs = require("fs");
|
|
29
|
-
|
|
30
|
-
fs.rename(oldPath, newPath, function (err) {
|
|
31
|
-
if (err) {
|
|
32
|
-
if (err.code === 'EXDEV') {
|
|
33
|
-
copy();
|
|
34
|
-
} else {
|
|
35
|
-
callback(err);
|
|
36
|
-
}
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
callback();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
function copy() {
|
|
43
|
-
const fs = require("fs");
|
|
44
|
-
|
|
45
|
-
var readStream = fs.createReadStream(oldPath);
|
|
46
|
-
var writeStream = fs.createWriteStream(newPath);
|
|
47
|
-
|
|
48
|
-
readStream.on('error', callback);
|
|
49
|
-
writeStream.on('error', callback);
|
|
50
|
-
|
|
51
|
-
readStream.on('close', function () {
|
|
52
|
-
fs.unlink(oldPath, callback);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
readStream.pipe(writeStream);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const round = (num, precision = 0) => {
|
|
60
|
-
var p = Math.pow(10, precision)
|
|
61
|
-
var n = (num * p) * (1 + Number.EPSILON)
|
|
62
|
-
return Math.round(n) / p
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const sanitizeMobileNumber = (mobileNumber) => {
|
|
66
|
-
if(typeof mobileNumber !== 'string') return mobileNumber
|
|
67
|
-
|
|
68
|
-
if(mobileNumber.length > 0){
|
|
69
|
-
mobileNumber = mobileNumber.replace(/[\- ]/g, '')
|
|
70
|
-
if(mobileNumber.substring(0, 1) === '0') mobileNumber = '+62' + mobileNumber.substring(1)
|
|
71
|
-
if(mobileNumber.substring(0, 1) !== '+'){
|
|
72
|
-
if(mobileNumber.substring(0, 2) === '62')
|
|
73
|
-
mobileNumber = '+' + mobileNumber
|
|
74
|
-
else
|
|
75
|
-
mobileNumber = '+62' + mobileNumber
|
|
76
|
-
}
|
|
77
|
-
if(mobileNumber.length > 0){
|
|
78
|
-
mobileNumber = mobileNumber[0] + mobileNumber.slice(1).replace(/\D/g, '')
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return mobileNumber
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const saveBase64 = async(data, dir = '/storage/files/images') => {
|
|
86
|
-
if(data.indexOf(',') >= 0){
|
|
87
|
-
data = data.substring(data.indexOf(',') + 1)
|
|
88
|
-
}
|
|
89
|
-
const buffer = Buffer.from(data, 'base64');
|
|
90
|
-
return await saveBuffer(buffer, dir)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const saveBuffer = async(buffer, dir = '/storage/files/images') => {
|
|
94
|
-
|
|
95
|
-
const fs = require("fs");
|
|
96
|
-
const md5 = require('md5')
|
|
97
|
-
|
|
98
|
-
const { fileTypeFromBuffer } = await import('file-type')
|
|
99
|
-
|
|
100
|
-
const type = await fileTypeFromBuffer(buffer)
|
|
101
|
-
|
|
102
|
-
const storagePath = process.env.ROOT_PATH + dir
|
|
103
|
-
const ext = type && type.ext ? '.' + type.ext : ''
|
|
104
|
-
const filename = md5(buffer) + ext
|
|
105
|
-
const to = storagePath + '/' + filename
|
|
106
|
-
|
|
107
|
-
fs.writeFileSync(to, buffer)
|
|
108
|
-
|
|
109
|
-
return filename
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const saveFromUrl = async(url, dir = '/storage/files/images') => {
|
|
113
|
-
const axios = require('axios')
|
|
114
|
-
|
|
115
|
-
const res = await axios({
|
|
116
|
-
method: 'GET',
|
|
117
|
-
url,
|
|
118
|
-
responseType: 'arraybuffer',
|
|
119
|
-
})
|
|
120
|
-
const buffer = Buffer.from(res.data)
|
|
121
|
-
return await saveBuffer(buffer, dir)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|
125
|
-
|
|
126
|
-
const strSlug = (title, separator) => {
|
|
127
|
-
if (typeof separator == 'undefined') separator = '-';
|
|
128
|
-
|
|
129
|
-
// Convert all dashes/underscores into separator
|
|
130
|
-
var flip = separator === '-' ? '_' : '-';
|
|
131
|
-
title = title.replace(flip, separator);
|
|
132
|
-
|
|
133
|
-
// Remove all characters that are not the separator, letters, numbers, or whitespace.
|
|
134
|
-
title = title.toLowerCase()
|
|
135
|
-
.replace(new RegExp('[^a-z0-9' + separator + '\\s]', 'g'), '');
|
|
136
|
-
|
|
137
|
-
// Replace all separator characters and whitespace by a single separator
|
|
138
|
-
title = title.replace(new RegExp('[' + separator + '\\s]+', 'g'), separator);
|
|
139
|
-
|
|
140
|
-
return title.replace(new RegExp('^[' + separator + '\\s]+|[' + separator + '\\s]+$', 'g'),'');
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const strVars = (text, vars, opt = { emptyUndefined:true }) => {
|
|
144
|
-
|
|
145
|
-
(text.match(/\{.*?(?=\})\}/gi) ?? []).forEach((match) => {
|
|
146
|
-
const key = match.substring(1, match.length - 1)
|
|
147
|
-
const value = vars[key] ?? (opt?.emptyUndefined ? '' : `{${key}}`)
|
|
148
|
-
text = text.replace(match, value)
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
return text
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const writeStorage = (path, content, append = false) => {
|
|
155
|
-
|
|
156
|
-
const fs = require("fs");
|
|
157
|
-
|
|
158
|
-
if(path.startsWith('/')) path = path.substring(1)
|
|
159
|
-
|
|
160
|
-
if(append){
|
|
161
|
-
fs.appendFileSync(process.env.ROOT_PATH + `/storage/${path}`, content)
|
|
162
|
-
}
|
|
163
|
-
else{
|
|
164
|
-
fs.writeFileSync(process.env.ROOT_PATH + `/storage/${path}`, content)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const bufferToStream = (buffer) => {
|
|
169
|
-
const { Duplex } = require('stream')
|
|
170
|
-
let stream = new Duplex()
|
|
171
|
-
stream.push(buffer)
|
|
172
|
-
stream.push(null)
|
|
173
|
-
return stream
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const sequelizeChunk = async (model, opt, callback, chunkSize = 5000) => {
|
|
177
|
-
|
|
178
|
-
let offset = 0
|
|
179
|
-
let iter = 0
|
|
180
|
-
while(true){
|
|
181
|
-
const items = await model.findAll({
|
|
182
|
-
...opt,
|
|
183
|
-
offset,
|
|
184
|
-
limit: chunkSize
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
if(items.length > 0){
|
|
188
|
-
await callback(items, iter)
|
|
189
|
-
offset += chunkSize
|
|
190
|
-
iter++
|
|
191
|
-
}
|
|
192
|
-
else{
|
|
193
|
-
break
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const getPresetSortWhereParams = (order, afterItem) => {
|
|
199
|
-
|
|
200
|
-
const { Op } = require('sequelize')
|
|
201
|
-
|
|
202
|
-
if(order.filter((_) => _[0] === 'id').length <= 0){
|
|
203
|
-
order.push([ 'id', 'desc' ])
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const opOr = []
|
|
207
|
-
for(let i = 0 ; i < order.length ; i++){
|
|
208
|
-
|
|
209
|
-
const obj = order[i]
|
|
210
|
-
|
|
211
|
-
if(obj.length !== 2) continue
|
|
212
|
-
|
|
213
|
-
const exp = {}
|
|
214
|
-
for(let j = 0 ; j < i ; j++){
|
|
215
|
-
exp[order[j][0]] = afterItem[order[j][0]]
|
|
216
|
-
}
|
|
217
|
-
exp[obj[0]] = obj[1] === 'desc' ? { [Op.lt]:afterItem[obj[0]] } : { [Op.gt]:afterItem[obj[0]] }
|
|
218
|
-
|
|
219
|
-
if(Object.keys(exp).length === 1){
|
|
220
|
-
opOr.push(exp)
|
|
221
|
-
}
|
|
222
|
-
else{
|
|
223
|
-
opOr.push({
|
|
224
|
-
[Op.and]: exp
|
|
225
|
-
})
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
let sortWhere = {}
|
|
230
|
-
if(opOr.length > 0){
|
|
231
|
-
sortWhere = {
|
|
232
|
-
[Op.or]: opOr
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
return sortWhere
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const unflatten = (flatObject) => {
|
|
239
|
-
const nestedObject = {};
|
|
240
|
-
|
|
241
|
-
for (const key in flatObject) {
|
|
242
|
-
if (Object.prototype.hasOwnProperty.call(flatObject, key)) {
|
|
243
|
-
const value = flatObject[key];
|
|
244
|
-
const keys = key.split('.');
|
|
245
|
-
|
|
246
|
-
let currentObj = nestedObject;
|
|
247
|
-
for (let i = 0; i < keys.length; i++) {
|
|
248
|
-
const currentKey = keys[i];
|
|
249
|
-
|
|
250
|
-
if (!currentObj[currentKey]) {
|
|
251
|
-
currentObj[currentKey] = {};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (i === keys.length - 1) {
|
|
255
|
-
currentObj[currentKey] = value;
|
|
256
|
-
} else {
|
|
257
|
-
currentObj = currentObj[currentKey];
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
return nestedObject;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
const accessNestedObject = function(obj, path) {
|
|
267
|
-
if(!obj || typeof path !== 'string') return undefined
|
|
268
|
-
|
|
269
|
-
const keys = path.split('.');
|
|
270
|
-
let nestedObj = obj;
|
|
271
|
-
|
|
272
|
-
for (let key of keys) {
|
|
273
|
-
if (nestedObj && nestedObj.hasOwnProperty(key)) {
|
|
274
|
-
nestedObj = nestedObj[key];
|
|
275
|
-
} else {
|
|
276
|
-
// Return undefined if any key in the path is missing
|
|
277
|
-
return undefined;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return nestedObj;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const createObjectFromPath = (obj, path, value) => {
|
|
285
|
-
const keys = path.split('.');
|
|
286
|
-
|
|
287
|
-
let current = obj;
|
|
288
|
-
for (let i = 0; i < keys.length; i++) {
|
|
289
|
-
const key = keys[i];
|
|
290
|
-
const indexMatch = key.match(/^(\d+)$/);
|
|
291
|
-
const isArrayIndex = indexMatch !== null;
|
|
292
|
-
|
|
293
|
-
const nextIsArrayIndex = !!(keys[i + 1] ?? '').match(/^(\d+)$/);
|
|
294
|
-
const isLast = i === keys.length - 1
|
|
295
|
-
|
|
296
|
-
if(isArrayIndex) {
|
|
297
|
-
const index = parseInt(indexMatch[1], 10);
|
|
298
|
-
if (!Array.isArray(current)) {
|
|
299
|
-
current = [];
|
|
300
|
-
}
|
|
301
|
-
if (typeof current[index] === 'undefined') {
|
|
302
|
-
current[index] = isLast ? value : nextIsArrayIndex ? [] : {};
|
|
303
|
-
}
|
|
304
|
-
current = current[index]
|
|
305
|
-
}
|
|
306
|
-
else{
|
|
307
|
-
if(typeof current[key] !== 'object' || current[key] === null) {
|
|
308
|
-
current[key] = isLast ? value : nextIsArrayIndex ? [] : {};
|
|
309
|
-
}
|
|
310
|
-
current = current[key];
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return obj;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const cssDict = {
|
|
318
|
-
'Global': '*',
|
|
319
|
-
'Font': 'font-family',
|
|
320
|
-
'Impact': "'Impact', 'Arial Black', 'Arial Bold', Gadget, sans-serif",
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const generateStylesheet = (styleObj) => {
|
|
324
|
-
|
|
325
|
-
return `*{ font-family: Impact; }`
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const hexToRgb = (hex) => {
|
|
330
|
-
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
331
|
-
return result ? {
|
|
332
|
-
r: parseInt(result[1], 16),
|
|
333
|
-
g: parseInt(result[2], 16),
|
|
334
|
-
b: parseInt(result[3], 16)
|
|
335
|
-
} : null;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const compClasses = [
|
|
339
|
-
'aspectRatio',
|
|
340
|
-
'bdSize', 'bdColor', 'bdRadius', 'bdStyle',
|
|
341
|
-
'bgColors', 'bgSize', 'bgPosition', 'bgRepeat',
|
|
342
|
-
'gap',
|
|
343
|
-
'padding', 'margin',
|
|
344
|
-
'direction', 'columns', 'display',
|
|
345
|
-
'width', 'minWidth', 'maxWidth',
|
|
346
|
-
'height', 'minHeight', 'maxHeight',
|
|
347
|
-
'fontFamily', 'fontSize', 'fontWeight', 'textColor', 'lineHeight', 'overflow',
|
|
348
|
-
'boxShadow', 'opacity',
|
|
349
|
-
'colSpan'
|
|
350
|
-
]
|
|
351
|
-
|
|
352
|
-
const containerClasses = [
|
|
353
|
-
'containerVariant', 'containerGridColumn', 'containerGap'
|
|
354
|
-
]
|
|
355
|
-
|
|
356
|
-
const itemClasses = [
|
|
357
|
-
'itemMinWidth', 'itemRatio', 'itemVariant'
|
|
358
|
-
]
|
|
359
|
-
|
|
360
|
-
const createComponentInstance = function(component){
|
|
361
|
-
|
|
362
|
-
if(!component.instance)
|
|
363
|
-
component.instance = {}
|
|
364
|
-
|
|
365
|
-
const compUid = '_' + component.uid.substring(0, 4) + ' '
|
|
366
|
-
|
|
367
|
-
Object.assign(component.instance, {
|
|
368
|
-
type: component.type,
|
|
369
|
-
uid: component.uid,
|
|
370
|
-
|
|
371
|
-
class: compUid + compClasses.map(key => {
|
|
372
|
-
return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
|
|
373
|
-
})
|
|
374
|
-
.filter(_ => _)
|
|
375
|
-
.join(' '),
|
|
376
|
-
|
|
377
|
-
containerClass: containerClasses.map(key => {
|
|
378
|
-
return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
|
|
379
|
-
})
|
|
380
|
-
.filter(_ => _)
|
|
381
|
-
.join(' '),
|
|
382
|
-
|
|
383
|
-
itemClass: itemClasses.map(key => {
|
|
384
|
-
return Array.isArray(component.props[key]) ? component.props[key].join(' ') : ''
|
|
385
|
-
})
|
|
386
|
-
.filter(_ => _)
|
|
387
|
-
.join(' ')
|
|
388
|
-
})
|
|
389
|
-
|
|
390
|
-
for(let key in component.props){
|
|
391
|
-
if(!compClasses.includes(key) && ![ 'enabled' ].includes(key)){
|
|
392
|
-
component.instance[key] = component.props[key]
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if(Array.isArray(component.items)){
|
|
397
|
-
component.instance.items = component.items.map((_) => createComponentInstance(_))
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
if(component.props && Array.isArray(component.props.items)){
|
|
401
|
-
component.instance.items = component.props.items
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
return component
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
const deepObjectContainsObject = (outerObject, innerObject) => {
|
|
408
|
-
for (const key in innerObject) {
|
|
409
|
-
if (innerObject.hasOwnProperty(key)) {
|
|
410
|
-
if (typeof innerObject[key] === 'object' && typeof outerObject[key] === 'object') {
|
|
411
|
-
// If both properties are objects, recursively check them
|
|
412
|
-
if (!deepObjectContainsObject(outerObject[key], innerObject[key])) {
|
|
413
|
-
return false; // Nested objects do not match
|
|
414
|
-
}
|
|
415
|
-
} else {
|
|
416
|
-
if (outerObject[key] !== innerObject[key]) {
|
|
417
|
-
return false; // Property in innerObject doesn't exist in outerObject or values don't match
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
return true; // All properties and values in innerObject exist in outerObject
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const removeStyleFromTag = (html) => {
|
|
426
|
-
const regex = /<[^>]+style="[^"]*"[^>]*>/g;
|
|
427
|
-
|
|
428
|
-
return html.replace(regex, (match) => {
|
|
429
|
-
return match.replace(/style="[^"]*"/, '');
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
const datasourceGet = async ({ Models }) => {
|
|
434
|
-
|
|
435
|
-
const models = []
|
|
436
|
-
for(let key in Models){
|
|
437
|
-
|
|
438
|
-
const columns = []
|
|
439
|
-
const attributes = Models[key].getAttributes()
|
|
440
|
-
for(let key in attributes){
|
|
441
|
-
|
|
442
|
-
let type
|
|
443
|
-
const fieldType = attributes[key].type.toString()
|
|
444
|
-
|
|
445
|
-
if(fieldType.startsWith('VARCHAR')){
|
|
446
|
-
type = 'string'
|
|
447
|
-
}
|
|
448
|
-
else if(fieldType.startsWith('INTEGER') || fieldType.startsWith('TINYINT')){
|
|
449
|
-
type = 'number'
|
|
450
|
-
}
|
|
451
|
-
else if(fieldType.startsWith('DATETIME')){
|
|
452
|
-
type = 'date'
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
if(type){
|
|
456
|
-
columns.push({
|
|
457
|
-
name: attributes[key].fieldName,
|
|
458
|
-
type,
|
|
459
|
-
})
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
models.push({
|
|
464
|
-
name: key,
|
|
465
|
-
columns
|
|
466
|
-
})
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return {
|
|
470
|
-
models
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
const datasourceLoad = async ({ datasource, Models }) => {
|
|
476
|
-
|
|
477
|
-
const obj = {}
|
|
478
|
-
|
|
479
|
-
if(Array.isArray(datasource)){
|
|
480
|
-
for(let _datasource of datasource){
|
|
481
|
-
|
|
482
|
-
const Model = Models[_datasource.model]
|
|
483
|
-
|
|
484
|
-
const where = {}
|
|
485
|
-
if(Array.isArray(_datasource.filters)){
|
|
486
|
-
for(let filter of _datasource.filters){
|
|
487
|
-
|
|
488
|
-
switch(filter.operator){
|
|
489
|
-
|
|
490
|
-
case '=':
|
|
491
|
-
where[filter.key] = filter.value
|
|
492
|
-
break
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
const rows = await Model.findAll({
|
|
499
|
-
where,
|
|
500
|
-
limit: 20
|
|
501
|
-
})
|
|
502
|
-
|
|
503
|
-
obj[_datasource.key] = rows.length === 1 ? rows[0].toJSON() :
|
|
504
|
-
(rows.length === 0 ? {} : rows.map(_ => _.toJSON()))
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
return obj
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
const dayTimeRange = (params, value) => {
|
|
512
|
-
const dayjs = require('dayjs')
|
|
513
|
-
|
|
514
|
-
/*params = {
|
|
515
|
-
'*': [ [ '08:00', '12:00' ], [ '13:00', '18:00' ] ],
|
|
516
|
-
'sat': [ [ '08:00', '12:00' ], [ '13:00', '14:00' ] ],
|
|
517
|
-
}
|
|
518
|
-
value = '2023-02-06 17:59:00'*/
|
|
519
|
-
|
|
520
|
-
if(!value)
|
|
521
|
-
value = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
522
|
-
|
|
523
|
-
const curDay = dayjs(value).format('ddd').toLowerCase()
|
|
524
|
-
const curTime = dayjs(value).format('HH:mm')
|
|
525
|
-
const ranges = params[curDay] ?? params['*']
|
|
526
|
-
|
|
527
|
-
return (ranges ?? []).some((range) => {
|
|
528
|
-
return curTime >= range[0] && curTime <= range[1]
|
|
529
|
-
})
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function capitalize(str) {
|
|
533
|
-
return (str ?? '').toLowerCase().replace(/\b\w/g, function(char) {
|
|
534
|
-
return char.toUpperCase();
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
const removeUnderscoredKey = (obj) => {
|
|
539
|
-
if (Array.isArray(obj)) {
|
|
540
|
-
return obj.map(removeUnderscoredKey);
|
|
541
|
-
}
|
|
542
|
-
else if (obj !== null && typeof obj === 'object') {
|
|
543
|
-
for(let key in obj){
|
|
544
|
-
if(key.startsWith('_')){
|
|
545
|
-
delete obj[key]
|
|
546
|
-
}
|
|
547
|
-
else if(Array.isArray(obj[key]) || (obj[key] !== null && typeof obj[key] === 'object')){
|
|
548
|
-
removeUnderscoredKey(obj[key])
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
return obj;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
const hashMake = async (text) => {
|
|
556
|
-
const bcrypt = require('bcrypt')
|
|
557
|
-
|
|
558
|
-
return bcrypt.hash(text + (process.env.APP_KEY ?? ''), 10)
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const hashCheck = (text, hash) => {
|
|
562
|
-
const bcrypt = require('bcrypt')
|
|
563
|
-
|
|
564
|
-
return bcrypt.compare(text + (process.env.APP_KEY ?? ''), hash)
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
const transactionWithRetry = async (sequelize, callback, opt = {}) => {
|
|
568
|
-
const { maxRetries = 99, delay = 1000 } = opt
|
|
569
|
-
|
|
570
|
-
let retries = 0
|
|
571
|
-
while(retries < maxRetries){
|
|
572
|
-
try{
|
|
573
|
-
return await sequelize.transaction(callback)
|
|
574
|
-
}
|
|
575
|
-
catch(e){
|
|
576
|
-
if(e.name === 'SequelizeConnectionAcquireTimeoutError' ||
|
|
577
|
-
(e.name === 'SequelizeDatabaseError' && [ 'ER_LOCK_DEADLOCK', '40001' ].includes(e.original.code))){
|
|
578
|
-
retries++
|
|
579
|
-
|
|
580
|
-
if(retries >= maxRetries){
|
|
581
|
-
throw e
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
await new Promise((resolve) => setTimeout(resolve, delay))
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
else{
|
|
588
|
-
throw e
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
const groupBy = (arr, key) => {
|
|
595
|
-
return arr.reduce((acc, item) => {
|
|
596
|
-
(acc[item[key]] = acc[item[key]] || []).push(item);
|
|
597
|
-
return acc;
|
|
598
|
-
}, {});
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
module.exports = {
|
|
602
|
-
capitalize,
|
|
603
|
-
ceil,
|
|
604
|
-
floor,
|
|
605
|
-
ftWildcard,
|
|
606
|
-
moveFile,
|
|
607
|
-
round,
|
|
608
|
-
sanitizeMobileNumber,
|
|
609
|
-
saveBase64,
|
|
610
|
-
saveBuffer,
|
|
611
|
-
saveFromUrl,
|
|
612
|
-
sleep,
|
|
613
|
-
strSlug,
|
|
614
|
-
strVars,
|
|
615
|
-
writeStorage,
|
|
616
|
-
bufferToStream,
|
|
617
|
-
sequelizeChunk,
|
|
618
|
-
getPresetSortWhereParams,
|
|
619
|
-
unflatten,
|
|
620
|
-
accessNestedObject,
|
|
621
|
-
createObjectFromPath,
|
|
622
|
-
generateStylesheet,
|
|
623
|
-
hexToRgb,
|
|
624
|
-
createComponentInstance,
|
|
625
|
-
deepObjectContainsObject,
|
|
626
|
-
removeStyleFromTag,
|
|
627
|
-
datasourceGet,
|
|
628
|
-
datasourceLoad,
|
|
629
|
-
dayTimeRange,
|
|
630
|
-
removeUnderscoredKey,
|
|
631
|
-
hashMake,
|
|
632
|
-
hashCheck,
|
|
633
|
-
transactionWithRetry,
|
|
634
|
-
groupBy
|
|
635
|
-
}
|