@budibase/server 1.0.160 → 1.0.163

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.
Files changed (172) hide show
  1. package/builder/assets/{index.f55956ef.js → index.cdd48cbf.js} +3 -3
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +96 -88
  4. package/coverage/coverage-final.json +2 -2
  5. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  6. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  7. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/index.html +1 -1
  15. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  21. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/index.html +24 -24
  40. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/utils.js.html +14 -8
  42. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +111 -48
  43. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  44. package/coverage/lcov-report/api/index.html +1 -1
  45. package/coverage/lcov-report/api/index.js.html +1 -1
  46. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/index.html +1 -1
  57. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  71. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  74. package/coverage/lcov-report/automations/actions.js.html +1 -1
  75. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  76. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  77. package/coverage/lcov-report/automations/index.html +1 -1
  78. package/coverage/lcov-report/automations/index.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/index.html +1 -1
  86. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  96. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  105. package/coverage/lcov-report/constants/index.html +1 -1
  106. package/coverage/lcov-report/constants/index.js.html +1 -1
  107. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  108. package/coverage/lcov-report/constants/screens.js.html +1 -1
  109. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  110. package/coverage/lcov-report/db/index.html +1 -1
  111. package/coverage/lcov-report/db/index.js.html +1 -1
  112. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  113. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  116. package/coverage/lcov-report/db/newid.js.html +1 -1
  117. package/coverage/lcov-report/db/utils.js.html +1 -1
  118. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  119. package/coverage/lcov-report/events/index.html +1 -1
  120. package/coverage/lcov-report/events/index.js.html +1 -1
  121. package/coverage/lcov-report/events/utils.js.html +1 -1
  122. package/coverage/lcov-report/index.html +19 -19
  123. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  124. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  125. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  126. package/coverage/lcov-report/middleware/builder.js.html +1 -1
  127. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  128. package/coverage/lcov-report/middleware/index.html +1 -1
  129. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  130. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  131. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  132. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  133. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  134. package/coverage/lcov-report/threads/automation.js.html +1 -1
  135. package/coverage/lcov-report/threads/index.html +1 -1
  136. package/coverage/lcov-report/threads/query.js.html +1 -1
  137. package/coverage/lcov-report/threads/utils.js.html +1 -1
  138. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  139. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  140. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  141. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  142. package/coverage/lcov-report/utilities/global.js.html +1 -1
  143. package/coverage/lcov-report/utilities/index.html +1 -1
  144. package/coverage/lcov-report/utilities/index.js.html +1 -1
  145. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  146. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  147. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  148. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  149. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  150. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  151. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  152. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  153. package/coverage/lcov-report/utilities/security.js.html +1 -1
  154. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  155. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  156. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  157. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  158. package/coverage/lcov-report/utilities/users.js.html +1 -1
  159. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  160. package/coverage/lcov.info +164 -148
  161. package/dist/api/controllers/view/utils.js +4 -2
  162. package/dist/api/controllers/view/viewBuilder.js +22 -8
  163. package/dist/integrations/mongodb.js +77 -13
  164. package/dist/package.json +5 -5
  165. package/dist/tsconfig.build.tsbuildinfo +1 -1
  166. package/package.json +6 -6
  167. package/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +58 -1
  168. package/src/api/controllers/view/tests/viewBuilder.spec.js +18 -0
  169. package/src/api/controllers/view/utils.js +4 -2
  170. package/src/api/controllers/view/viewBuilder.js +32 -11
  171. package/src/integrations/mongodb.ts +112 -13
  172. package/src/integrations/tests/mongo.spec.js +34 -17
@@ -3477,15 +3477,15 @@ BRH:18
3477
3477
  end_of_record
3478
3478
  TN:
3479
3479
  SF:src/api/controllers/view/utils.js
3480
- FN:11,(anonymous_0)
3481
- FN:27,(anonymous_1)
3482
- FN:49,(anonymous_2)
3483
- FN:60,(anonymous_3)
3484
- FN:98,(anonymous_4)
3485
- FN:114,(anonymous_5)
3486
- FN:123,(anonymous_6)
3487
- FN:131,(anonymous_7)
3488
- FN:140,(anonymous_8)
3480
+ FN:12,(anonymous_0)
3481
+ FN:28,(anonymous_1)
3482
+ FN:50,(anonymous_2)
3483
+ FN:61,(anonymous_3)
3484
+ FN:99,(anonymous_4)
3485
+ FN:115,(anonymous_5)
3486
+ FN:125,(anonymous_6)
3487
+ FN:133,(anonymous_7)
3488
+ FN:142,(anonymous_8)
3489
3489
  FNF:9
