@intuitionrobotics/thunderstorm 0.41.69 → 0.41.72
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/app-backend/api/v1/utils/version/_assert.js +1 -1
- package/app-backend/api/v1/utils/version/_assert.js.map +1 -1
- package/app-backend/api/v1/utils/version/assert.js +13 -58
- package/app-backend/api/v1/utils/version/assert.js.map +1 -1
- package/app-backend/core/BaseStorm.js +34 -87
- package/app-backend/core/BaseStorm.js.map +1 -1
- package/app-backend/core/Storm.js +42 -112
- package/app-backend/core/Storm.js.map +1 -1
- package/app-backend/exceptions.js +11 -27
- package/app-backend/exceptions.js.map +1 -1
- package/app-backend/modules/CleanupScheduler.js +24 -92
- package/app-backend/modules/CleanupScheduler.js.map +1 -1
- package/app-backend/modules/FirestoreBackupScheduler.js +47 -138
- package/app-backend/modules/FirestoreBackupScheduler.js.map +1 -1
- package/app-backend/modules/ForceUpgrade.js +31 -82
- package/app-backend/modules/ForceUpgrade.js.map +1 -1
- package/app-backend/modules/http/AxiosHttpModule.js +116 -184
- package/app-backend/modules/http/AxiosHttpModule.js.map +1 -1
- package/app-backend/modules/proxy/RemoteProxy.js +40 -90
- package/app-backend/modules/proxy/RemoteProxy.js.map +1 -1
- package/app-backend/modules/proxy/RemoteProxyCaller.js +49 -122
- package/app-backend/modules/proxy/RemoteProxyCaller.js.map +1 -1
- package/app-backend/modules/server/HttpServer.js +153 -216
- package/app-backend/modules/server/HttpServer.js.map +1 -1
- package/app-backend/modules/server/server-api.js +236 -361
- package/app-backend/modules/server/server-api.js.map +1 -1
- package/app-backend/modules/server/server-errors.js +51 -91
- package/app-backend/modules/server/server-errors.js.map +1 -1
- package/app-backend/utils/LogClient_File.js +23 -42
- package/app-backend/utils/LogClient_File.js.map +1 -1
- package/app-backend/utils/file.js +7 -50
- package/app-backend/utils/file.js.map +1 -1
- package/app-backend/utils/promisify-request.js +13 -43
- package/app-backend/utils/promisify-request.js.map +1 -1
- package/app-backend/utils/to-be-removed.js +7 -8
- package/app-backend/utils/to-be-removed.js.map +1 -1
- package/app-backend/utils/types.js +1 -1
- package/app-backend/utils/types.js.map +1 -1
- package/app-frontend/components/ActionButton.js +5 -5
- package/app-frontend/components/ActionButton.js.map +1 -1
- package/app-frontend/components/DropDown.js +91 -119
- package/app-frontend/components/DropDown.js.map +1 -1
- package/app-frontend/components/FilterInput.js +31 -48
- package/app-frontend/components/FilterInput.js.map +1 -1
- package/app-frontend/components/GenericSelect.js +30 -59
- package/app-frontend/components/GenericSelect.js.map +1 -1
- package/app-frontend/components/GenericTabs.js +5 -23
- package/app-frontend/components/GenericTabs.js.map +1 -1
- package/app-frontend/components/Overlay.js +15 -34
- package/app-frontend/components/Overlay.js.map +1 -1
- package/app-frontend/components/TS_Input.js +43 -60
- package/app-frontend/components/TS_Input.js.map +1 -1
- package/app-frontend/components/TS_Table.js +31 -48
- package/app-frontend/components/TS_Table.js.map +1 -1
- package/app-frontend/components/TS_TextArea.js +21 -48
- package/app-frontend/components/TS_TextArea.js.map +1 -1
- package/app-frontend/components/Tabs.js +16 -33
- package/app-frontend/components/Tabs.js.map +1 -1
- package/app-frontend/components/adapter/Adapter.js +103 -154
- package/app-frontend/components/adapter/Adapter.js.map +1 -1
- package/app-frontend/components/adapter/BaseRenderer.js +9 -32
- package/app-frontend/components/adapter/BaseRenderer.js.map +1 -1
- package/app-frontend/components/checkbox/TS_Checkbox.js +12 -29
- package/app-frontend/components/checkbox/TS_Checkbox.js.map +1 -1
- package/app-frontend/components/checkbox/TS_CheckboxField.js +16 -34
- package/app-frontend/components/checkbox/TS_CheckboxField.js.map +1 -1
- package/app-frontend/components/form/Form.js +21 -39
- package/app-frontend/components/form/Form.js.map +1 -1
- package/app-frontend/components/playground/Example_NewProps.js +25 -53
- package/app-frontend/components/playground/Example_NewProps.js.map +1 -1
- package/app-frontend/components/playground/Playground.js +21 -49
- package/app-frontend/components/playground/Playground.js.map +1 -1
- package/app-frontend/components/tree/MenuComponent.js +11 -27
- package/app-frontend/components/tree/MenuComponent.js.map +1 -1
- package/app-frontend/components/tree/MultiTypeAdaptor.js +16 -32
- package/app-frontend/components/tree/MultiTypeAdaptor.js.map +1 -1
- package/app-frontend/components/tree/SimpleTreeNodeRenderer.js +18 -52
- package/app-frontend/components/tree/SimpleTreeNodeRenderer.js.map +1 -1
- package/app-frontend/components/tree/Tree.js +142 -178
- package/app-frontend/components/tree/Tree.js.map +1 -1
- package/app-frontend/components/treeicons.js +5 -5
- package/app-frontend/components/treeicons.js.map +1 -1
- package/app-frontend/core/AbstractThunder.js +27 -43
- package/app-frontend/core/AbstractThunder.js.map +1 -1
- package/app-frontend/core/AppPage.js +16 -32
- package/app-frontend/core/AppPage.js.map +1 -1
- package/app-frontend/core/AppWrapper.js +9 -10
- package/app-frontend/core/AppWrapper.js.map +1 -1
- package/app-frontend/core/BaseComponent.js +62 -106
- package/app-frontend/core/BaseComponent.js.map +1 -1
- package/app-frontend/core/SimpleScriptInjector.js +12 -31
- package/app-frontend/core/SimpleScriptInjector.js.map +1 -1
- package/app-frontend/core/Thunder.js +32 -48
- package/app-frontend/core/Thunder.js.map +1 -1
- package/app-frontend/core/thunder-dispatcher.js +18 -67
- package/app-frontend/core/thunder-dispatcher.js.map +1 -1
- package/app-frontend/modules/ConnectivityModule.js +16 -32
- package/app-frontend/modules/ConnectivityModule.js.map +1 -1
- package/app-frontend/modules/ForceUpgrade.js +17 -33
- package/app-frontend/modules/ForceUpgrade.js.map +1 -1
- package/app-frontend/modules/HistoryModule.js +51 -79
- package/app-frontend/modules/HistoryModule.js.map +1 -1
- package/app-frontend/modules/ResourcesModule.js +12 -28
- package/app-frontend/modules/ResourcesModule.js.map +1 -1
- package/app-frontend/modules/StorageModule.js +47 -68
- package/app-frontend/modules/StorageModule.js.map +1 -1
- package/app-frontend/modules/ThunderstormModule.js +15 -31
- package/app-frontend/modules/ThunderstormModule.js.map +1 -1
- package/app-frontend/modules/component-loader/ReactEntryComponentInjector.js +24 -41
- package/app-frontend/modules/component-loader/ReactEntryComponentInjector.js.map +1 -1
- package/app-frontend/modules/component-loader/entry-component-loading-module.js +19 -36
- package/app-frontend/modules/component-loader/entry-component-loading-module.js.map +1 -1
- package/app-frontend/modules/dialog/Dialog.js +55 -96
- package/app-frontend/modules/dialog/Dialog.js.map +1 -1
- package/app-frontend/modules/dialog/DialogModule.js +48 -84
- package/app-frontend/modules/dialog/DialogModule.js.map +1 -1
- package/app-frontend/modules/http/HttpClient.js +46 -93
- package/app-frontend/modules/http/HttpClient.js.map +1 -1
- package/app-frontend/modules/http/XhrHttpModule.js +66 -88
- package/app-frontend/modules/http/XhrHttpModule.js.map +1 -1
- package/app-frontend/modules/locale/LocaleModule.js +23 -50
- package/app-frontend/modules/locale/LocaleModule.js.map +1 -1
- package/app-frontend/modules/menu/MenuAndButton.js +23 -40
- package/app-frontend/modules/menu/MenuAndButton.js.map +1 -1
- package/app-frontend/modules/menu/MenuModule.js +25 -42
- package/app-frontend/modules/menu/MenuModule.js.map +1 -1
- package/app-frontend/modules/menu/PopupMenu.js +37 -64
- package/app-frontend/modules/menu/PopupMenu.js.map +1 -1
- package/app-frontend/modules/routing/RoutingModule.js +47 -66
- package/app-frontend/modules/routing/RoutingModule.js.map +1 -1
- package/app-frontend/modules/routing/route.js +31 -33
- package/app-frontend/modules/routing/route.js.map +1 -1
- package/app-frontend/modules/toaster/BaseToaster.js +18 -36
- package/app-frontend/modules/toaster/BaseToaster.js.map +1 -1
- package/app-frontend/modules/toaster/Toaster.js +12 -38
- package/app-frontend/modules/toaster/Toaster.js.map +1 -1
- package/app-frontend/modules/toaster/ToasterModule.js +61 -88
- package/app-frontend/modules/toaster/ToasterModule.js.map +1 -1
- package/app-frontend/modules/tooltip/Tooltip.js +25 -52
- package/app-frontend/modules/tooltip/Tooltip.js.map +1 -1
- package/app-frontend/modules/tooltip/TooltipModule.js +32 -51
- package/app-frontend/modules/tooltip/TooltipModule.js.map +1 -1
- package/app-frontend/tools/KeyboardListener.js +24 -41
- package/app-frontend/tools/KeyboardListener.js.map +1 -1
- package/app-frontend/tools/Stylable.js +14 -28
- package/app-frontend/tools/Stylable.js.map +1 -1
- package/app-frontend/utils/tools.js +8 -8
- package/app-frontend/utils/tools.js.map +1 -1
- package/app-frontend/widgets/FieldEditor.js +16 -32
- package/app-frontend/widgets/FieldEditor.js.map +1 -1
- package/app-frontend/widgets/FieldEditorClick.js +32 -49
- package/app-frontend/widgets/FieldEditorClick.js.map +1 -1
- package/app-frontend/widgets/FieldEditorWithButtons.js +33 -49
- package/app-frontend/widgets/FieldEditorWithButtons.js.map +1 -1
- package/app-frontend/widgets/click-to-drag/ClickToDrag.js +25 -41
- package/app-frontend/widgets/click-to-drag/ClickToDrag.js.map +1 -1
- package/app-frontend/widgets/click-to-drag/OverlayWithDocumentListener.js +22 -38
- package/app-frontend/widgets/click-to-drag/OverlayWithDocumentListener.js.map +1 -1
- package/package.json +4 -4
- package/shared/BaseHttpModule.js +44 -64
- package/shared/BaseHttpModule.js.map +1 -1
- package/shared/BaseHttpRequest.js +122 -176
- package/shared/BaseHttpRequest.js.map +1 -1
- package/shared/request-types.js +4 -19
- package/shared/request-types.js.map +1 -1
- package/test-backend/StormTester.js +37 -90
- package/test-backend/StormTester.js.map +1 -1
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -21,89 +8,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
9
|
});
|
|
23
10
|
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
12
|
exports.CleanupScheduler = exports.CleanupScheduler_Class = void 0;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
case 0: return [4 /*yield*/, cleanupStatusCollection.queryUnique({ where: { moduleKey: cleanupItem.moduleKey } })];
|
|
74
|
-
case 1:
|
|
75
|
-
doc = _a.sent();
|
|
76
|
-
if (doc && doc.timestamp + cleanupItem.interval > ts_common_1.currentTimeMillies())
|
|
77
|
-
return [2 /*return*/];
|
|
78
|
-
_a.label = 2;
|
|
79
|
-
case 2:
|
|
80
|
-
_a.trys.push([2, 5, , 6]);
|
|
81
|
-
return [4 /*yield*/, cleanupItem.cleanup()];
|
|
82
|
-
case 3:
|
|
83
|
-
_a.sent();
|
|
84
|
-
return [4 /*yield*/, cleanupStatusCollection.upsert({ timestamp: ts_common_1.currentTimeMillies(), moduleKey: cleanupItem.moduleKey })];
|
|
85
|
-
case 4:
|
|
86
|
-
_a.sent();
|
|
87
|
-
return [3 /*break*/, 6];
|
|
88
|
-
case 5:
|
|
89
|
-
e_1 = _a.sent();
|
|
90
|
-
this.logWarning("cleanup of " + cleanupItem.moduleKey + " has failed with error '" + e_1 + "'");
|
|
91
|
-
return [3 /*break*/, 6];
|
|
92
|
-
case 6: return [2 /*return*/];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); }))];
|
|
96
|
-
case 1:
|
|
97
|
-
_a.sent();
|
|
98
|
-
return [2 /*return*/];
|
|
13
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
14
|
+
const firebase_function_1 = require("@intuitionrobotics/firebase/app-backend/functions/firebase-function");
|
|
15
|
+
const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-backend/FirebaseModule");
|
|
16
|
+
const dispatch_onCleanupSchedulerAct = new ts_common_1.Dispatcher("__onCleanupSchedulerAct");
|
|
17
|
+
class CleanupScheduler_Class extends firebase_function_1.FirebaseScheduledFunction {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const cleanupStatusCollection = FirebaseModule_1.FirebaseModule.createAdminSession().getFirestore().getCollection('cleanup-status', ["moduleKey"]);
|
|
22
|
+
const cleanups = dispatch_onCleanupSchedulerAct.dispatchModule([]);
|
|
23
|
+
yield Promise.all(cleanups.map((cleanupItem) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const doc = yield cleanupStatusCollection.queryUnique({ where: { moduleKey: cleanupItem.moduleKey } });
|
|
25
|
+
if (doc && doc.timestamp + cleanupItem.interval > ts_common_1.currentTimeMillies())
|
|
26
|
+
return;
|
|
27
|
+
try {
|
|
28
|
+
yield cleanupItem.cleanup();
|
|
29
|
+
yield cleanupStatusCollection.upsert({ timestamp: ts_common_1.currentTimeMillies(), moduleKey: cleanupItem.moduleKey });
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
this.logWarning(`cleanup of ${cleanupItem.moduleKey} has failed with error '${e}'`);
|
|
99
33
|
}
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
return _this;
|
|
34
|
+
})));
|
|
35
|
+
});
|
|
36
|
+
this.setSchedule('every 1 hours');
|
|
104
37
|
}
|
|
105
|
-
|
|
106
|
-
}(firebase_function_1.FirebaseScheduledFunction));
|
|
38
|
+
}
|
|
107
39
|
exports.CleanupScheduler_Class = CleanupScheduler_Class;
|
|
108
40
|
exports.CleanupScheduler = new CleanupScheduler_Class();
|
|
109
41
|
//# sourceMappingURL=CleanupScheduler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CleanupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/CleanupScheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CleanupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/CleanupScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAGsC;AACtC,2GAA8G;AAC9G,2FAAsF;AAiBtF,MAAM,8BAA8B,GAAG,IAAI,sBAAU,CAAmD,yBAAyB,CAAC,CAAC;AAEnI,MAAa,sBACZ,SAAQ,6CAAyB;IAEjC;QACC,KAAK,EAAE,CAAC;QAIT,qBAAgB,GAAG,GAAuB,EAAE;YAC3C,MAAM,uBAAuB,GAAG,+BAAc,CAAC,kBAAkB,EAAE,CAAC,YAAY,EAAE,CAAC,aAAa,CAAgB,gBAAgB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;YACjJ,MAAM,QAAQ,GAAG,8BAA8B,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;YACnE,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAM,WAAW,EAAC,EAAE;gBAClD,MAAM,GAAG,GAAG,MAAM,uBAAuB,CAAC,WAAW,CAAC,EAAC,KAAK,EAAE,EAAC,SAAS,EAAE,WAAW,CAAC,SAAS,EAAC,EAAC,CAAC,CAAC;gBACnG,IAAI,GAAG,IAAI,GAAG,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,GAAG,8BAAkB,EAAE;oBACrE,OAAO;gBAER,IAAI;oBACH,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;oBAC5B,MAAM,uBAAuB,CAAC,MAAM,CAAC,EAAC,SAAS,EAAE,8BAAkB,EAAE,EAAE,SAAS,EAAE,WAAW,CAAC,SAAS,EAAC,CAAC,CAAC;iBAC1G;gBAAC,OAAO,CAAC,EAAE;oBACX,IAAI,CAAC,UAAU,CAAC,cAAc,WAAW,CAAC,SAAS,2BAA2B,CAAC,GAAG,CAAC,CAAC;iBACpF;YACF,CAAC,CAAA,CAAC,CAAC,CAAC;QACL,CAAC,CAAA,CAAC;QAlBD,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACnC,CAAC;CAkBD;AAxBD,wDAwBC;AAEY,QAAA,gBAAgB,GAAG,IAAI,sBAAsB,EAAE,CAAC"}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -21,135 +8,57 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
21
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
9
|
});
|
|
23
10
|
};
|
|
24
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
25
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
26
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
27
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
28
|
-
function step(op) {
|
|
29
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
30
|
-
while (_) try {
|
|
31
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
32
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
33
|
-
switch (op[0]) {
|
|
34
|
-
case 0: case 1: t = op; break;
|
|
35
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
36
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
37
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
38
|
-
default:
|
|
39
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
40
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
41
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
42
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
43
|
-
if (t[2]) _.ops.pop();
|
|
44
|
-
_.trys.pop(); continue;
|
|
45
|
-
}
|
|
46
|
-
op = body.call(thisArg, _);
|
|
47
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
48
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
12
|
exports.FirestoreBackupScheduler = exports.FirestoreBackupScheduler_Class = void 0;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
switch (_a.label) {
|
|
66
|
-
case 0:
|
|
67
|
-
backupStatusCollection = FirebaseModule_1.FirebaseModule.createAdminSession().getFirestore().getCollection('firestore-backup-status', ["moduleKey", "timestamp"]);
|
|
68
|
-
backups = [];
|
|
69
|
-
ts_common_1.filterInstances(dispatch_onFirestoreBackupSchedulerAct.dispatchModule([])).forEach(function (backupArray) {
|
|
70
|
-
backups.push.apply(backups, backupArray);
|
|
71
|
-
});
|
|
72
|
-
return [4 /*yield*/, FirebaseModule_1.FirebaseModule.createAdminSession().getStorage().getOrCreateBucket()];
|
|
73
|
-
case 1:
|
|
74
|
-
bucket = _a.sent();
|
|
75
|
-
return [4 /*yield*/, Promise.all(backups.map(function (backupItem) { return __awaiter(_this, void 0, void 0, function () {
|
|
76
|
-
var query, docs, latestDoc, backupPath, toBackupData, keepInterval, queryOld, oldDocs, e_1, errorMessage;
|
|
77
|
-
var _this = this;
|
|
78
|
-
return __generator(this, function (_a) {
|
|
79
|
-
switch (_a.label) {
|
|
80
|
-
case 0:
|
|
81
|
-
query = {
|
|
82
|
-
where: { moduleKey: backupItem.moduleKey },
|
|
83
|
-
orderBy: [{ key: "timestamp", order: "asc" }],
|
|
84
|
-
limit: 1
|
|
85
|
-
};
|
|
86
|
-
return [4 /*yield*/, backupStatusCollection.query(query)];
|
|
87
|
-
case 1:
|
|
88
|
-
docs = _a.sent();
|
|
89
|
-
latestDoc = docs[0];
|
|
90
|
-
if (latestDoc && latestDoc.timestamp + backupItem.interval > ts_common_1.currentTimeMillies())
|
|
91
|
-
return [2 /*return*/];
|
|
92
|
-
backupPath = "backup/firestore/" + backupItem.moduleKey + "/" + ts_common_1.currentTimeMillies() + ".json";
|
|
93
|
-
_a.label = 2;
|
|
94
|
-
case 2:
|
|
95
|
-
_a.trys.push([2, 11, , 13]);
|
|
96
|
-
return [4 /*yield*/, backupItem.collection.query(backupItem.backupQuery)];
|
|
97
|
-
case 3:
|
|
98
|
-
toBackupData = _a.sent();
|
|
99
|
-
return [4 /*yield*/, bucket.getFile(backupPath)];
|
|
100
|
-
case 4: return [4 /*yield*/, (_a.sent()).write(toBackupData)];
|
|
101
|
-
case 5:
|
|
102
|
-
_a.sent();
|
|
103
|
-
return [4 /*yield*/, backupStatusCollection.upsert({ timestamp: ts_common_1.currentTimeMillies(), moduleKey: backupItem.moduleKey, backupPath: backupPath })];
|
|
104
|
-
case 6:
|
|
105
|
-
_a.sent();
|
|
106
|
-
keepInterval = backupItem.keepInterval;
|
|
107
|
-
if (!keepInterval) return [3 /*break*/, 10];
|
|
108
|
-
queryOld = { where: { moduleKey: backupItem.moduleKey, timestamp: { $lt: ts_common_1.currentTimeMillies() - keepInterval } } };
|
|
109
|
-
return [4 /*yield*/, backupStatusCollection.query(queryOld)];
|
|
110
|
-
case 7:
|
|
111
|
-
oldDocs = _a.sent();
|
|
112
|
-
return [4 /*yield*/, Promise.all(oldDocs.map(function (oldDoc) { return __awaiter(_this, void 0, void 0, function () {
|
|
113
|
-
return __generator(this, function (_a) {
|
|
114
|
-
switch (_a.label) {
|
|
115
|
-
case 0: return [4 /*yield*/, bucket.getFile(oldDoc.backupPath)];
|
|
116
|
-
case 1: return [4 /*yield*/, (_a.sent()).delete()];
|
|
117
|
-
case 2:
|
|
118
|
-
_a.sent();
|
|
119
|
-
return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}); }))];
|
|
123
|
-
case 8:
|
|
124
|
-
_a.sent();
|
|
125
|
-
return [4 /*yield*/, backupStatusCollection.delete(queryOld)];
|
|
126
|
-
case 9:
|
|
127
|
-
_a.sent();
|
|
128
|
-
_a.label = 10;
|
|
129
|
-
case 10: return [3 /*break*/, 13];
|
|
130
|
-
case 11:
|
|
131
|
-
e_1 = _a.sent();
|
|
132
|
-
this.logWarning("backup of " + backupItem.moduleKey + " has failed with error", e_1);
|
|
133
|
-
errorMessage = "Error backing up firestore collection config:\n " + ts_common_1.__stringify(backupItem, true) + "\nError: " + ts_common_1._logger_logException(e_1);
|
|
134
|
-
return [4 /*yield*/, ts_common_1.dispatch_onServerError.dispatchModuleAsync([ts_common_1.ServerErrorSeverity.Critical, this, errorMessage])];
|
|
135
|
-
case 12:
|
|
136
|
-
_a.sent();
|
|
137
|
-
return [3 /*break*/, 13];
|
|
138
|
-
case 13: return [2 /*return*/];
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}); }))];
|
|
142
|
-
case 2:
|
|
143
|
-
_a.sent();
|
|
144
|
-
return [2 /*return*/];
|
|
145
|
-
}
|
|
13
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
14
|
+
const firebase_function_1 = require("@intuitionrobotics/firebase/app-backend/functions/firebase-function");
|
|
15
|
+
const FirebaseModule_1 = require("@intuitionrobotics/firebase/app-backend/FirebaseModule");
|
|
16
|
+
const dispatch_onFirestoreBackupSchedulerAct = new ts_common_1.Dispatcher("__onFirestoreBackupSchedulerAct");
|
|
17
|
+
class FirestoreBackupScheduler_Class extends firebase_function_1.FirebaseScheduledFunction {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.onScheduledEvent = () => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
const backupStatusCollection = FirebaseModule_1.FirebaseModule.createAdminSession().getFirestore().getCollection('firestore-backup-status', ["moduleKey", "timestamp"]);
|
|
22
|
+
const backups = [];
|
|
23
|
+
ts_common_1.filterInstances(dispatch_onFirestoreBackupSchedulerAct.dispatchModule([])).forEach(backupArray => {
|
|
24
|
+
backups.push(...backupArray);
|
|
146
25
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
26
|
+
const bucket = yield FirebaseModule_1.FirebaseModule.createAdminSession().getStorage().getOrCreateBucket();
|
|
27
|
+
yield Promise.all(backups.map((backupItem) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const query = {
|
|
29
|
+
where: { moduleKey: backupItem.moduleKey },
|
|
30
|
+
orderBy: [{ key: "timestamp", order: "asc" }],
|
|
31
|
+
limit: 1
|
|
32
|
+
};
|
|
33
|
+
const docs = yield backupStatusCollection.query(query);
|
|
34
|
+
const latestDoc = docs[0];
|
|
35
|
+
if (latestDoc && latestDoc.timestamp + backupItem.interval > ts_common_1.currentTimeMillies())
|
|
36
|
+
return;
|
|
37
|
+
const backupPath = `backup/firestore/${backupItem.moduleKey}/${ts_common_1.currentTimeMillies()}.json`;
|
|
38
|
+
try {
|
|
39
|
+
const toBackupData = yield backupItem.collection.query(backupItem.backupQuery);
|
|
40
|
+
yield (yield bucket.getFile(backupPath)).write(toBackupData);
|
|
41
|
+
yield backupStatusCollection.upsert({ timestamp: ts_common_1.currentTimeMillies(), moduleKey: backupItem.moduleKey, backupPath });
|
|
42
|
+
const keepInterval = backupItem.keepInterval;
|
|
43
|
+
if (keepInterval) {
|
|
44
|
+
const queryOld = { where: { moduleKey: backupItem.moduleKey, timestamp: { $lt: ts_common_1.currentTimeMillies() - keepInterval } } };
|
|
45
|
+
const oldDocs = yield backupStatusCollection.query(queryOld);
|
|
46
|
+
yield Promise.all(oldDocs.map((oldDoc) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
yield (yield bucket.getFile(oldDoc.backupPath)).delete();
|
|
48
|
+
})));
|
|
49
|
+
yield backupStatusCollection.delete(queryOld);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
this.logWarning(`backup of ${backupItem.moduleKey} has failed with error`, e);
|
|
54
|
+
const errorMessage = `Error backing up firestore collection config:\n ${ts_common_1.__stringify(backupItem, true)}\nError: ${ts_common_1._logger_logException(e)}`;
|
|
55
|
+
yield ts_common_1.dispatch_onServerError.dispatchModuleAsync([ts_common_1.ServerErrorSeverity.Critical, this, errorMessage]);
|
|
56
|
+
}
|
|
57
|
+
})));
|
|
58
|
+
});
|
|
59
|
+
this.setSchedule('every 24 hours');
|
|
150
60
|
}
|
|
151
|
-
|
|
152
|
-
}(firebase_function_1.FirebaseScheduledFunction));
|
|
61
|
+
}
|
|
153
62
|
exports.FirestoreBackupScheduler_Class = FirestoreBackupScheduler_Class;
|
|
154
63
|
exports.FirestoreBackupScheduler = new FirestoreBackupScheduler_Class();
|
|
155
64
|
//# sourceMappingURL=FirestoreBackupScheduler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirestoreBackupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/FirestoreBackupScheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FirestoreBackupScheduler.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/FirestoreBackupScheduler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAQsC;AACtC,2GAA8G;AAC9G,2FAAsF;AAqBtF,MAAM,sCAAsC,GAAG,IAAI,sBAAU,CAC5D,iCAAiC,CAAC,CAAC;AAEpC,MAAa,8BACZ,SAAQ,6CAAyB;IAEjC;QACC,KAAK,EAAE,CAAC;QAIT,qBAAgB,GAAG,GAAuB,EAAE;YAC3C,MAAM,sBAAsB,GAAG,+BAAc,CAAC,kBAAkB,EAAE,CAAC,YAAY,EAAE,CAAC,aAAa,CAAY,yBAAyB,EACzB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;YACvI,MAAM,OAAO,GAAkC,EAAE,CAAC;YAClD,2BAAe,CAAC,sCAAsC,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC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22
|
-
var __extends = (this && this.__extends) || (function () {
|
|
23
|
-
var extendStatics = function (d, b) {
|
|
24
|
-
extendStatics = Object.setPrototypeOf ||
|
|
25
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
26
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
27
|
-
return extendStatics(d, b);
|
|
28
|
-
};
|
|
29
|
-
return function (d, b) {
|
|
30
|
-
extendStatics(d, b);
|
|
31
|
-
function __() { this.constructor = d; }
|
|
32
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
22
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
23
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
24
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,87 +28,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
28
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
29
|
});
|
|
43
30
|
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
46
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (_) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
72
32
|
exports.ForceUpgrade = void 0;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
33
|
+
const ts_common_1 = require("@intuitionrobotics/ts-common");
|
|
34
|
+
const HttpServer_1 = require("./server/HttpServer");
|
|
35
|
+
const exceptions_1 = require("../exceptions");
|
|
36
|
+
const force_upgrade_1 = require("../../shared/force-upgrade");
|
|
37
|
+
const Header_AppVersion = new HttpServer_1.HeaderKey(force_upgrade_1.HeaderKey_AppVersion);
|
|
38
|
+
const Header_BrowserType = new HttpServer_1.HeaderKey(force_upgrade_1.HeaderKey_BrowserType);
|
|
39
|
+
const Header_UserAgent = new HttpServer_1.HeaderKey(force_upgrade_1.HeaderKey_UserAgent);
|
|
40
|
+
const DefaultRegexps = {
|
|
81
41
|
chrome: "Chrome/([0-9\.]+)"
|
|
82
42
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
function ForceUpgrade_Class() {
|
|
86
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
87
|
-
}
|
|
88
|
-
ForceUpgrade_Class.prototype.compareVersion = function (request) {
|
|
43
|
+
class ForceUpgrade_Class extends ts_common_1.Module {
|
|
44
|
+
compareVersion(request) {
|
|
89
45
|
var _a, _b, _c;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
46
|
+
const appVersion = Header_AppVersion.get(request);
|
|
47
|
+
const userAgentString = Header_UserAgent.get(request);
|
|
48
|
+
const browserType = Header_BrowserType.get(request);
|
|
93
49
|
if (!browserType)
|
|
94
|
-
throw new ts_common_1.ImplementationMissingException(
|
|
95
|
-
|
|
96
|
-
|
|
50
|
+
throw new ts_common_1.ImplementationMissingException(`Browser type not specified`);
|
|
51
|
+
const chromeRegexp = ((_a = this.config.regexp) === null || _a === void 0 ? void 0 : _a[browserType]) || DefaultRegexps[browserType];
|
|
52
|
+
const version = (_b = userAgentString.match(new RegExp(chromeRegexp))) === null || _b === void 0 ? void 0 : _b[1];
|
|
97
53
|
if (!version)
|
|
98
|
-
throw new ts_common_1.BadImplementationException(
|
|
99
|
-
|
|
54
|
+
throw new ts_common_1.BadImplementationException(`Error extracting version.. \nUserAgent: '${userAgentString}'\n config: '${ts_common_1.__stringify(this.config)}'`);
|
|
55
|
+
const requiredBrowserVersion = (_c = this.config.browser) === null || _c === void 0 ? void 0 : _c[browserType];
|
|
100
56
|
if (!requiredBrowserVersion)
|
|
101
|
-
throw new ts_common_1.ImplementationMissingException(
|
|
102
|
-
|
|
103
|
-
|
|
57
|
+
throw new ts_common_1.ImplementationMissingException(`Unsupported browser type: ${browserType}`);
|
|
58
|
+
let app = false;
|
|
59
|
+
let browser = false;
|
|
104
60
|
if (this.config.app)
|
|
105
61
|
app = ts_common_1.compareVersions(appVersion, this.config.app) === 1;
|
|
106
62
|
if (requiredBrowserVersion)
|
|
107
63
|
browser = ts_common_1.compareVersions(version, requiredBrowserVersion) === 1;
|
|
108
|
-
return { app
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (upgradeRequired.app || upgradeRequired.browser)
|
|
116
|
-
throw new exceptions_1.ApiException(426, "require upgrade..").setErrorBody({ type: "upgrade-required", body: upgradeRequired });
|
|
117
|
-
return [2 /*return*/];
|
|
118
|
-
});
|
|
64
|
+
return { app, browser };
|
|
65
|
+
}
|
|
66
|
+
assertVersion(request) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const upgradeRequired = this.compareVersion(request);
|
|
69
|
+
if (upgradeRequired.app || upgradeRequired.browser)
|
|
70
|
+
throw new exceptions_1.ApiException(426, "require upgrade..").setErrorBody({ type: "upgrade-required", body: upgradeRequired });
|
|
119
71
|
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}); }); };
|
|
124
|
-
return ForceUpgrade_Class;
|
|
125
|
-
}(ts_common_1.Module));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
ForceUpgrade_Class.Middleware = (request) => __awaiter(void 0, void 0, void 0, function* () { return exports.ForceUpgrade.assertVersion(request); });
|
|
126
75
|
exports.ForceUpgrade = new ForceUpgrade_Class();
|
|
127
76
|
//# sourceMappingURL=ForceUpgrade.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForceUpgrade.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ForceUpgrade.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG
|
|
1
|
+
{"version":3,"file":"ForceUpgrade.js","sourceRoot":"","sources":["../../../src/main/app-backend/modules/ForceU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