@saltcorn/data 0.6.2-beta.1 → 0.6.2-beta.2

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 (555) hide show
  1. package/dist/base-plugin/actions.d.ts +141 -0
  2. package/dist/base-plugin/actions.d.ts.map +1 -0
  3. package/dist/base-plugin/actions.js +551 -0
  4. package/dist/base-plugin/actions.js.map +1 -0
  5. package/dist/base-plugin/base.test.d.ts +2 -0
  6. package/dist/base-plugin/base.test.d.ts.map +1 -0
  7. package/dist/base-plugin/base.test.js +15 -0
  8. package/dist/base-plugin/base.test.js.map +1 -0
  9. package/dist/base-plugin/fieldviews.d.ts +25 -0
  10. package/dist/base-plugin/fieldviews.d.ts.map +1 -0
  11. package/dist/base-plugin/fieldviews.js +159 -0
  12. package/dist/base-plugin/fieldviews.js.map +1 -0
  13. package/dist/base-plugin/fileviews.d.ts +52 -0
  14. package/dist/base-plugin/fileviews.d.ts.map +1 -0
  15. package/dist/base-plugin/fileviews.js +59 -0
  16. package/dist/base-plugin/fileviews.js.map +1 -0
  17. package/dist/base-plugin/index.d.ts +524 -0
  18. package/dist/base-plugin/index.d.ts.map +1 -0
  19. package/{base-plugin → dist/base-plugin}/index.js +22 -24
  20. package/dist/base-plugin/index.js.map +1 -0
  21. package/dist/base-plugin/types.d.ts +383 -0
  22. package/dist/base-plugin/types.d.ts.map +1 -0
  23. package/dist/base-plugin/types.js +1080 -0
  24. package/dist/base-plugin/types.js.map +1 -0
  25. package/dist/base-plugin/viewtemplates/edit.d.ts +116 -0
  26. package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -0
  27. package/dist/base-plugin/viewtemplates/edit.js +561 -0
  28. package/dist/base-plugin/viewtemplates/edit.js.map +1 -0
  29. package/dist/base-plugin/viewtemplates/feed.d.ts +73 -0
  30. package/dist/base-plugin/viewtemplates/feed.d.ts.map +1 -0
  31. package/dist/base-plugin/viewtemplates/feed.js +348 -0
  32. package/dist/base-plugin/viewtemplates/feed.js.map +1 -0
  33. package/dist/base-plugin/viewtemplates/filter.d.ts +46 -0
  34. package/dist/base-plugin/viewtemplates/filter.d.ts.map +1 -0
  35. package/dist/base-plugin/viewtemplates/filter.js +267 -0
  36. package/dist/base-plugin/viewtemplates/filter.js.map +1 -0
  37. package/dist/base-plugin/viewtemplates/list.d.ts +99 -0
  38. package/dist/base-plugin/viewtemplates/list.d.ts.map +1 -0
  39. package/dist/base-plugin/viewtemplates/list.js +471 -0
  40. package/dist/base-plugin/viewtemplates/list.js.map +1 -0
  41. package/dist/base-plugin/viewtemplates/listshowlist.d.ts +41 -0
  42. package/dist/base-plugin/viewtemplates/listshowlist.d.ts.map +1 -0
  43. package/dist/base-plugin/viewtemplates/listshowlist.js +248 -0
  44. package/dist/base-plugin/viewtemplates/listshowlist.js.map +1 -0
  45. package/dist/base-plugin/viewtemplates/room.d.ts +140 -0
  46. package/dist/base-plugin/viewtemplates/room.d.ts.map +1 -0
  47. package/dist/base-plugin/viewtemplates/room.js +469 -0
  48. package/dist/base-plugin/viewtemplates/room.js.map +1 -0
  49. package/dist/base-plugin/viewtemplates/show.d.ts +101 -0
  50. package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -0
  51. package/dist/base-plugin/viewtemplates/show.js +562 -0
  52. package/dist/base-plugin/viewtemplates/show.js.map +1 -0
  53. package/dist/base-plugin/viewtemplates/viewable_fields.d.ts +108 -0
  54. package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -0
  55. package/dist/base-plugin/viewtemplates/viewable_fields.js +563 -0
  56. package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -0
  57. package/dist/contracts.d.ts +49 -0
  58. package/dist/contracts.d.ts.map +1 -0
  59. package/dist/contracts.js +212 -0
  60. package/dist/contracts.js.map +1 -0
  61. package/dist/coverage/lcov-report/block-navigation.d.ts +2 -0
  62. package/dist/coverage/lcov-report/block-navigation.d.ts.map +1 -0
  63. package/dist/coverage/lcov-report/block-navigation.js +66 -0
  64. package/dist/coverage/lcov-report/block-navigation.js.map +1 -0
  65. package/dist/coverage/lcov-report/prettify.d.ts +1 -0
  66. package/dist/coverage/lcov-report/prettify.d.ts.map +1 -0
  67. package/dist/coverage/lcov-report/prettify.js +478 -0
  68. package/dist/coverage/lcov-report/prettify.js.map +1 -0
  69. package/dist/coverage/lcov-report/sorter.d.ts +2 -0
  70. package/dist/coverage/lcov-report/sorter.d.ts.map +1 -0
  71. package/dist/coverage/lcov-report/sorter.js +141 -0
  72. package/dist/coverage/lcov-report/sorter.js.map +1 -0
  73. package/dist/db/connect.d.ts +40 -0
  74. package/dist/db/connect.d.ts.map +1 -0
  75. package/dist/db/connect.js +150 -0
  76. package/dist/db/connect.js.map +1 -0
  77. package/dist/db/db.test.d.ts +2 -0
  78. package/dist/db/db.test.d.ts.map +1 -0
  79. package/dist/db/db.test.js +28 -0
  80. package/dist/db/db.test.js.map +1 -0
  81. package/dist/db/fixtures.d.ts +8 -0
  82. package/dist/db/fixtures.d.ts.map +1 -0
  83. package/dist/db/fixtures.js +300 -0
  84. package/dist/db/fixtures.js.map +1 -0
  85. package/dist/db/index.d.ts +3 -0
  86. package/dist/db/index.d.ts.map +1 -0
  87. package/dist/db/index.js +41 -0
  88. package/dist/db/index.js.map +1 -0
  89. package/dist/db/reset_schema.d.ts +13 -0
  90. package/dist/db/reset_schema.d.ts.map +1 -0
  91. package/{db → dist/db}/reset_schema.js +45 -55
  92. package/dist/db/reset_schema.js.map +1 -0
  93. package/dist/db/state.d.ts +56 -0
  94. package/dist/db/state.d.ts.map +1 -0
  95. package/dist/db/state.js +608 -0
  96. package/dist/db/state.js.map +1 -0
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.d.ts.map +1 -0
  99. package/{index.js → dist/index.js} +2 -1
  100. package/dist/index.js.map +1 -0
  101. package/dist/migrate.d.ts +12 -0
  102. package/dist/migrate.d.ts.map +1 -0
  103. package/dist/migrate.js +94 -0
  104. package/dist/migrate.js.map +1 -0
  105. package/dist/migrations/202005141503.d.ts +2 -0
  106. package/dist/migrations/202005141503.d.ts.map +1 -0
  107. package/{migrations → dist/migrations}/202005141503.js +2 -1
  108. package/dist/migrations/202005141503.js.map +1 -0
  109. package/dist/migrations/202005241712.d.ts +2 -0
  110. package/dist/migrations/202005241712.d.ts.map +1 -0
  111. package/{migrations → dist/migrations}/202005241712.js +2 -1
  112. package/dist/migrations/202005241712.js.map +1 -0
  113. package/dist/migrations/202005251037.d.ts +2 -0
  114. package/dist/migrations/202005251037.d.ts.map +1 -0
  115. package/{migrations → dist/migrations}/202005251037.js +2 -1
  116. package/dist/migrations/202005251037.js.map +1 -0
  117. package/dist/migrations/202005282134.d.ts +2 -0
  118. package/dist/migrations/202005282134.d.ts.map +1 -0
  119. package/{migrations → dist/migrations}/202005282134.js +2 -1
  120. package/dist/migrations/202005282134.js.map +1 -0
  121. package/dist/migrations/202006022156.d.ts +2 -0
  122. package/dist/migrations/202006022156.d.ts.map +1 -0
  123. package/{migrations → dist/migrations}/202006022156.js +2 -1
  124. package/dist/migrations/202006022156.js.map +1 -0
  125. package/dist/migrations/202006051507.d.ts +2 -0
  126. package/dist/migrations/202006051507.d.ts.map +1 -0
  127. package/{migrations → dist/migrations}/202006051507.js +2 -1
  128. package/dist/migrations/202006051507.js.map +1 -0
  129. package/dist/migrations/202006240906.d.ts +2 -0
  130. package/dist/migrations/202006240906.d.ts.map +1 -0
  131. package/{migrations → dist/migrations}/202006240906.js +2 -1
  132. package/dist/migrations/202006240906.js.map +1 -0
  133. package/dist/migrations/202007091707.d.ts +2 -0
  134. package/dist/migrations/202007091707.d.ts.map +1 -0
  135. package/{migrations → dist/migrations}/202007091707.js +2 -1
  136. package/dist/migrations/202007091707.js.map +1 -0
  137. package/dist/migrations/202007202144.d.ts +2 -0
  138. package/dist/migrations/202007202144.d.ts.map +1 -0
  139. package/{migrations → dist/migrations}/202007202144.js +2 -1
  140. package/dist/migrations/202007202144.js.map +1 -0
  141. package/dist/migrations/202008031500.d.ts +2 -0
  142. package/dist/migrations/202008031500.d.ts.map +1 -0
  143. package/dist/migrations/202008031500.js +4 -0
  144. package/dist/migrations/202008031500.js.map +1 -0
  145. package/dist/migrations/202008051415.d.ts +2 -0
  146. package/dist/migrations/202008051415.d.ts.map +1 -0
  147. package/{migrations → dist/migrations}/202008051415.js +2 -1
  148. package/dist/migrations/202008051415.js.map +1 -0
  149. package/dist/migrations/202008121149.d.ts +3 -0
  150. package/dist/migrations/202008121149.d.ts.map +1 -0
  151. package/{migrations → dist/migrations}/202008121149.js +2 -2
  152. package/dist/migrations/202008121149.js.map +1 -0
  153. package/dist/migrations/202009112140.d.ts +3 -0
  154. package/dist/migrations/202009112140.d.ts.map +1 -0
  155. package/{migrations → dist/migrations}/202009112140.js +2 -2
  156. package/dist/migrations/202009112140.js.map +1 -0
  157. package/dist/migrations/202009181655.d.ts +2 -0
  158. package/dist/migrations/202009181655.d.ts.map +1 -0
  159. package/dist/migrations/202009181655.js +7 -0
  160. package/dist/migrations/202009181655.js.map +1 -0
  161. package/dist/migrations/202009221105.d.ts +2 -0
  162. package/dist/migrations/202009221105.d.ts.map +1 -0
  163. package/dist/migrations/202009221105.js +4 -0
  164. package/dist/migrations/202009221105.js.map +1 -0
  165. package/dist/migrations/202009231331.d.ts +2 -0
  166. package/dist/migrations/202009231331.d.ts.map +1 -0
  167. package/{migrations → dist/migrations}/202009231331.js +2 -1
  168. package/dist/migrations/202009231331.js.map +1 -0
  169. package/dist/migrations/202009301531.d.ts +2 -0
  170. package/dist/migrations/202009301531.d.ts.map +1 -0
  171. package/dist/migrations/202009301531.js +8 -0
  172. package/dist/migrations/202009301531.js.map +1 -0
  173. package/dist/migrations/202010231444.d.ts +2 -0
  174. package/dist/migrations/202010231444.d.ts.map +1 -0
  175. package/dist/migrations/202010231444.js +4 -0
  176. package/dist/migrations/202010231444.js.map +1 -0
  177. package/dist/migrations/202010251412.d.ts +2 -0
  178. package/dist/migrations/202010251412.d.ts.map +1 -0
  179. package/dist/migrations/202010251412.js +10 -0
  180. package/dist/migrations/202010251412.js.map +1 -0
  181. package/dist/migrations/202011021749.d.ts +2 -0
  182. package/dist/migrations/202011021749.d.ts.map +1 -0
  183. package/{migrations → dist/migrations}/202011021749.js +2 -1
  184. package/dist/migrations/202011021749.js.map +1 -0
  185. package/dist/migrations/202011051353.d.ts +2 -0
  186. package/dist/migrations/202011051353.d.ts.map +1 -0
  187. package/{migrations → dist/migrations}/202011051353.js +2 -1
  188. package/dist/migrations/202011051353.js.map +1 -0
  189. package/dist/migrations/202011111127.d.ts +2 -0
  190. package/dist/migrations/202011111127.d.ts.map +1 -0
  191. package/{migrations → dist/migrations}/202011111127.js +2 -1
  192. package/dist/migrations/202011111127.js.map +1 -0
  193. package/dist/migrations/202012011203.d.ts +2 -0
  194. package/dist/migrations/202012011203.d.ts.map +1 -0
  195. package/{migrations → dist/migrations}/202012011203.js +2 -1
  196. package/dist/migrations/202012011203.js.map +1 -0
  197. package/dist/migrations/202012100841.d.ts +2 -0
  198. package/dist/migrations/202012100841.d.ts.map +1 -0
  199. package/{migrations → dist/migrations}/202012100841.js +2 -1
  200. package/dist/migrations/202012100841.js.map +1 -0
  201. package/dist/migrations/202012281835.d.ts +2 -0
  202. package/dist/migrations/202012281835.d.ts.map +1 -0
  203. package/{migrations → dist/migrations}/202012281835.js +2 -1
  204. package/dist/migrations/202012281835.js.map +1 -0
  205. package/dist/migrations/202101061051.d.ts +2 -0
  206. package/dist/migrations/202101061051.d.ts.map +1 -0
  207. package/{migrations → dist/migrations}/202101061051.js +2 -1
  208. package/dist/migrations/202101061051.js.map +1 -0
  209. package/dist/migrations/202101141128.d.ts +2 -0
  210. package/dist/migrations/202101141128.d.ts.map +1 -0
  211. package/dist/migrations/202101141128.js +4 -0
  212. package/dist/migrations/202101141128.js.map +1 -0
  213. package/dist/migrations/202102091312.d.ts +3 -0
  214. package/dist/migrations/202102091312.d.ts.map +1 -0
  215. package/dist/migrations/202102091312.js +19 -0
  216. package/dist/migrations/202102091312.js.map +1 -0
  217. package/dist/migrations/202102101624.d.ts +2 -0
  218. package/dist/migrations/202102101624.d.ts.map +1 -0
  219. package/dist/migrations/202102101624.js +7 -0
  220. package/dist/migrations/202102101624.js.map +1 -0
  221. package/dist/migrations/202102172148.d.ts +2 -0
  222. package/dist/migrations/202102172148.d.ts.map +1 -0
  223. package/{migrations → dist/migrations}/202102172148.js +2 -2
  224. package/dist/migrations/202102172148.js.map +1 -0
  225. package/dist/migrations/202102261650.d.ts +2 -0
  226. package/dist/migrations/202102261650.d.ts.map +1 -0
  227. package/dist/migrations/202102261650.js +7 -0
  228. package/dist/migrations/202102261650.js.map +1 -0
  229. package/dist/migrations/202106102347.d.ts +2 -0
  230. package/dist/migrations/202106102347.d.ts.map +1 -0
  231. package/{migrations → dist/migrations}/202106102347.js +2 -3
  232. package/dist/migrations/202106102347.js.map +1 -0
  233. package/dist/migrations/202106112120.d.ts +2 -0
  234. package/dist/migrations/202106112120.d.ts.map +1 -0
  235. package/{migrations → dist/migrations}/202106112120.js +2 -3
  236. package/dist/migrations/202106112120.js.map +1 -0
  237. package/dist/migrations/202106120012.d.ts +2 -0
  238. package/dist/migrations/202106120012.d.ts.map +1 -0
  239. package/{migrations → dist/migrations}/202106120012.js +2 -3
  240. package/dist/migrations/202106120012.js.map +1 -0
  241. package/dist/migrations/202106120220.d.ts +2 -0
  242. package/dist/migrations/202106120220.d.ts.map +1 -0
  243. package/{migrations → dist/migrations}/202106120220.js +2 -4
  244. package/dist/migrations/202106120220.js.map +1 -0
  245. package/dist/migrations/202106121701.d.ts +2 -0
  246. package/dist/migrations/202106121701.d.ts.map +1 -0
  247. package/{migrations → dist/migrations}/202106121701.js +2 -3
  248. package/dist/migrations/202106121701.js.map +1 -0
  249. package/dist/migrations/202106121703.d.ts +3 -0
  250. package/dist/migrations/202106121703.d.ts.map +1 -0
  251. package/{migrations → dist/migrations}/202106121703.js +2 -3
  252. package/dist/migrations/202106121703.js.map +1 -0
  253. package/dist/migrations/202106251126.d.ts +2 -0
  254. package/dist/migrations/202106251126.d.ts.map +1 -0
  255. package/dist/migrations/202106251126.js +6 -0
  256. package/dist/migrations/202106251126.js.map +1 -0
  257. package/dist/migrations/202107281619.d.ts +2 -0
  258. package/dist/migrations/202107281619.d.ts.map +1 -0
  259. package/{migrations → dist/migrations}/202107281619.js +2 -1
  260. package/dist/migrations/202107281619.js.map +1 -0
  261. package/dist/migrations/202107302158.d.ts +3 -0
  262. package/dist/migrations/202107302158.d.ts.map +1 -0
  263. package/{migrations → dist/migrations}/202107302158.js +2 -3
  264. package/dist/migrations/202107302158.js.map +1 -0
  265. package/dist/migrations/202108022257.d.ts +2 -0
  266. package/dist/migrations/202108022257.d.ts.map +1 -0
  267. package/{migrations → dist/migrations}/202108022257.js +3 -4
  268. package/dist/migrations/202108022257.js.map +1 -0
  269. package/dist/migrations/202109201624.d.ts +2 -0
  270. package/dist/migrations/202109201624.d.ts.map +1 -0
  271. package/{migrations → dist/migrations}/202109201624.js +2 -1
  272. package/dist/migrations/202109201624.js.map +1 -0
  273. package/dist/migrations/202109301031.d.ts +3 -0
  274. package/dist/migrations/202109301031.d.ts.map +1 -0
  275. package/{migrations → dist/migrations}/202109301031.js +2 -2
  276. package/dist/migrations/202109301031.js.map +1 -0
  277. package/dist/migrations/202111290253.d.ts +3 -0
  278. package/dist/migrations/202111290253.d.ts.map +1 -0
  279. package/dist/migrations/202111290253.js +5 -0
  280. package/dist/migrations/202111290253.js.map +1 -0
  281. package/dist/models/backup.d.ts +22 -0
  282. package/dist/models/backup.d.ts.map +1 -0
  283. package/{models → dist/models}/backup.js +95 -192
  284. package/dist/models/backup.js.map +1 -0
  285. package/dist/models/config.d.ts +177 -0
  286. package/dist/models/config.d.ts.map +1 -0
  287. package/dist/models/config.js +683 -0
  288. package/dist/models/config.js.map +1 -0
  289. package/dist/models/crash.d.ts +74 -0
  290. package/dist/models/crash.d.ts.map +1 -0
  291. package/dist/models/crash.js +118 -0
  292. package/dist/models/crash.js.map +1 -0
  293. package/dist/models/discovery.d.ts +28 -0
  294. package/dist/models/discovery.d.ts.map +1 -0
  295. package/dist/models/discovery.js +163 -0
  296. package/dist/models/discovery.js.map +1 -0
  297. package/dist/models/email.d.ts +16 -0
  298. package/dist/models/email.d.ts.map +1 -0
  299. package/dist/models/email.js +90 -0
  300. package/dist/models/email.js.map +1 -0
  301. package/dist/models/eventlog.d.ts +77 -0
  302. package/dist/models/eventlog.d.ts.map +1 -0
  303. package/dist/models/eventlog.js +132 -0
  304. package/dist/models/eventlog.js.map +1 -0
  305. package/dist/models/expression.d.ts +54 -0
  306. package/dist/models/expression.d.ts.map +1 -0
  307. package/dist/models/expression.js +274 -0
  308. package/dist/models/expression.js.map +1 -0
  309. package/dist/models/field.d.ts +217 -0
  310. package/dist/models/field.d.ts.map +1 -0
  311. package/dist/models/field.js +619 -0
  312. package/dist/models/field.js.map +1 -0
  313. package/dist/models/fieldrepeat.d.ts +49 -0
  314. package/dist/models/fieldrepeat.d.ts.map +1 -0
  315. package/dist/models/fieldrepeat.js +88 -0
  316. package/dist/models/fieldrepeat.js.map +1 -0
  317. package/dist/models/file.d.ts +122 -0
  318. package/dist/models/file.d.ts.map +1 -0
  319. package/dist/models/file.js +224 -0
  320. package/dist/models/file.js.map +1 -0
  321. package/dist/models/form.d.ts +82 -0
  322. package/dist/models/form.d.ts.map +1 -0
  323. package/dist/models/form.js +163 -0
  324. package/dist/models/form.js.map +1 -0
  325. package/dist/models/index.d.ts +1 -0
  326. package/dist/models/index.d.ts.map +1 -0
  327. package/{models → dist/models}/index.js +42 -42
  328. package/dist/models/index.js.map +1 -0
  329. package/dist/models/layout.d.ts +34 -0
  330. package/dist/models/layout.d.ts.map +1 -0
  331. package/dist/models/layout.js +153 -0
  332. package/dist/models/layout.js.map +1 -0
  333. package/dist/models/library.d.ts +50 -0
  334. package/dist/models/library.d.ts.map +1 -0
  335. package/dist/models/library.js +129 -0
  336. package/dist/models/library.js.map +1 -0
  337. package/dist/models/pack.d.ts +89 -0
  338. package/dist/models/pack.d.ts.map +1 -0
  339. package/dist/models/pack.js +383 -0
  340. package/dist/models/pack.js.map +1 -0
  341. package/dist/models/page.d.ts +101 -0
  342. package/dist/models/page.d.ts.map +1 -0
  343. package/dist/models/page.js +223 -0
  344. package/dist/models/page.js.map +1 -0
  345. package/dist/models/plugin.d.ts +100 -0
  346. package/dist/models/plugin.d.ts.map +1 -0
  347. package/dist/models/plugin.js +204 -0
  348. package/dist/models/plugin.js.map +1 -0
  349. package/dist/models/random.d.ts +24 -0
  350. package/dist/models/random.d.ts.map +1 -0
  351. package/dist/models/random.js +186 -0
  352. package/dist/models/random.js.map +1 -0
  353. package/dist/models/role.d.ts +42 -0
  354. package/dist/models/role.d.ts.map +1 -0
  355. package/dist/models/role.js +64 -0
  356. package/dist/models/role.js.map +1 -0
  357. package/dist/models/scheduler.d.ts +18 -0
  358. package/dist/models/scheduler.d.ts.map +1 -0
  359. package/dist/models/scheduler.js +159 -0
  360. package/dist/models/scheduler.js.map +1 -0
  361. package/dist/models/table.d.ts +326 -0
  362. package/dist/models/table.d.ts.map +1 -0
  363. package/dist/models/table.js +1006 -0
  364. package/dist/models/table.js.map +1 -0
  365. package/dist/models/table_constraints.d.ts +69 -0
  366. package/dist/models/table_constraints.d.ts.map +1 -0
  367. package/dist/models/table_constraints.js +118 -0
  368. package/dist/models/table_constraints.js.map +1 -0
  369. package/dist/models/tenant.d.ts +55 -0
  370. package/dist/models/tenant.d.ts.map +1 -0
  371. package/{models → dist/models}/tenant.js +40 -63
  372. package/dist/models/tenant.js.map +1 -0
  373. package/dist/models/trigger.d.ts +133 -0
  374. package/dist/models/trigger.d.ts.map +1 -0
  375. package/dist/models/trigger.js +292 -0
  376. package/dist/models/trigger.js.map +1 -0
  377. package/dist/models/user.d.ts +235 -0
  378. package/dist/models/user.d.ts.map +1 -0
  379. package/dist/models/user.js +434 -0
  380. package/dist/models/user.js.map +1 -0
  381. package/dist/models/view.d.ts +204 -0
  382. package/dist/models/view.d.ts.map +1 -0
  383. package/dist/models/view.js +497 -0
  384. package/dist/models/view.js.map +1 -0
  385. package/dist/models/workflow.d.ts +48 -0
  386. package/dist/models/workflow.d.ts.map +1 -0
  387. package/dist/models/workflow.js +190 -0
  388. package/dist/models/workflow.js.map +1 -0
  389. package/dist/plugin-helper.d.ts +145 -0
  390. package/dist/plugin-helper.d.ts.map +1 -0
  391. package/dist/plugin-helper.js +1158 -0
  392. package/dist/plugin-helper.js.map +1 -0
  393. package/dist/plugin-testing.d.ts +3 -0
  394. package/dist/plugin-testing.d.ts.map +1 -0
  395. package/dist/plugin-testing.js +120 -0
  396. package/dist/plugin-testing.js.map +1 -0
  397. package/dist/tests/actions.test.d.ts +2 -0
  398. package/dist/tests/actions.test.d.ts.map +1 -0
  399. package/dist/tests/actions.test.js +205 -0
  400. package/dist/tests/actions.test.js.map +1 -0
  401. package/dist/tests/auxtest.test.d.ts +2 -0
  402. package/dist/tests/auxtest.test.d.ts.map +1 -0
  403. package/dist/tests/auxtest.test.js +48 -0
  404. package/dist/tests/auxtest.test.js.map +1 -0
  405. package/dist/tests/backup.test.d.ts +2 -0
  406. package/dist/tests/backup.test.d.ts.map +1 -0
  407. package/dist/tests/backup.test.js +88 -0
  408. package/dist/tests/backup.test.js.map +1 -0
  409. package/dist/tests/calc.test.d.ts +2 -0
  410. package/dist/tests/calc.test.d.ts.map +1 -0
  411. package/dist/tests/calc.test.js +231 -0
  412. package/dist/tests/calc.test.js.map +1 -0
  413. package/dist/tests/config.test.d.ts +2 -0
  414. package/dist/tests/config.test.d.ts.map +1 -0
  415. package/dist/tests/config.test.js +83 -0
  416. package/dist/tests/config.test.js.map +1 -0
  417. package/dist/tests/discover.test.d.ts +2 -0
  418. package/dist/tests/discover.test.d.ts.map +1 -0
  419. package/dist/tests/discover.test.js +106 -0
  420. package/dist/tests/discover.test.js.map +1 -0
  421. package/dist/tests/exact_views.test.d.ts +2 -0
  422. package/dist/tests/exact_views.test.d.ts.map +1 -0
  423. package/dist/tests/exact_views.test.js +511 -0
  424. package/dist/tests/exact_views.test.js.map +1 -0
  425. package/dist/tests/field.test.d.ts +2 -0
  426. package/dist/tests/field.test.d.ts.map +1 -0
  427. package/dist/tests/field.test.js +237 -0
  428. package/dist/tests/field.test.js.map +1 -0
  429. package/dist/tests/form.test.d.ts +2 -0
  430. package/dist/tests/form.test.d.ts.map +1 -0
  431. package/dist/tests/form.test.js +191 -0
  432. package/dist/tests/form.test.js.map +1 -0
  433. package/dist/tests/mocks.d.ts +111 -0
  434. package/dist/tests/mocks.d.ts.map +1 -0
  435. package/dist/tests/mocks.js +165 -0
  436. package/dist/tests/mocks.js.map +1 -0
  437. package/dist/tests/models.test.d.ts +2 -0
  438. package/dist/tests/models.test.d.ts.map +1 -0
  439. package/dist/tests/models.test.js +210 -0
  440. package/dist/tests/models.test.js.map +1 -0
  441. package/dist/tests/pack.test.d.ts +2 -0
  442. package/dist/tests/pack.test.d.ts.map +1 -0
  443. package/dist/tests/pack.test.js +331 -0
  444. package/dist/tests/pack.test.js.map +1 -0
  445. package/dist/tests/plugin.test.d.ts +2 -0
  446. package/dist/tests/plugin.test.d.ts.map +1 -0
  447. package/dist/tests/plugin.test.js +53 -0
  448. package/dist/tests/plugin.test.js.map +1 -0
  449. package/dist/tests/random.test.d.ts +2 -0
  450. package/dist/tests/random.test.d.ts.map +1 -0
  451. package/dist/tests/random.test.js +138 -0
  452. package/dist/tests/random.test.js.map +1 -0
  453. package/dist/tests/table.test.d.ts +2 -0
  454. package/dist/tests/table.test.d.ts.map +1 -0
  455. package/dist/tests/table.test.js +1048 -0
  456. package/dist/tests/table.test.js.map +1 -0
  457. package/dist/tests/tenant.test.d.ts +2 -0
  458. package/dist/tests/tenant.test.d.ts.map +1 -0
  459. package/dist/tests/tenant.test.js +45 -0
  460. package/dist/tests/tenant.test.js.map +1 -0
  461. package/dist/tests/user.test.d.ts +2 -0
  462. package/dist/tests/user.test.d.ts.map +1 -0
  463. package/dist/tests/user.test.js +190 -0
  464. package/dist/tests/user.test.js.map +1 -0
  465. package/dist/tests/view.test.d.ts +2 -0
  466. package/dist/tests/view.test.d.ts.map +1 -0
  467. package/dist/tests/view.test.js +238 -0
  468. package/dist/tests/view.test.js.map +1 -0
  469. package/dist/tests/workflow.test.d.ts +2 -0
  470. package/dist/tests/workflow.test.d.ts.map +1 -0
  471. package/dist/tests/workflow.test.js +115 -0
  472. package/dist/tests/workflow.test.js.map +1 -0
  473. package/dist/tsconfig.ref.tsbuildinfo +1 -0
  474. package/dist/utils.d.ts +26 -0
  475. package/dist/utils.d.ts.map +1 -0
  476. package/dist/utils.js +124 -0
  477. package/dist/utils.js.map +1 -0
  478. package/package.json +32 -8
  479. package/base-plugin/actions.js +0 -629
  480. package/base-plugin/base.test.js +0 -15
  481. package/base-plugin/fieldviews.js +0 -197
  482. package/base-plugin/fileviews.js +0 -65
  483. package/base-plugin/types.js +0 -1154
  484. package/base-plugin/viewtemplates/edit.js +0 -672
  485. package/base-plugin/viewtemplates/feed.js +0 -434
  486. package/base-plugin/viewtemplates/filter.js +0 -358
  487. package/base-plugin/viewtemplates/list.js +0 -575
  488. package/base-plugin/viewtemplates/listshowlist.js +0 -292
  489. package/base-plugin/viewtemplates/room.js +0 -652
  490. package/base-plugin/viewtemplates/show.js +0 -689
  491. package/base-plugin/viewtemplates/viewable_fields.js +0 -714
  492. package/contracts.js +0 -311
  493. package/db/connect.js +0 -151
  494. package/db/db.test.js +0 -33
  495. package/db/fixtures.js +0 -303
  496. package/db/index.js +0 -63
  497. package/db/state.js +0 -674
  498. package/migrate.js +0 -99
  499. package/migrations/202008031500.js +0 -4
  500. package/migrations/202009181655.js +0 -6
  501. package/migrations/202009221105.js +0 -4
  502. package/migrations/202009301531.js +0 -7
  503. package/migrations/202010231444.js +0 -4
  504. package/migrations/202010251412.js +0 -9
  505. package/migrations/202101141128.js +0 -4
  506. package/migrations/202102091312.js +0 -19
  507. package/migrations/202102101624.js +0 -5
  508. package/migrations/202102261650.js +0 -6
  509. package/migrations/202106251126.js +0 -5
  510. package/models/config.js +0 -680
  511. package/models/crash.js +0 -126
  512. package/models/discovery.js +0 -195
  513. package/models/email.js +0 -92
  514. package/models/eventlog.js +0 -146
  515. package/models/expression.js +0 -276
  516. package/models/field.js +0 -746
  517. package/models/fieldrepeat.js +0 -96
  518. package/models/file.js +0 -234
  519. package/models/form.js +0 -169
  520. package/models/layout.js +0 -146
  521. package/models/library.js +0 -135
  522. package/models/pack.js +0 -466
  523. package/models/page.js +0 -255
  524. package/models/plugin.js +0 -219
  525. package/models/random.js +0 -206
  526. package/models/role.js +0 -94
  527. package/models/scheduler.js +0 -163
  528. package/models/table.js +0 -1211
  529. package/models/table_constraints.js +0 -133
  530. package/models/trigger.js +0 -327
  531. package/models/user.js +0 -503
  532. package/models/view.js +0 -622
  533. package/models/workflow.js +0 -205
  534. package/plugin-helper.js +0 -1311
  535. package/plugin-testing.js +0 -124
  536. package/tests/actions.test.js +0 -232
  537. package/tests/auxtest.test.js +0 -52
  538. package/tests/backup.test.js +0 -92
  539. package/tests/calc.test.js +0 -243
  540. package/tests/config.test.js +0 -91
  541. package/tests/discover.test.js +0 -114
  542. package/tests/exact_views.test.js +0 -526
  543. package/tests/field.test.js +0 -253
  544. package/tests/form.test.js +0 -198
  545. package/tests/mocks.js +0 -173
  546. package/tests/models.test.js +0 -221
  547. package/tests/pack.test.js +0 -350
  548. package/tests/plugin.test.js +0 -59
  549. package/tests/random.test.js +0 -154
  550. package/tests/table.test.js +0 -1091
  551. package/tests/tenant.test.js +0 -56
  552. package/tests/user.test.js +0 -196
  553. package/tests/view.test.js +0 -251
  554. package/tests/workflow.test.js +0 -119
  555. package/utils.js +0 -137