3490
3490
  FNH:6
3491
3491
  FNDA:2,(anonymous_0)
@@ -3500,194 +3500,210 @@ FNDA:1,(anonymous_8)
3500
3500
  DA:7,41
3501
3501
  DA:8,41
3502
3502
  DA:9,41
3503
- DA:11,41
3504
- DA:12,2
3503
+ DA:10,41
3504
+ DA:12,41
3505
3505
  DA:13,2
3506
3506
  DA:14,2
3507
3507
  DA:15,2
3508
- DA:18,0
3508
+ DA:16,2
3509
3509
  DA:19,0
3510
- DA:22,0
3510
+ DA:20,0
3511
3511
  DA:23,0
3512
- DA:27,41
3513
- DA:28,2
3512
+ DA:24,0
3513
+ DA:28,41
3514
3514
  DA:29,2
3515
3515
  DA:30,2
3516
3516
  DA:31,2
3517
3517
  DA:32,2
3518
- DA:34,5
3519
- DA:35,4
3520
- DA:37,1
3521
- DA:43,0
3522
- DA:49,0
3518
+ DA:33,2
3519
+ DA:35,5
3520
+ DA:36,4
3521
+ DA:38,1
3522
+ DA:44,0
3523
3523
  DA:50,0
3524
3524
  DA:51,0
3525
- DA:57,2
3526
- DA:60,41
3527
- DA:61,8
3525
+ DA:52,0
3526
+ DA:58,2
3527
+ DA:61,41
3528
3528
  DA:62,8
3529
3529
  DA:63,8
3530
3530
  DA:64,8
3531
- DA:69,8
3532
- DA:70,0
3533
- DA:72,8
3534
- DA:74,0
3531
+ DA:65,8
3532
+ DA:70,8
3533
+ DA:71,0
3534
+ DA:73,8
3535
3535
  DA:75,0
3536
3536
  DA:76,0
3537
- DA:82,0
3537
+ DA:77,0
3538
3538
  DA:83,0
3539
3539
  DA:84,0
3540
3540
  DA:85,0
3541
3541
  DA:86,0
3542
- DA:88,0
3542
+ DA:87,0
3543
3543
  DA:89,0
3544
- DA:94,0
3545
- DA:98,41
3546
- DA:99,1
3544
+ DA:90,0
3545
+ DA:95,0
3546
+ DA:99,41
3547
3547
  DA:100,1
3548
3548
  DA:101,1
3549
3549
  DA:102,1
3550
3550
  DA:103,1
3551
3551
  DA:104,1
3552
3552
  DA:105,1
3553
- DA:107,0
3553
+ DA:106,1
3554
3554
  DA:108,0
3555
3555
  DA:109,0
3556
3556
  DA:110,0
3557
- DA:114,41
3558
- DA:116,0
3557
+ DA:111,0
3558
+ DA:115,41
3559
3559
  DA:117,0
3560
- DA:118,0
3561
3560
  DA:119,0
3562
3561
  DA:120,0
3563
- DA:123,41
3564
- DA:124,0
3565
- DA:125,0
3562
+ DA:121,0
3563
+ DA:122,0
3564
+ DA:125,41
3566
3565
  DA:126,0
3567
3566
  DA:127,0
3568
3567
  DA:128,0
3569
- DA:131,41
3570
- DA:132,6
3571
- DA:133,6
3568
+ DA:129,0
3569
+ DA:130,0
3570
+ DA:133,41
3572
3571
  DA:134,6
3573
- DA:135,1
3574
- DA:137,5
3575
- DA:140,41
3576
- DA:141,1
3577
- DA:142,0
3578
- DA:143,0
3572
+ DA:135,6
3573
+ DA:136,6
3574
+ DA:137,1
3575
+ DA:139,5
3576
+ DA:142,41
3577
+ DA:143,1
3578
+ DA:144,0
3579
3579
  DA:145,0
3580
3580
  DA:147,0
