@saltcorn/data 1.1.0-beta.9 → 1.1.1-beta.0

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 (166) hide show
  1. package/dist/base-plugin/actions.d.ts +102 -9
  2. package/dist/base-plugin/actions.d.ts.map +1 -1
  3. package/dist/base-plugin/actions.js +183 -29
  4. package/dist/base-plugin/actions.js.map +1 -1
  5. package/dist/base-plugin/fieldviews.d.ts +0 -1
  6. package/dist/base-plugin/fieldviews.d.ts.map +1 -1
  7. package/dist/base-plugin/index.d.ts +169 -123
  8. package/dist/base-plugin/index.d.ts.map +1 -1
  9. package/dist/base-plugin/index.js +11 -1
  10. package/dist/base-plugin/index.js.map +1 -1
  11. package/dist/base-plugin/types.d.ts.map +1 -1
  12. package/dist/base-plugin/types.js +17 -9
  13. package/dist/base-plugin/types.js.map +1 -1
  14. package/dist/base-plugin/viewtemplates/edit.d.ts +7 -13
  15. package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
  16. package/dist/base-plugin/viewtemplates/edit.js +90 -12
  17. package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
  18. package/dist/base-plugin/viewtemplates/feed.d.ts +0 -8
  19. package/dist/base-plugin/viewtemplates/feed.d.ts.map +1 -1
  20. package/dist/base-plugin/viewtemplates/filter.d.ts +0 -8
  21. package/dist/base-plugin/viewtemplates/filter.d.ts.map +1 -1
  22. package/dist/base-plugin/viewtemplates/list.d.ts +0 -10
  23. package/dist/base-plugin/viewtemplates/list.d.ts.map +1 -1
  24. package/dist/base-plugin/viewtemplates/room.d.ts +0 -2
  25. package/dist/base-plugin/viewtemplates/room.d.ts.map +1 -1
  26. package/dist/base-plugin/viewtemplates/room.js +7 -2
  27. package/dist/base-plugin/viewtemplates/room.js.map +1 -1
  28. package/dist/base-plugin/viewtemplates/show.d.ts +0 -9
  29. package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -1
  30. package/dist/base-plugin/viewtemplates/show.js +2 -2
  31. package/dist/base-plugin/viewtemplates/show.js.map +1 -1
  32. package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -1
  33. package/dist/base-plugin/viewtemplates/viewable_fields.js +8 -5
  34. package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -1
  35. package/dist/base-plugin/viewtemplates/workflow-room.d.ts +59 -0
  36. package/dist/base-plugin/viewtemplates/workflow-room.d.ts.map +1 -0
  37. package/dist/base-plugin/viewtemplates/workflow-room.js +274 -0
  38. package/dist/base-plugin/viewtemplates/workflow-room.js.map +1 -0
  39. package/dist/db/index.js +1 -1
  40. package/dist/db/index.js.map +1 -1
  41. package/dist/db/state.d.ts +16 -0
  42. package/dist/db/state.d.ts.map +1 -1
  43. package/dist/db/state.js +55 -3
  44. package/dist/db/state.js.map +1 -1
  45. package/dist/diagram/cy_raster.d.ts +1 -1
  46. package/dist/diagram/cy_raster.d.ts.map +1 -1
  47. package/dist/diagram/node_extract_utils.d.ts +2 -2
  48. package/dist/diagram/node_extract_utils.d.ts.map +1 -1
  49. package/dist/diagram/nodes/node.d.ts +1 -1
  50. package/dist/diagram/nodes/node.d.ts.map +1 -1
  51. package/dist/migrations/202412051957.d.ts +3 -0
  52. package/dist/migrations/202412051957.d.ts.map +1 -0
  53. package/dist/migrations/202412051957.js +48 -0
  54. package/dist/migrations/202412051957.js.map +1 -0
  55. package/dist/migrations/202412111526.d.ts +3 -0
  56. package/dist/migrations/202412111526.d.ts.map +1 -0
  57. package/dist/migrations/202412111526.js +38 -0
  58. package/dist/migrations/202412111526.js.map +1 -0
  59. package/dist/models/config.d.ts +2 -4
  60. package/dist/models/config.d.ts.map +1 -1
  61. package/dist/models/config.js +44 -34
  62. package/dist/models/config.js.map +1 -1
  63. package/dist/models/crash.d.ts +1 -1
  64. package/dist/models/crash.d.ts.map +1 -1
  65. package/dist/models/email.d.ts +1 -1
  66. package/dist/models/eventlog.d.ts +1 -1
  67. package/dist/models/eventlog.d.ts.map +1 -1
  68. package/dist/models/expression.d.ts.map +1 -1
  69. package/dist/models/expression.js +16 -2
  70. package/dist/models/expression.js.map +1 -1
  71. package/dist/models/field.d.ts.map +1 -1
  72. package/dist/models/field.js +22 -4
  73. package/dist/models/field.js.map +1 -1
  74. package/dist/models/fieldrepeat.d.ts +1 -1
  75. package/dist/models/fieldrepeat.d.ts.map +1 -1
  76. package/dist/models/file.d.ts +7 -3
  77. package/dist/models/file.d.ts.map +1 -1
  78. package/dist/models/file.js +3 -3
  79. package/dist/models/file.js.map +1 -1
  80. package/dist/models/form.d.ts +1 -1
  81. package/dist/models/form.d.ts.map +1 -1
  82. package/dist/models/form.js +5 -1
  83. package/dist/models/form.js.map +1 -1
  84. package/dist/models/index.d.ts +2 -2
  85. package/dist/models/index.d.ts.map +1 -1
  86. package/dist/models/index.js +1 -1
  87. package/dist/models/index.js.map +1 -1
  88. package/dist/models/layout.d.ts +1 -1
  89. package/dist/models/layout.d.ts.map +1 -1
  90. package/dist/models/model_instance.d.ts +1 -0
  91. package/dist/models/model_instance.d.ts.map +1 -1
  92. package/dist/models/notification.d.ts +1 -1
  93. package/dist/models/notification.d.ts.map +1 -1
  94. package/dist/models/page.d.ts.map +1 -1
  95. package/dist/models/page.js +3 -1
  96. package/dist/models/page.js.map +1 -1
  97. package/dist/models/page_group.d.ts +1 -1
  98. package/dist/models/page_group.d.ts.map +1 -1
  99. package/dist/models/page_group.js +7 -1
  100. package/dist/models/page_group.js.map +1 -1
  101. package/dist/models/page_group_member.d.ts +1 -1
  102. package/dist/models/page_group_member.d.ts.map +1 -1
  103. package/dist/models/plugin.d.ts.map +1 -1
  104. package/dist/models/plugin.js +5 -3
  105. package/dist/models/plugin.js.map +1 -1
  106. package/dist/models/scheduler.d.ts.map +1 -1
  107. package/dist/models/scheduler.js +4 -0
  108. package/dist/models/scheduler.js.map +1 -1
  109. package/dist/models/table.d.ts +4 -3
  110. package/dist/models/table.d.ts.map +1 -1
  111. package/dist/models/table.js +34 -3
  112. package/dist/models/table.js.map +1 -1
  113. package/dist/models/table_constraints.d.ts +2 -2
  114. package/dist/models/table_constraints.d.ts.map +1 -1
  115. package/dist/models/tag.d.ts +1 -1
  116. package/dist/models/tag.d.ts.map +1 -1
  117. package/dist/models/tag_entry.d.ts +1 -1
  118. package/dist/models/tag_entry.d.ts.map +1 -1
  119. package/dist/models/trigger.d.ts +5 -1
  120. package/dist/models/trigger.d.ts.map +1 -1
  121. package/dist/models/trigger.js +38 -7
  122. package/dist/models/trigger.js.map +1 -1
  123. package/dist/models/user.d.ts +1 -1
  124. package/dist/models/user.d.ts.map +1 -1
  125. package/dist/models/view.d.ts +1 -1
  126. package/dist/models/view.d.ts.map +1 -1
  127. package/dist/models/view.js +3 -3
  128. package/dist/models/workflow.d.ts +1 -1
  129. package/dist/models/workflow.d.ts.map +1 -1
  130. package/dist/models/workflow_run.d.ts +79 -0
  131. package/dist/models/workflow_run.d.ts.map +1 -0
  132. package/dist/models/workflow_run.js +477 -0
  133. package/dist/models/workflow_run.js.map +1 -0
  134. package/dist/models/workflow_step.d.ts +58 -0
  135. package/dist/models/workflow_step.d.ts.map +1 -0
  136. package/dist/models/workflow_step.js +144 -0
  137. package/dist/models/workflow_step.js.map +1 -0
  138. package/dist/models/workflow_trace.d.ts +57 -0
  139. package/dist/models/workflow_trace.d.ts.map +1 -0
  140. package/dist/models/workflow_trace.js +90 -0
  141. package/dist/models/workflow_trace.js.map +1 -0
  142. package/dist/plugin-helper.d.ts +1 -0
  143. package/dist/plugin-helper.d.ts.map +1 -1
  144. package/dist/plugin-helper.js +8 -9
  145. package/dist/plugin-helper.js.map +1 -1
  146. package/dist/tests/actions.test.js.map +1 -1
  147. package/dist/tests/auxtest.test.js +6 -3
  148. package/dist/tests/auxtest.test.js.map +1 -1
  149. package/dist/tests/config.test.js +2 -2
  150. package/dist/tests/config.test.js.map +1 -1
  151. package/dist/tests/field.test.js +47 -0
  152. package/dist/tests/field.test.js.map +1 -1
  153. package/dist/tests/mocks.d.ts +1 -1
  154. package/dist/tests/mocks.js +1 -1
  155. package/dist/tests/mocks.js.map +1 -1
  156. package/dist/tests/workflow.test.js +9 -0
  157. package/dist/tests/workflow.test.js.map +1 -1
  158. package/dist/tests/workflow_run.test.d.ts +2 -0
  159. package/dist/tests/workflow_run.test.d.ts.map +1 -0
  160. package/dist/tests/workflow_run.test.js +109 -0
  161. package/dist/tests/workflow_run.test.js.map +1 -0
  162. package/dist/utils.d.ts +9 -1
  163. package/dist/utils.d.ts.map +1 -1
  164. package/dist/utils.js +32 -6
  165. package/dist/utils.js.map +1 -1
  166. package/package.json +12 -9