@@ -1,629 +0,0 @@
1
- /**
2
- * Action description
3
- * @category saltcorn-data
4
- * @module base-plugin/actions
5
- * @subcategory base-plugin
6
- */
7
-
8
- const fetch = require("node-fetch");
9
- const vm = require("vm");
10
- const Table = require("../models/table");
11
- const View = require("../models/view");
12
- const { getState } = require("../db/state");
13
- const User = require("../models/user");
14
- const Trigger = require("../models/trigger");
15
- const {
16
- getMailTransport,
17
- transformBootstrapEmail,
18
- } = require("../models/email");
19
- const { mockReqRes } = require("../tests/mocks");
20
- const {
21
- get_async_expression_function,
22
- recalculate_for_stored,
23
- } = require("../models/expression");
24
- const { div, code } = require("@saltcorn/markup/tags");
25
- const { sleep } = require("../utils");
26
- const db = require("../db");
27
- //action use cases: field modify, like/rate (insert join), notify, send row to webhook
28
- // todo add translation
29
-
30
- /**
31
- * @param {object} opts
32
- * @param {object} opts.row
33
- * @param {object} opts.table
34
- * @param {object} opts.channel
35
- * @param {object} opts.configuration
36
- * @param {object} opts.user
37
- * @param {...*} opts.rest
38
- * @returns {Promise<object>}
39
- */
40
- const run_code = async ({
41
- row,
42
- table,
43
- channel,
44
- configuration: { code, run_where },
45
- user,
46
- ...rest
47
- }) => {
48
- if (run_where === "Client page") return { eval_js: code };
49
- const Actions = {};
50
- Object.entries(getState().actions).forEach(([k, v]) => {
51
- Actions[k] = (args = {}) => {
52
- v.run({ row, table, user, configuration: args, ...rest, ...args });
53
- };
54
- });
55
- const trigger_actions = await Trigger.find({
56
- when_trigger: { or: ["API call", "Never"] },
57
- });
58
- for (const trigger of trigger_actions) {
59
- const state_action = getState().actions[trigger.action];
60
- Actions[trigger.name] = (args = {}) => {
61
- state_action.run({
62
- row,
63
- table,
64
- configuration: trigger.configuration,
65
- user,
66
- ...rest,
67
- ...args,
68
- });
69
- };
70
- }
71
- const emitEvent = (eventType, channel, payload) =>
72
- Trigger.emitEvent(eventType, channel, user, payload);
73
- const fetchJSON = async (...args) => await (await fetch(...args)).json();
74
- const f = vm.runInNewContext(`async () => {${code}}`, {
75
- Table,
76
- table,
77
- row,
78
- user,
79
- console,
80
- Actions,
81
- emitEvent,
82
- sleep,
83
- fetchJSON,
84
- fetch,
85
- channel: table ? table.name : channel,
86
- ...(row || {}),
87
- ...getState().function_context,
88
- ...rest,
89
- });
90
- return await f();
91
- };
92
-
93
- module.exports = {
94
- /**
95
- * @namespace
96
- * @category saltcorn-data
97
- * @subcategory actions
98
- */
99
- blocks: {
100
- disableInBuilder: true,
101
- disableInList: true,
102
- configFields: [
103
- {
104
- name: "workspace",
105
- input_type: "hidden",
106
- },
107
- {
108
- name: "code",
109
- input_type: "hidden",
110
- },
111
- ],
112
- /**
113
- * @type {base-plugin/actions~run_code}
114
- * @see base-plugin/actions~run_code
115
- */
116
- run: run_code,
117
- },
118
-
119
- /**
120
- * @namespace
121
- * @category saltcorn-data
122
- * @subcategory actions
123
- */
124
- emit_event: {
125
- /**
126
- * @returns {object[]}
127
- */
128
- configFields: () => [
129
- {
130
- name: "eventType",
131
- label: "Event type",
132
- required: true,
133
- input_type: "select",
134
- options: Trigger.when_options,
135
- },
136
- {
137
- name: "channel",
138
- label: "Channel",
139
- type: "String",
140
- fieldview: "textarea",
141
- },
142
- {
143
- name: "payload",
144
- label: "Payload JSON",
145
- sublabel: "Leave blank to use row from table",
146
- type: "String",
147
- fieldview: "textarea",
148
- },
149
- ],
150
- /**
151
- * @param {object} opts
152
- * @param {object} opts.row
153
- * @param {object} opts.configuration
154
- * @param {object} opts.user
155
- * @returns {Promise<void>}
156
- */
157
- run: async ({
158
- row,
159
- configuration: { eventType, channel, payload },
160
- user,
161
- }) => {
162
- return await Trigger.emitEvent(
163
- eventType,
164
- channel,
165
- user,
166
- payload ? JSON.parse(payload) : row
167
- );
168
- },
169
- },
170
-
171
- /**
172
- * @namespace
173
- * @category saltcorn-data
174
- * @subcategory actions
175
- */
176
- webhook: {
177
- configFields: [
178
- {
179
- name: "url",
180
- label: "URL",
181
- type: "String",
182
- sublabel: "Trigger will call specified URL",
183
- },
184
- {
185
- name: "body",
186
- label: "JSON body",
187
- sublabel: "Leave blank to use row from table",
188
- type: "String",
189
- fieldview: "textarea", // I think that textarea is better
190
- },
191
- ],
192
- /**
193
- * @param {object} opts
194
- * @param {string} opts.url
195
- * @param {object} opts.body
196
- * @returns {Promise<object>}
197
- */
198
- run: async ({ row, configuration: { url, body } }) => {
199
- return await fetch(url, {
200
- method: "post",
201
- body: body || JSON.stringify(row),
202
- headers: { "Content-Type": "application/json" },
203
- });
204
- },
205
- },
206
-
207
- /**
208
- * @namespace
209
- * @category saltcorn-data
210
- * @subcategory actions
211
- */
212
- find_or_create_dm_room: {
213
- /**
214
- * @returns {Promise<object[]>}
215
- */
216
- configFields: async () => {
217
- const views = await View.find_all_views_where(
218
- ({ viewrow }) => viewrow.viewtemplate === "Room"
219
- );
220
-
221
- const view_opts = views.map((v) => v.name);
222
- return [
223
- {
224
- name: "viewname",
225
- label: "Room view",
226
- sublabel: "Select a view with the Room viewtemplate",
227
- input_type: "select",
228
- options: view_opts,
229
- },
230
- ];
231
- },
232
-
233
- /**
234
- * @param {object} opts
235
- * @param {object} opts.row
236
- * @param {*} opts.table
237
- * @param {object} opts.configuration
238
- * @param {object} opts.user
239
- * @returns {Promise<object>}
240
- */
241
- run: async ({ row, table, configuration: { viewname }, user }) => {
242
- const view = await View.findOne({ name: viewname });
243
- const { participant_field } = view.configuration;
244
- const [
245
- part_table_name,
246
- part_key_to_room,
247
- part_user_field,
248
- ] = participant_field.split(".");
249
- const roomtable = Table.findOne({ id: view.table_id });
250
- const parttable = Table.findOne({ name: part_table_name });
251
-
252
- //find a room that has both participants
253
- // select id from rooms r where uid1 in (select id from participants where...) and
254
-
255
- const { rows } = await db.query(
256
- `with my_rooms as (select "${part_key_to_room}" from "${db.getTenantSchema()}"."${db.sqlsanitize(
257
- part_table_name
258
- )}" where "${part_user_field}" = $1)
259
- select * from "${db.getTenantSchema()}"."${db.sqlsanitize(
260
- roomtable.name
261
- )}" r where r.id in (select "${part_key_to_room}" from my_rooms)
262
- and $2 in (select "${part_user_field}" from "${db.getTenantSchema()}"."${db.sqlsanitize(
263
- part_table_name
264
- )}" where "${part_key_to_room}" = r.id)`,
265
- [user.id, row.id]
266
- );
267
- if (rows.length > 0) {
268
- return { goto: `/view/${viewname}?id=${rows[0].id}` };
269
- } else {
270
- //create room
271
- const room_id = await roomtable.insertRow({});
272
- await parttable.insertRow({
273
- [part_user_field]: user.id,
274
- [part_key_to_room]: room_id,
275
- });
276
- await parttable.insertRow({
277
- [part_user_field]: row.id,
278
- [part_key_to_room]: room_id,
279
- });
280
- return { goto: `/view/${viewname}?id=${room_id}` };
281
- }
282
- },
283
- },
284
-
285
- /**
286
- * @namespace
287
- * @category saltcorn-data
288
- * @subcategory actions
289
- */
290
- send_email: {
291
- /**
292
- * @param {object} opts
293
- * @param {object} opts.table
294
- * @returns {Promise<object[]>}
295
- */
296
- configFields: async ({ table }) => {
297
- if (!table) return [];
298
- const views = await View.find_table_views_where(
299
- table,
300
- ({ viewtemplate }) => viewtemplate.runMany || viewtemplate.renderRows
301
- );
302
-
303
- const view_opts = views.map((v) => v.name);
304
- const fields = await table.getFields();
305
- const field_opts = fields
306
- .filter(
307
- (f) =>
308
- (f.type && f.type.name === "String") || f.reftable_name === "users"
309
- )
310
- .map((f) => f.name);
311
- return [
312
- {
313
- name: "viewname",
314
- label: "View to send",
315
- sublabel:
316
- "Select a view that can render a single record - for instance, of the Show template.",
317
- input_type: "select",
318
- options: view_opts,
319
- },
320
- {
321
- name: "to_email",
322
- label: "Recipient email address",
323
- sublabel:
324
- "Select email addresses for send email. Choose option to get more information",
325
- input_type: "select",
326
- required: true,
327
-
328
- options: ["Fixed", "User", "Field"],
329
- },
330
- {
331
- name: "to_email_field",
332
- label: "Field with email address",
333
- sublabel:
334
- "Field with email address a String, or Key to user who will receive email",
335
- input_type: "select",
336
-
337
- options: field_opts,
338
-
339
- showIf: { to_email: "Field" },
340
- },
341
- {
342
- name: "to_email_fixed",
343
- label: "Fixed address",
344
- sublabel: "Email address to send emails", // todo send to few addresses?
345
- type: "String",
346
- showIf: { to_email: "Fixed" },
347
- },
348
- {
349
- name: "subject",
350
- label: "Subject",
351
- sublabel: "Subject of email",
352
- type: "String",
353
- required: true,
354
- },
355
- ];
356
- },
357
- requireRow: true,
358
- /**
359
- * @param {object} opts
360
- * @param {object} opts.row
361
- * @param {object} opts.table
362
- * @param {object} opts.configuration
363
- * @param {object} opts.user
364
- * @returns {Promise<object>}
365
- */
366
- run: async ({
367
- row,
368
- table,
369
- configuration: {
370
- viewname,
371
- subject,
372
- to_email,
373
- to_email_field,
374
- to_email_fixed,
375
- },
376
- user,
377
- }) => {
378
- let to_addr;
379
- switch (to_email) {
380
- case "Fixed":
381
- to_addr = to_email_fixed;
382
- break;
383
- case "User":
384
- to_addr = user.email;
385
- break;
386
- case "Field":
387
- const fields = await table.getFields();
388
- const field = fields.find((f) => f.name === to_email_field);
389
- if (field && field.type.name === "String")
390
- to_addr = row[to_email_field];
391
- else if (field && field.reftable_name === "users") {
392
- const refuser = await User.findOne({ id: row[to_email_field] });
393
- to_addr = refuser.email;
394
- }
395
- break;
396
- }
397
- const view = await View.findOne({ name: viewname });
398
- const htmlBs = await view.run({ id: row.id }, mockReqRes);
399
- const html = await transformBootstrapEmail(htmlBs);
400
- console.log(
401
- "Sending email from %s to %s with subject %s to_email",
402
- getState().getConfig("email_from"),
403
- to_addr,
404
- subject,
405
- to_addr
406
- );
407
- const email = {
408
- from: getState().getConfig("email_from"),
409
- to: to_addr,
410
- subject,
411
- html,
412
- };
413
- //console.log(email);
414
- await getMailTransport().sendMail(email);
415
- return { notify: `E-mail sent to ${to_addr}` };
416
- },
417
- },
418
-
419
- /**
420
- * @namespace
421
- * @category saltcorn-data
422
- * @subcategory actions
423
- */
424
- insert_joined_row: {
425
- /**
426
- * @param {object} opts
427
- * @param {object} opts.table
428
- * @returns {Promise<object[]>}
429
- */
430
- configFields: async ({ table }) => {
431
- if (!table) return [];
432
- const { child_field_list } = await table.get_child_relations();
433
- return [
434
- {
435
- name: "joined_table",
436
- label: "Relation",
437
- sublabel: "Relation", // todo more detailed explanation
438
- input_type: "select",
439
- options: child_field_list,
440
- },
441
- ];
442
- },
443
- requireRow: true,
444
- /**
445
- * @param {object} opts
446
- * @param {object} opts.row
447
- * @param {object} opts.table
448
- * @param {object} opts.configuration
449
- * @param {object} opts.user
450
- * @returns {Promise<object>}
451
- */
452
- run: async ({ row, table, configuration: { joined_table }, user }) => {
453
- const [join_table_name, join_field] = joined_table.split(".");
454
- const joinTable = await Table.findOne({ name: join_table_name });
455
- const fields = await joinTable.getFields();
456
- const newRow = { [join_field]: row.id };
457
- for (const field of fields) {
458
- if (
459
- field.type === "Key" &&
460
- field.reftable_name === "users" &&
461
- user &&
462
- user.id
463
- )
464
- newRow[field.name] = user.id;
465
- }
466
- return await joinTable.insertRow(newRow);
467
- },
468
- },
469
-
470
- /**
471
- * @namespace
472
- * @category saltcorn-data
473
- * @subcategory actions
474
- */
475
- duplicate_row: {
476
- /**
477
- * @returns {Promise<object[]>}
478
- */
479
- configFields: () => [],
480
- requireRow: true,
481
- /**
482
- * @param {object} opts
483
- * @param {object} opts.row
484
- * @param {object} opts.table
485
- * @param {*} opts.user
486
- * @returns {Promise<object>}
487
- */
488
- run: async ({ row, table, user }) => {
489
- const newRow = { ...row };
490
- await table.getFields();
491
- delete newRow[table.pk_name];
492
- await table.insertRow(newRow);
493
- return { reload_page: true };
494
- },
495
- },
496
-
497
- /**
498
- * @namespace
499
- * @category saltcorn-data
500
- * @subcategory actions
501
- */
502
- recalculate_stored_fields: {
503
- /**
504
- * @param {object} opts
505
- * @param {object} opts.table
506
- * @returns {Promise<object[]>}
507
- */
508
- configFields: async ({ table }) => {
509
- const tables = await Table.find();
510
- return [
511
- {
512
- name: "table",
513
- label: "Table",
514
- sublabel: "Table on which to recalculate stored calculated fields",
515
- input_type: "select",
516
- options: tables.map((t) => t.name),
517
- },
518
- ];
519
- },
520
- /**
521
- * @param {object} opts
522
- * @param {object} opts.configuration
523
- * @returns {Promise<void>}
524
- */
525
- run: async ({ configuration: { table } }) => {
526
- const table_for_recalc = await Table.findOne({ name: table });
527
- recalculate_for_stored(table_for_recalc);
528
- },
529
- },
530
-
531
- /**
532
- * @namespace
533
- * @category saltcorn-data
534
- * @subcategory actions
535
- */
536
- insert_any_row: {
537
- /**
538
- * @param {object} opts
539
- * @param {*} opts.table
540
- * @returns {Promise<object[]>}
541
- */
542
- configFields: async ({ table }) => {
543
- const tables = await Table.find();
544
- return [
545
- {
546
- name: "table",
547
- label: "Table",
548
- sublabel: "Table to insert rows in",
549
- input_type: "select",
550
- options: tables.map((t) => t.name),
551
- },
552
- {
553
- name: "row_expr",
554
- label: "Row expression",
555
- sublabel: "Expression for JavaScript object",
556
- type: "String",
557
- fieldview: "textarea",
558
- },
559
- ];
560
- },
561
- /**
562
- * @param {object} opts
563
- * @param {object} opts.row
564
- * @param {object} opts.configuration
565
- * @param {object} opts.user
566
- * @param {...*} opts.rest
567
- * @returns {Promise<object|boolean>}
568
- */
569
- run: async ({ row, configuration: { row_expr, table }, user, ...rest }) => {
570
- const f = get_async_expression_function(row_expr, [], {
571
- row: row || {},
572
- user,
573
- console,
574
- });
575
- const calcrow = await f({});
576
- const table_for_insert = await Table.findOne({ name: table });
577
- const res = await table_for_insert.tryInsertRow(calcrow, user && user.id);
578
- if (res.error) return res;
579
- else return true;
580
- },
581
- },
582
-
583
- /**
584
- * @namespace
585
- * @category saltcorn-data
586
- * @subcategory actions
587
- */
588
- run_js_code: {
589
- /**
590
- * @param {object} opts
591
- * @param {object} opts.table
592
- * @returns {Promise<object[]>}
593
- */
594
- configFields: async ({ table }) => {
595
- const fields = table ? (await table.getFields()).map((f) => f.name) : [];
596
- const vars = [
597
- ...(table ? ["row"] : []),
598
- "user",
599
- "console",
600
- "Actions",
601
- "Table",
602
- ...(table ? ["table"] : []),
603
- ...fields,
604
- ]
605
- .map((f) => code(f))
606
- .join(", ");
607
- return [
608
- {
609
- name: "code",
610
- label: "Code",
611
- input_type: "code",
612
- attributes: { mode: "application/javascript" },
613
- sublabel: div("Variables in scope: ", vars),
614
- },
615
- {
616
- name: "run_where",
617
- label: "Run where",
618
- input_type: "select",
619
- options: ["Server", "Client page"],
620
- },
621
- ];
622
- },
623
- /**
624
- * @type {base-plugin/actions~run_code}
625
- * @see base-plugin/actions~run_code
626
- **/
627
- run: run_code,
628
- },
629
- };
@@ -1,15 +0,0 @@
1
- const { auto_test_plugin } = require("../plugin-testing");
2
- const plugin = require(".");
3
- const db = require("../db");
4
-
5
- afterAll(db.close);
6
- beforeAll(async () => {
7
- await require("../db/reset_schema")();
8
- await require("../db/fixtures")();
9
- });
10
-
11
- describe("base plugin", () => {
12
- it("passes auto test", async () => {
13
- await auto_test_plugin(plugin);
14
- });
15
- });