3581
- LF:81
3582
- LH:43
3583
- BRDA:13,0,0,2
3584
- BRDA:13,0,1,0
3585
- BRDA:18,1,0,0
3586
- BRDA:18,1,1,0
3587
- BRDA:30,2,0,2
3588
- BRDA:30,2,1,0
3589
- BRDA:34,3,0,4
3590
- BRDA:34,3,1,1
3591
- BRDA:62,4,0,8
3592
- BRDA:62,4,1,0
3593
- BRDA:69,5,0,0
3594
- BRDA:69,5,1,8
3595
- BRDA:75,6,0,0
3596
- BRDA:75,6,1,0
3597
- BRDA:84,7,0,0
3598
- BRDA:84,7,1,0
3599
- BRDA:88,8,0,0
3600
- BRDA:88,8,1,0
3601
- BRDA:88,9,0,0
3602
- BRDA:88,9,1,0
3603
- BRDA:100,10,0,1
3604
- BRDA:100,10,1,0
3605
- BRDA:134,11,0,1
3606
- BRDA:134,11,1,5
3607
- BRDA:142,12,0,0
3608
- BRDA:142,12,1,0
3581
+ DA:149,0
3582
+ LF:82
3583
+ LH:44
3584
+ BRDA:14,0,0,2
3585
+ BRDA:14,0,1,0
3586
+ BRDA:19,1,0,0
3587
+ BRDA:19,1,1,0
3588
+ BRDA:31,2,0,2
3589
+ BRDA:31,2,1,0
3590
+ BRDA:35,3,0,4
3591
+ BRDA:35,3,1,1
3592
+ BRDA:63,4,0,8
3593
+ BRDA:63,4,1,0
3594
+ BRDA:70,5,0,0
3595
+ BRDA:70,5,1,8
3596
+ BRDA:76,6,0,0
3597
+ BRDA:76,6,1,0
3598
+ BRDA:85,7,0,0
3599
+ BRDA:85,7,1,0
3600
+ BRDA:89,8,0,0
3601
+ BRDA:89,8,1,0
3602
+ BRDA:89,9,0,0
3603
+ BRDA:89,9,1,0
3604
+ BRDA:101,10,0,1
3605
+ BRDA:101,10,1,0
3606
+ BRDA:136,11,0,1
3607
+ BRDA:136,11,1,5
3608
+ BRDA:144,12,0,0
3609
+ BRDA:144,12,1,0
3609
3610
  BRF:26
3610
3611
  BRH:9
3611
3612
  end_of_record
3612
3613
  TN:
3613
3614
  SF:src/api/controllers/view/viewBuilder.js
3614
- FN:13,(anonymous_0)
3615
- FN:71,parseFilterExpression
3616
- FN:108,parseEmitExpression
3617
- FN:123,viewTemplate
3618
- FNF:4
3619
- FNH:3
3620
- FNDA:0,(anonymous_0)
3621
- FNDA:11,parseFilterExpression
3622
- FNDA:11,parseEmitExpression
3623
- FNDA:11,viewTemplate
3615
+ FN:19,(anonymous_0)
3616
+ FN:77,parseFilterExpression
3617
+ FN:114,parseEmitExpression
3618
+ FN:129,viewTemplate
3619
+ FN:145,(anonymous_4)
3620
+ FNF:5
3621
+ FNH:5
3622
+ FNDA:7,(anonymous_0)
3623
+ FNDA:19,parseFilterExpression
3624
+ FNDA:12,parseEmitExpression
3625
+ FNDA:12,viewTemplate
3626
+ FNDA:1,(anonymous_4)
3624
3627
  DA:1,42
3625
3628
  DA:13,42
3626
- DA:14,0
3627
- DA:22,42
3629
+ DA:19,42
3630
+ DA:20,7
3628
3631
  DA:28,42
3629
3632
  DA:34,42
3630
- DA:72,11
3631
- DA:74,11
3632
- DA:75,11
3633
- DA:76,2
3634
- DA:77,1
3635
- DA:80,2
3636
- DA:81,0
3637
- DA:84,2
3638
- DA:85,0
3639
- DA:86,2
3633
+ DA:40,42
3634
+ DA:78,19
3635
+ DA:80,19
3636
+ DA:81,19
3637
+ DA:82,10
3638
+ DA:83,1
3639
+ DA:86,10
3640
3640
  DA:87,0