@@ -22,6 +22,7 @@ declare function run_code({ row, table, channel, configuration: { code, run_wher
22
22
  export namespace blocks {
23
23
  export const disableInBuilder: boolean;
24
24
  export const disableInList: boolean;
25
+ export const disableInWorkflow: boolean;
25
26
  export const description: string;
26
27
  export const configFields: {
27
28
  name: string;
@@ -73,8 +74,9 @@ export namespace emit_event {
73
74
  export namespace webhook {
74
75
  const description_2: string;
75
76
  export { description_2 as description };
76
- export function configFields_2({ table }: {
77
+ export function configFields_2({ table, mode }: {
77
78
  table: any;
79
+ mode: any;
78
80
  }): Promise<({
79
81
  name: string;
80
82
  label: string;
@@ -119,7 +121,7 @@ export namespace webhook {
119
121
  showIf?: undefined;
120
122
  })[]>;
121
123
  export { configFields_2 as configFields };
122
- export function run_1({ row, user, table, configuration: { url, body, authorization, response_field, method }, }: {
124
+ export function run_1({ row, user, table, configuration: { url, body, authorization, response_field, response_var, method, }, }: {
123
125
  url: string;
124
126
  body: object;
125
127
  }): Promise<object>;
@@ -149,9 +151,31 @@ export namespace find_or_create_dm_room {
149
151
  export namespace send_email {
150
152
  const description_4: string;
151
153
  export { description_4 as description };
152
- export function configFields_4({ table }: {
154
+ export function configFields_4({ table, mode }: {
153
155
  table: any;
156
+ mode: any;
154
157
  }): Promise<({
158
+ name: string;
159
+ label: string;
160
+ sublabel: string;
161
+ type: string;
162
+ required?: undefined;
163
+ fieldview?: undefined;
164
+ } | {
165
+ name: string;
166
+ label: string;
167
+ sublabel: string;
168
+ type: string;
169
+ required: boolean;
170
+ fieldview?: undefined;
171
+ } | {
172
+ name: string;
173
+ label: string;
174
+ type: string;
175
+ fieldview: string;
176
+ required: boolean;
177
+ sublabel?: undefined;
178
+ })[] | ({
155
179
  name: string;
156
180
  label: string;
157
181
  type: string;
@@ -316,7 +340,7 @@ export namespace send_email {
316
340
  })[]>;
317
341
  export { configFields_4 as configFields };
318
342
  export const requireRow: boolean;
319
- export function run_3({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, cc_email, only_if, attachment_path, disable_notify, confirm_field, }, user, }: {
343
+ export function run_3({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, cc_email, only_if, attachment_path, disable_notify, confirm_field, body, }, user, mode, }: {
320
344
  row: object;
321
345
  table: object;
322
346
  configuration: object;
@@ -339,6 +363,8 @@ export namespace insert_joined_row {
339
363
  options: any;
340
364
  }[]>;
341
365
  export { configFields_5 as configFields };
366
+ const disableInWorkflow_1: boolean;
367
+ export { disableInWorkflow_1 as disableInWorkflow };
342
368
  const requireRow_1: boolean;
343
369
  export { requireRow_1 as requireRow };
344
370
  export function run_4({ row, table, configuration: { joined_table }, user }: {
@@ -356,6 +382,8 @@ export namespace duplicate_row {
356
382
  export { description_6 as description };
357
383
  export function configFields_6(): never[];
358
384
  export { configFields_6 as configFields };
385
+ const disableInWorkflow_2: boolean;
386
+ export { disableInWorkflow_2 as disableInWorkflow };
359
387
  const requireRow_2: boolean;
360
388
  export { requireRow_2 as requireRow };
361
389
  export function run_5({ row, table, user }: {
@@ -415,8 +443,8 @@ export namespace recalculate_stored_fields {
415
443
  export namespace insert_any_row {
416
444
  const description_8: string;
417
445
  export { description_8 as description };
418
- export function configFields_8({ table }: {
419
- table: any;
446
+ export function configFields_8({ mode }: {
447
+ mode: any;
420
448
  }): Promise<({
421
449
  name: string;
422
450
  label: string;
@@ -433,6 +461,14 @@ export namespace insert_any_row {
433
461
  fieldview: string;
434
462
  input_type?: undefined;
435
463
  options?: undefined;
464
+ } | {
465
+ name: string;
466
+ label: string;
467
+ sublabel: string;
468
+ type: string;
469
+ input_type?: undefined;
470
+ options?: undefined;
471
+ fieldview?: undefined;
436
472
  })[]>;
437
473
  export { configFields_8 as configFields };
438
474
  export function run_7({ row, table, configuration, user, referrer, ...rest }: {
@@ -460,9 +496,24 @@ export namespace modify_row {
460
496
  attributes: {
461
497
  mode: string;
462
498
  options?: undefined;
499
+ showIf?: undefined;
463
500
  };
464
501
  type?: undefined;
465
502
  required?: undefined;
503
+ showIf?: undefined;
504
+ } | {
505
+ name: string;
506
+ label: string;
507
+ type: string;
508
+ required: boolean;
509
+ attributes: {
510
+ options: string[];
511
+ mode?: undefined;
512
+ showIf?: undefined;
513
+ };
514
+ sublabel?: undefined;
515
+ input_type?: undefined;
516
+ showIf?: undefined;
466
517
  } | {
467
518
  name: string;
468
519
  label: string;
@@ -470,21 +521,38 @@ export namespace modify_row {
470
521
  required: boolean;
471
522
  attributes: {
472
523
  options: string[];
524
+ showIf: {
525
+ where: string;
526
+ };
473
527
  mode?: undefined;
474
528
  };
475
529
  sublabel?: undefined;
476
530
  input_type?: undefined;
531
+ showIf?: undefined;
532
+ } | {
533
+ name: string;
534
+ label: string;
535
+ type: string;
536
+ required: boolean;
537
+ showIf: {
538
+ where: string;
539
+ };
540
+ sublabel?: undefined;
541
+ input_type?: undefined;
542
+ attributes?: undefined;
477
543
  })[]>;
478
544
  export { configFields_9 as configFields };
479
545
  const requireRow_3: boolean;
480
546
  export { requireRow_3 as requireRow };
481
- export function run_8({ row, table, configuration: { row_expr, where }, user, ...rest }: {
547
+ export function run_8({ row, table, configuration: { row_expr, where, select_table, query }, user, ...rest }: {
482
548
  [x: string]: any;
483
549
  row: any;
484
550
  table: any;
485
551
  configuration: {
486
552
  row_expr: any;
487
553
  where: any;
554
+ select_table: any;
555
+ query: any;
488
556
  };
489
557
  user: any;
490
558
  }): Promise<any>;
@@ -608,6 +676,8 @@ export namespace navigate {
608
676
  export namespace step_control_flow {
609
677
  const description_12: string;
610
678
  export { description_12 as description };
679
+ const disableInWorkflow_3: boolean;
680
+ export { disableInWorkflow_3 as disableInWorkflow };
611
681
  const configFields_12: ({
612
682
  name: string;
613
683
  label: string;
@@ -745,6 +815,7 @@ export namespace run_js_code {
745
815
  input_type: string;
746
816
  attributes: {
747
817
  mode: string;
818
+ secondColHoriz?: undefined;
748
819
  };
749
820
  class: string;
750
821
  validator(s: any): any;
@@ -762,8 +833,11 @@ export namespace run_js_code {
762
833
  showIf: {
763
834
  run_where: string;
764
835
  };
836
+ attributes: {
837
+ secondColHoriz: boolean;
838
+ mode?: undefined;
839
+ };
765
840
  name?: undefined;
766
- attributes?: undefined;
767
841
  class?: undefined;
768
842
  options?: undefined;
769
843
  } | {
@@ -785,9 +859,26 @@ export namespace run_js_code {
785
859
  export namespace run_js_code_in_field {
786
860
  const description_16: string;
787
861
  export { description_16 as description };
788
- export function configFields_16({ table }: {
862
+ export function configFields_16({ table, mode }: {
789
863
  table: any;
864
+ mode: any;
790
865
  }): Promise<({
866
+ name: string;
867
+ label: string;
868
+ sublabel: string;
869
+ type: string;
870
+ required: boolean;
871
+ input_type?: undefined;
872
+ options?: undefined;
873
+ } | {
874
+ name: string;
875
+ label: string;
876
+ input_type: string;
877
+ options: string[];
878
+ sublabel?: undefined;
879
+ type?: undefined;
880
+ required?: undefined;
881
+ })[] | ({
791
882
  name: string;
792
883
  label: string;
793
884
  sublabel: string;
@@ -821,6 +912,8 @@ export namespace duplicate_row_prefill_edit {
821
912
  table: any;
822
913
  }): Promise<any[]>;
823
914
  export { configFields_17 as configFields };
915
+ const disableInWorkflow_4: boolean;
916
+ export { disableInWorkflow_4 as disableInWorkflow };
824
917
  const requireRow_6: boolean;
825
918
  export { requireRow_6 as requireRow };
826
919
  export function run_15({ row, table, configuration: { viewname, ...flds }, user }: {
@@ -1 +1 @@
1
- {"version":3,"file":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;;;;OAMJ;;;;;;;;IAKa;;;;;;;;;;SAsBb;;IAQI;;;;sBA8BJ;;;;;;;;IAOa;;;;;;;;;;;;;;;;;;;;UA2Cb;;IACI;;;;;;;;sBAeJ;;;;;;;;IAMa,2CAAQ;;IACjB;;;;;;;;OAKJ"}
@@ -20,7 +20,7 @@ const { get_async_expression_function, recalculate_for_stored, eval_expression,
20
20
  const { div, code, a, span } = require("@saltcorn/markup/tags");
21
21
  const { sleep, getSessionId, urlStringToObject, dollarizeObject, objectToQueryString, interpolate, } = require("../utils");
22
22
  const db = require("../db");
23
- const { isNode, isWeb, ppVal } = require("../utils");
23
+ const { isNode, isWeb, ppVal, getFetchProxyOptions } = require("../utils");
24
24
  const { available_languages } = require("../models/config");
25
25
  //action use cases: field modify, like/rate (insert join), notify, send row to webhook
26
26
  // todo add translation
@@ -143,6 +143,7 @@ module.exports = {
143
143
  blocks: {
144
144
  disableInBuilder: true,
145
145
  disableInList: true,
146
+ disableInWorkflow: true,
146
147
  description: "Build action with drag and drop steps similar to Scratch",
147
148
  configFields: [
148
149
  {
@@ -212,7 +213,7 @@ module.exports = {
212
213
  */
213
214
  webhook: {
214
215
  description: "Make an outbound HTTP POST request",
215
- configFields: async ({ table }) => {
216
+ configFields: async ({ table, mode }) => {
216
217
  let field_opts = [];
217
218
  if (table) {
218
219
  field_opts = table.fields
@@ -257,6 +258,16 @@ module.exports = {
257
258
  },
258
259
  ]
259
260
  : []),
261
+ ...(mode === "workflow"
262
+ ? [
263
+ {
264
+ name: "response_var",
265
+ label: "Response variable",
266
+ sublabel: "Variable in the context to fill with the response",
267
+ type: "String",
268
+ },
269
+ ]
270
+ : []),
260
271
  ];
261
272
  },
262
273
  /**
@@ -265,11 +276,12 @@ module.exports = {
265
276
  * @param {object} opts.body
266
277
  * @returns {Promise<object>}
267
278
  */
268
- run: async ({ row, user, table, configuration: { url, body, authorization, response_field, method }, }) => {
279
+ run: async ({ row, user, table, configuration: { url, body, authorization, response_field, response_var, method, }, }) => {
269
280
  let url1 = interpolate(url, row, user);
270
281
  const fetchOpts = {
271
282
  method: (method || "post").toLowerCase(),
272
283
  headers: { "Content-Type": "application/json" },
284
+ ...getFetchProxyOptions(),
273
285
  };
274
286
  if (method !== "GET") {
275
287
  let postBody;
@@ -289,10 +301,16 @@ module.exports = {
289
301
  if (authorization)
290
302
  fetchOpts.headers.Authorization = interpolate(authorization, row, user);
291
303
  const response = await fetch(url1, fetchOpts);
292
- if (table && row && response_field) {
304
+ const contentType = response.headers.get("content-type");
305
+ const isJSON = contentType && contentType.indexOf("application/json") !== -1;
306
+ if (response_var) {
307
+ const parsedResponse = isJSON
308
+ ? await response.json()
309
+ : await response.text();
310
+ return { [response_var]: parsedResponse };
311
+ }
312
+ else if (table && row && response_field) {
293
313
  const field = table.getField(response_field);
294
- const contentType = response.headers.get("content-type");
295
- const isJSON = contentType && contentType.indexOf("application/json") !== -1;
296
314
  const parsedResponse = isJSON
297
315
  ? await response.json()
298
316
  : await response.text();
@@ -381,7 +399,50 @@ module.exports = {
381
399
  * @returns {Promise<object[]>}
382
400
  */
383
401
  description: "Send an email, based on a chosen view for this table",
384
- configFields: async ({ table }) => {
402
+ configFields: async ({ table, mode }) => {
403
+ if (mode === "workflow") {
404
+ return [
405
+ {
406
+ name: "to_email",
407
+ label: "To",
408
+ sublabel: "To addresses, comma separated, <code>{{ }}</code> interpolations usable",
409
+ type: "String",
410
+ },
411
+ {
412
+ name: "cc_email",
413
+ label: "cc",
414
+ sublabel: "cc addresses, comma separated, <code>{{ }}</code> interpolations usable",
415
+ type: "String",
416
+ },
417
+ {
418
+ name: "subject",
419
+ label: "Subject",
420
+ sublabel: "Subject of email, <code>{{ }}</code> interpolations usable",
421
+ type: "String",
422
+ required: true,
423
+ },
424
+ {
425
+ name: "body",
426
+ label: "Body",
427
+ type: "String",
428
+ fieldview: "textarea",
429
+ required: true,
430
+ },
431
+ /* {
432
+ name: "attachment_paths",
433
+ label: "Attachments",
434
+ sublabel:
435
+ "Comma-separated list of files to attach. <code>{{ }}</code> interpolations usable",
436
+ type: "String",
437
+ },*/
438
+ {
439
+ name: "confirm_field",
440
+ label: "Send confirmation variable",
441
+ type: "String",
442
+ sublabel: "Bool variable set in context indicate successful sending of email message",
443
+ },
444
+ ];
445
+ }
385
446
  if (!table)
386
447
  return [];
387
448
  const views = await View.find_table_views_where(table, ({ viewtemplate }) => viewtemplate?.runMany || viewtemplate?.renderRows);
@@ -512,7 +573,24 @@ module.exports = {
512
573
  * @param {object} opts.user
513
574
  * @returns {Promise<object>}
514
575
  */
515
- run: async ({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, cc_email, only_if, attachment_path, disable_notify, confirm_field, }, user, }) => {
576
+ run: async ({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, cc_email, only_if, attachment_path, disable_notify, confirm_field, body, }, user, mode, }) => {
577
+ const from = getState().getConfig("email_from");
578
+ if (mode === "workflow") {
579
+ const email = {
580
+ from,
581
+ to: interpolate(to_email, row, user),
582
+ cc: interpolate(cc_email, row, user),
583
+ subject: interpolate(subject, row, user),
584
+ html: interpolate(body, row, user),
585
+ // attachments,
586
+ };
587
+ const sendres = await getMailTransport().sendMail(email);
588
+ getState().log(5, `send_email result: ${JSON.stringify(sendres)}`);
589
+ if (confirm_field)
590
+ return { [confirm_field]: sendres.accepted.length > 0 };
591
+ else
592
+ return;
593
+ }
516
594
  let to_addr;
517
595
  let useRow = row;
518
596
  const fvs = [
@@ -574,7 +652,6 @@ module.exports = {
574
652
  const view = await View.findOne({ name: viewname });
575
653
  setBody.html = await viewToEmailHtml(view, { id: row[table.pk_name] });
576
654
  }
577
- const from = getState().getConfig("email_from");
578
655
  const attachments = await loadAttachments(attachment_path, row, user ? user : { role_id: 100 });
579
656
  const the_subject = subject_formula
580
657
  ? eval_expression(subject, useRow, user, "send_email subject formula")
@@ -641,6 +718,7 @@ module.exports = {
641
718
  },
642
719
  ];
643
720
  },
721
+ disableInWorkflow: true,
644
722
  requireRow: true,
645
723
  /**
646
724
  * @param {object} opts
@@ -681,6 +759,7 @@ module.exports = {
681
759
  */
682
760
  description: "Duplicate the current row",
683
761
  configFields: () => [],
762
+ disableInWorkflow: true,
684
763
  requireRow: true,
685
764
  /**
686
765
  * @param {object} opts
@@ -773,7 +852,7 @@ module.exports = {
773
852
  * @returns {Promise<object[]>}
774
853
  */
775
854
  description: "insert a row into any table, using a formula expression",
776
- configFields: async ({ table }) => {
855
+ configFields: async ({ mode }) => {
777
856
  const tables = await Table.find({}, { cached: true });
778
857
  return [
779
858
  {
@@ -790,6 +869,16 @@ module.exports = {
790
869
  type: "String",
791
870
  fieldview: "textarea",
792
871
  },
872
+ ...(mode === "workflow"
873
+ ? [
874
+ {
875
+ name: "id_variable",
876
+ label: "ID variable",
877
+ sublabel: "Variable in the context to fill with the created ID value",
878
+ type: "String",
879
+ },
880
+ ]
881
+ : []),
793
882
  ];
794
883
  },
795
884
  /**
@@ -803,7 +892,7 @@ module.exports = {
803
892
  */
804
893
  run: async ({ row, table, configuration, user, referrer, ...rest }) => {
805
894
  const state = urlStringToObject(referrer);
806
- const f = get_async_expression_function(configuration.row_expr, table?.fields || [], {
895
+ const f = get_async_expression_function(configuration.row_expr, table?.fields || Object.keys(row).map((k) => ({ name: k })), {
807
896
  user,
808
897
  console,
809
898
  session_id: rest.req && getSessionId(rest.req),
@@ -814,6 +903,8 @@ module.exports = {
814
903
  const res = await table_for_insert.tryInsertRow(calcrow, user);
815
904
  if (res.error)
816
905
  return res;
906
+ else if (configuration.id_variable)
907
+ return { [configuration.id_variable]: res.success };
817
908
  else
818
909
  return true;
819
910
  },
@@ -825,11 +916,6 @@ module.exports = {
825
916
  * @subcategory actions
826
917
  */
827
918
  modify_row: {
828
- /**
829
- * @param {object} opts
830
- * @param {*} opts.table
831
- * @returns {Promise<object[]>}
832
- */
833
919
  description: "Modify the triggering row",
834
920
  configFields: async ({ mode, when_trigger }) => {
835
921
  return [
@@ -840,7 +926,10 @@ module.exports = {
840
926
  input_type: "code",
841
927
  attributes: { mode: "application/javascript" },
842
928
  },
843
- ...(mode === "edit" || mode === "filter" || when_trigger === "Validate"
929
+ ...(mode === "edit" ||
930
+ mode === "filter" ||
931
+ when_trigger === "Validate" ||
932
+ mode === "workflow"
844
933
  ? [
845
934
  {
846
935
  name: "where",
@@ -852,22 +941,59 @@ module.exports = {
852
941
  ? ["Row"]
853
942
  : mode === "filter"
854
943
  ? ["Filter state"]
855
- : ["Form", "Database"],
944
+ : mode === "workflow"
945
+ ? ["Database", "Active edit view"]
946
+ : ["Form", "Database"],
856
947
  },
857
948
  },
858
949
  ]
859
950
  : []),
951
+ ...(mode === "workflow"
952
+ ? [
953
+ {
954
+ name: "select_table",
955
+ label: "Table",
956
+ type: "String",
957
+ required: true,
958
+ attributes: {
959
+ options: (await Table.find()).map((t) => t.name),
960
+ showIf: { where: "Database" },
961
+ },
962
+ },
963
+ {
964
+ name: "query",
965
+ label: "Query object",
966
+ type: "String",
967
+ required: true,
968
+ showIf: { where: "Database" },
969
+ },
970
+ ]
971
+ : []),
860
972
  ];
861
973
  },
862
974
  requireRow: true,
863
- run: async ({ row, table, configuration: { row_expr, where }, user, ...rest }) => {
864
- const f = get_async_expression_function(row_expr, table.fields, {
975
+ run: async ({ row, table, configuration: { row_expr, where, select_table, query }, user, ...rest }) => {
976
+ const f = get_async_expression_function(row_expr, table?.fields || Object.keys(row).map((k) => ({ name: k })), {
865
977
  row: row || {},
866
978
  user,
867
979
  });
868
980
  const calcrow = await f(row, user);
869
- if (where === "Form" || where === "Filter state" || where === "Row")
981
+ if (where === "Form" ||
982
+ where === "Filter state" ||
983
+ where === "Row" ||
984
+ where === "Active edit view")
870
985
  return { set_fields: calcrow };
986
+ if (select_table && query) {
987
+ //get table
988
+ const table = Table.findOne(select_table);
989
+ // evaluate query
990
+ const q = eval_expression(query, row, user, "Query expression in modify_row step");
991
+ const rows = await table.getRows(q);
992
+ for (const row of rows) {
993
+ await table.updateRow(calcrow, row[table.pk_name]);
994
+ }
995
+ return;
996
+ }
871
997
  const res = await table.tryUpdateRow(calcrow, row[table.pk_name], user);
872
998
  if (res.error)
873
999
  return res;
@@ -886,11 +1012,15 @@ module.exports = {
886
1012
  configFields: async ({ mode, when_trigger }) => {
887
1013
  const tables = await Table.find({}, { cached: true });
888
1014
  return [
889
- {
890
- name: "delete_triggering_row",
891
- label: "Delete triggering row",
892
- type: "Bool",
893
- },
1015
+ ...(mode === "workflow"
1016
+ ? []
1017
+ : [
1018
+ {
1019
+ name: "delete_triggering_row",
1020
+ label: "Delete triggering row",
1021
+ type: "Bool",
1022
+ },
1023
+ ]),
894
1024
  {
895
1025
  name: "table_name",
896
1026
  label: "Table",
@@ -969,7 +1099,11 @@ module.exports = {
969
1099
  case "Popup modal":
970
1100
  return { popup: url1 };
971
1101
  case "Back":
972
- return { eval_js: isWeb(req) ? "history.back()" : "parent.goBack()" };
1102
+ return {
1103
+ eval_js: isWeb(req)
1104
+ ? "history.back()"
1105
+ : "parent.saltcorn.mobileApp.navigation.goBack()",
1106
+ };
973
1107
  case "Close tab":
974
1108
  return { eval_js: "window.close()" };
975
1109
  case "Close modal":
@@ -989,6 +1123,7 @@ module.exports = {
989
1123
  * @returns {Promise<object[]>}
990
1124
  */
991
1125
  description: "Step control flow",
1126
+ disableInWorkflow: true,
992
1127
  configFields: [
993
1128
  {
994
1129
  name: "control_action",
@@ -1179,6 +1314,7 @@ module.exports = {
1179
1314
  topic: "JavaScript action code",
1180
1315
  },
1181
1316
  showIf: { run_where: "Server" },
1317
+ attributes: { secondColHoriz: true },
1182
1318
  },
1183
1319
  {
1184
1320
  input_type: "section_header",
@@ -1188,6 +1324,7 @@ module.exports = {
1188
1324
  topic: "JavaScript action code",
1189
1325
  },
1190
1326
  showIf: { run_where: "Client page" },
1327
+ attributes: { secondColHoriz: true },
1191
1328
  },
1192
1329
  {
1193
1330
  name: "run_where",
@@ -1211,7 +1348,23 @@ module.exports = {
1211
1348
  * @returns {Promise<object[]>}
1212
1349
  */
1213
1350
  description: "Run arbitrary JavaScript code from a String field",
1214
- configFields: async ({ table }) => {
1351
+ configFields: async ({ table, mode }) => {
1352
+ if (mode === "workflow")
1353
+ return [
1354
+ {
1355
+ name: "code_field",
1356
+ label: "Code field",
1357
+ sublabel: "String variable in context contains the JavaScript code to run",
1358
+ type: "String",
1359
+ required: true,
1360
+ },
1361
+ {
1362
+ name: "run_where",
1363
+ label: "Run where",
1364
+ input_type: "select",
1365
+ options: ["Server", "Client page"],
1366
+ },
1367
+ ];
1215
1368
  const field_opts = table.fields
1216
1369
  .filter((f) => f.type?.name === "String")
1217
1370
  .map((f) => f.name);
@@ -1249,7 +1402,7 @@ module.exports = {
1249
1402
  * @type {base-plugin/actions~run_code}
1250
1403
  * @see base-plugin/actions~run_code
1251
1404
  **/
1252
- run: async ({ table, configuration: { code_field, run_where }, row, ...rest }) => {
1405
+ run: async ({ table, configuration: { code_field, run_where }, row, mode, ...rest }) => {
1253
1406
  let code;
1254
1407
  if (code_field.includes(".")) {
1255
1408
  const [ref, target] = code_field.split(".");
@@ -1296,6 +1449,7 @@ module.exports = {
1296
1449
  ...fldOpts,
1297
1450
  ];
1298
1451
  },
1452
+ disableInWorkflow: true,
1299
1453
  requireRow: true,
1300
1454
  run: async ({ row, table, configuration: { viewname, ...flds }, user }) => {
1301
1455
  const qs = Object.entries(flds)