@saltcorn/data 0.6.1-beta.0 → 0.6.1

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 (60) hide show
  1. package/base-plugin/actions.js +172 -1
  2. package/base-plugin/fieldviews.js +63 -0
  3. package/base-plugin/fileviews.js +41 -0
  4. package/base-plugin/index.js +35 -0
  5. package/base-plugin/types.js +345 -9
  6. package/base-plugin/viewtemplates/edit.js +107 -0
  7. package/base-plugin/viewtemplates/feed.js +46 -0
  8. package/base-plugin/viewtemplates/filter.js +43 -0
  9. package/base-plugin/viewtemplates/list.js +73 -1
  10. package/base-plugin/viewtemplates/listshowlist.js +54 -3
  11. package/base-plugin/viewtemplates/room.js +100 -0
  12. package/base-plugin/viewtemplates/show.js +86 -0
  13. package/base-plugin/viewtemplates/viewable_fields.js +124 -0
  14. package/contracts.js +58 -0
  15. package/db/connect.js +13 -5
  16. package/db/db.test.js +0 -154
  17. package/db/fixtures.js +13 -1
  18. package/db/index.js +42 -3
  19. package/db/reset_schema.js +11 -0
  20. package/db/state.js +105 -36
  21. package/index.js +13 -0
  22. package/migrate.js +4 -1
  23. package/models/backup.js +78 -0
  24. package/models/config.js +113 -22
  25. package/models/crash.js +44 -0
  26. package/models/discovery.js +13 -11
  27. package/models/email.js +17 -0
  28. package/models/eventlog.js +51 -0
  29. package/models/expression.js +49 -1
  30. package/models/field.js +88 -9
  31. package/models/fieldrepeat.js +33 -0
  32. package/models/file.js +23 -4
  33. package/models/form.js +34 -0
  34. package/models/index.js +42 -0
  35. package/models/layout.js +33 -0
  36. package/models/library.js +44 -0
  37. package/models/pack.js +88 -0
  38. package/models/page.js +13 -3
  39. package/models/plugin.js +9 -2
  40. package/models/random.js +36 -0
  41. package/models/role.js +36 -0
  42. package/models/scheduler.js +28 -0
  43. package/models/table.js +34 -15
  44. package/models/table_constraints.js +44 -0
  45. package/models/tenant.js +46 -9
  46. package/models/trigger.js +24 -11
  47. package/models/user.js +33 -8
  48. package/models/view.js +89 -8
  49. package/models/workflow.js +31 -0
  50. package/package.json +7 -5
  51. package/plugin-helper.js +102 -44
  52. package/plugin-testing.js +4 -0
  53. package/tests/exact_views.test.js +5 -5
  54. package/utils.js +4 -0
  55. package/db/internal.js +0 -229
  56. package/db/multi-tenant.js +0 -24
  57. package/db/pg.js +0 -374
  58. package/db/single-tenant.js +0 -8
  59. package/db/sqlite.js +0 -280
  60. package/db/tenants.js +0 -6
package/migrate.js CHANGED
@@ -1,7 +1,10 @@
1
1
  /**
2
2
  * DB structure migration functionality
3
- * @type {module:fs}
3
+ * @category saltcorn-data
4
+ * @module migrate
4
5
  */
6
+
7
+ /** @type {module:fs} */
5
8
  const fs = require("fs");
6
9
  const path = require("path");
7
10
  const db = require("./db");
package/models/backup.js CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @category saltcorn-data
3
+ * @module models/backup
4
+ * @subcategory models
5
+ */
1
6
  const { contract, is } = require("contractis");
2
7
  const { getState } = require("../db/state");
3
8
  const db = require("../db");
@@ -30,6 +35,11 @@ const { asyncMap } = require("../utils");
30
35
  const Trigger = require("./trigger");
31
36
  const Library = require("./library");
32
37
 