3641
- DA:90,2
3642
- DA:92,2
3643
- DA:96,2
3644
- DA:99,11
3645
- DA:109,11
3646
- DA:125,11
3647
- DA:126,0
3648
- DA:128,11
3649
- DA:129,11
3650
- DA:131,11
3651
- DA:133,11
3652
- DA:135,11
3653
- DA:137,11
3654
- DA:138,6
3655
- DA:144,11
3656
- DA:162,42
3657
- LF:33
3658
- LH:28
3659
- BRDA:76,0,0,1
3660
- BRDA:76,0,1,1
3661
- BRDA:76,1,0,2
3662
- BRDA:76,1,1,1
3663
- BRDA:80,2,0,0
3664
- BRDA:80,2,1,2
3665
- BRDA:84,3,0,0
3666
- BRDA:84,3,1,2
3667
- BRDA:86,4,0,0
3668
- BRDA:86,4,1,2
3669
- BRDA:90,5,0,2
3670
- BRDA:90,5,1,0
3671
- BRDA:109,6,0,11
3672
- BRDA:109,6,1,9
3673
- BRDA:123,7,0,8
3674
- BRDA:125,8,0,0
3675
- BRDA:125,8,1,11
3676
- BRDA:125,9,0,11
3677
- BRDA:125,9,1,11
3678
- BRDA:125,9,2,1
3679
- BRDA:129,10,0,1
3680
- BRDA:129,10,1,10
3681
- BRDA:133,11,0,6
3682
- BRDA:133,11,1,5
3683
- BRDA:133,12,0,11
3684
- BRDA:133,12,1,7
3685
- BRDA:137,13,0,6
3686
- BRDA:137,13,1,5
3687
- BRDA:139,14,0,1
3688
- BRDA:139,14,1,5
3689
- BRF:30
3690
- BRH:25
3641
+ DA:90,10
3642
+ DA:91,0
3643
+ DA:92,10
3644
+ DA:93,7
3645
+ DA:96,3
3646
+ DA:98,3
3647
+ DA:102,10
3648
+ DA:105,19
3649
+ DA:115,12
3650
+ DA:131,12
3651
+ DA:132,0
3652
+ DA:135,12
3653
+ DA:136,12
3654
+ DA:138,12
3655
+ DA:139,7
3656
+ DA:143,7
3657
+ DA:146,1
3658
+ DA:149,7
3659
+ DA:155,12
3660
+ DA:156,12
3661
+ DA:158,12
3662
+ DA:159,12
3663
+ DA:160,12
3664
+ DA:163,12
3665
+ DA:165,12
3666
+ DA:183,42
3667
+ LF:40
3668
+ LH:37
3669
+ BRDA:82,0,0,1
3670
+ BRDA:82,0,1,9
3671
+ BRDA:82,1,0,10
3672
+ BRDA:82,1,1,1
3673
+ BRDA:86,2,0,0
3674
+ BRDA:86,2,1,10
3675
+ BRDA:90,3,0,0
3676
+ BRDA:90,3,1,10
3677
+ BRDA:92,4,0,7
3678
+ BRDA:92,4,1,3
3679
+ BRDA:96,5,0,2
3680
+ BRDA:96,5,1,1
3681
+ BRDA:115,6,0,12
3682
+ BRDA:115,6,1,10
3683
+ BRDA:129,7,0,8
3684
+ BRDA:131,8,0,0
3685
+ BRDA:131,8,1,12
3686
+ BRDA:131,9,0,12
3687
+ BRDA:131,9,1,12
3688
+ BRDA:131,9,2,2
3689
+ BRDA:138,10,0,7
3690
+ BRDA:138,10,1,5
3691
+ BRDA:140,11,0,1
3692
+ BRDA:140,11,1,6
3693
+ BRDA:143,12,0,7
3694
+ BRDA:143,12,1,0
3695
+ BRDA:146,13,0,1
3696
+ BRDA:146,13,1,0
3697
+ BRDA:156,14,0,2
3698
+ BRDA:156,14,1,10
3699
+ BRDA:160,15,0,7
3700
+ BRDA:160,15,1,5
3701
+ BRDA:163,16,0,7
3702
+ BRDA:163,16,1,5
3703
+ BRDA:163,17,0,12
3704
+ BRDA:163,17,1,8
3705
+ BRF:36
3706
+ BRH:31
3691
3707
  end_of_record
3692
3708
  TN:
