@xuda.io/xuda-deploy-startup-loader 1.0.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.
- package/index.mjs +72 -0
- package/package.json +8 -0
package/index.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const loader = async function (SESSION_ID) {
|
|
2
|
+
const db = await func.utils.connect_pouchdb(SESSION_ID);
|
|
3
|
+
var _session = SESSION_OBJ[SESSION_ID];
|
|
4
|
+
try {
|
|
5
|
+
const response = await fetch(
|
|
6
|
+
`https://${_session.domain}/${_session.app_id}_startup_data.${
|
|
7
|
+
_session?.opt?.app_build_id?.toString() || "0"
|
|
8
|
+
}.json`,
|
|
9
|
+
{
|
|
10
|
+
method: "GET",
|
|
11
|
+
headers: {
|
|
12
|
+
Accept: "application/json",
|
|
13
|
+
"Content-Type": "application/json",
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
glb.register_startup_programs = true;
|
|
20
|
+
return;
|
|
21
|
+
// throw new Error(response);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const json = await response.json();
|
|
25
|
+
|
|
26
|
+
// console.log(json);
|
|
27
|
+
|
|
28
|
+
///////////////////
|
|
29
|
+
db.put({
|
|
30
|
+
_id: `cache_rt_info`,
|
|
31
|
+
data: { code: 1, data: json.rt_info_obj },
|
|
32
|
+
docType: "cache_app",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
////////////////////
|
|
36
|
+
for await (const [plugin_name, val] of Object.entries(json.plugins_setup)) {
|
|
37
|
+
await db.put({
|
|
38
|
+
_id: `cache_plugin_setup_${plugin_name}`,
|
|
39
|
+
data: val,
|
|
40
|
+
docType: "cache_plugin",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
////////////////////
|
|
45
|
+
const loader_module = await func.common.get_module(
|
|
46
|
+
SESSION_ID,
|
|
47
|
+
`xuda-progs-loader-module.mjs`
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
for await (const [prog_id, val] of Object.entries(json.docs_obj)) {
|
|
51
|
+
await loader_module.save_objects_cache(
|
|
52
|
+
SESSION_ID,
|
|
53
|
+
prog_id,
|
|
54
|
+
"DOCS_OBJ",
|
|
55
|
+
val
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
setTimeout(() => {
|
|
60
|
+
for (let prog_id of [
|
|
61
|
+
...json.rt_info_obj?.accessible_deployed_progs_arr,
|
|
62
|
+
...json.rt_info_obj?.accessible_deployed_tables_arr,
|
|
63
|
+
] || []) {
|
|
64
|
+
loader_module.DOCS_OBJ_get(SESSION_ID, prog_id);
|
|
65
|
+
}
|
|
66
|
+
}, 20000);
|
|
67
|
+
|
|
68
|
+
return json;
|
|
69
|
+
} catch (err) {
|
|
70
|
+
console.warn(err.message);
|
|
71
|
+
}
|
|
72
|
+
};
|