@saltcorn/server 0.9.1-beta.1 → 0.9.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/help/API actions.tmd +20 -1
- package/package.json +13 -13
- package/public/saltcorn-common.js +31 -1
- package/routes/api.js +10 -2
- package/s3storage.js +6 -5
package/help/API actions.tmd
CHANGED
|
@@ -9,4 +9,23 @@ If you make a GET request, the query string values
|
|
|
9
9
|
are accessible as a JSON object using the `row` variable (e.g. in a `run_js_code`).
|
|
10
10
|
|
|
11
11
|
If you return a value from the action, it will be available in the `data`
|
|
12
|
-
subfield of the JSON body in the HTTP response
|
|
12
|
+
subfield of the JSON body in the HTTP response
|
|
13
|
+
|
|
14
|
+
### Redirection as response
|
|
15
|
+
|
|
16
|
+
Normally API call will return a JSON object with a true/false success field
|
|
17
|
+
and the response from the action, if any, in the data field. You may instead
|
|
18
|
+
require the API call to redirect to a different URL. You can do this in two
|
|
19
|
+
different ways.
|
|
20
|
+
|
|
21
|
+
**Static redirect**: if you set the `scgotourl` HTTP header, the response will
|
|
22
|
+
redirect to this URL.
|
|
23
|
+
|
|
24
|
+
**Dynamic redirect**: The redirect URL can also come from the action. If this
|
|
25
|
+
returns an object with the `goto` field (e.g.
|
|
26
|
+
`return {goto: "https://myapp.com/view/ShowTheThing?id"+newid}`)
|
|
27
|
+
that is normally returned in the JSON post body so it can be processed by client code.
|
|
28
|
+
You can instead request that this is processed server-side, by (a) setting a
|
|
29
|
+
`_process_result` field to true in the row data, i.e. JSON body in POST and query
|
|
30
|
+
string in GET or (b) setting the `scprocessresults` HTTP header. This will cause the
|
|
31
|
+
API call to return an HTTP redirect with the `goto` value.
|
package/package.json
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.9.1-beta.
|
|
3
|
+
"version": "0.9.1-beta.3",
|
|
4
4
|
"description": "Server app for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@
|
|
10
|
-
"@saltcorn/
|
|
11
|
-
"@saltcorn/
|
|
12
|
-
"@saltcorn/
|
|
13
|
-
"@saltcorn/
|
|
14
|
-
"@saltcorn/
|
|
15
|
-
"@saltcorn/
|
|
9
|
+
"@aws-sdk/client-s3": "^3.451.0",
|
|
10
|
+
"@saltcorn/base-plugin": "0.9.1-beta.3",
|
|
11
|
+
"@saltcorn/builder": "0.9.1-beta.3",
|
|
12
|
+
"@saltcorn/data": "0.9.1-beta.3",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.1-beta.3",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.1-beta.3",
|
|
15
|
+
"@saltcorn/markup": "0.9.1-beta.3",
|
|
16
|
+
"@saltcorn/sbadmin2": "0.9.1-beta.3",
|
|
16
17
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
17
18
|
"@socket.io/sticky": "^1.0.1",
|
|
18
19
|
"adm-zip": "0.5.10",
|
|
19
|
-
"aws-sdk": "^2.1386.0",
|
|
20
20
|
"connect-flash": "^0.1.1",
|
|
21
21
|
"connect-pg-simple": "^6.1.0",
|
|
22
22
|
"content-disposition": "^0.5.3",
|
|
23
23
|
"contractis": "^0.1.0",
|
|
24
24
|
"cookie-parser": "^1.4.4",
|
|
25
25
|
"cookie-session": "^1.4.0",
|
|
26
|
+
"cors": "2.8.5",
|
|
26
27
|
"csurf": "^1.11.0",
|
|
27
28
|
"csv-stringify": "^5.5.0",
|
|
28
29
|
"express": "^4.17.1",
|
|
@@ -32,7 +33,6 @@
|
|
|
32
33
|
"express-session": "^1.17.1",
|
|
33
34
|
"greenlock": "^4.0.4",
|
|
34
35
|
"greenlock-express": "^4.0.3",
|
|
35
|
-
"underscore": "1.13.6",
|
|
36
36
|
"helmet": "^3.23.3",
|
|
37
37
|
"i18n": "^0.15.1",
|
|
38
38
|
"imapflow": "1.0.123",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"markdown-it": "^13.0.2",
|
|
42
42
|
"moment": "^2.29.4",
|
|
43
43
|
"multer": "1.4.5-lts.1",
|
|
44
|
-
"multer-s3": "^
|
|
44
|
+
"multer-s3": "^3.0.1",
|
|
45
45
|
"node-fetch": "2.6.9",
|
|
46
46
|
"node-watch": "^0.7.2",
|
|
47
47
|
"notp": "2.0.3",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
"systeminformation": "^5.21.7",
|
|
60
60
|
"thirty-two": "1.0.2",
|
|
61
61
|
"tmp-promise": "^3.0.2",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
62
|
+
"underscore": "1.13.6",
|
|
63
|
+
"uuid": "^8.2.0"
|
|
64
64
|
},
|
|
65
65
|
"optionalDependencies": {
|
|
66
66
|
"connect-sqlite3": "^0.9.11",
|
|
@@ -381,6 +381,17 @@ function get_form_record(e_in, select_labels) {
|
|
|
381
381
|
? $(`form[data-viewname=${e_in.viewname}]`)
|
|
382
382
|
: e_in.closest(".form-namespace");
|
|
383
383
|
|
|
384
|
+
const form = $(e).closest("form");
|
|
385
|
+
|
|
386
|
+
const rowVals = form.attr("data-row-values");
|
|
387
|
+
if (rowVals)
|
|
388
|
+
try {
|
|
389
|
+
const initRow = JSON.parse(decodeURIComponent(rowVals));
|
|
390
|
+
Object.assign(rec, initRow);
|
|
391
|
+
} catch (error) {
|
|
392
|
+
console.error(error);
|
|
393
|
+
}
|
|
394
|
+
|
|
384
395
|
e.find("input[name],select[name],textarea[name]").each(function () {
|
|
385
396
|
const name = $(this).attr("data-fieldname") || $(this).attr("name");
|
|
386
397
|
if (select_labels && $(this).prop("tagName").toLowerCase() === "select")
|
|
@@ -737,7 +748,26 @@ function initialize_page() {
|
|
|
737
748
|
cm.on(
|
|
738
749
|
"change",
|
|
739
750
|
$.debounce(() => {
|
|
740
|
-
$(el).
|
|
751
|
+
if ($(el).hasClass("validate-statements")) {
|
|
752
|
+
try {
|
|
753
|
+
let AsyncFunction = Object.getPrototypeOf(
|
|
754
|
+
async function () {}
|
|
755
|
+
).constructor;
|
|
756
|
+
AsyncFunction(cm.getValue());
|
|
757
|
+
$(el).closest("form").trigger("change");
|
|
758
|
+
} catch (e) {
|
|
759
|
+
const form = $(el).closest("form");
|
|
760
|
+
const errorArea = form.parent().find(".full-form-error");
|
|
761
|
+
if (errorArea.length) errorArea.text(e.message);
|
|
762
|
+
else
|
|
763
|
+
form
|
|
764
|
+
.parent()
|
|
765
|
+
.append(
|
|
766
|
+
`<p class="text-danger full-form-error">${e.message}</p>`
|
|
767
|
+
);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
} else $(el).closest("form").trigger("change");
|
|
741
771
|
}),
|
|
742
772
|
500,
|
|
743
773
|
null,
|
package/routes/api.js
CHANGED
|
@@ -358,14 +358,22 @@ router.all(
|
|
|
358
358
|
if (accessAllowed(req, user, trigger)) {
|
|
359
359
|
try {
|
|
360
360
|
const action = getState().actions[trigger.action];
|
|
361
|
+
const row = req.method === "GET" ? req.query : req.body;
|
|
361
362
|
const resp = await action.run({
|
|
362
363
|
configuration: trigger.configuration,
|
|
363
364
|
body: req.body,
|
|
364
|
-
row
|
|
365
|
+
row,
|
|
365
366
|
req,
|
|
366
367
|
user: user || req.user,
|
|
367
368
|
});
|
|
368
|
-
|
|
369
|
+
if (
|
|
370
|
+
(row._process_result || req.headers?.scprocessresults) &&
|
|
371
|
+
resp?.goto
|
|
372
|
+
)
|
|
373
|
+
res.redirect(resp.goto);
|
|
374
|
+
else if (req.headers?.scgotourl)
|
|
375
|
+
res.redirect(req.headers?.scgotourl);
|
|
376
|
+
else res.json({ success: true, data: resp });
|
|
369
377
|
} catch (e) {
|
|
370
378
|
Crash.create(e, req);
|
|
371
379
|
res.status(400).json({ success: false, error: e.message });
|
package/s3storage.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require("aws-sdk/
|
|
2
|
-
const aws = require("aws-sdk");
|
|
1
|
+
const { S3 } = require("@aws-sdk/client-s3");
|
|
3
2
|
const multer = require("multer");
|
|
4
3
|
const multerS3 = require("multer-s3");
|
|
5
4
|
const { getState } = require("@saltcorn/data/db/state");
|
|
@@ -8,9 +7,11 @@ const { v4: uuidv4 } = require("uuid");
|
|
|
8
7
|
const contentDisposition = require("content-disposition");
|
|
9
8
|
const fs = require("fs");
|
|
10
9
|
function createS3Client() {
|
|
11
|
-
return new
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
return new S3({
|
|
11
|
+
credentials: {
|
|
12
|
+
secretAccessKey: getState().getConfig("storage_s3_access_secret"),
|
|
13
|
+
accessKeyId: getState().getConfig("storage_s3_access_key"),
|
|
14
|
+
},
|
|
14
15
|
region: getState().getConfig("storage_s3_region"),
|
|
15
16
|
endpoint: getState().getConfig("storage_s3_endpoint"),
|
|
16
17
|
});
|