@xuda.io/runtime-bundle 1.0.559 → 1.0.561
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/js/modules/xuda-actions-module.esm.js +4 -0
- package/js/modules/xuda-actions-module.esm.min.js +1 -1
- package/js/modules/xuda-studio-checker.min.mjs +1 -1
- package/js/modules/xuda-studio-checker.mjs +1 -0
- package/js/xuda-runtime-bundle.js +380 -703
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +380 -703
- package/js/xuda-runtime-slim.min.es.js +380 -703
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +380 -703
- package/js/xuda-worker-bundle.js +380 -703
- package/js/xuda-worker-bundle.min.js +1 -1
- package/js/xuda_common-bundle.js +382 -705
- package/js/xuda_common-bundle.min.js +1 -1
- package/package.json +1 -1
package/js/xuda-runtime-slim.js
CHANGED
|
@@ -1622,12 +1622,9 @@ wi&&(An.prototype[wi]=Xe),An}();typeof define=="function"&&typeof define.amd=="o
|
|
|
1622
1622
|
},
|
|
1623
1623
|
};
|
|
1624
1624
|
});
|
|
1625
|
-
|
|
1626
1625
|
"use strict";
|
|
1626
|
+
|
|
1627
1627
|
'use strict';
|
|
1628
1628
|
|
|
1629
|
-
if (
|
|
1630
|
-
typeof IS_DOCKER === "undefined" ||
|
|
1631
|
-
typeof IS_PROCESS_SERVER === "undefined"
|
|
1632
|
-
) {
|
|
1629
|
+
if (typeof IS_DOCKER === 'undefined' || typeof IS_PROCESS_SERVER === 'undefined') {
|
|
1633
1630
|
var SESSION_OBJ = {};
|
|
1634
1631
|
var DOCS_OBJ = {};
|
|
1635
1632
|
}
|
|
@@ -1644,17 +1641,7 @@ var PROJECT_OBJ = {};
|
|
|
1644
1641
|
var APP_OBJ = {};
|
|
1645
1642
|
var SESSION_ID = null;
|
|
1646
1643
|
|
|
1647
|
-
glb.PROTECTED_VARS = [
|
|
1648
|
-
"_NULL",
|
|
1649
|
-
"_THIS",
|
|
1650
|
-
"_FOR_KEY",
|
|
1651
|
-
"_FOR_VAL",
|
|
1652
|
-
"_ROWNO",
|
|
1653
|
-
"_ROWID",
|
|
1654
|
-
"_ROWDOC",
|
|
1655
|
-
"_KEY",
|
|
1656
|
-
"_VAL",
|
|
1657
|
-
];
|
|
1644
|
+
glb.PROTECTED_VARS = ['_NULL', '_THIS', '_FOR_KEY', '_FOR_VAL', '_ROWNO', '_ROWID', '_ROWDOC', '_KEY', '_VAL'];
|
|
1658
1645
|
|
|
1659
1646
|
// glb.newRecord = 999999;
|
|
1660
1647
|
|
|
@@ -1671,7 +1658,7 @@ func.common.find_item_by_key_root = function (arr, key, val) {
|
|
|
1671
1658
|
};
|
|
1672
1659
|
func.common.find_ROWID_idx = function (_ds, rowId) {
|
|
1673
1660
|
if (!_ds?.data_feed?.rows) {
|
|
1674
|
-
throw new Error(
|
|
1661
|
+
throw new Error('data_feed not found');
|
|
1675
1662
|
}
|
|
1676
1663
|
|
|
1677
1664
|
// Find the index of the object with the given _ROWID
|
|
@@ -1685,129 +1672,55 @@ func.common.find_ROWID_idx = function (_ds, rowId) {
|
|
|
1685
1672
|
// Return the found index
|
|
1686
1673
|
return index;
|
|
1687
1674
|
};
|
|
1688
|
-
func.common.input_mask = async function (
|
|
1689
|
-
|
|
1690
|
-
valP,
|
|
1691
|
-
typeP,
|
|
1692
|
-
maskP,
|
|
1693
|
-
elemP,
|
|
1694
|
-
grid_objP,
|
|
1695
|
-
grid_row_idP,
|
|
1696
|
-
grid_col_idP,
|
|
1697
|
-
dsSessionP
|
|
1698
|
-
) {
|
|
1699
|
-
const module = await func.common.get_module(
|
|
1700
|
-
SESSION_ID,
|
|
1701
|
-
"xuda-input-musk-utils-module.mjs"
|
|
1702
|
-
);
|
|
1675
|
+
func.common.input_mask = async function (actionP, valP, typeP, maskP, elemP, grid_objP, grid_row_idP, grid_col_idP, dsSessionP) {
|
|
1676
|
+
const module = await func.common.get_module(SESSION_ID, 'xuda-input-musk-utils-module.mjs');
|
|
1703
1677
|
|
|
1704
|
-
module.input_mask(
|
|
1705
|
-
actionP,
|
|
1706
|
-
valP,
|
|
1707
|
-
typeP,
|
|
1708
|
-
maskP,
|
|
1709
|
-
elemP,
|
|
1710
|
-
grid_objP,
|
|
1711
|
-
grid_row_idP,
|
|
1712
|
-
grid_col_idP,
|
|
1713
|
-
dsSessionP
|
|
1714
|
-
);
|
|
1678
|
+
module.input_mask(actionP, valP, typeP, maskP, elemP, grid_objP, grid_row_idP, grid_col_idP, dsSessionP);
|
|
1715
1679
|
};
|
|
1716
1680
|
|
|
1717
|
-
glb.MAIN_WINDOW_TYPES_ARR = [
|
|
1718
|
-
glb.FUNCTION_NODES_ARR = [
|
|
1719
|
-
"batch",
|
|
1720
|
-
"get_data",
|
|
1721
|
-
"set_data",
|
|
1722
|
-
"Alert_error",
|
|
1723
|
-
"Alert_warning",
|
|
1724
|
-
"Alert_info",
|
|
1725
|
-
"Alert_ok",
|
|
1726
|
-
"javascript",
|
|
1727
|
-
"SQL",
|
|
1728
|
-
];
|
|
1681
|
+
glb.MAIN_WINDOW_TYPES_ARR = ['screen', 'program'];
|
|
1682
|
+
glb.FUNCTION_NODES_ARR = ['batch', 'get_data', 'set_data', 'Alert_error', 'Alert_warning', 'Alert_info', 'Alert_ok', 'javascript', 'SQL'];
|
|
1729
1683
|
glb.emailRegex = /^[\w\.-]+@[a-zA-Z\d\.-]+\.[a-zA-Z]{2,}$/;
|
|
1730
1684
|
|
|
1731
|
-
const FIREBASE_AUTH_PROPERTIES_ARR = [
|
|
1732
|
-
"provider",
|
|
1733
|
-
"token",
|
|
1734
|
-
"first_name",
|
|
1735
|
-
"last_name",
|
|
1736
|
-
"email",
|
|
1737
|
-
"user_id",
|
|
1738
|
-
"picture",
|
|
1739
|
-
"verified_email",
|
|
1740
|
-
"locale",
|
|
1741
|
-
"error_code",
|
|
1742
|
-
"error_msg",
|
|
1743
|
-
];
|
|
1685
|
+
const FIREBASE_AUTH_PROPERTIES_ARR = ['provider', 'token', 'first_name', 'last_name', 'email', 'user_id', 'picture', 'verified_email', 'locale', 'error_code', 'error_msg'];
|
|
1744
1686
|
|
|
1745
1687
|
const CLIENT_INFO_PROPERTIES_ARR = [
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1688
|
+
'fingerprint',
|
|
1689
|
+
'device',
|
|
1690
|
+
'user_agent',
|
|
1691
|
+
'browser_version',
|
|
1692
|
+
'browser_name',
|
|
1693
|
+
'engine_version',
|
|
1694
|
+
'engine_name',
|
|
1695
|
+
'client_ip',
|
|
1696
|
+
'os_name',
|
|
1697
|
+
'os_version',
|
|
1698
|
+
'device_model',
|
|
1699
|
+
'device_vendor',
|
|
1700
|
+
'device_type',
|
|
1701
|
+
'screen_current_resolution_x',
|
|
1702
|
+
'screen_current_resolution_y',
|
|
1703
|
+
'screen_available_resolution_x',
|
|
1704
|
+
'screen_available_resolution_y',
|
|
1705
|
+
'language',
|
|
1706
|
+
'time_zone',
|
|
1707
|
+
'cpu_architecture',
|
|
1708
|
+
'uuid',
|
|
1709
|
+
'cursor_pos_x',
|
|
1710
|
+
'cursor_pos_y',
|
|
1769
1711
|
];
|
|
1770
1712
|
|
|
1771
|
-
const APP_PROPERTIES_ARR = [
|
|
1772
|
-
|
|
1773
|
-
const DATASOURCE_PROPERTIES_ARR = [
|
|
1774
|
-
"rows",
|
|
1775
|
-
"type",
|
|
1776
|
-
"first_row_id",
|
|
1777
|
-
"last_row_id",
|
|
1778
|
-
"query_from_segments_json",
|
|
1779
|
-
"query_to_segments_json",
|
|
1780
|
-
"locate_query_from_segments_json",
|
|
1781
|
-
"locate_query_to_segments_json",
|
|
1782
|
-
"first_row_segments_json",
|
|
1783
|
-
"last_row_segments_json",
|
|
1784
|
-
"rowid_snapshot",
|
|
1785
|
-
"rowid",
|
|
1786
|
-
];
|
|
1713
|
+
const APP_PROPERTIES_ARR = ['build', 'author', 'date', 'name'];
|
|
1787
1714
|
|
|
1788
|
-
|
|
1789
|
-
"component",
|
|
1790
|
-
"web_app",
|
|
1791
|
-
"ios_app",
|
|
1792
|
-
"android_app",
|
|
1793
|
-
"electron_app",
|
|
1794
|
-
"osx_app",
|
|
1795
|
-
"windows_app",
|
|
1796
|
-
];
|
|
1715
|
+
const DATASOURCE_PROPERTIES_ARR = ['rows', 'type', 'first_row_id', 'last_row_id', 'query_from_segments_json', 'query_to_segments_json', 'locate_query_from_segments_json', 'locate_query_to_segments_json', 'first_row_segments_json', 'last_row_segments_json', 'rowid_snapshot', 'rowid'];
|
|
1797
1716
|
|
|
1798
|
-
glb.
|
|
1799
|
-
"SYS_DATE",
|
|
1800
|
-
"SYS_DATE_TIME",
|
|
1801
|
-
"SYS_DATE_VALUE",
|
|
1802
|
-
"SYS_DATE_WEEK_YEAR",
|
|
1803
|
-
"SYS_DATE_MONTH_YEAR",
|
|
1804
|
-
"SYS_TIME_SHORT",
|
|
1805
|
-
"SYS_TIME",
|
|
1806
|
-
];
|
|
1717
|
+
glb.MOBILE_ARR = ['component', 'web_app', 'ios_app', 'android_app', 'electron_app', 'osx_app', 'windows_app'];
|
|
1807
1718
|
|
|
1808
|
-
glb.
|
|
1719
|
+
glb.SYS_DATE_ARR = ['SYS_DATE', 'SYS_DATE_TIME', 'SYS_DATE_VALUE', 'SYS_DATE_WEEK_YEAR', 'SYS_DATE_MONTH_YEAR', 'SYS_TIME_SHORT', 'SYS_TIME'];
|
|
1809
1720
|
|
|
1810
|
-
|
|
1721
|
+
glb.API_OUTPUT_ARR = ['json', 'html', 'xml', 'text', 'css', 'javascript'];
|
|
1722
|
+
|
|
1723
|
+
const PROTECTED_NAMES_ARR = ['THIS', 'ROWID']; //tbd
|
|
1811
1724
|
|
|
1812
1725
|
// func.common.get_custom_icon = async function (
|
|
1813
1726
|
// SESSION_ID,
|
|
@@ -1850,19 +1763,13 @@ const PROTECTED_NAMES_ARR = ["THIS", "ROWID"]; //tbd
|
|
|
1850
1763
|
// } else return ret;
|
|
1851
1764
|
// };
|
|
1852
1765
|
|
|
1853
|
-
func.common.db = async function (
|
|
1854
|
-
SESSION_ID,
|
|
1855
|
-
serviceP,
|
|
1856
|
-
dataP,
|
|
1857
|
-
opt = {},
|
|
1858
|
-
dsSession
|
|
1859
|
-
) {
|
|
1766
|
+
func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSession) {
|
|
1860
1767
|
return new Promise(async function (resolve, reject) {
|
|
1861
1768
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1862
1769
|
const app_id = _session.app_id;
|
|
1863
1770
|
|
|
1864
|
-
if (_session.engine_mode ===
|
|
1865
|
-
console.log(
|
|
1771
|
+
if (_session.engine_mode === 'live_preview') {
|
|
1772
|
+
console.log('request', dataP);
|
|
1866
1773
|
}
|
|
1867
1774
|
|
|
1868
1775
|
var data = {
|
|
@@ -1874,18 +1781,15 @@ func.common.db = async function (
|
|
|
1874
1781
|
app_token: _session.app_token,
|
|
1875
1782
|
res_token: _session.res_token,
|
|
1876
1783
|
engine_mode: _session.engine_mode,
|
|
1877
|
-
req_id:
|
|
1784
|
+
req_id: 'rt_req_' + crypto.randomUUID(),
|
|
1878
1785
|
app_replicate: APP_OBJ[app_id].app_replicate,
|
|
1879
1786
|
};
|
|
1880
1787
|
|
|
1881
1788
|
try {
|
|
1882
|
-
if (
|
|
1883
|
-
typeof firebase !== "undefined" &&
|
|
1884
|
-
firebase?.auth()?.currentUser?.displayName
|
|
1885
|
-
) {
|
|
1789
|
+
if (typeof firebase !== 'undefined' && firebase?.auth()?.currentUser?.displayName) {
|
|
1886
1790
|
data.device_name = firebase.auth().currentUser.displayName;
|
|
1887
1791
|
}
|
|
1888
|
-
} catch (error) {
|
|
1792
|
+
} catch (error) {}
|
|
1889
1793
|
|
|
1890
1794
|
for (const [key, val] of Object.entries(dataP)) {
|
|
1891
1795
|
data[key] = val;
|
|
@@ -1893,20 +1797,14 @@ func.common.db = async function (
|
|
|
1893
1797
|
|
|
1894
1798
|
const success_callback = function (ret) {
|
|
1895
1799
|
if (dataP.table_id && DOCS_OBJ[app_id][dataP.table_id]) {
|
|
1896
|
-
func.utils.debug.watch(
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
DOCS_OBJ[app_id][dataP.table_id].properties.menuName,
|
|
1901
|
-
{
|
|
1902
|
-
req: data,
|
|
1903
|
-
res: ret,
|
|
1904
|
-
}
|
|
1905
|
-
);
|
|
1800
|
+
func.utils.debug.watch(SESSION_ID, dataP.table_id, 'table', DOCS_OBJ[app_id][dataP.table_id].properties.menuName, {
|
|
1801
|
+
req: data,
|
|
1802
|
+
res: ret,
|
|
1803
|
+
});
|
|
1906
1804
|
}
|
|
1907
1805
|
|
|
1908
|
-
if (_session.engine_mode ===
|
|
1909
|
-
console.log(
|
|
1806
|
+
if (_session.engine_mode === 'live_preview') {
|
|
1807
|
+
console.log('response', ret);
|
|
1910
1808
|
}
|
|
1911
1809
|
resolve(ret, true);
|
|
1912
1810
|
};
|
|
@@ -1917,31 +1815,14 @@ func.common.db = async function (
|
|
|
1917
1815
|
function cleanString(json) {
|
|
1918
1816
|
let str = JSON.stringify(json);
|
|
1919
1817
|
// Replace all non-alphanumeric characters with an empty string
|
|
1920
|
-
return str.replace(/[^a-zA-Z0-9]/g,
|
|
1818
|
+
return str.replace(/[^a-zA-Z0-9]/g, '');
|
|
1921
1819
|
}
|
|
1922
1820
|
const get_rep_id = function () {
|
|
1923
1821
|
let _data = {};
|
|
1924
|
-
const fields_to_skip = [
|
|
1925
|
-
"fields",
|
|
1926
|
-
"viewSourceDesc",
|
|
1927
|
-
"skip",
|
|
1928
|
-
"limit",
|
|
1929
|
-
"count",
|
|
1930
|
-
"reduce",
|
|
1931
|
-
"prog_id",
|
|
1932
|
-
"sortModel",
|
|
1933
|
-
"filterModelMongo",
|
|
1934
|
-
"filterModelSql",
|
|
1935
|
-
"filterModelUserMongo",
|
|
1936
|
-
"filterModelUserSql",
|
|
1937
|
-
];
|
|
1822
|
+
const fields_to_skip = ['fields', 'viewSourceDesc', 'skip', 'limit', 'count', 'reduce', 'prog_id', 'sortModel', 'filterModelMongo', 'filterModelSql', 'filterModelUserMongo', 'filterModelUserSql'];
|
|
1938
1823
|
|
|
1939
1824
|
for (let [key, val] of Object.entries(dataP)) {
|
|
1940
|
-
if (
|
|
1941
|
-
typeof val !== "undefined" &&
|
|
1942
|
-
val !== null &&
|
|
1943
|
-
!fields_to_skip.includes(key)
|
|
1944
|
-
) {
|
|
1825
|
+
if (typeof val !== 'undefined' && val !== null && !fields_to_skip.includes(key)) {
|
|
1945
1826
|
_data[key] = val;
|
|
1946
1827
|
}
|
|
1947
1828
|
}
|
|
@@ -1959,13 +1840,13 @@ func.common.db = async function (
|
|
|
1959
1840
|
|
|
1960
1841
|
let ret = await db.find({
|
|
1961
1842
|
selector: {
|
|
1962
|
-
docType:
|
|
1843
|
+
docType: 'rep_request',
|
|
1963
1844
|
table_id: data.table_id,
|
|
1964
1845
|
},
|
|
1965
1846
|
});
|
|
1966
1847
|
|
|
1967
1848
|
if (doc.stat < 3) {
|
|
1968
|
-
throw
|
|
1849
|
+
throw 'not ready';
|
|
1969
1850
|
}
|
|
1970
1851
|
|
|
1971
1852
|
/// delete table refunded requests
|
|
@@ -1980,10 +1861,7 @@ func.common.db = async function (
|
|
|
1980
1861
|
};
|
|
1981
1862
|
|
|
1982
1863
|
const read_dbs_pouch = async function (db) {
|
|
1983
|
-
if (
|
|
1984
|
-
_session?.DS_GLB?.[dsSession]?.refreshed &&
|
|
1985
|
-
(dataP.filterModelMongo || dataP.filterModelSql)
|
|
1986
|
-
) {
|
|
1864
|
+
if (_session?.DS_GLB?.[dsSession]?.refreshed && (dataP.filterModelMongo || dataP.filterModelSql)) {
|
|
1987
1865
|
return {
|
|
1988
1866
|
code: 1,
|
|
1989
1867
|
data: await func.db.pouch[serviceP](SESSION_ID, data),
|
|
@@ -1992,8 +1870,7 @@ func.common.db = async function (
|
|
|
1992
1870
|
|
|
1993
1871
|
const rep_id = get_rep_id();
|
|
1994
1872
|
|
|
1995
|
-
const { code: table_req_code, data: table_req_id } =
|
|
1996
|
-
await validate_existence_of_whole_table_request(db);
|
|
1873
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
1997
1874
|
if (table_req_code > 0) {
|
|
1998
1875
|
return {
|
|
1999
1876
|
code: 1,
|
|
@@ -2003,7 +1880,7 @@ func.common.db = async function (
|
|
|
2003
1880
|
|
|
2004
1881
|
try {
|
|
2005
1882
|
const doc = await db.get(rep_id);
|
|
2006
|
-
if (doc.stat < 3) throw
|
|
1883
|
+
if (doc.stat < 3) throw 'replication not ready';
|
|
2007
1884
|
const json = {
|
|
2008
1885
|
code: 1,
|
|
2009
1886
|
data: await func.db.pouch[serviceP](SESSION_ID, data),
|
|
@@ -2011,12 +1888,7 @@ func.common.db = async function (
|
|
|
2011
1888
|
|
|
2012
1889
|
return json;
|
|
2013
1890
|
} catch (err) {
|
|
2014
|
-
const json = await func.common.perform_rpi_request(
|
|
2015
|
-
SESSION_ID,
|
|
2016
|
-
serviceP,
|
|
2017
|
-
opt,
|
|
2018
|
-
data
|
|
2019
|
-
);
|
|
1891
|
+
const json = await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
2020
1892
|
if (json.data.opt) {
|
|
2021
1893
|
try {
|
|
2022
1894
|
try {
|
|
@@ -2027,16 +1899,16 @@ func.common.db = async function (
|
|
|
2027
1899
|
selector: json.data.opt.selector,
|
|
2028
1900
|
stat: 1,
|
|
2029
1901
|
ts: Date.now(),
|
|
2030
|
-
docType:
|
|
1902
|
+
docType: 'rep_request',
|
|
2031
1903
|
table_id: dataP.table_id,
|
|
2032
1904
|
prog_id: dataP.prog_id,
|
|
2033
1905
|
entire_table: table_req_id === rep_id,
|
|
2034
|
-
source:
|
|
1906
|
+
source: 'runtime',
|
|
2035
1907
|
e: data,
|
|
2036
1908
|
});
|
|
2037
1909
|
}
|
|
2038
1910
|
func.db.pouch.set_db_replication_from_server(SESSION_ID);
|
|
2039
|
-
} catch (err) {
|
|
1911
|
+
} catch (err) {}
|
|
2040
1912
|
}
|
|
2041
1913
|
return json;
|
|
2042
1914
|
}
|
|
@@ -2047,8 +1919,7 @@ func.common.db = async function (
|
|
|
2047
1919
|
// throw "online";
|
|
2048
1920
|
// }
|
|
2049
1921
|
|
|
2050
|
-
const { code: table_req_code, data: table_req_id } =
|
|
2051
|
-
await validate_existence_of_whole_table_request(db);
|
|
1922
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
2052
1923
|
|
|
2053
1924
|
if (table_req_code > 0) {
|
|
2054
1925
|
data.full_table_downloaded = true;
|
|
@@ -2057,37 +1928,25 @@ func.common.db = async function (
|
|
|
2057
1928
|
await db.get(dataP.row_id);
|
|
2058
1929
|
return await func.db.pouch[serviceP](SESSION_ID, data);
|
|
2059
1930
|
} catch (err) {
|
|
2060
|
-
return await func.common.perform_rpi_request(
|
|
2061
|
-
SESSION_ID,
|
|
2062
|
-
serviceP,
|
|
2063
|
-
opt,
|
|
2064
|
-
data
|
|
2065
|
-
);
|
|
1931
|
+
return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
2066
1932
|
}
|
|
2067
1933
|
};
|
|
2068
1934
|
const create_dbs_pouch = async function (db) {
|
|
2069
1935
|
try {
|
|
2070
|
-
const { code: table_req_code, data: table_req_id } =
|
|
2071
|
-
await validate_existence_of_whole_table_request(db);
|
|
1936
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
2072
1937
|
|
|
2073
1938
|
if (table_req_code > 0) {
|
|
2074
1939
|
data.full_table_downloaded = true;
|
|
2075
1940
|
}
|
|
2076
1941
|
return await func.db.pouch[serviceP](SESSION_ID, data);
|
|
2077
1942
|
} catch (err) {
|
|
2078
|
-
return await func.common.perform_rpi_request(
|
|
2079
|
-
SESSION_ID,
|
|
2080
|
-
serviceP,
|
|
2081
|
-
opt,
|
|
2082
|
-
data
|
|
2083
|
-
);
|
|
1943
|
+
return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
2084
1944
|
}
|
|
2085
1945
|
};
|
|
2086
1946
|
const delete_dbs_pouch = async function (db) {
|
|
2087
|
-
for await (let row_id of dataP.ids) {
|
|
1947
|
+
for await (let row_id of dataP.ids || []) {
|
|
2088
1948
|
try {
|
|
2089
|
-
const { code: table_req_code, data: table_req_id } =
|
|
2090
|
-
await validate_existence_of_whole_table_request(db);
|
|
1949
|
+
const { code: table_req_code, data: table_req_id } = await validate_existence_of_whole_table_request(db);
|
|
2091
1950
|
|
|
2092
1951
|
if (table_req_code > 0) {
|
|
2093
1952
|
data.full_table_downloaded = true;
|
|
@@ -2096,41 +1955,32 @@ func.common.db = async function (
|
|
|
2096
1955
|
await db.get(row_id);
|
|
2097
1956
|
let _data = _.cloneDeep(dataP);
|
|
2098
1957
|
_data.ids = [row_id];
|
|
2099
|
-
return await func.db.pouch[
|
|
1958
|
+
return await func.db.pouch['dbs_delete'](SESSION_ID, _data);
|
|
2100
1959
|
} catch (err) {
|
|
2101
|
-
return await func.common.perform_rpi_request(
|
|
2102
|
-
SESSION_ID,
|
|
2103
|
-
serviceP,
|
|
2104
|
-
opt,
|
|
2105
|
-
data
|
|
2106
|
-
);
|
|
1960
|
+
return await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
2107
1961
|
}
|
|
2108
1962
|
}
|
|
2109
1963
|
};
|
|
2110
|
-
if (
|
|
2111
|
-
typeof IS_DOCKER === "undefined" &&
|
|
2112
|
-
typeof IS_PROCESS_SERVER === "undefined"
|
|
2113
|
-
) {
|
|
1964
|
+
if (typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined') {
|
|
2114
1965
|
try {
|
|
2115
1966
|
if (!SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(serviceP)) {
|
|
2116
|
-
throw
|
|
1967
|
+
throw '';
|
|
2117
1968
|
}
|
|
2118
|
-
if (!(await func?.db?.pouch?.get_replication_stat(SESSION_ID)))
|
|
2119
|
-
throw "";
|
|
1969
|
+
if (!(await func?.db?.pouch?.get_replication_stat(SESSION_ID))) throw '';
|
|
2120
1970
|
const db = await func.utils.connect_pouchdb(SESSION_ID);
|
|
2121
1971
|
switch (serviceP) {
|
|
2122
|
-
case
|
|
1972
|
+
case 'dbs_read': {
|
|
2123
1973
|
try {
|
|
2124
1974
|
return success_callback(await read_dbs_pouch(db));
|
|
2125
1975
|
} catch (err) {
|
|
2126
|
-
if (err ===
|
|
2127
|
-
throw
|
|
1976
|
+
if (err === 'creating index in progress') {
|
|
1977
|
+
throw '';
|
|
2128
1978
|
}
|
|
2129
1979
|
return error_callback(err);
|
|
2130
1980
|
}
|
|
2131
1981
|
break;
|
|
2132
1982
|
}
|
|
2133
|
-
case
|
|
1983
|
+
case 'dbs_update': {
|
|
2134
1984
|
try {
|
|
2135
1985
|
const ret = {
|
|
2136
1986
|
code: 1,
|
|
@@ -2142,7 +1992,7 @@ func.common.db = async function (
|
|
|
2142
1992
|
}
|
|
2143
1993
|
break;
|
|
2144
1994
|
}
|
|
2145
|
-
case
|
|
1995
|
+
case 'dbs_create': {
|
|
2146
1996
|
try {
|
|
2147
1997
|
const ret = {
|
|
2148
1998
|
code: 1,
|
|
@@ -2154,7 +2004,7 @@ func.common.db = async function (
|
|
|
2154
2004
|
}
|
|
2155
2005
|
break;
|
|
2156
2006
|
}
|
|
2157
|
-
case
|
|
2007
|
+
case 'dbs_delete': {
|
|
2158
2008
|
try {
|
|
2159
2009
|
const ret = {
|
|
2160
2010
|
code: 1,
|
|
@@ -2168,17 +2018,12 @@ func.common.db = async function (
|
|
|
2168
2018
|
}
|
|
2169
2019
|
|
|
2170
2020
|
default:
|
|
2171
|
-
throw
|
|
2021
|
+
throw '';
|
|
2172
2022
|
break;
|
|
2173
2023
|
}
|
|
2174
2024
|
} catch (err) {
|
|
2175
2025
|
try {
|
|
2176
|
-
const json = await func.common.perform_rpi_request(
|
|
2177
|
-
SESSION_ID,
|
|
2178
|
-
serviceP,
|
|
2179
|
-
opt,
|
|
2180
|
-
data
|
|
2181
|
-
);
|
|
2026
|
+
const json = await func.common.perform_rpi_request(SESSION_ID, serviceP, opt, data);
|
|
2182
2027
|
return success_callback(json, true);
|
|
2183
2028
|
} catch (err) {
|
|
2184
2029
|
return error_callback(err);
|
|
@@ -2199,14 +2044,14 @@ func.common.db = async function (
|
|
|
2199
2044
|
var e = {};
|
|
2200
2045
|
_.forEach(data, function (val, key) {
|
|
2201
2046
|
if (!val) {
|
|
2202
|
-
if (typeof val ===
|
|
2203
|
-
e[key] =
|
|
2047
|
+
if (typeof val === 'boolean') {
|
|
2048
|
+
e[key] = 'false';
|
|
2204
2049
|
} else {
|
|
2205
|
-
e[key] =
|
|
2050
|
+
e[key] = '';
|
|
2206
2051
|
}
|
|
2207
2052
|
} else {
|
|
2208
|
-
if (typeof val ===
|
|
2209
|
-
e[key] =
|
|
2053
|
+
if (typeof val === 'boolean') {
|
|
2054
|
+
e[key] = 'true';
|
|
2210
2055
|
} else {
|
|
2211
2056
|
e[key] = val;
|
|
2212
2057
|
}
|
|
@@ -2214,7 +2059,7 @@ func.common.db = async function (
|
|
|
2214
2059
|
});
|
|
2215
2060
|
|
|
2216
2061
|
if (data.fields && !data.fields.length) {
|
|
2217
|
-
e.fields =
|
|
2062
|
+
e.fields = '';
|
|
2218
2063
|
}
|
|
2219
2064
|
|
|
2220
2065
|
return e;
|
|
@@ -2224,13 +2069,8 @@ func.common.db = async function (
|
|
|
2224
2069
|
await func.utils.FILES_OBJ.get(SESSION_ID, dataP.table_id);
|
|
2225
2070
|
await func.utils.TREE_OBJ.get(SESSION_ID, dataP.table_id);
|
|
2226
2071
|
}
|
|
2227
|
-
data.db_driver =
|
|
2228
|
-
__.rpi.http_calls(
|
|
2229
|
-
serviceP,
|
|
2230
|
-
{ body: get_white_spaced_data(data) },
|
|
2231
|
-
null,
|
|
2232
|
-
response
|
|
2233
|
-
);
|
|
2072
|
+
data.db_driver = 'xuda';
|
|
2073
|
+
__.rpi.http_calls(serviceP, { body: get_white_spaced_data(data) }, null, response);
|
|
2234
2074
|
});
|
|
2235
2075
|
};
|
|
2236
2076
|
|
|
@@ -2250,11 +2090,7 @@ func.common.getParametersFromUrl = function () {
|
|
|
2250
2090
|
return parameters;
|
|
2251
2091
|
};
|
|
2252
2092
|
|
|
2253
|
-
func.common.getObjectFromUrl = function (
|
|
2254
|
-
url,
|
|
2255
|
-
element_attributes_obj,
|
|
2256
|
-
embed_params_obj
|
|
2257
|
-
) {
|
|
2093
|
+
func.common.getObjectFromUrl = function (url, element_attributes_obj, embed_params_obj) {
|
|
2258
2094
|
var result = {};
|
|
2259
2095
|
if (element_attributes_obj) {
|
|
2260
2096
|
for (let [key, val] of Object.entries(element_attributes_obj)) {
|
|
@@ -2267,33 +2103,26 @@ func.common.getObjectFromUrl = function (
|
|
|
2267
2103
|
}
|
|
2268
2104
|
}
|
|
2269
2105
|
|
|
2270
|
-
if (
|
|
2271
|
-
!url &&
|
|
2272
|
-
typeof IS_DOCKER === "undefined" &&
|
|
2273
|
-
typeof IS_PROCESS_SERVER === "undefined"
|
|
2274
|
-
) {
|
|
2106
|
+
if (!url && typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined') {
|
|
2275
2107
|
url = location.href;
|
|
2276
2108
|
}
|
|
2277
|
-
var question = url.indexOf(
|
|
2278
|
-
var hash = url.indexOf(
|
|
2109
|
+
var question = url.indexOf('?');
|
|
2110
|
+
var hash = url.indexOf('#');
|
|
2279
2111
|
if (hash == -1 && question == -1) return result;
|
|
2280
2112
|
if (hash == -1) hash = url.length;
|
|
2281
|
-
var query =
|
|
2282
|
-
question == -1 || hash == question + 1
|
|
2283
|
-
? url.substring(hash)
|
|
2284
|
-
: url.substring(question + 1, hash);
|
|
2113
|
+
var query = question == -1 || hash == question + 1 ? url.substring(hash) : url.substring(question + 1, hash);
|
|
2285
2114
|
// var result = {};
|
|
2286
|
-
query.split(
|
|
2115
|
+
query.split('&').forEach(function (part) {
|
|
2287
2116
|
if (!part) return;
|
|
2288
|
-
part = part.split(
|
|
2289
|
-
var eq = part.indexOf(
|
|
2117
|
+
part = part.split('+').join(' '); // replace every + with space, regexp-free version
|
|
2118
|
+
var eq = part.indexOf('=');
|
|
2290
2119
|
var key = eq > -1 ? part.substr(0, eq) : part;
|
|
2291
|
-
var val = eq > -1 ? decodeURIComponent(part.substr(eq + 1)) :
|
|
2292
|
-
var from = key.indexOf(
|
|
2120
|
+
var val = eq > -1 ? decodeURIComponent(part.substr(eq + 1)) : '';
|
|
2121
|
+
var from = key.indexOf('[');
|
|
2293
2122
|
if (from == -1) {
|
|
2294
2123
|
result[decodeURIComponent(key)] = val;
|
|
2295
2124
|
} else {
|
|
2296
|
-
var to = key.indexOf(
|
|
2125
|
+
var to = key.indexOf(']', from);
|
|
2297
2126
|
var index = decodeURIComponent(key.substring(from + 1, to));
|
|
2298
2127
|
key = decodeURIComponent(key.substring(0, from));
|
|
2299
2128
|
if (!result[key]) result[key] = [];
|
|
@@ -2308,159 +2137,158 @@ func.common.getObjectFromUrl = function (
|
|
|
2308
2137
|
func.common.getContrast_color = function (hexcolor) {
|
|
2309
2138
|
function colourNameToHex(colour) {
|
|
2310
2139
|
var colours = {
|
|
2311
|
-
aliceblue:
|
|
2312
|
-
antiquewhite:
|
|
2313
|
-
aqua:
|
|
2314
|
-
aquamarine:
|
|
2315
|
-
azure:
|
|
2316
|
-
beige:
|
|
2317
|
-
bisque:
|
|
2318
|
-
black:
|
|
2319
|
-
blanchedalmond:
|
|
2320
|
-
blue:
|
|
2321
|
-
blueviolet:
|
|
2322
|
-
brown:
|
|
2323
|
-
burlywood:
|
|
2324
|
-
cadetblue:
|
|
2325
|
-
chartreuse:
|
|
2326
|
-
chocolate:
|
|
2327
|
-
coral:
|
|
2328
|
-
cornflowerblue:
|
|
2329
|
-
cornsilk:
|
|
2330
|
-
crimson:
|
|
2331
|
-
cyan:
|
|
2332
|
-
darkblue:
|
|
2333
|
-
darkcyan:
|
|
2334
|
-
darkgoldenrod:
|
|
2335
|
-
darkgray:
|
|
2336
|
-
darkgreen:
|
|
2337
|
-
darkkhaki:
|
|
2338
|
-
darkmagenta:
|
|
2339
|
-
darkolivegreen:
|
|
2340
|
-
darkorange:
|
|
2341
|
-
darkorchid:
|
|
2342
|
-
darkred:
|
|
2343
|
-
darksalmon:
|
|
2344
|
-
darkseagreen:
|
|
2345
|
-
darkslateblue:
|
|
2346
|
-
darkslategray:
|
|
2347
|
-
darkturquoise:
|
|
2348
|
-
darkviolet:
|
|
2349
|
-
deeppink:
|
|
2350
|
-
deepskyblue:
|
|
2351
|
-
dimgray:
|
|
2352
|
-
dodgerblue:
|
|
2353
|
-
firebrick:
|
|
2354
|
-
floralwhite:
|
|
2355
|
-
forestgreen:
|
|
2356
|
-
fuchsia:
|
|
2357
|
-
gainsboro:
|
|
2358
|
-
ghostwhite:
|
|
2359
|
-
gold:
|
|
2360
|
-
goldenrod:
|
|
2361
|
-
gray:
|
|
2362
|
-
green:
|
|
2363
|
-
greenyellow:
|
|
2364
|
-
honeydew:
|
|
2365
|
-
hotpink:
|
|
2366
|
-
|
|
2367
|
-
indigo:
|
|
2368
|
-
ivory:
|
|
2369
|
-
khaki:
|
|
2370
|
-
lavender:
|
|
2371
|
-
lavenderblush:
|
|
2372
|
-
lawngreen:
|
|
2373
|
-
lemonchiffon:
|
|
2374
|
-
lightblue:
|
|
2375
|
-
lightcoral:
|
|
2376
|
-
lightcyan:
|
|
2377
|
-
lightgoldenrodyellow:
|
|
2378
|
-
lightgrey:
|
|
2379
|
-
lightgreen:
|
|
2380
|
-
lightpink:
|
|
2381
|
-
lightsalmon:
|
|
2382
|
-
lightseagreen:
|
|
2383
|
-
lightskyblue:
|
|
2384
|
-
lightslategray:
|
|
2385
|
-
lightsteelblue:
|
|
2386
|
-
lightyellow:
|
|
2387
|
-
lime:
|
|
2388
|
-
limegreen:
|
|
2389
|
-
linen:
|
|
2390
|
-
magenta:
|
|
2391
|
-
maroon:
|
|
2392
|
-
mediumaquamarine:
|
|
2393
|
-
mediumblue:
|
|
2394
|
-
mediumorchid:
|
|
2395
|
-
mediumpurple:
|
|
2396
|
-
mediumseagreen:
|
|
2397
|
-
mediumslateblue:
|
|
2398
|
-
mediumspringgreen:
|
|
2399
|
-
mediumturquoise:
|
|
2400
|
-
mediumvioletred:
|
|
2401
|
-
midnightblue:
|
|
2402
|
-
mintcream:
|
|
2403
|
-
mistyrose:
|
|
2404
|
-
moccasin:
|
|
2405
|
-
navajowhite:
|
|
2406
|
-
navy:
|
|
2407
|
-
oldlace:
|
|
2408
|
-
olive:
|
|
2409
|
-
olivedrab:
|
|
2410
|
-
orange:
|
|
2411
|
-
orangered:
|
|
2412
|
-
orchid:
|
|
2413
|
-
palegoldenrod:
|
|
2414
|
-
palegreen:
|
|
2415
|
-
paleturquoise:
|
|
2416
|
-
palevioletred:
|
|
2417
|
-
papayawhip:
|
|
2418
|
-
peachpuff:
|
|
2419
|
-
peru:
|
|
2420
|
-
pink:
|
|
2421
|
-
plum:
|
|
2422
|
-
powderblue:
|
|
2423
|
-
purple:
|
|
2424
|
-
rebeccapurple:
|
|
2425
|
-
red:
|
|
2426
|
-
rosybrown:
|
|
2427
|
-
royalblue:
|
|
2428
|
-
saddlebrown:
|
|
2429
|
-
salmon:
|
|
2430
|
-
sandybrown:
|
|
2431
|
-
seagreen:
|
|
2432
|
-
seashell:
|
|
2433
|
-
sienna:
|
|
2434
|
-
silver:
|
|
2435
|
-
skyblue:
|
|
2436
|
-
slateblue:
|
|
2437
|
-
slategray:
|
|
2438
|
-
snow:
|
|
2439
|
-
springgreen:
|
|
2440
|
-
steelblue:
|
|
2441
|
-
tan:
|
|
2442
|
-
teal:
|
|
2443
|
-
thistle:
|
|
2444
|
-
tomato:
|
|
2445
|
-
turquoise:
|
|
2446
|
-
violet:
|
|
2447
|
-
wheat:
|
|
2448
|
-
white:
|
|
2449
|
-
whitesmoke:
|
|
2450
|
-
yellow:
|
|
2451
|
-
yellowgreen:
|
|
2140
|
+
aliceblue: '#f0f8ff',
|
|
2141
|
+
antiquewhite: '#faebd7',
|
|
2142
|
+
aqua: '#00ffff',
|
|
2143
|
+
aquamarine: '#7fffd4',
|
|
2144
|
+
azure: '#f0ffff',
|
|
2145
|
+
beige: '#f5f5dc',
|
|
2146
|
+
bisque: '#ffe4c4',
|
|
2147
|
+
black: '#000000',
|
|
2148
|
+
blanchedalmond: '#ffebcd',
|
|
2149
|
+
blue: '#0000ff',
|
|
2150
|
+
blueviolet: '#8a2be2',
|
|
2151
|
+
brown: '#a52a2a',
|
|
2152
|
+
burlywood: '#deb887',
|
|
2153
|
+
cadetblue: '#5f9ea0',
|
|
2154
|
+
chartreuse: '#7fff00',
|
|
2155
|
+
chocolate: '#d2691e',
|
|
2156
|
+
coral: '#ff7f50',
|
|
2157
|
+
cornflowerblue: '#6495ed',
|
|
2158
|
+
cornsilk: '#fff8dc',
|
|
2159
|
+
crimson: '#dc143c',
|
|
2160
|
+
cyan: '#00ffff',
|
|
2161
|
+
darkblue: '#00008b',
|
|
2162
|
+
darkcyan: '#008b8b',
|
|
2163
|
+
darkgoldenrod: '#b8860b',
|
|
2164
|
+
darkgray: '#a9a9a9',
|
|
2165
|
+
darkgreen: '#006400',
|
|
2166
|
+
darkkhaki: '#bdb76b',
|
|
2167
|
+
darkmagenta: '#8b008b',
|
|
2168
|
+
darkolivegreen: '#556b2f',
|
|
2169
|
+
darkorange: '#ff8c00',
|
|
2170
|
+
darkorchid: '#9932cc',
|
|
2171
|
+
darkred: '#8b0000',
|
|
2172
|
+
darksalmon: '#e9967a',
|
|
2173
|
+
darkseagreen: '#8fbc8f',
|
|
2174
|
+
darkslateblue: '#483d8b',
|
|
2175
|
+
darkslategray: '#2f4f4f',
|
|
2176
|
+
darkturquoise: '#00ced1',
|
|
2177
|
+
darkviolet: '#9400d3',
|
|
2178
|
+
deeppink: '#ff1493',
|
|
2179
|
+
deepskyblue: '#00bfff',
|
|
2180
|
+
dimgray: '#696969',
|
|
2181
|
+
dodgerblue: '#1e90ff',
|
|
2182
|
+
firebrick: '#b22222',
|
|
2183
|
+
floralwhite: '#fffaf0',
|
|
2184
|
+
forestgreen: '#228b22',
|
|
2185
|
+
fuchsia: '#ff00ff',
|
|
2186
|
+
gainsboro: '#dcdcdc',
|
|
2187
|
+
ghostwhite: '#f8f8ff',
|
|
2188
|
+
gold: '#ffd700',
|
|
2189
|
+
goldenrod: '#daa520',
|
|
2190
|
+
gray: '#808080',
|
|
2191
|
+
green: '#008000',
|
|
2192
|
+
greenyellow: '#adff2f',
|
|
2193
|
+
honeydew: '#f0fff0',
|
|
2194
|
+
hotpink: '#ff69b4',
|
|
2195
|
+
'indianred ': '#cd5c5c',
|
|
2196
|
+
indigo: '#4b0082',
|
|
2197
|
+
ivory: '#fffff0',
|
|
2198
|
+
khaki: '#f0e68c',
|
|
2199
|
+
lavender: '#e6e6fa',
|
|
2200
|
+
lavenderblush: '#fff0f5',
|
|
2201
|
+
lawngreen: '#7cfc00',
|
|
2202
|
+
lemonchiffon: '#fffacd',
|
|
2203
|
+
lightblue: '#add8e6',
|
|
2204
|
+
lightcoral: '#f08080',
|
|
2205
|
+
lightcyan: '#e0ffff',
|
|
2206
|
+
lightgoldenrodyellow: '#fafad2',
|
|
2207
|
+
lightgrey: '#d3d3d3',
|
|
2208
|
+
lightgreen: '#90ee90',
|
|
2209
|
+
lightpink: '#ffb6c1',
|
|
2210
|
+
lightsalmon: '#ffa07a',
|
|
2211
|
+
lightseagreen: '#20b2aa',
|
|
2212
|
+
lightskyblue: '#87cefa',
|
|
2213
|
+
lightslategray: '#778899',
|
|
2214
|
+
lightsteelblue: '#b0c4de',
|
|
2215
|
+
lightyellow: '#ffffe0',
|
|
2216
|
+
lime: '#00ff00',
|
|
2217
|
+
limegreen: '#32cd32',
|
|
2218
|
+
linen: '#faf0e6',
|
|
2219
|
+
magenta: '#ff00ff',
|
|
2220
|
+
maroon: '#800000',
|
|
2221
|
+
mediumaquamarine: '#66cdaa',
|
|
2222
|
+
mediumblue: '#0000cd',
|
|
2223
|
+
mediumorchid: '#ba55d3',
|
|
2224
|
+
mediumpurple: '#9370d8',
|
|
2225
|
+
mediumseagreen: '#3cb371',
|
|
2226
|
+
mediumslateblue: '#7b68ee',
|
|
2227
|
+
mediumspringgreen: '#00fa9a',
|
|
2228
|
+
mediumturquoise: '#48d1cc',
|
|
2229
|
+
mediumvioletred: '#c71585',
|
|
2230
|
+
midnightblue: '#191970',
|
|
2231
|
+
mintcream: '#f5fffa',
|
|
2232
|
+
mistyrose: '#ffe4e1',
|
|
2233
|
+
moccasin: '#ffe4b5',
|
|
2234
|
+
navajowhite: '#ffdead',
|
|
2235
|
+
navy: '#000080',
|
|
2236
|
+
oldlace: '#fdf5e6',
|
|
2237
|
+
olive: '#808000',
|
|
2238
|
+
olivedrab: '#6b8e23',
|
|
2239
|
+
orange: '#ffa500',
|
|
2240
|
+
orangered: '#ff4500',
|
|
2241
|
+
orchid: '#da70d6',
|
|
2242
|
+
palegoldenrod: '#eee8aa',
|
|
2243
|
+
palegreen: '#98fb98',
|
|
2244
|
+
paleturquoise: '#afeeee',
|
|
2245
|
+
palevioletred: '#d87093',
|
|
2246
|
+
papayawhip: '#ffefd5',
|
|
2247
|
+
peachpuff: '#ffdab9',
|
|
2248
|
+
peru: '#cd853f',
|
|
2249
|
+
pink: '#ffc0cb',
|
|
2250
|
+
plum: '#dda0dd',
|
|
2251
|
+
powderblue: '#b0e0e6',
|
|
2252
|
+
purple: '#800080',
|
|
2253
|
+
rebeccapurple: '#663399',
|
|
2254
|
+
red: '#ff0000',
|
|
2255
|
+
rosybrown: '#bc8f8f',
|
|
2256
|
+
royalblue: '#4169e1',
|
|
2257
|
+
saddlebrown: '#8b4513',
|
|
2258
|
+
salmon: '#fa8072',
|
|
2259
|
+
sandybrown: '#f4a460',
|
|
2260
|
+
seagreen: '#2e8b57',
|
|
2261
|
+
seashell: '#fff5ee',
|
|
2262
|
+
sienna: '#a0522d',
|
|
2263
|
+
silver: '#c0c0c0',
|
|
2264
|
+
skyblue: '#87ceeb',
|
|
2265
|
+
slateblue: '#6a5acd',
|
|
2266
|
+
slategray: '#708090',
|
|
2267
|
+
snow: '#fffafa',
|
|
2268
|
+
springgreen: '#00ff7f',
|
|
2269
|
+
steelblue: '#4682b4',
|
|
2270
|
+
tan: '#d2b48c',
|
|
2271
|
+
teal: '#008080',
|
|
2272
|
+
thistle: '#d8bfd8',
|
|
2273
|
+
tomato: '#ff6347',
|
|
2274
|
+
turquoise: '#40e0d0',
|
|
2275
|
+
violet: '#ee82ee',
|
|
2276
|
+
wheat: '#f5deb3',
|
|
2277
|
+
white: '#ffffff',
|
|
2278
|
+
whitesmoke: '#f5f5f5',
|
|
2279
|
+
yellow: '#ffff00',
|
|
2280
|
+
yellowgreen: '#9acd32',
|
|
2452
2281
|
};
|
|
2453
2282
|
|
|
2454
|
-
if (typeof colours[colour.toLowerCase()] !=
|
|
2455
|
-
return colours[colour.toLowerCase()];
|
|
2283
|
+
if (typeof colours[colour.toLowerCase()] != 'undefined') return colours[colour.toLowerCase()];
|
|
2456
2284
|
|
|
2457
2285
|
return false;
|
|
2458
2286
|
}
|
|
2459
|
-
if (!hexcolor.includes(
|
|
2287
|
+
if (!hexcolor.includes('#')) {
|
|
2460
2288
|
hexcolor = colourNameToHex(hexcolor);
|
|
2461
2289
|
}
|
|
2462
2290
|
// If a leading # is provided, remove it
|
|
2463
|
-
if (hexcolor.slice(0, 1) ===
|
|
2291
|
+
if (hexcolor.slice(0, 1) === '#') {
|
|
2464
2292
|
hexcolor = hexcolor.slice(1);
|
|
2465
2293
|
}
|
|
2466
2294
|
|
|
@@ -2473,51 +2301,30 @@ func.common.getContrast_color = function (hexcolor) {
|
|
|
2473
2301
|
var yiq = (r * 299 + g * 587 + b * 114) / 1000;
|
|
2474
2302
|
|
|
2475
2303
|
// Check contrast
|
|
2476
|
-
return yiq >= 128 ?
|
|
2304
|
+
return yiq >= 128 ? 'black' : 'white';
|
|
2477
2305
|
};
|
|
2478
2306
|
|
|
2479
2307
|
func.common.get_url = function (SESSION_ID, method, path) {
|
|
2480
|
-
return `https://${SESSION_OBJ[SESSION_ID].domain}/${method}${path ?
|
|
2481
|
-
}`;
|
|
2308
|
+
return `https://${SESSION_OBJ[SESSION_ID].domain}/${method}${path ? '/' + path : '/'}`;
|
|
2482
2309
|
};
|
|
2483
2310
|
|
|
2484
2311
|
var UI_FRAMEWORK_INSTALLED = null;
|
|
2485
2312
|
var UI_FRAMEWORK_PLUGIN = {};
|
|
2486
2313
|
|
|
2487
|
-
func.common.get_cast_val = async function (
|
|
2488
|
-
SESSION_ID,
|
|
2489
|
-
source,
|
|
2490
|
-
attributeP,
|
|
2491
|
-
typeP,
|
|
2492
|
-
valP,
|
|
2493
|
-
errorP
|
|
2494
|
-
) {
|
|
2314
|
+
func.common.get_cast_val = async function (SESSION_ID, source, attributeP, typeP, valP, errorP) {
|
|
2495
2315
|
const report_conversion_error = function (res) {
|
|
2496
2316
|
if (errorP) {
|
|
2497
|
-
return func.utils.debug_report(
|
|
2498
|
-
SESSION_ID,
|
|
2499
|
-
_.capitalize(source),
|
|
2500
|
-
errorP,
|
|
2501
|
-
"W"
|
|
2502
|
-
);
|
|
2317
|
+
return func.utils.debug_report(SESSION_ID, _.capitalize(source), errorP, 'W');
|
|
2503
2318
|
}
|
|
2504
2319
|
var msg = `error converting ${attributeP} from ${valP} to ${typeP}`;
|
|
2505
|
-
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg,
|
|
2320
|
+
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg, 'E');
|
|
2506
2321
|
};
|
|
2507
2322
|
const report_conversion_warn = function (msg) {
|
|
2508
2323
|
var msg = `type mismatch auto conversion made to ${attributeP} from value ${valP} to ${typeP}`;
|
|
2509
|
-
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg,
|
|
2324
|
+
func.utils.debug_report(SESSION_ID, _.capitalize(source), msg, 'W');
|
|
2510
2325
|
};
|
|
2511
|
-
const module = await func.common.get_module(
|
|
2512
|
-
|
|
2513
|
-
`xuda-get-cast-util-module.mjs`
|
|
2514
|
-
);
|
|
2515
|
-
return module.cast(
|
|
2516
|
-
typeP,
|
|
2517
|
-
valP,
|
|
2518
|
-
report_conversion_error,
|
|
2519
|
-
report_conversion_warn
|
|
2520
|
-
);
|
|
2326
|
+
const module = await func.common.get_module(SESSION_ID, `xuda-get-cast-util-module.mjs`);
|
|
2327
|
+
return module.cast(typeP, valP, report_conversion_error, report_conversion_warn);
|
|
2521
2328
|
};
|
|
2522
2329
|
var WEB_WORKER = {};
|
|
2523
2330
|
var WEB_WORKER_CALLBACK_QUEUE = {};
|
|
@@ -2539,9 +2346,7 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
2539
2346
|
const module_ret = await import(src);
|
|
2540
2347
|
var params = get_params();
|
|
2541
2348
|
|
|
2542
|
-
const ret = module_ret.XudaModule
|
|
2543
|
-
? new module_ret.XudaModule(params)
|
|
2544
|
-
: await invoke_init_module(module_ret, params);
|
|
2349
|
+
const ret = module_ret.XudaModule ? new module_ret.XudaModule(params) : await invoke_init_module(module_ret, params);
|
|
2545
2350
|
|
|
2546
2351
|
return ret;
|
|
2547
2352
|
};
|
|
@@ -2558,13 +2363,11 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
2558
2363
|
_,
|
|
2559
2364
|
...paramsP,
|
|
2560
2365
|
};
|
|
2561
|
-
if (typeof IS_PROCESS_SERVER !==
|
|
2562
|
-
params.IS_PROCESS_SERVER = IS_PROCESS_SERVER;
|
|
2366
|
+
if (typeof IS_PROCESS_SERVER !== 'undefined') params.IS_PROCESS_SERVER = IS_PROCESS_SERVER;
|
|
2563
2367
|
|
|
2564
|
-
if (typeof IS_API_SERVER !==
|
|
2565
|
-
params.IS_API_SERVER = IS_API_SERVER;
|
|
2368
|
+
if (typeof IS_API_SERVER !== 'undefined') params.IS_API_SERVER = IS_API_SERVER;
|
|
2566
2369
|
|
|
2567
|
-
if (typeof IS_DOCKER !==
|
|
2370
|
+
if (typeof IS_DOCKER !== 'undefined') params.IS_DOCKER = IS_DOCKER;
|
|
2568
2371
|
|
|
2569
2372
|
return params;
|
|
2570
2373
|
};
|
|
@@ -2575,73 +2378,29 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
2575
2378
|
return module_ret;
|
|
2576
2379
|
};
|
|
2577
2380
|
const _session = SESSION_OBJ[SESSION_ID];
|
|
2578
|
-
if (_session.worker_type ===
|
|
2579
|
-
ret = await get_ret(
|
|
2381
|
+
if (_session.worker_type === 'Dev') {
|
|
2382
|
+
ret = await get_ret('./modules/' + module);
|
|
2580
2383
|
|
|
2581
2384
|
return ret;
|
|
2582
2385
|
}
|
|
2583
|
-
if (_session.worker_type ===
|
|
2584
|
-
if (
|
|
2585
|
-
|
|
2586
|
-
typeof IS_PROCESS_SERVER !== "undefined"
|
|
2587
|
-
) {
|
|
2588
|
-
ret = await get_ret(
|
|
2589
|
-
func.utils.get_resource_filename(
|
|
2590
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
2591
|
-
? ""
|
|
2592
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
2593
|
-
`${_conf.xuda_home}root/dist/runtime/js/modules/` + module
|
|
2594
|
-
)
|
|
2595
|
-
);
|
|
2386
|
+
if (_session.worker_type === 'Debug') {
|
|
2387
|
+
if (typeof IS_DOCKER !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
2388
|
+
ret = await get_ret(func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + module));
|
|
2596
2389
|
} else {
|
|
2597
|
-
ret = await get_ret(
|
|
2598
|
-
func.common.get_url(
|
|
2599
|
-
SESSION_ID,
|
|
2600
|
-
"dist",
|
|
2601
|
-
func.utils.get_resource_filename(
|
|
2602
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
2603
|
-
? ""
|
|
2604
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
2605
|
-
"runtime/js/modules/" + module
|
|
2606
|
-
)
|
|
2607
|
-
)
|
|
2608
|
-
);
|
|
2390
|
+
ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/modules/' + module)));
|
|
2609
2391
|
}
|
|
2610
2392
|
|
|
2611
2393
|
return ret;
|
|
2612
2394
|
}
|
|
2613
2395
|
|
|
2614
2396
|
const rep = function () {
|
|
2615
|
-
return _.endsWith(module,
|
|
2616
|
-
? module.replace(".js", ".min.js")
|
|
2617
|
-
: module.replace(".mjs", ".min.mjs");
|
|
2397
|
+
return _.endsWith(module, '.js') ? module.replace('.js', '.min.js') : module.replace('.mjs', '.min.mjs');
|
|
2618
2398
|
};
|
|
2619
2399
|
|
|
2620
|
-
if (
|
|
2621
|
-
|
|
2622
|
-
typeof IS_PROCESS_SERVER !== "undefined"
|
|
2623
|
-
) {
|
|
2624
|
-
ret = await get_ret(
|
|
2625
|
-
func.utils.get_resource_filename(
|
|
2626
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
2627
|
-
? ""
|
|
2628
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
2629
|
-
`${_conf.xuda_home}root/dist/runtime/js/modules/` + rep()
|
|
2630
|
-
)
|
|
2631
|
-
);
|
|
2400
|
+
if (typeof IS_DOCKER !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
|
|
2401
|
+
ret = await get_ret(func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + rep()));
|
|
2632
2402
|
} else {
|
|
2633
|
-
ret = await get_ret(
|
|
2634
|
-
func.common.get_url(
|
|
2635
|
-
SESSION_ID,
|
|
2636
|
-
"dist",
|
|
2637
|
-
func.utils.get_resource_filename(
|
|
2638
|
-
SESSION_OBJ[SESSION_ID].engine_mode === "live_preview"
|
|
2639
|
-
? ""
|
|
2640
|
-
: SESSION_OBJ[SESSION_ID]?.opt?.app_build_id,
|
|
2641
|
-
"runtime/js/modules/" + rep()
|
|
2642
|
-
)
|
|
2643
|
-
)
|
|
2644
|
-
);
|
|
2403
|
+
ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/modules/' + rep())));
|
|
2645
2404
|
}
|
|
2646
2405
|
|
|
2647
2406
|
return ret;
|
|
@@ -2650,209 +2409,160 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
|
|
|
2650
2409
|
func.api = {};
|
|
2651
2410
|
func.api.set_field_value = async function (field_id, value, avoid_refresh) {
|
|
2652
2411
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2653
|
-
const api_utils = await func.common.get_module(
|
|
2412
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2413
|
+
func,
|
|
2414
|
+
glb,
|
|
2415
|
+
SESSION_OBJ,
|
|
2654
2416
|
SESSION_ID,
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
glb,
|
|
2659
|
-
SESSION_OBJ,
|
|
2660
|
-
SESSION_ID,
|
|
2661
|
-
APP_OBJ,
|
|
2662
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2663
|
-
}
|
|
2664
|
-
);
|
|
2417
|
+
APP_OBJ,
|
|
2418
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2419
|
+
});
|
|
2665
2420
|
|
|
2666
2421
|
return await api_utils.set_field_value(field_id, value, avoid_refresh);
|
|
2667
2422
|
};
|
|
2668
2423
|
func.api.get_field_value = async function (field_id) {
|
|
2669
2424
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2670
|
-
const api_utils = await func.common.get_module(
|
|
2425
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2426
|
+
func,
|
|
2427
|
+
glb,
|
|
2428
|
+
SESSION_OBJ,
|
|
2671
2429
|
SESSION_ID,
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
glb,
|
|
2676
|
-
SESSION_OBJ,
|
|
2677
|
-
SESSION_ID,
|
|
2678
|
-
APP_OBJ,
|
|
2679
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2680
|
-
}
|
|
2681
|
-
);
|
|
2430
|
+
APP_OBJ,
|
|
2431
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2432
|
+
});
|
|
2682
2433
|
|
|
2683
2434
|
return await api_utils.get_field_value(field_id);
|
|
2684
2435
|
};
|
|
2685
2436
|
func.api.invoke_event = async function (event_id) {
|
|
2686
2437
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2687
|
-
const api_utils = await func.common.get_module(
|
|
2438
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2439
|
+
func,
|
|
2440
|
+
glb,
|
|
2441
|
+
SESSION_OBJ,
|
|
2688
2442
|
SESSION_ID,
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
glb,
|
|
2693
|
-
SESSION_OBJ,
|
|
2694
|
-
SESSION_ID,
|
|
2695
|
-
APP_OBJ,
|
|
2696
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2697
|
-
}
|
|
2698
|
-
);
|
|
2443
|
+
APP_OBJ,
|
|
2444
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2445
|
+
});
|
|
2699
2446
|
|
|
2700
2447
|
return await api_utils.invoke_event(event_id);
|
|
2701
2448
|
};
|
|
2702
2449
|
func.api.call_project_api = async function (prog_id, params) {
|
|
2703
2450
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2704
|
-
const api_utils = await func.common.get_module(
|
|
2451
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2452
|
+
func,
|
|
2453
|
+
glb,
|
|
2454
|
+
SESSION_OBJ,
|
|
2705
2455
|
SESSION_ID,
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
glb,
|
|
2710
|
-
SESSION_OBJ,
|
|
2711
|
-
SESSION_ID,
|
|
2712
|
-
APP_OBJ,
|
|
2713
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2714
|
-
}
|
|
2715
|
-
);
|
|
2456
|
+
APP_OBJ,
|
|
2457
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2458
|
+
});
|
|
2716
2459
|
|
|
2717
2460
|
return await api_utils.call_project_api(prog_id, params, null);
|
|
2718
2461
|
};
|
|
2719
2462
|
func.api.call_system_api = async function (api_method, payload) {
|
|
2720
2463
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2721
|
-
const api_utils = await func.common.get_module(
|
|
2464
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2465
|
+
func,
|
|
2466
|
+
glb,
|
|
2467
|
+
SESSION_OBJ,
|
|
2722
2468
|
SESSION_ID,
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
glb,
|
|
2727
|
-
SESSION_OBJ,
|
|
2728
|
-
SESSION_ID,
|
|
2729
|
-
APP_OBJ,
|
|
2730
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2731
|
-
}
|
|
2732
|
-
);
|
|
2469
|
+
APP_OBJ,
|
|
2470
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2471
|
+
});
|
|
2733
2472
|
|
|
2734
2473
|
return await api_utils.call_system_api(api_method, payload, null);
|
|
2735
2474
|
};
|
|
2736
2475
|
|
|
2737
2476
|
func.api.dbs_create = async function (table_id, data, cb) {
|
|
2738
2477
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2739
|
-
const api_utils = await func.common.get_module(
|
|
2478
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2479
|
+
func,
|
|
2480
|
+
glb,
|
|
2481
|
+
SESSION_OBJ,
|
|
2740
2482
|
SESSION_ID,
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
glb,
|
|
2745
|
-
SESSION_OBJ,
|
|
2746
|
-
SESSION_ID,
|
|
2747
|
-
APP_OBJ,
|
|
2748
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2749
|
-
}
|
|
2750
|
-
);
|
|
2483
|
+
APP_OBJ,
|
|
2484
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2485
|
+
});
|
|
2751
2486
|
|
|
2752
2487
|
return await api_utils.dbs_create(table_id, row_id, data, cb);
|
|
2753
2488
|
};
|
|
2754
2489
|
func.api.dbs_read = async function (table_id, selector, fields, sort, limit, skip, cb) {
|
|
2755
2490
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2756
|
-
const api_utils = await func.common.get_module(
|
|
2491
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2492
|
+
func,
|
|
2493
|
+
glb,
|
|
2494
|
+
SESSION_OBJ,
|
|
2757
2495
|
SESSION_ID,
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
glb,
|
|
2762
|
-
SESSION_OBJ,
|
|
2763
|
-
SESSION_ID,
|
|
2764
|
-
APP_OBJ,
|
|
2765
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2766
|
-
}
|
|
2767
|
-
);
|
|
2496
|
+
APP_OBJ,
|
|
2497
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2498
|
+
});
|
|
2768
2499
|
|
|
2769
2500
|
return await api_utils.dbs_read(table_id, selector, fields, sort, limit, skip, cb);
|
|
2770
2501
|
};
|
|
2771
2502
|
func.api.dbs_update = async function (table_id, row_id, data) {
|
|
2772
2503
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2773
|
-
const api_utils = await func.common.get_module(
|
|
2504
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2505
|
+
func,
|
|
2506
|
+
glb,
|
|
2507
|
+
SESSION_OBJ,
|
|
2774
2508
|
SESSION_ID,
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
glb,
|
|
2779
|
-
SESSION_OBJ,
|
|
2780
|
-
SESSION_ID,
|
|
2781
|
-
APP_OBJ,
|
|
2782
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2783
|
-
}
|
|
2784
|
-
);
|
|
2509
|
+
APP_OBJ,
|
|
2510
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2511
|
+
});
|
|
2785
2512
|
|
|
2786
2513
|
return await api_utils.dbs_update(table_id, row_id, data, cb);
|
|
2787
2514
|
};
|
|
2788
2515
|
func.api.dbs_delete = async function (table_id, row_id, cb) {
|
|
2789
2516
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2790
|
-
const api_utils = await func.common.get_module(
|
|
2517
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2518
|
+
func,
|
|
2519
|
+
glb,
|
|
2520
|
+
SESSION_OBJ,
|
|
2791
2521
|
SESSION_ID,
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
glb,
|
|
2796
|
-
SESSION_OBJ,
|
|
2797
|
-
SESSION_ID,
|
|
2798
|
-
APP_OBJ,
|
|
2799
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2800
|
-
}
|
|
2801
|
-
);
|
|
2522
|
+
APP_OBJ,
|
|
2523
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2524
|
+
});
|
|
2802
2525
|
|
|
2803
2526
|
return await api_utils.dbs_delete(table_id, row_id, cb);
|
|
2804
2527
|
};
|
|
2805
2528
|
|
|
2806
2529
|
func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
2807
2530
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2808
|
-
const api_utils = await func.common.get_module(
|
|
2531
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2532
|
+
func,
|
|
2533
|
+
glb,
|
|
2534
|
+
SESSION_OBJ,
|
|
2809
2535
|
SESSION_ID,
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
glb,
|
|
2814
|
-
SESSION_OBJ,
|
|
2815
|
-
SESSION_ID,
|
|
2816
|
-
APP_OBJ,
|
|
2817
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2818
|
-
}
|
|
2819
|
-
);
|
|
2536
|
+
APP_OBJ,
|
|
2537
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2538
|
+
});
|
|
2820
2539
|
|
|
2821
2540
|
return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
2822
2541
|
};
|
|
2823
2542
|
|
|
2824
2543
|
func.api.call_javascript = async function (prog_id, params, evaluate) {
|
|
2825
2544
|
const SESSION_ID = Object.keys(SESSION_OBJ)[0];
|
|
2826
|
-
const api_utils = await func.common.get_module(
|
|
2545
|
+
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
2546
|
+
func,
|
|
2547
|
+
glb,
|
|
2548
|
+
SESSION_OBJ,
|
|
2827
2549
|
SESSION_ID,
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
glb,
|
|
2832
|
-
SESSION_OBJ,
|
|
2833
|
-
SESSION_ID,
|
|
2834
|
-
APP_OBJ,
|
|
2835
|
-
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2836
|
-
}
|
|
2837
|
-
);
|
|
2550
|
+
APP_OBJ,
|
|
2551
|
+
dsSession: func.utils.get_last_datasource_no(SESSION_ID),
|
|
2552
|
+
});
|
|
2838
2553
|
|
|
2839
2554
|
return await api_utils.call_javascript(prog_id, params, evaluate);
|
|
2840
2555
|
};
|
|
2841
2556
|
|
|
2842
2557
|
glb.rpi_request_queue_num = 0;
|
|
2843
|
-
func.common.perform_rpi_request = async function (
|
|
2844
|
-
SESSION_ID,
|
|
2845
|
-
serviceP,
|
|
2846
|
-
opt = {},
|
|
2847
|
-
data
|
|
2848
|
-
) {
|
|
2558
|
+
func.common.perform_rpi_request = async function (SESSION_ID, serviceP, opt = {}, data) {
|
|
2849
2559
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
2850
2560
|
var _data_system = _session?.DS_GLB?.[0]?.data_system;
|
|
2851
2561
|
|
|
2852
2562
|
const set_ajax = async function (stat) {
|
|
2853
2563
|
var datasource_changes = {
|
|
2854
2564
|
[0]: {
|
|
2855
|
-
[
|
|
2565
|
+
['data_system']: { SYS_GLOBAL_BOL_AJAX_BUSY: stat },
|
|
2856
2566
|
},
|
|
2857
2567
|
};
|
|
2858
2568
|
await func.datasource.update(SESSION_ID, datasource_changes);
|
|
@@ -2861,12 +2571,7 @@ func.common.perform_rpi_request = async function (
|
|
|
2861
2571
|
// _data_system.SYS_GLOBAL_BOL_AJAX_BUSY = 1;
|
|
2862
2572
|
await set_ajax(1);
|
|
2863
2573
|
if (!_data_system.SYS_GLOBAL_BOL_CONNECTED) {
|
|
2864
|
-
func.utils.alerts.toast(
|
|
2865
|
-
SESSION_ID,
|
|
2866
|
-
"Server connection error",
|
|
2867
|
-
"You are not connected to the server, so your request cannot be processed.",
|
|
2868
|
-
"error"
|
|
2869
|
-
);
|
|
2574
|
+
func.utils.alerts.toast(SESSION_ID, 'Server connection error', 'You are not connected to the server, so your request cannot be processed.', 'error');
|
|
2870
2575
|
return { code: 88, data: {} };
|
|
2871
2576
|
}
|
|
2872
2577
|
}
|
|
@@ -2880,8 +2585,8 @@ func.common.perform_rpi_request = async function (
|
|
|
2880
2585
|
const timeoutPromise = new Promise((_, reject) =>
|
|
2881
2586
|
setTimeout(() => {
|
|
2882
2587
|
controller.abort();
|
|
2883
|
-
reject(new Error(
|
|
2884
|
-
}, timeout)
|
|
2588
|
+
reject(new Error('Request timed out'));
|
|
2589
|
+
}, timeout),
|
|
2885
2590
|
);
|
|
2886
2591
|
|
|
2887
2592
|
const fetchPromise = fetch(url, { ...options, signal });
|
|
@@ -2889,27 +2594,24 @@ func.common.perform_rpi_request = async function (
|
|
|
2889
2594
|
return Promise.race([fetchPromise, timeoutPromise]);
|
|
2890
2595
|
};
|
|
2891
2596
|
|
|
2892
|
-
var url = func.common.get_url(SESSION_ID,
|
|
2597
|
+
var url = func.common.get_url(SESSION_ID, 'rpi', '');
|
|
2893
2598
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
2894
2599
|
const app_id = _session.app_id;
|
|
2895
2600
|
|
|
2896
|
-
if (
|
|
2897
|
-
|
|
2898
|
-
_session.rpi_http_methods?.includes(serviceP)
|
|
2899
|
-
) {
|
|
2900
|
-
url = "https://" + _session.host + "/rpi/";
|
|
2601
|
+
if (APP_OBJ[app_id].is_deployment && _session.rpi_http_methods?.includes(serviceP)) {
|
|
2602
|
+
url = 'https://' + _session.host + '/rpi/';
|
|
2901
2603
|
}
|
|
2902
2604
|
|
|
2903
2605
|
url += serviceP;
|
|
2904
2606
|
|
|
2905
2607
|
try {
|
|
2906
2608
|
const response = await fetchWithTimeout(url, {
|
|
2907
|
-
method: opt.type ? opt.type :
|
|
2609
|
+
method: opt.type ? opt.type : 'POST',
|
|
2908
2610
|
headers: {
|
|
2909
|
-
Accept:
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2611
|
+
Accept: 'application/json',
|
|
2612
|
+
'Content-Type': 'application/json',
|
|
2613
|
+
'xu-gtp-token': _session.gtp_token,
|
|
2614
|
+
'xu-app-token': _session.app_token,
|
|
2913
2615
|
},
|
|
2914
2616
|
body: JSON.stringify(data),
|
|
2915
2617
|
});
|
|
@@ -2922,10 +2624,7 @@ func.common.perform_rpi_request = async function (
|
|
|
2922
2624
|
} catch (err) {
|
|
2923
2625
|
console.error(err);
|
|
2924
2626
|
if (err === 503) {
|
|
2925
|
-
_this.func.UI.utils.progressScreen.show(
|
|
2926
|
-
SESSION_ID,
|
|
2927
|
-
`Error code ${err}, reloading in 5 sec`
|
|
2928
|
-
);
|
|
2627
|
+
_this.func.UI.utils.progressScreen.show(SESSION_ID, `Error code ${err}, reloading in 5 sec`);
|
|
2929
2628
|
setTimeout(async () => {
|
|
2930
2629
|
await func.index.delete_pouch(SESSION_ID);
|
|
2931
2630
|
location.reload();
|
|
@@ -2936,23 +2635,19 @@ func.common.perform_rpi_request = async function (
|
|
|
2936
2635
|
};
|
|
2937
2636
|
|
|
2938
2637
|
try {
|
|
2939
|
-
if (_session.engine_mode ===
|
|
2940
|
-
throw new Error(
|
|
2638
|
+
if (_session.engine_mode === 'live_preview') {
|
|
2639
|
+
throw new Error('live_preview');
|
|
2941
2640
|
}
|
|
2942
2641
|
|
|
2943
2642
|
if (SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(serviceP)) {
|
|
2944
|
-
const ret = await func.common.get_data_from_websocket(
|
|
2945
|
-
SESSION_ID,
|
|
2946
|
-
serviceP,
|
|
2947
|
-
data
|
|
2948
|
-
);
|
|
2643
|
+
const ret = await func.common.get_data_from_websocket(SESSION_ID, serviceP, data);
|
|
2949
2644
|
if (_data_system) {
|
|
2950
2645
|
// _data_system.SYS_GLOBAL_BOL_AJAX_BUSY = 0;
|
|
2951
2646
|
await set_ajax(0);
|
|
2952
2647
|
}
|
|
2953
2648
|
return ret;
|
|
2954
2649
|
} else {
|
|
2955
|
-
throw new Error(
|
|
2650
|
+
throw new Error('method not found in rpi_http_methods');
|
|
2956
2651
|
}
|
|
2957
2652
|
} catch (err) {
|
|
2958
2653
|
const ret = await http();
|
|
@@ -2964,11 +2659,7 @@ func.common.perform_rpi_request = async function (
|
|
|
2964
2659
|
}
|
|
2965
2660
|
};
|
|
2966
2661
|
|
|
2967
|
-
func.common.get_data_from_websocket = async function (
|
|
2968
|
-
SESSION_ID,
|
|
2969
|
-
serviceP,
|
|
2970
|
-
data
|
|
2971
|
-
) {
|
|
2662
|
+
func.common.get_data_from_websocket = async function (SESSION_ID, serviceP, data) {
|
|
2972
2663
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
2973
2664
|
return new Promise(function (resolve, reject) {
|
|
2974
2665
|
const dbs_calls = function () {
|
|
@@ -2979,60 +2670,46 @@ func.common.get_data_from_websocket = async function (
|
|
|
2979
2670
|
websocket_queue_num: glb.websocket_queue_num,
|
|
2980
2671
|
};
|
|
2981
2672
|
if (glb.IS_WORKER) {
|
|
2982
|
-
func.utils.post_back_to_client(
|
|
2983
|
-
SESSION_ID,
|
|
2984
|
-
"get_dbs_data_from_websocket",
|
|
2985
|
-
_session.worker_id,
|
|
2986
|
-
obj
|
|
2987
|
-
);
|
|
2673
|
+
func.utils.post_back_to_client(SESSION_ID, 'get_dbs_data_from_websocket', _session.worker_id, obj);
|
|
2988
2674
|
|
|
2989
|
-
self.addEventListener(
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
resolve(event.detail.data);
|
|
2993
|
-
}
|
|
2994
|
-
);
|
|
2675
|
+
self.addEventListener('get_ws_data_worker_' + glb.websocket_queue_num, (event) => {
|
|
2676
|
+
resolve(event.detail.data);
|
|
2677
|
+
});
|
|
2995
2678
|
// throw new Error("not ready yet");
|
|
2996
2679
|
} else {
|
|
2997
2680
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
2998
|
-
RUNTIME_SERVER_WEBSOCKET.emit(
|
|
2999
|
-
$(
|
|
3000
|
-
|
|
3001
|
-
(
|
|
3002
|
-
|
|
3003
|
-
$("body").off(
|
|
3004
|
-
"get_ws_data_response_" + data.e.websocket_queue_num
|
|
3005
|
-
);
|
|
3006
|
-
}
|
|
3007
|
-
);
|
|
2681
|
+
RUNTIME_SERVER_WEBSOCKET.emit('message', obj);
|
|
2682
|
+
$('body').on('get_ws_data_response_' + glb.websocket_queue_num, (e, data) => {
|
|
2683
|
+
resolve(data.data);
|
|
2684
|
+
$('body').off('get_ws_data_response_' + data.e.websocket_queue_num);
|
|
2685
|
+
});
|
|
3008
2686
|
} else {
|
|
3009
|
-
throw new Error(
|
|
2687
|
+
throw new Error('fail to fetch from ws websocket inactive');
|
|
3010
2688
|
}
|
|
3011
2689
|
}
|
|
3012
2690
|
};
|
|
3013
2691
|
const heartbeat = function () {
|
|
3014
2692
|
const obj = {
|
|
3015
|
-
service:
|
|
2693
|
+
service: 'heartbeat',
|
|
3016
2694
|
data,
|
|
3017
2695
|
};
|
|
3018
2696
|
|
|
3019
2697
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
3020
|
-
RUNTIME_SERVER_WEBSOCKET.emit(
|
|
3021
|
-
$(
|
|
2698
|
+
RUNTIME_SERVER_WEBSOCKET.emit('message', obj);
|
|
2699
|
+
$('body').on('heartbeat_response', (e, data) => {
|
|
3022
2700
|
resolve(data.data);
|
|
3023
|
-
$(
|
|
2701
|
+
$('body').off('heartbeat_response');
|
|
3024
2702
|
});
|
|
3025
2703
|
} else {
|
|
3026
|
-
throw new Error(
|
|
2704
|
+
throw new Error('fail to fetch from ws websocket inactive');
|
|
3027
2705
|
}
|
|
3028
2706
|
};
|
|
3029
|
-
if (serviceP ===
|
|
2707
|
+
if (serviceP === 'heartbeat') {
|
|
3030
2708
|
return heartbeat();
|
|
3031
2709
|
}
|
|
3032
2710
|
dbs_calls();
|
|
3033
2711
|
});
|
|
3034
2712
|
};
|
|
3035
|
-
|
|
3036
2713
|
glb.DEBUG_INFO_OBJ = {};
|
|
3037
2714
|
// var CONNECTION_ATTEMPTS = 0;
|
|
3038
2715
|
glb.APP_INFO = {};
|