@saltcorn/server 0.9.6-beta.11 → 0.9.6-beta.13

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/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@saltcorn/server",
3
- "version": "0.9.6-beta.11",
3
+ "version": "0.9.6-beta.13",
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
9
  "@aws-sdk/client-s3": "^3.451.0",
10
- "@saltcorn/base-plugin": "0.9.6-beta.11",
11
- "@saltcorn/builder": "0.9.6-beta.11",
12
- "@saltcorn/data": "0.9.6-beta.11",
13
- "@saltcorn/admin-models": "0.9.6-beta.11",
14
- "@saltcorn/filemanager": "0.9.6-beta.11",
15
- "@saltcorn/markup": "0.9.6-beta.11",
16
- "@saltcorn/plugins-loader": "0.9.6-beta.11",
17
- "@saltcorn/sbadmin2": "0.9.6-beta.11",
10
+ "@saltcorn/base-plugin": "0.9.6-beta.13",
11
+ "@saltcorn/builder": "0.9.6-beta.13",
12
+ "@saltcorn/data": "0.9.6-beta.13",
13
+ "@saltcorn/admin-models": "0.9.6-beta.13",
14
+ "@saltcorn/filemanager": "0.9.6-beta.13",
15
+ "@saltcorn/markup": "0.9.6-beta.13",
16
+ "@saltcorn/plugins-loader": "0.9.6-beta.13",
17
+ "@saltcorn/sbadmin2": "0.9.6-beta.13",
18
18
  "@socket.io/cluster-adapter": "^0.2.1",
19
19
  "@socket.io/sticky": "^1.0.1",
20
20
  "adm-zip": "0.5.10",
@@ -1373,15 +1373,15 @@ async function common_done(res, viewnameOrElem, isWeb = true) {
1373
1373
  });
1374
1374
  }
1375
1375
  if (res.eval_js) await handle(res.eval_js, eval_it);
1376
-
1377
- if (res.goto && !isWeb)
1378
- // TODO ch
1379
- notifyAlert({
1380
- type: "danger",
1381
- text: "Goto is not supported in a mobile deployment.",
1382
- });
1383
1376
  else if (res.goto) {
1384
- if (res.target === "_blank") window.open(res.goto, "_blank").focus();
1377
+ if (!isWeb) {
1378
+ const next = new URL(res.goto, "http://localhost");
1379
+ const pathname = next.pathname;
1380
+ if (pathname.startsWith("/view/") || pathname.startsWith("/page/")) {
1381
+ const route = `get${pathname}${next.search ? "?" + next.search : ""}`;
1382
+ await parent.handleRoute(route);
1383
+ } else parent.cordova.InAppBrowser.open(res.goto, "_system");
1384
+ } else if (res.target === "_blank") window.open(res.goto, "_blank").focus();
1385
1385
  else {
1386
1386
  const prev = new URL(window.location.href);
1387
1387
  const next = new URL(res.goto, prev.origin);
@@ -1729,7 +1729,13 @@ function close_saltcorn_modal() {
1729
1729
  function reload_embedded_view(viewname, new_query_string) {
1730
1730
  const isNode = getIsNode();
1731
1731
  const updater = ($e, res) => {
1732
- $e.html(res);
1732
+ const localState = $e.attr("data-sc-local-state");
1733
+ const parent = $e.parent();
1734
+ $e.replaceWith(res);
1735
+ if (localState && !new_query_string) {
1736
+ const newE = parent.find(`[data-sc-embed-viewname="${viewname}"]`);
1737
+ newE.attr("data-sc-local-state", localState);
1738
+ }
1733
1739
  initialize_page();
1734
1740
  };
1735
1741
  if (window._sc_loglevel > 4)
package/routes/api.js CHANGED
@@ -260,6 +260,12 @@ router.get(
260
260
  );
261
261
  if (!table) {
262
262
  getState().log(3, `API get ${tableName} table not found`);
263
+ getState().log(
264
+ 6,
265
+ `API get failure additonal info: URL=${req.originalUrl}${
266
+ getState().getConfig("log_ip_address", false) ? ` IP=${req.ip}` : ""
267
+ }`
268
+ );
263
269
  res.status(404).json({ error: req.__("Not found") });
264
270
  return;
265
271
  }
@@ -9,6 +9,7 @@ const {
9
9
  toInclude,
10
10
  toSucceed,
11
11
  } = require("../auth/testhelp");
12
+ const load_plugins = require("../load_plugins");
12
13
  const db = require("@saltcorn/data/db");
13
14
  const { sleep } = require("@saltcorn/data/tests/mocks");
14
15
 
@@ -16,6 +17,7 @@ const Table = require("@saltcorn/data/models/table");
16
17
  const TableConstraint = require("@saltcorn/data/models/table_constraints");
17
18
  const Field = require("@saltcorn/data/models/field");
18
19
  const User = require("@saltcorn/data/models/user");
20
+ const Plugin = require("@saltcorn/data/models/plugin");
19
21
 
20
22
  beforeAll(async () => {
21
23
  await resetToFixtures();
@@ -35,6 +37,27 @@ const initSyncInfo = async (tbls) => {
35
37
  }
36
38
  };
37
39
 
40
+ const createAnswersTbl = async () => {
41
+ await load_plugins.loadAndSaveNewPlugin(
42
+ new Plugin({
43
+ name: "json",
44
+ source: "npm",
45
+ location: "@saltcorn/json",
46
+ version: "latest",
47
+ })
48
+ );
49
+ const table = await Table.create("Answers", {
50
+ min_role_read: 100,
51
+ min_role_write: 100,
52
+ });
53
+ await Field.create({
54
+ table,
55
+ name: "answer",
56
+ label: "Answer",
57
+ type: "JSON",
58
+ });
59
+ };
60
+
38
61
  describe("load remote insert/updates", () => {
39
62
  if (!db.isSQLite) {
40
63
  beforeAll(async () => {
@@ -416,6 +439,42 @@ describe("Upload changes", () => {
416
439
  });
417
440
  });
418
441
 
442
+ it("upload json", async () => {
443
+ await createAnswersTbl();
444
+ const table = Table.findOne({ name: "Answers" });
445
+ expect(table).toBeDefined();
446
+ const app = await getApp({ disableCsrf: true });
447
+ const loginCookie = await getAdminLoginCookie();
448
+ const rows = [
449
+ {
450
+ id: 1,
451
+ answer: true,
452
+ },
453
+ {
454
+ id: 2,
455
+ answer: false,
456
+ },
457
+ {
458
+ id: 3,
459
+ answer: 1,
460
+ },
461
+ {
462
+ id: 4,
463
+ answer: ["latte", "americano", "filter"],
464
+ },
465
+ ];
466
+ const resp = await doUpload(app, loginCookie, new Date().valueOf(), {
467
+ Answers: {
468
+ inserts: rows,
469
+ },
470
+ });
471
+ expect(resp.status).toBe(200);
472
+ const { syncDir } = resp._body;
473
+ const result = await getResult(app, loginCookie, syncDir);
474
+ expect(result).toBeDefined();
475
+ expect(await table.getRows()).toEqual(rows);
476
+ });
477
+
419
478
  it("handles inserts with TableConstraint conflicts", async () => {
420
479
  const books = Table.findOne({ name: "books" });
421
480
  const oldCount = await books.countRows();