3693
3709
  SF:src/api/routes/analytics.js
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  const { ViewNames, generateMemoryViewID, getMemoryViewParams, DocumentTypes, SEPARATOR, } = require("../../../db/utils");
12
12
  const env = require("../../../environment");
13
13
  const { getAppDB } = require("@budibase/backend-core/context");
14
+ const viewBuilder = require("./viewBuilder");
14
15
  exports.getView = (viewName) => __awaiter(void 0, void 0, void 0, function* () {
15
16
  const db = getAppDB();
16
17
  if (env.SELF_HOSTED) {
@@ -104,7 +105,8 @@ exports.deleteView = (viewName) => __awaiter(void 0, void 0, void 0, function* (
104
105
  exports.migrateToInMemoryView = (db, viewName) => __awaiter(void 0, void 0, void 0, function* () {
105
106
  // delete the view initially
106
107
  const designDoc = yield db.get("_design/database");
107
- const view = designDoc.views[viewName];
108
+ // run the view back through the view builder to update it
109
+ const view = viewBuilder(designDoc.views[viewName].meta);
108
110
  delete designDoc.views[viewName];
109
111
  yield db.put(designDoc);
110
112
  yield exports.saveView(db, null, viewName, view);
@@ -112,7 +114,7 @@ exports.migrateToInMemoryView = (db, viewName) => __awaiter(void 0, void 0, void
112
114
  exports.migrateToDesignView = (db, viewName) => __awaiter(void 0, void 0, void 0, function* () {
113
115
  let view = yield db.get(generateMemoryViewID(viewName));
114
116
  const designDoc = yield db.get("_design/database");
115
- designDoc.views[viewName] = view.view;
117
+ designDoc.views[viewName] = viewBuilder(view.view.meta);
116
118
  yield db.put(designDoc);
117
119
  yield db.remove(view._id, view._rev);
118
120
  });
@@ -10,6 +10,11 @@ const TOKEN_MAP = {
10
10
  AND: "&&",
11
11
  OR: "||",
12
12
  };
13
+ const CONDITIONS = {
14
+ EMPTY: "EMPTY",
15
+ NOT_EMPTY: "NOT_EMPTY",
16
+ CONTAINS: "CONTAINS",
17
+ };
13
18
  const isEmptyExpression = key => {
14
19
  return `(
15
20
  doc["${key}"] === undefined ||
@@ -71,13 +76,13 @@ function parseFilterExpression(filters) {
71
76
  if (!first && filter.conjunction) {
72
77
  expression.push(TOKEN_MAP[filter.conjunction]);
73
78
  }
74
- if (filter.condition === "CONTAINS") {
79
+ if (filter.condition === CONDITIONS.CONTAINS) {
75
80
  expression.push(`doc["${filter.key}"].${TOKEN_MAP[filter.condition]}("${filter.value}")`);
76
81
  }
77
- else if (filter.condition === "EMPTY") {
82
+ else if (filter.condition === CONDITIONS.EMPTY) {
78
83
  expression.push(isEmptyExpression(filter.key));
79
84
  }
80
- else if (filter.condition === "NOT_EMPTY") {
85
+ else if (filter.condition === CONDITIONS.NOT_EMPTY) {
81
86
  expression.push(`!${isEmptyExpression(filter.key)}`);
82
87
  }
83
88
  else {
@@ -113,14 +118,23 @@ function viewTemplate({ field, tableId, groupBy, filters = [], calculation }) {
113
118
  if (filters && filters.length > 0 && filters[0].conjunction) {
114
119
  delete filters[0].conjunction;
115
120
  }
121
+ let schema = null, statFilter = null;
122
+ if (calculation) {
123
+ schema = Object.assign(Object.assign({}, (groupBy ? GROUP_PROPERTY : FIELD_PROPERTY)), SCHEMA_MAP[calculation]);
124
+ if (!filters.find(filter => filter.key === field && filter.condition === CONDITIONS.NOT_EMPTY)) {
125
+ statFilter = parseFilterExpression([
126
+ { key: field, condition: CONDITIONS.NOT_EMPTY },
127
+ ]);
128
+ }
129
+ }
116
130
  const parsedFilters = parseFilterExpression(filters);
117
131
  const filterExpression = parsedFilters ? `&& (${parsedFilters})` : "";
118
132
  const emitExpression = parseEmitExpression(field, groupBy);
133
+ const tableExpression = `doc.tableId === "${tableId}"`;
134
+ const coreExpression = statFilter
135
+ ? `(${tableExpression} && ${statFilter})`
136
+ : tableExpression;
119
137
  const reduction = field && calculation ? { reduce: `_${calculation}` } : {};
120
- let schema = null;
121
- if (calculation) {
122
- schema = Object.assign(Object.assign({}, (groupBy ? GROUP_PROPERTY : FIELD_PROPERTY)), SCHEMA_MAP[calculation]);
123
- }
124
138
  return Object.assign({ meta: {
125
139
  field,
126
140
  tableId,
@@ -129,7 +143,7 @@ function viewTemplate({ field, tableId, groupBy, filters = [], calculation }) {
129
143
  schema,
130
144
  calculation,
131
145
  }, map: `function (doc) {
132
- if (doc.tableId === "${tableId}" ${filterExpression}) {
146
+ if (${coreExpression} ${filterExpression}) {
133
147
  ${emitExpression}
134
148
  }
135
149
  }` }, reduction);
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const datasource_1 = require("../definitions/datasource");
13
+ const mongodb_1 = require("mongodb");
13
14
  var MongoDBModule;
14
15
  (function (MongoDBModule) {
15
- const { MongoClient } = require("mongodb");
16
16
  const SCHEMA = {
17
17
  docs: "https://github.com/mongodb/node-mongodb-native",
18
18
  friendlyName: "MongoDB",
@@ -64,27 +64,79 @@ var MongoDBModule;
64
64
  class MongoIntegration {
65
65
  constructor(config) {
66
66
  this.config = config;
67
- this.client = new MongoClient(config.connectionString);
67
+ this.client = new mongodb_1.MongoClient(config.connectionString);
68
68
  }
69
69
  connect() {
70
70
  return __awaiter(this, void 0, void 0, function* () {
71
71
  return this.client.connect();
72
72
  });
73
73
  }
74
+ createObjectIds(json) {
75
+ const self = this;
76
+ function interpolateObjectIds(json) {
77
+ var _a;
78
+ for (let field of Object.keys(json)) {
79
+ if (json[field] instanceof Object) {
80
+ json[field] = self.createObjectIds(json[field]);
81
+ }
82
+ if (field === "_id" && typeof json[field] === "string") {
83
+ const id = (_a = json["_id"].match(/(?<=objectid\(['"]).*(?=['"]\))/gi)) === null || _a === void 0 ? void 0 : _a[0];
84
+ if (id) {
85
+ json["_id"] = mongodb_1.ObjectID.createFromHexString(id);
86
+ }
87
+ }
88
+ }
89
+ return json;
90
+ }
91
+ if (Array.isArray(json)) {
92
+ for (let i = 0; i < json.length; i++) {
93
+ json[i] = interpolateObjectIds(json[i]);
94
+ }
95
+ return json;
96
+ }
97
+ return interpolateObjectIds(json);
98
+ }
99
+ parseQueryParams(params, mode) {
100
+ let queryParams = params.split(/(?<=(},)).*{/g);
101
+ let group1 = queryParams[0];
102
+ let group2 = queryParams[2];
103
+ let group3 = queryParams[4];
104
+ if (group1) {
105
+ group1 = JSON.parse(group1.replace(/,+$/, ""));
106
+ }
107
+ if (group2) {
108
+ group2 = JSON.parse("{" + group2.replace(/,+$/, ""));
109
+ }
110
+ if (group3) {
111
+ group3 = JSON.parse("{" + group3.replace(/,+$/, ""));
112
+ }
113
+ if (mode === "update") {
114
+ return {
115
+ filter: group1,
116
+ update: group2,
117
+ options: group3 !== null && group3 !== void 0 ? group3 : {},
118
+ };
119
+ }
120
+ return {
121
+ filter: group1,
122
+ options: group2 !== null && group2 !== void 0 ? group2 : {},
123
+ };
124
+ }
74
125
  create(query) {
75
126
  return __awaiter(this, void 0, void 0, function* () {
76
127
  try {
77
128
  yield this.connect();
78
129
  const db = this.client.db(this.config.db);
79
130
  const collection = db.collection(query.extra.collection);
131
+ let json = this.createObjectIds(query.json);
80
132
  // For mongodb we add an extra actionType to specify
81
133
  // which method we want to call on the collection
82
134
  switch (query.extra.actionTypes) {
83
135
  case "insertOne": {
84
- return yield collection.insertOne(query.json);
136
+ return yield collection.insertOne(json);
85
137
  }
86
138
  case "insertMany": {
87
- return yield collection.insertOne(query.json).toArray();
139
+ return yield collection.insertMany(json);
88
140
  }
89
141
  default: {
90
142
  throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for create`);
@@ -106,21 +158,23 @@ var MongoDBModule;
106
158
  yield this.connect();
107
159
  const db = this.client.db(this.config.db);
108
160
  const collection = db.collection(query.extra.collection);
161
+ let json = this.createObjectIds(query.json);
109
162
  switch (query.extra.actionTypes) {
110
163
  case "find": {
111
- return yield collection.find(query.json).toArray();
164
+ return yield collection.find(json).toArray();
112
165
  }
113
166
  case "findOne": {
114
- return yield collection.findOne(query.json);
167
+ return yield collection.findOne(json);
115
168
  }
116
169
  case "findOneAndUpdate": {
117
- return yield collection.findOneAndUpdate(query.json);
170
+ let findAndUpdateJson = json;
171
+ return yield collection.findOneAndUpdate(findAndUpdateJson.filter, findAndUpdateJson.update, findAndUpdateJson.options);
118
172
  }
119
173
  case "count": {
120
- return yield collection.countDocuments(query.json);
174
+ return yield collection.countDocuments(json);
121
175
  }
122
176
  case "distinct": {
123
- return yield collection.distinct(query.json);
177
+ return yield collection.distinct(json);
124
178
  }
125
179
  default: {
126
180
  throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for read`);
@@ -142,12 +196,17 @@ var MongoDBModule;
142
196
  yield this.connect();
143
197
  const db = this.client.db(this.config.db);
144
198
  const collection = db.collection(query.extra.collection);
199
+ let queryJson = query.json;
200
+ if (typeof queryJson === "string") {
201
+ queryJson = this.parseQueryParams(queryJson, "update");
202
+ }
203
+ let json = this.createObjectIds(queryJson);
145
204
  switch (query.extra.actionTypes) {
146
205
  case "updateOne": {
147
- return yield collection.updateOne(query.json);
206
+ return yield collection.updateOne(json.filter, json.update, json.options);
148
207
  }
149
208
  case "updateMany": {
150
- return yield collection.updateMany(query.json).toArray();
209
+ return yield collection.updateMany(json.filter, json.update, json.options);
151
210
  }
152
211
  default: {
153
212
  throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for update`);
@@ -169,12 +228,17 @@ var MongoDBModule;
169
228
  yield this.connect();
170
229
  const db = this.client.db(this.config.db);
171
230
  const collection = db.collection(query.extra.collection);
231
+ let queryJson = query.json;
232
+ if (typeof queryJson === "string") {
233
+ queryJson = this.parseQueryParams(queryJson, "delete");
234
+ }
235
+ let json = this.createObjectIds(queryJson);
172
236
  switch (query.extra.actionTypes) {
173
237
  case "deleteOne": {
174
- return yield collection.deleteOne(query.json);
238
+ return yield collection.deleteOne(json.filter, json.options);
175
239
  }
176
240
  case "deleteMany": {
177
- return yield collection.deleteMany(query.json).toArray();
241
+ return yield collection.deleteMany(json.filter, json.options);
178
242
  }
179
243
  default: {
180
244
  throw new Error(`actionType ${query.extra.actionTypes} does not exist on DB for delete`);
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.159",
4
+ "version": "1.0.162",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -69,10 +69,10 @@
69
69
  "license": "GPL-3.0",
70
70
  "dependencies": {
71
71
  "@apidevtools/swagger-parser": "^10.0.3",
72
- "@budibase/backend-core": "^1.0.159",
73
- "@budibase/client": "^1.0.159",
74
- "@budibase/pro": "1.0.159",
75
- "@budibase/string-templates": "^1.0.159",
72
+ "@budibase/backend-core": "^1.0.162",
73
+ "@budibase/client": "^1.0.162",
74
+ "@budibase/pro": "1.0.162",
75
+ "@budibase/string-templates": "^1.0.162",
76
76
  "@bull-board/api": "^3.7.0",
77
77
  "@bull-board/koa": "^3.7.0",
78
78
  "@elastic/elasticsearch": "7.10.0",