38
+ /**
39
+ * @function
40
+ * @param {string} dirpath
41
+ * @returns {Promise<void>}
42
+ */
33
43
  const create_pack = contract(
34
44
  is.fun(is.str, is.promise(is.undefined)),
35
45
  async (dirpath) => {
@@ -58,6 +68,12 @@ const create_pack = contract(
58
68
  }
59
69
  );
60
70
 
71
+ /**
72
+ * @function
73
+ * @param {object[]} rows
74
+ * @param {string} fnm
75
+ * @returns {Promise<void>}
76
+ */
61
77
  const create_csv_from_rows = contract(
62
78
  is.fun([is.array(is.obj()), is.str], is.promise(is.undefined)),
63
79
  async (rows, fnm) => {
@@ -74,6 +90,12 @@ const create_csv_from_rows = contract(
74
90
  }
75
91
  );
76
92
 
93
+ /**
94
+ * @function
95
+ * @param {Table} table
96
+ * @param {string} dirpath
97
+ * @returns {Promise<void>}
98
+ */
77
99
  const create_table_json = contract(
78
100
  is.fun([is.class("Table"), is.str], is.promise(is.undefined)),
79
101
  async (table, dirpath) => {
@@ -85,6 +107,11 @@ const create_table_json = contract(
85
107
  }
86
108
  );
87
109
 
110
+ /**
111
+ * @function
112
+ * @param {string} root_dirpath
113
+ * @return {Promise<void>}
114
+ */
88
115
  const create_table_jsons = contract(
89
116
  is.fun(is.str, is.promise(is.undefined)),
90
117
  async (root_dirpath) => {
@@ -97,6 +124,11 @@ const create_table_jsons = contract(
97
124
  }
98
125
  );
99
126
 
127
+ /**
128
+ * @function
129
+ * @param {string} root_dirpath
130
+ * @returns {Promise<void>}
131
+ */
100
132
  const backup_files = contract(
101
133
  is.fun(is.str, is.promise(is.undefined)),
102
134
  async (root_dirpath) => {
@@ -113,6 +145,11 @@ const backup_files = contract(
113
145
  }
114
146
  );
115
147
 
148
+ /**
149
+ * @function
150
+ * @param {string} root_dirpath
151
+ * @returns {Promise<void>}
152
+ */
116
153
  const backup_config = contract(
117
154
  is.fun(is.str, is.promise(is.undefined)),
118
155
  async (root_dirpath) => {
@@ -129,6 +166,12 @@ const backup_config = contract(
129
166
  }
130
167
  }
131
168
  );
169
+
170
+ /**
171
+ * @function
172
+ * @param {string} [fnm]
173
+ * @returns {Promise<string>}
174
+ */
132
175
  const create_backup = contract(
133
176
  is.fun([is.maybe(is.str)], is.promise(is.str)),
134
177
  async (fnm) => {
@@ -156,6 +199,12 @@ const create_backup = contract(
156
199
  }
157
200
  );
158
201
 
202
+ /**
203
+ * @function
204
+ * @param {string} fnm
205
+ * @param {string} dir
206
+ * @returns {Promise<void>}
207
+ */
159
208
  const extract = contract(
160
209
  is.fun([is.str, is.str], is.promise(is.undefined)),
161
210
  async (fnm, dir) => {
@@ -168,6 +217,12 @@ const extract = contract(
168
217
  });
169
218
  }
170
219
  );
220
+
221
+ /**
222
+ * @function
223
+ * @param {string} dirpath
224
+ * @returns {Promise<object>}
225
+ */
171
226
  const restore_files = contract(
172
227
  is.fun(is.str, is.promise(is.obj({}))),
173
228
  async (dirpath) => {
@@ -191,6 +246,11 @@ const restore_files = contract(
191
246
  }
192
247
  );
193
248
 
249
+ /**
250
+ * @function
251
+ * @param {object} file_users
252
+ * @returns {Promise<void>}
253
+ */
194
254
  const restore_file_users = contract(
195
255
  is.fun(is.obj({}), is.promise(is.undefined)),
196
256
  async (file_users) => {
@@ -200,6 +260,12 @@ const restore_file_users = contract(
200
260
  }
201
261
  );
202
262
 
263
+ /**
264
+ * @function
265
+ * @param {string} file_users
266
+ * @param {boolean} [restore_first_user]
267
+ * @returns {Promise<string|undefined>}
268
+ */
203
269
  const restore_tables = contract(
204
270
  is.fun([is.str, is.maybe(is.bool)], is.promise(is.maybe(is.str))),
205
271
  async (dirpath, restore_first_user) => {
@@ -237,6 +303,11 @@ const restore_tables = contract(
237
303
  }
238
304
  );
239
305
 
306
+ /**
307
+ * @function
308
+ * @param {string} dirpath
309
+ * @returns {Promise<void>}
310
+ */
240
311
  const restore_config = contract(
241
312
  is.fun(is.str, is.promise(is.undefined)),
242
313
  async (dirpath) => {
@@ -250,6 +321,13 @@ const restore_config = contract(
250
321
  }
251
322
  );
252
323
 
324
+ /**
325
+ * @function
326
+ * @param {string} fnm
327
+ * @param {function} loadAndSaveNewPlugin
328
+ * @param {boolean} [restore_first_user]
329
+ * @returns {Promise<void>}
330
+ */
253
331
  const restore = contract(
254
332
  is.fun(
255
333
  [is.str, is.fun(is_plugin, is.undefined), is.maybe(is.bool)],