@openinc/parse-server-opendash 2.3.13 → 2.3.14
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/dist/config.d.ts +2 -2
- package/dist/config.js +455 -455
- package/dist/featuremap.json +75 -75
- package/dist/functions/_init.d.ts +1 -1
- package/dist/functions/_init.js +20 -20
- package/dist/functions/getAdminConfig.d.ts +1 -1
- package/dist/functions/getAdminConfig.js +63 -63
- package/dist/functions/getSchemaForAdmin.d.ts +1 -1
- package/dist/functions/getSchemaForAdmin.js +14 -14
- package/dist/functions/opendash-geo-features.d.ts +1 -1
- package/dist/functions/opendash-geo-features.js +19 -19
- package/dist/functions/openinc-auth-change-password.d.ts +1 -1
- package/dist/functions/openinc-auth-change-password.js +30 -30
- package/dist/functions/openinc-auth-confirm-email.d.ts +1 -1
- package/dist/functions/openinc-auth-confirm-email.js +18 -18
- package/dist/functions/openinc-auth-email-confirmation-request.d.ts +1 -1
- package/dist/functions/openinc-auth-email-confirmation-request.js +42 -42
- package/dist/functions/openinc-auth-email-confirmation.d.ts +1 -1
- package/dist/functions/openinc-auth-email-confirmation.js +23 -23
- package/dist/functions/openinc-auth-login-admin.d.ts +1 -1
- package/dist/functions/openinc-auth-login-admin.js +69 -69
- package/dist/functions/openinc-auth-login-passwordless.d.ts +1 -1
- package/dist/functions/openinc-auth-login-passwordless.js +50 -50
- package/dist/functions/openinc-auth-login.d.ts +1 -1
- package/dist/functions/openinc-auth-login.js +45 -45
- package/dist/functions/openinc-auth-password-reset-request.d.ts +1 -1
- package/dist/functions/openinc-auth-password-reset-request.js +42 -42
- package/dist/functions/openinc-auth-password-reset.d.ts +1 -1
- package/dist/functions/openinc-auth-password-reset.js +28 -28
- package/dist/functions/openinc-auth-signup.d.ts +1 -1
- package/dist/functions/openinc-auth-signup.js +88 -88
- package/dist/functions/openinc-auth-validate-token.d.ts +1 -1
- package/dist/functions/openinc-auth-validate-token.js +37 -37
- package/dist/functions/openinc-auth.common.d.ts +15 -15
- package/dist/functions/openinc-auth.common.js +67 -67
- package/dist/functions/openinc-config.d.ts +1 -1
- package/dist/functions/openinc-config.js +92 -92
- package/dist/functions/openinc-geo-google-autocomplete.d.ts +1 -1
- package/dist/functions/openinc-geo-google-autocomplete.js +58 -58
- package/dist/functions/openinc-geo-google.common.d.ts +2 -2
- package/dist/functions/openinc-geo-google.common.js +34 -34
- package/dist/functions/openinc-geo-graphhopper-geocode-reverse-raw.d.ts +1 -1
- package/dist/functions/openinc-geo-graphhopper-geocode-reverse-raw.js +24 -24
- package/dist/functions/openinc-geo-graphhopper-geocode-reverse.d.ts +1 -1
- package/dist/functions/openinc-geo-graphhopper-geocode-reverse.js +24 -24
- package/dist/functions/openinc-geo-graphhopper-geocode.d.ts +1 -1
- package/dist/functions/openinc-geo-graphhopper-geocode.js +24 -24
- package/dist/functions/openinc-geo-graphhopper-route-simple.d.ts +1 -1
- package/dist/functions/openinc-geo-graphhopper-route-simple.js +33 -33
- package/dist/functions/openinc-geo-graphhopper.common.d.ts +2 -2
- package/dist/functions/openinc-geo-graphhopper.common.js +60 -60
- package/dist/helper/Config.d.ts +33 -33
- package/dist/helper/Config.js +156 -156
- package/dist/helper/pdf2img.d.ts +12 -12
- package/dist/helper/pdf2img.js +111 -111
- package/dist/hooks/Alarm.d.ts +1 -1
- package/dist/hooks/Alarm.js +40 -40
- package/dist/hooks/AlarmAction.d.ts +1 -1
- package/dist/hooks/AlarmAction.js +15 -15
- package/dist/hooks/AlarmWebhook.d.ts +1 -1
- package/dist/hooks/AlarmWebhook.js +16 -16
- package/dist/hooks/Attachment.d.ts +1 -1
- package/dist/hooks/Attachment.js +18 -18
- package/dist/hooks/BDE_Form.d.ts +1 -1
- package/dist/hooks/BDE_Form.js +53 -53
- package/dist/hooks/BDE_List.d.ts +1 -1
- package/dist/hooks/BDE_List.js +17 -17
- package/dist/hooks/BDE_ListEntry.d.ts +1 -1
- package/dist/hooks/BDE_ListEntry.js +17 -17
- package/dist/hooks/BDE_Page.d.ts +1 -1
- package/dist/hooks/BDE_Page.js +44 -44
- package/dist/hooks/BDE_Result.d.ts +1 -1
- package/dist/hooks/BDE_Result.js +128 -128
- package/dist/hooks/BDE_Unit.d.ts +1 -1
- package/dist/hooks/BDE_Unit.js +17 -17
- package/dist/hooks/Config.d.ts +1 -1
- package/dist/hooks/Config.js +16 -16
- package/dist/hooks/Core_Email.d.ts +11 -11
- package/dist/hooks/Core_Email.js +111 -111
- package/dist/hooks/Core_Token.d.ts +1 -1
- package/dist/hooks/Core_Token.js +11 -11
- package/dist/hooks/Dashboard.d.ts +1 -1
- package/dist/hooks/Dashboard.js +33 -33
- package/dist/hooks/GTFS_Agency.d.ts +1 -1
- package/dist/hooks/GTFS_Agency.js +18 -18
- package/dist/hooks/GTFS_Bikes_Allowed.d.ts +1 -1
- package/dist/hooks/GTFS_Bikes_Allowed.js +18 -18
- package/dist/hooks/GTFS_Calendar.d.ts +1 -1
- package/dist/hooks/GTFS_Calendar.js +18 -18
- package/dist/hooks/GTFS_Direction.d.ts +1 -1
- package/dist/hooks/GTFS_Direction.js +18 -18
- package/dist/hooks/GTFS_Level.d.ts +1 -1
- package/dist/hooks/GTFS_Level.js +18 -18
- package/dist/hooks/GTFS_Location_Type.d.ts +1 -1
- package/dist/hooks/GTFS_Location_Type.js +18 -18
- package/dist/hooks/GTFS_Route.d.ts +1 -1
- package/dist/hooks/GTFS_Route.js +18 -18
- package/dist/hooks/GTFS_Route_Type.d.ts +1 -1
- package/dist/hooks/GTFS_Route_Type.js +18 -18
- package/dist/hooks/GTFS_Stop.d.ts +1 -1
- package/dist/hooks/GTFS_Stop.js +18 -18
- package/dist/hooks/GTFS_Stop_Times.d.ts +1 -1
- package/dist/hooks/GTFS_Stop_Times.js +18 -18
- package/dist/hooks/GTFS_Trip.d.ts +1 -1
- package/dist/hooks/GTFS_Trip.js +18 -18
- package/dist/hooks/GTFS_Wheelchair_Accessible.d.ts +1 -1
- package/dist/hooks/GTFS_Wheelchair_Accessible.js +18 -18
- package/dist/hooks/GTFS_Wheelchair_Boarding.d.ts +1 -1
- package/dist/hooks/GTFS_Wheelchair_Boarding.js +18 -18
- package/dist/hooks/Group.d.ts +1 -1
- package/dist/hooks/Group.js +56 -56
- package/dist/hooks/Knowledge_Article.d.ts +1 -1
- package/dist/hooks/Knowledge_Article.js +18 -18
- package/dist/hooks/Knowledge_Category.d.ts +1 -1
- package/dist/hooks/Knowledge_Category.js +18 -18
- package/dist/hooks/Knowledge_Document.d.ts +1 -1
- package/dist/hooks/Knowledge_Document.js +60 -60
- package/dist/hooks/Knowledge_DocumentPage.d.ts +1 -1
- package/dist/hooks/Knowledge_DocumentPage.js +22 -22
- package/dist/hooks/Knowledge_Video.d.ts +1 -1
- package/dist/hooks/Knowledge_Video.js +18 -18
- package/dist/hooks/Language.d.ts +1 -1
- package/dist/hooks/Language.js +18 -18
- package/dist/hooks/Log.d.ts +1 -1
- package/dist/hooks/Log.js +18 -18
- package/dist/hooks/MIAAS_MDSEndpoint.d.ts +1 -1
- package/dist/hooks/MIAAS_MDSEndpoint.js +18 -18
- package/dist/hooks/Maintenance_Article.d.ts +1 -1
- package/dist/hooks/Maintenance_Article.js +18 -18
- package/dist/hooks/Maintenance_Downtime.d.ts +1 -1
- package/dist/hooks/Maintenance_Downtime.js +18 -18
- package/dist/hooks/Maintenance_Duedate.d.ts +1 -1
- package/dist/hooks/Maintenance_Duedate.js +18 -18
- package/dist/hooks/Maintenance_Frequency.d.ts +1 -1
- package/dist/hooks/Maintenance_Frequency.js +18 -18
- package/dist/hooks/Maintenance_Issuecategory.d.ts +1 -1
- package/dist/hooks/Maintenance_Issuecategory.js +21 -21
- package/dist/hooks/Maintenance_Item.d.ts +1 -1
- package/dist/hooks/Maintenance_Item.js +18 -18
- package/dist/hooks/Maintenance_Kanban_State.d.ts +1 -1
- package/dist/hooks/Maintenance_Kanban_State.js +18 -18
- package/dist/hooks/Maintenance_Media.d.ts +1 -1
- package/dist/hooks/Maintenance_Media.js +18 -18
- package/dist/hooks/Maintenance_Message.d.ts +1 -1
- package/dist/hooks/Maintenance_Message.js +18 -18
- package/dist/hooks/Maintenance_Message_Body.d.ts +1 -1
- package/dist/hooks/Maintenance_Message_Body.js +18 -18
- package/dist/hooks/Maintenance_Order.d.ts +1 -1
- package/dist/hooks/Maintenance_Order.js +18 -18
- package/dist/hooks/Maintenance_Priority.d.ts +1 -1
- package/dist/hooks/Maintenance_Priority.js +18 -18
- package/dist/hooks/Maintenance_Restriction.d.ts +1 -1
- package/dist/hooks/Maintenance_Restriction.js +18 -18
- package/dist/hooks/Maintenance_Schedule.d.ts +1 -1
- package/dist/hooks/Maintenance_Schedule.js +18 -18
- package/dist/hooks/Maintenance_Schedule_Execution.d.ts +1 -1
- package/dist/hooks/Maintenance_Schedule_Execution.js +18 -18
- package/dist/hooks/Maintenance_Schedule_Execution_Step.d.ts +1 -1
- package/dist/hooks/Maintenance_Schedule_Execution_Step.js +18 -18
- package/dist/hooks/Maintenance_Schedule_Step.d.ts +1 -1
- package/dist/hooks/Maintenance_Schedule_Step.js +18 -18
- package/dist/hooks/Maintenance_SourceMeta.d.ts +1 -1
- package/dist/hooks/Maintenance_SourceMeta.js +18 -18
- package/dist/hooks/Maintenance_Ticket.d.ts +1 -1
- package/dist/hooks/Maintenance_Ticket.js +18 -18
- package/dist/hooks/Maintenance_Ticket_Issuecategory.d.ts +1 -1
- package/dist/hooks/Maintenance_Ticket_Issuecategory.js +18 -18
- package/dist/hooks/Maintenance_Ticket_Kanban_State.d.ts +1 -1
- package/dist/hooks/Maintenance_Ticket_Kanban_State.js +23 -23
- package/dist/hooks/Maintenance_Ticket_Source.d.ts +1 -1
- package/dist/hooks/Maintenance_Ticket_Source.js +18 -18
- package/dist/hooks/Monitoring_Slideshow.d.ts +1 -1
- package/dist/hooks/Monitoring_Slideshow.js +17 -17
- package/dist/hooks/NavigationGroup.d.ts +1 -1
- package/dist/hooks/NavigationGroup.js +15 -15
- package/dist/hooks/NavigationItem.d.ts +1 -1
- package/dist/hooks/NavigationItem.js +16 -16
- package/dist/hooks/Notification.d.ts +1 -1
- package/dist/hooks/Notification.js +73 -73
- package/dist/hooks/Permission.d.ts +1 -1
- package/dist/hooks/Permission.js +19 -19
- package/dist/hooks/Push.d.ts +1 -1
- package/dist/hooks/Push.js +30 -30
- package/dist/hooks/Report.d.ts +1 -1
- package/dist/hooks/Report.js +16 -16
- package/dist/hooks/Share.d.ts +1 -1
- package/dist/hooks/Share.js +16 -16
- package/dist/hooks/Source.d.ts +1 -1
- package/dist/hooks/Source.js +91 -91
- package/dist/hooks/Tenant.d.ts +1 -1
- package/dist/hooks/Tenant.js +75 -75
- package/dist/hooks/TenantTrustedDomain.d.ts +1 -1
- package/dist/hooks/TenantTrustedDomain.js +12 -12
- package/dist/hooks/UserData.d.ts +1 -1
- package/dist/hooks/UserData.js +16 -16
- package/dist/hooks/VirtualKPI.d.ts +1 -1
- package/dist/hooks/VirtualKPI.js +18 -18
- package/dist/hooks/Widget.d.ts +1 -1
- package/dist/hooks/Widget.js +16 -16
- package/dist/hooks/WidgetPreset.d.ts +1 -1
- package/dist/hooks/WidgetPreset.js +18 -18
- package/dist/hooks/_User.d.ts +1 -1
- package/dist/hooks/_User.js +108 -108
- package/dist/hooks/_beforeLogin.d.ts +1 -1
- package/dist/hooks/_beforeLogin.js +22 -22
- package/dist/hooks/_init.d.ts +1 -1
- package/dist/hooks/_init.js +23 -23
- package/dist/index.d.ts +65 -65
- package/dist/index.js +399 -399
- package/dist/ow.d.ts +20 -20
- package/dist/ow.js +88 -91
- package/dist/types/Alarm.d.ts +36 -36
- package/dist/types/Alarm.js +59 -59
- package/dist/types/AlarmAction.d.ts +42 -42
- package/dist/types/AlarmAction.js +71 -71
- package/dist/types/AlarmWebhook.d.ts +40 -40
- package/dist/types/AlarmWebhook.js +65 -65
- package/dist/types/Attachment.d.ts +21 -21
- package/dist/types/Attachment.js +29 -29
- package/dist/types/BDE_Form.d.ts +26 -26
- package/dist/types/BDE_Form.js +41 -41
- package/dist/types/BDE_List.d.ts +14 -14
- package/dist/types/BDE_List.js +17 -17
- package/dist/types/BDE_ListEntry.d.ts +21 -21
- package/dist/types/BDE_ListEntry.js +29 -29
- package/dist/types/BDE_Page.d.ts +17 -17
- package/dist/types/BDE_Page.js +23 -23
- package/dist/types/BDE_Result.d.ts +20 -20
- package/dist/types/BDE_Result.js +29 -29
- package/dist/types/BDE_Unit.d.ts +23 -23
- package/dist/types/BDE_Unit.js +32 -32
- package/dist/types/Config.d.ts +24 -24
- package/dist/types/Config.js +35 -35
- package/dist/types/Core_Email.d.ts +26 -26
- package/dist/types/Core_Email.js +41 -41
- package/dist/types/Core_Token.d.ts +23 -23
- package/dist/types/Core_Token.js +35 -35
- package/dist/types/Dashboard.d.ts +34 -34
- package/dist/types/Dashboard.js +53 -53
- package/dist/types/GTFS_Agency.d.ts +39 -39
- package/dist/types/GTFS_Agency.js +65 -65
- package/dist/types/GTFS_Bikes_Allowed.d.ts +21 -21
- package/dist/types/GTFS_Bikes_Allowed.js +29 -29
- package/dist/types/GTFS_Calendar.d.ts +42 -42
- package/dist/types/GTFS_Calendar.js +71 -71
- package/dist/types/GTFS_Direction.d.ts +21 -21
- package/dist/types/GTFS_Direction.js +29 -29
- package/dist/types/GTFS_Level.d.ts +21 -21
- package/dist/types/GTFS_Level.js +29 -29
- package/dist/types/GTFS_Location_Type.d.ts +24 -24
- package/dist/types/GTFS_Location_Type.js +35 -35
- package/dist/types/GTFS_Route.d.ts +46 -46
- package/dist/types/GTFS_Route.js +77 -77
- package/dist/types/GTFS_Route_Type.d.ts +24 -24
- package/dist/types/GTFS_Route_Type.js +35 -35
- package/dist/types/GTFS_Stop.d.ts +60 -60
- package/dist/types/GTFS_Stop.js +101 -101
- package/dist/types/GTFS_Stop_Times.d.ts +32 -32
- package/dist/types/GTFS_Stop_Times.js +47 -47
- package/dist/types/GTFS_Trip.d.ts +41 -41
- package/dist/types/GTFS_Trip.js +59 -59
- package/dist/types/GTFS_Wheelchair_Accessible.d.ts +21 -21
- package/dist/types/GTFS_Wheelchair_Accessible.js +29 -29
- package/dist/types/GTFS_Wheelchair_Boarding.d.ts +24 -24
- package/dist/types/GTFS_Wheelchair_Boarding.js +35 -35
- package/dist/types/Group.d.ts +32 -32
- package/dist/types/Group.js +47 -47
- package/dist/types/Knowledge_Article.d.ts +29 -29
- package/dist/types/Knowledge_Article.js +41 -41
- package/dist/types/Knowledge_Category.d.ts +25 -25
- package/dist/types/Knowledge_Category.js +35 -35
- package/dist/types/Knowledge_Document.d.ts +29 -29
- package/dist/types/Knowledge_Document.js +41 -41
- package/dist/types/Knowledge_DocumentPage.d.ts +31 -31
- package/dist/types/Knowledge_DocumentPage.js +47 -47
- package/dist/types/Knowledge_Video.d.ts +35 -35
- package/dist/types/Knowledge_Video.js +53 -53
- package/dist/types/Language.d.ts +14 -14
- package/dist/types/Language.js +17 -17
- package/dist/types/Log.d.ts +17 -17
- package/dist/types/Log.js +23 -23
- package/dist/types/MIAAS_MDSEndpoint.d.ts +29 -29
- package/dist/types/MIAAS_MDSEndpoint.js +47 -47
- package/dist/types/Maintenance_Article.d.ts +32 -32
- package/dist/types/Maintenance_Article.js +44 -44
- package/dist/types/Maintenance_Downtime.d.ts +26 -26
- package/dist/types/Maintenance_Downtime.js +35 -35
- package/dist/types/Maintenance_Duedate.d.ts +35 -35
- package/dist/types/Maintenance_Duedate.js +53 -53
- package/dist/types/Maintenance_Frequency.d.ts +26 -26
- package/dist/types/Maintenance_Frequency.js +35 -35
- package/dist/types/Maintenance_Issuecategory.d.ts +36 -36
- package/dist/types/Maintenance_Issuecategory.js +56 -56
- package/dist/types/Maintenance_Item.d.ts +21 -21
- package/dist/types/Maintenance_Item.js +29 -29
- package/dist/types/Maintenance_Kanban_State.d.ts +33 -33
- package/dist/types/Maintenance_Kanban_State.js +53 -53
- package/dist/types/Maintenance_Media.d.ts +21 -21
- package/dist/types/Maintenance_Media.js +29 -29
- package/dist/types/Maintenance_Message.d.ts +27 -27
- package/dist/types/Maintenance_Message.js +41 -41
- package/dist/types/Maintenance_Message_Body.d.ts +22 -22
- package/dist/types/Maintenance_Message_Body.js +29 -29
- package/dist/types/Maintenance_Order.d.ts +24 -24
- package/dist/types/Maintenance_Order.js +32 -32
- package/dist/types/Maintenance_Priority.d.ts +26 -26
- package/dist/types/Maintenance_Priority.js +35 -35
- package/dist/types/Maintenance_Restriction.d.ts +26 -26
- package/dist/types/Maintenance_Restriction.js +35 -35
- package/dist/types/Maintenance_Schedule.d.ts +37 -37
- package/dist/types/Maintenance_Schedule.js +56 -56
- package/dist/types/Maintenance_Schedule_Execution.d.ts +39 -39
- package/dist/types/Maintenance_Schedule_Execution.js +56 -56
- package/dist/types/Maintenance_Schedule_Execution_Step.d.ts +44 -44
- package/dist/types/Maintenance_Schedule_Execution_Step.js +71 -71
- package/dist/types/Maintenance_Schedule_Step.d.ts +38 -38
- package/dist/types/Maintenance_Schedule_Step.js +59 -59
- package/dist/types/Maintenance_SourceMeta.d.ts +23 -23
- package/dist/types/Maintenance_SourceMeta.js +29 -29
- package/dist/types/Maintenance_Ticket.d.ts +30 -30
- package/dist/types/Maintenance_Ticket.js +41 -41
- package/dist/types/Maintenance_Ticket_Issuecategory.d.ts +27 -27
- package/dist/types/Maintenance_Ticket_Issuecategory.js +35 -35
- package/dist/types/Maintenance_Ticket_Kanban_State.d.ts +27 -27
- package/dist/types/Maintenance_Ticket_Kanban_State.js +35 -35
- package/dist/types/Maintenance_Ticket_Source.d.ts +27 -27
- package/dist/types/Maintenance_Ticket_Source.js +35 -35
- package/dist/types/Monitoring_Slideshow.d.ts +20 -20
- package/dist/types/Monitoring_Slideshow.js +26 -26
- package/dist/types/NavigationGroup.d.ts +24 -24
- package/dist/types/NavigationGroup.js +35 -35
- package/dist/types/NavigationItem.d.ts +48 -48
- package/dist/types/NavigationItem.js +83 -83
- package/dist/types/Notification.d.ts +30 -30
- package/dist/types/Notification.js +47 -47
- package/dist/types/Permission.d.ts +18 -18
- package/dist/types/Permission.js +23 -23
- package/dist/types/Push.d.ts +27 -27
- package/dist/types/Push.js +41 -41
- package/dist/types/Report.d.ts +39 -39
- package/dist/types/Report.js +65 -65
- package/dist/types/Share.d.ts +34 -34
- package/dist/types/Share.js +53 -53
- package/dist/types/Source.d.ts +26 -26
- package/dist/types/Source.js +38 -38
- package/dist/types/Tenant.d.ts +45 -45
- package/dist/types/Tenant.js +77 -77
- package/dist/types/TenantTrustedDomain.d.ts +18 -18
- package/dist/types/TenantTrustedDomain.js +23 -23
- package/dist/types/UserData.d.ts +21 -21
- package/dist/types/UserData.js +29 -29
- package/dist/types/VirtualKPI.d.ts +21 -21
- package/dist/types/VirtualKPI.js +29 -29
- package/dist/types/Widget.d.ts +24 -24
- package/dist/types/Widget.js +35 -35
- package/dist/types/WidgetPreset.d.ts +40 -40
- package/dist/types/WidgetPreset.js +65 -65
- package/dist/types/_Role.d.ts +13 -13
- package/dist/types/_Role.js +2 -2
- package/dist/types/_Session.d.ts +15 -15
- package/dist/types/_Session.js +2 -2
- package/dist/types/_User.d.ts +28 -28
- package/dist/types/_User.js +2 -2
- package/dist/types/index.d.ts +152 -152
- package/dist/types/index.js +150 -150
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,399 +1,399 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.initAutoload = exports.autoloadCloudCode = exports.afterDeleteHook = exports.beforeDeleteHook = exports.afterSaveHook = exports.beforeSaveHook = exports.defaultAclHandler = exports.defaultHandler = exports.immutableField = exports.ensureUserRole = exports.ensureRole = exports.getConfigBoolean = exports.getConfig = exports.requirePermission = exports.hasPermission = exports.init = exports.PREFIX = exports.sendTemplateEmail = exports.sendSimpleEmail = exports.Config = void 0;
|
|
7
|
-
const parse_server_schema_1 = require("@openinc/parse-server-schema");
|
|
8
|
-
const fast_equals_1 = require("fast-equals");
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = require("path");
|
|
11
|
-
const web_push_1 = __importDefault(require("web-push"));
|
|
12
|
-
const config_1 = require("./config");
|
|
13
|
-
const featuremap_json_1 = __importDefault(require("./featuremap.json"));
|
|
14
|
-
const _init_1 = require("./functions/_init");
|
|
15
|
-
const Core_Email_1 = require("./hooks/Core_Email");
|
|
16
|
-
const _init_2 = require("./hooks/_init");
|
|
17
|
-
const types_1 = require("./types");
|
|
18
|
-
var Config_1 = require("./helper/Config");
|
|
19
|
-
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
|
|
20
|
-
var Core_Email_2 = require("./hooks/Core_Email");
|
|
21
|
-
Object.defineProperty(exports, "sendSimpleEmail", { enumerable: true, get: function () { return Core_Email_2.sendSimpleEmail; } });
|
|
22
|
-
Object.defineProperty(exports, "sendTemplateEmail", { enumerable: true, get: function () { return Core_Email_2.sendTemplateEmail; } });
|
|
23
|
-
exports.PREFIX = "OD3_";
|
|
24
|
-
let schema = {};
|
|
25
|
-
async function init() {
|
|
26
|
-
try {
|
|
27
|
-
const pkg = require("../package.json");
|
|
28
|
-
console.log(`[${pkg.name}] init (v${pkg.version})`);
|
|
29
|
-
}
|
|
30
|
-
catch (error) { }
|
|
31
|
-
await config_1.config.init(true);
|
|
32
|
-
await (0, Core_Email_1.initEmailTransport)();
|
|
33
|
-
await initWebPush();
|
|
34
|
-
await initSchema();
|
|
35
|
-
await initDefaultRoles();
|
|
36
|
-
await initDefaultData();
|
|
37
|
-
await (0, _init_2.init)();
|
|
38
|
-
await (0, _init_1.init)();
|
|
39
|
-
await initAutoload();
|
|
40
|
-
}
|
|
41
|
-
exports.init = init;
|
|
42
|
-
async function initWebPush() {
|
|
43
|
-
try {
|
|
44
|
-
if (config_1.config.getBoolean("WEB_PUSH_ENABLED")) {
|
|
45
|
-
web_push_1.default.setVapidDetails(config_1.config.get("WEB_PUSH_HOST"), config_1.config.get("WEB_PUSH_VAPID_PUBLIC_KEY"), config_1.config.get("WEB_PUSH_VAPID_PRIVATE_KEY"));
|
|
46
|
-
web_push_1.default.setGCMAPIKey(config_1.config.get("WEB_PUSH_FCM_KEY"));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.error(error);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async function initSchema() {
|
|
55
|
-
const schemaConfig = await (0, parse_server_schema_1.loadConfig)();
|
|
56
|
-
try {
|
|
57
|
-
await (0, parse_server_schema_1.up)(schemaConfig, (0, path_1.resolve)(__dirname, "../schema"), {
|
|
58
|
-
prefix: exports.PREFIX,
|
|
59
|
-
deleteClasses: config_1.config.getBoolean("FORCE_SCHEMA"),
|
|
60
|
-
deleteFields: config_1.config.getBoolean("FORCE_SCHEMA"),
|
|
61
|
-
filter: (className) => isClassEnabled(className),
|
|
62
|
-
});
|
|
63
|
-
schema = Object.fromEntries((await Parse.Schema.all()).map((schema) => [
|
|
64
|
-
schema.className,
|
|
65
|
-
schema,
|
|
66
|
-
]));
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
console.error("Error while updating schema");
|
|
70
|
-
console.error(error);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async function initDefaultRoles() {
|
|
75
|
-
try {
|
|
76
|
-
await ensureRole("od-user");
|
|
77
|
-
await ensureRole("od-admin");
|
|
78
|
-
await ensureRole("od-tenant-user");
|
|
79
|
-
await ensureRole("od-tenant-verified");
|
|
80
|
-
await ensureRole("od-tenant-admin");
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error(error);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async function initDefaultData() {
|
|
87
|
-
try {
|
|
88
|
-
// TODO
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
console.error(error);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
async function hasPermission(sessionToken, key) {
|
|
95
|
-
const result = await new Parse.Query(types_1.Permission)
|
|
96
|
-
.equalTo("key", key)
|
|
97
|
-
.first({ sessionToken });
|
|
98
|
-
return !!result;
|
|
99
|
-
}
|
|
100
|
-
exports.hasPermission = hasPermission;
|
|
101
|
-
async function requirePermission(request, key, message) {
|
|
102
|
-
if (request.master) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (!key) {
|
|
106
|
-
throw new Parse.Error(119, "Missing Permission (1): " + (message || key || "Master Key Only"));
|
|
107
|
-
}
|
|
108
|
-
if (!request.sessionToken) {
|
|
109
|
-
throw new Parse.Error(119, "Missing Permission (2): " + (message || key || "Master Key Only"));
|
|
110
|
-
}
|
|
111
|
-
const p = await hasPermission(request.sessionToken, key);
|
|
112
|
-
if (!p) {
|
|
113
|
-
throw new Parse.Error(119, "Missing Permission (3): " + (message || key || "Master Key Only"));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.requirePermission = requirePermission;
|
|
117
|
-
async function getConfig(key) {
|
|
118
|
-
const result = await new Parse.Query(types_1.Config).equalTo("key", key).first({
|
|
119
|
-
useMasterKey: true,
|
|
120
|
-
});
|
|
121
|
-
const value = result?.get("value");
|
|
122
|
-
console.log("[@openinc/parse-server-opendash][Config]", key, value);
|
|
123
|
-
return value || "";
|
|
124
|
-
}
|
|
125
|
-
exports.getConfig = getConfig;
|
|
126
|
-
async function getConfigBoolean(key) {
|
|
127
|
-
const value = await getConfig(key);
|
|
128
|
-
if (!value || value.toLowerCase() === "false" || value === "0") {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
exports.getConfigBoolean = getConfigBoolean;
|
|
134
|
-
async function ensureRole(name, options) {
|
|
135
|
-
const label = options?.label || undefined;
|
|
136
|
-
const acl = options?.acl || new Parse.ACL();
|
|
137
|
-
const childRoles = options?.childRoles || undefined;
|
|
138
|
-
console.log(`[@openinc/parse-server-opendash] ensureRole(${name})`
|
|
139
|
-
// JSON.stringify({ label, acl, childRoles }, null, 2)
|
|
140
|
-
);
|
|
141
|
-
let role = await new Parse.Query(Parse.Role)
|
|
142
|
-
.equalTo("name", name)
|
|
143
|
-
.first({ useMasterKey: true });
|
|
144
|
-
if (!role) {
|
|
145
|
-
role = new Parse.Role(name, acl);
|
|
146
|
-
role.set("label", label);
|
|
147
|
-
await role.save(null, {
|
|
148
|
-
useMasterKey: true,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
let changed = false;
|
|
152
|
-
if (role.get("label") !== label) {
|
|
153
|
-
role.set("label", label);
|
|
154
|
-
changed = true;
|
|
155
|
-
}
|
|
156
|
-
if (!(0, fast_equals_1.deepEqual)(acl.toJSON(), role.getACL()?.toJSON())) {
|
|
157
|
-
role.setACL(acl);
|
|
158
|
-
changed = true;
|
|
159
|
-
}
|
|
160
|
-
if (Array.isArray(childRoles) && childRoles.length > 0) {
|
|
161
|
-
const relation = role.getRoles();
|
|
162
|
-
const currentChildRoles = await relation
|
|
163
|
-
.query()
|
|
164
|
-
.find({ useMasterKey: true });
|
|
165
|
-
const currentChildRoleNames = currentChildRoles.map((role) => role.get("name"));
|
|
166
|
-
for (const childRoleName of childRoles) {
|
|
167
|
-
if (currentChildRoleNames.includes(childRoleName)) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
const childRole = await new Parse.Query(Parse.Role)
|
|
171
|
-
.equalTo("name", childRoleName)
|
|
172
|
-
.find({ useMasterKey: true });
|
|
173
|
-
relation.add(childRole);
|
|
174
|
-
changed = true;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (changed) {
|
|
178
|
-
await role.save(null, { useMasterKey: true });
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
exports.ensureRole = ensureRole;
|
|
182
|
-
async function ensureUserRole(user, roleName, add = false) {
|
|
183
|
-
const role = await new Parse.Query(Parse.Role)
|
|
184
|
-
.equalTo("name", roleName)
|
|
185
|
-
.first({ useMasterKey: true });
|
|
186
|
-
if (role) {
|
|
187
|
-
const relation = role.relation("users");
|
|
188
|
-
if (add) {
|
|
189
|
-
relation.add(user);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
relation.remove(user);
|
|
193
|
-
}
|
|
194
|
-
await role.save(null, { useMasterKey: true });
|
|
195
|
-
console.log("userRole", user.get("username"), roleName, add);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
exports.ensureUserRole = ensureUserRole;
|
|
199
|
-
async function immutableField(request, fieldName, permissionName = "parse:edit-immutable-fields") {
|
|
200
|
-
if (!request.original || request.master) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
const previousValue = JSON.stringify(request.original.get(fieldName));
|
|
204
|
-
const nextValue = JSON.stringify(request.object.get(fieldName));
|
|
205
|
-
if ((0, fast_equals_1.deepEqual)(previousValue, nextValue)) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
await requirePermission(request, permissionName, `You are not allowed to edit the '${fieldName}' field.`);
|
|
209
|
-
}
|
|
210
|
-
exports.immutableField = immutableField;
|
|
211
|
-
async function defaultHandler(request) {
|
|
212
|
-
const className = request.object.className;
|
|
213
|
-
if (request.master) {
|
|
214
|
-
console.log(`[@openinc/parse-server-opendash] Skipping default beforeSave() handler of ${className} for masterkey`);
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
if (!request.user) {
|
|
218
|
-
throw new Error();
|
|
219
|
-
}
|
|
220
|
-
const currentSchema = schema[className];
|
|
221
|
-
if (!currentSchema) {
|
|
222
|
-
console.warn(`[@openinc/parse-server-opendash] Skipping default beforeSave() handler, no schema found for ${className}`);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const userField = !!currentSchema?.fields?.user;
|
|
226
|
-
const tenantField = !!currentSchema?.fields?.tenant;
|
|
227
|
-
if (userField) {
|
|
228
|
-
await immutableField(request, "user");
|
|
229
|
-
}
|
|
230
|
-
if (tenantField) {
|
|
231
|
-
await immutableField(request, "tenant");
|
|
232
|
-
}
|
|
233
|
-
if (!request.original) {
|
|
234
|
-
if (userField) {
|
|
235
|
-
request.object.set("user", request.user);
|
|
236
|
-
}
|
|
237
|
-
if (tenantField) {
|
|
238
|
-
const user = (await request.user?.fetch({
|
|
239
|
-
useMasterKey: true,
|
|
240
|
-
}));
|
|
241
|
-
request.object.set("tenant", user.get("tenant"));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
exports.defaultHandler = defaultHandler;
|
|
246
|
-
async function defaultAclHandler(request, options) {
|
|
247
|
-
const className = request.object.className;
|
|
248
|
-
const currentSchema = schema[className];
|
|
249
|
-
if (!currentSchema) {
|
|
250
|
-
console.warn(`[@openinc/parse-server-opendash] Skipping default beforeSave() ACL handler, no schema found for ${className}`);
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const userField = !!currentSchema?.fields?.user;
|
|
254
|
-
const tenantField = !!currentSchema?.fields?.tenant;
|
|
255
|
-
if (!options?.allowCustomACL || !request.object.getACL()) {
|
|
256
|
-
request.object.setACL(new Parse.ACL());
|
|
257
|
-
}
|
|
258
|
-
const acl = request.object.getACL();
|
|
259
|
-
acl.setRoleReadAccess("od-admin", true);
|
|
260
|
-
acl.setRoleWriteAccess("od-admin", true);
|
|
261
|
-
if (userField) {
|
|
262
|
-
const user = request.object.get("user");
|
|
263
|
-
if (user) {
|
|
264
|
-
acl.setReadAccess(user.id, true);
|
|
265
|
-
acl.setWriteAccess(user.id, true);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (tenantField) {
|
|
269
|
-
const tenant = request.object.get("tenant");
|
|
270
|
-
if (tenant) {
|
|
271
|
-
if (!options?.denyTenantUserRead) {
|
|
272
|
-
acl.setRoleReadAccess(`od-tenant-user-${tenant.id}`, true);
|
|
273
|
-
}
|
|
274
|
-
if (options?.allowTenantUserWrite) {
|
|
275
|
-
acl.setRoleWriteAccess(`od-tenant-user-${tenant.id}`, true);
|
|
276
|
-
}
|
|
277
|
-
acl.setRoleReadAccess(`od-tenant-admin-${tenant.id}`, true);
|
|
278
|
-
acl.setRoleWriteAccess(`od-tenant-admin-${tenant.id}`, true);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
exports.defaultAclHandler = defaultAclHandler;
|
|
283
|
-
const beforeSaveHooks = {};
|
|
284
|
-
function beforeSaveHook(target, callback) {
|
|
285
|
-
// @ts-ignore
|
|
286
|
-
const className = typeof target === "string" ? target : target.className;
|
|
287
|
-
if (!beforeSaveHooks[className]) {
|
|
288
|
-
beforeSaveHooks[className] = [];
|
|
289
|
-
Parse.Cloud.beforeSave(className, async function beforeSaveHookFunction(request) {
|
|
290
|
-
const sessionToken = request.user?.getSessionToken();
|
|
291
|
-
const newRequest = { ...request, sessionToken };
|
|
292
|
-
for (const fn of beforeSaveHooks[className]) {
|
|
293
|
-
await fn(newRequest);
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
beforeSaveHooks[className].push(callback);
|
|
298
|
-
}
|
|
299
|
-
exports.beforeSaveHook = beforeSaveHook;
|
|
300
|
-
const afterSaveHooks = {};
|
|
301
|
-
function afterSaveHook(target, callback) {
|
|
302
|
-
// @ts-ignore
|
|
303
|
-
const className = typeof target === "string" ? target : target.className;
|
|
304
|
-
if (!afterSaveHooks[className]) {
|
|
305
|
-
afterSaveHooks[className] = [];
|
|
306
|
-
Parse.Cloud.afterSave(className, async function afterSaveHookFunction(request) {
|
|
307
|
-
const sessionToken = request.user?.getSessionToken();
|
|
308
|
-
const newRequest = { ...request, sessionToken };
|
|
309
|
-
for (const fn of afterSaveHooks[className]) {
|
|
310
|
-
await fn(newRequest);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
afterSaveHooks[className].push(callback);
|
|
315
|
-
}
|
|
316
|
-
exports.afterSaveHook = afterSaveHook;
|
|
317
|
-
const beforeDeleteHooks = {};
|
|
318
|
-
function beforeDeleteHook(target, callback) {
|
|
319
|
-
// @ts-ignore
|
|
320
|
-
const className = typeof target === "string" ? target : target.className;
|
|
321
|
-
if (!beforeDeleteHooks[className]) {
|
|
322
|
-
beforeDeleteHooks[className] = [];
|
|
323
|
-
Parse.Cloud.beforeDelete(className, async function beforeDeleteHookFunction(request) {
|
|
324
|
-
const sessionToken = request.user?.getSessionToken();
|
|
325
|
-
const newRequest = { ...request, sessionToken };
|
|
326
|
-
for (const fn of beforeDeleteHooks[className]) {
|
|
327
|
-
await fn(newRequest);
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
beforeDeleteHooks[className].push(callback);
|
|
332
|
-
}
|
|
333
|
-
exports.beforeDeleteHook = beforeDeleteHook;
|
|
334
|
-
const afterDeleteHooks = {};
|
|
335
|
-
function afterDeleteHook(target, callback) {
|
|
336
|
-
// @ts-ignore
|
|
337
|
-
const className = typeof target === "string" ? target : target.className;
|
|
338
|
-
if (!afterDeleteHooks[className]) {
|
|
339
|
-
afterDeleteHooks[className] = [];
|
|
340
|
-
Parse.Cloud.afterDelete(className, async function afterDeleteHookFunction(request) {
|
|
341
|
-
const sessionToken = request.user?.getSessionToken();
|
|
342
|
-
const newRequest = { ...request, sessionToken };
|
|
343
|
-
for (const fn of afterDeleteHooks[className]) {
|
|
344
|
-
await fn(newRequest);
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
afterDeleteHooks[className].push(callback);
|
|
349
|
-
}
|
|
350
|
-
exports.afterDeleteHook = afterDeleteHook;
|
|
351
|
-
async function autoloadCloudCode(path, regex = /^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$/) {
|
|
352
|
-
const fns = fs_1.default
|
|
353
|
-
.readdirSync(path)
|
|
354
|
-
.filter((filename) => filename.endsWith(".js"))
|
|
355
|
-
.map((filename) => filename.replace(".js", ""))
|
|
356
|
-
.filter((name) => regex.test(name));
|
|
357
|
-
for (const name of fns) {
|
|
358
|
-
const { init } = require((0, path_1.join)(path, name));
|
|
359
|
-
await init(name).catch((e) => console.error(e));
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
exports.autoloadCloudCode = autoloadCloudCode;
|
|
363
|
-
async function initAutoload() {
|
|
364
|
-
const path = config_1.config.get("AUTOLOAD_DIR");
|
|
365
|
-
if (path) {
|
|
366
|
-
await autoloadCloudCode((0, path_1.resolve)(process.cwd(), path));
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
exports.initAutoload = initAutoload;
|
|
370
|
-
function getFeatureForClassName(className) {
|
|
371
|
-
const map = featuremap_json_1.default;
|
|
372
|
-
return map[className] || "unknown";
|
|
373
|
-
}
|
|
374
|
-
function isFeatureEnabled(feature) {
|
|
375
|
-
switch (feature) {
|
|
376
|
-
case "CORE":
|
|
377
|
-
return config_1.config.getBoolean("FEATURE_CORE");
|
|
378
|
-
case "MONITORING":
|
|
379
|
-
return config_1.config.getBoolean("FEATURE_MONITORING");
|
|
380
|
-
case "BDE":
|
|
381
|
-
return config_1.config.getBoolean("FEATURE_BDE");
|
|
382
|
-
case "GTFS":
|
|
383
|
-
return config_1.config.getBoolean("FEATURE_GTFS");
|
|
384
|
-
case "KNOWLEDGE":
|
|
385
|
-
return config_1.config.getBoolean("FEATURE_KNOWLEDGE");
|
|
386
|
-
case "MAINTENANCE":
|
|
387
|
-
return config_1.config.getBoolean("FEATURE_MAINTENANCE");
|
|
388
|
-
case "MIAAS":
|
|
389
|
-
return config_1.config.getBoolean("FEATURE_MIAAS");
|
|
390
|
-
default:
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
function isClassEnabled(className) {
|
|
395
|
-
// if (!config.getBoolean("FEATURES_ENABLED")) return true;
|
|
396
|
-
const feature = getFeatureForClassName(className);
|
|
397
|
-
const enabled = isFeatureEnabled(feature);
|
|
398
|
-
return enabled;
|
|
399
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.initAutoload = exports.autoloadCloudCode = exports.afterDeleteHook = exports.beforeDeleteHook = exports.afterSaveHook = exports.beforeSaveHook = exports.defaultAclHandler = exports.defaultHandler = exports.immutableField = exports.ensureUserRole = exports.ensureRole = exports.getConfigBoolean = exports.getConfig = exports.requirePermission = exports.hasPermission = exports.init = exports.PREFIX = exports.sendTemplateEmail = exports.sendSimpleEmail = exports.Config = void 0;
|
|
7
|
+
const parse_server_schema_1 = require("@openinc/parse-server-schema");
|
|
8
|
+
const fast_equals_1 = require("fast-equals");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = require("path");
|
|
11
|
+
const web_push_1 = __importDefault(require("web-push"));
|
|
12
|
+
const config_1 = require("./config");
|
|
13
|
+
const featuremap_json_1 = __importDefault(require("./featuremap.json"));
|
|
14
|
+
const _init_1 = require("./functions/_init");
|
|
15
|
+
const Core_Email_1 = require("./hooks/Core_Email");
|
|
16
|
+
const _init_2 = require("./hooks/_init");
|
|
17
|
+
const types_1 = require("./types");
|
|
18
|
+
var Config_1 = require("./helper/Config");
|
|
19
|
+
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
|
|
20
|
+
var Core_Email_2 = require("./hooks/Core_Email");
|
|
21
|
+
Object.defineProperty(exports, "sendSimpleEmail", { enumerable: true, get: function () { return Core_Email_2.sendSimpleEmail; } });
|
|
22
|
+
Object.defineProperty(exports, "sendTemplateEmail", { enumerable: true, get: function () { return Core_Email_2.sendTemplateEmail; } });
|
|
23
|
+
exports.PREFIX = "OD3_";
|
|
24
|
+
let schema = {};
|
|
25
|
+
async function init() {
|
|
26
|
+
try {
|
|
27
|
+
const pkg = require("../package.json");
|
|
28
|
+
console.log(`[${pkg.name}] init (v${pkg.version})`);
|
|
29
|
+
}
|
|
30
|
+
catch (error) { }
|
|
31
|
+
await config_1.config.init(true);
|
|
32
|
+
await (0, Core_Email_1.initEmailTransport)();
|
|
33
|
+
await initWebPush();
|
|
34
|
+
await initSchema();
|
|
35
|
+
await initDefaultRoles();
|
|
36
|
+
await initDefaultData();
|
|
37
|
+
await (0, _init_2.init)();
|
|
38
|
+
await (0, _init_1.init)();
|
|
39
|
+
await initAutoload();
|
|
40
|
+
}
|
|
41
|
+
exports.init = init;
|
|
42
|
+
async function initWebPush() {
|
|
43
|
+
try {
|
|
44
|
+
if (config_1.config.getBoolean("WEB_PUSH_ENABLED")) {
|
|
45
|
+
web_push_1.default.setVapidDetails(config_1.config.get("WEB_PUSH_HOST"), config_1.config.get("WEB_PUSH_VAPID_PUBLIC_KEY"), config_1.config.get("WEB_PUSH_VAPID_PRIVATE_KEY"));
|
|
46
|
+
web_push_1.default.setGCMAPIKey(config_1.config.get("WEB_PUSH_FCM_KEY"));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error(error);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async function initSchema() {
|
|
55
|
+
const schemaConfig = await (0, parse_server_schema_1.loadConfig)();
|
|
56
|
+
try {
|
|
57
|
+
await (0, parse_server_schema_1.up)(schemaConfig, (0, path_1.resolve)(__dirname, "../schema"), {
|
|
58
|
+
prefix: exports.PREFIX,
|
|
59
|
+
deleteClasses: config_1.config.getBoolean("FORCE_SCHEMA"),
|
|
60
|
+
deleteFields: config_1.config.getBoolean("FORCE_SCHEMA"),
|
|
61
|
+
filter: (className) => isClassEnabled(className),
|
|
62
|
+
});
|
|
63
|
+
schema = Object.fromEntries((await Parse.Schema.all()).map((schema) => [
|
|
64
|
+
schema.className,
|
|
65
|
+
schema,
|
|
66
|
+
]));
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.error("Error while updating schema");
|
|
70
|
+
console.error(error);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function initDefaultRoles() {
|
|
75
|
+
try {
|
|
76
|
+
await ensureRole("od-user");
|
|
77
|
+
await ensureRole("od-admin");
|
|
78
|
+
await ensureRole("od-tenant-user");
|
|
79
|
+
await ensureRole("od-tenant-verified");
|
|
80
|
+
await ensureRole("od-tenant-admin");
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
console.error(error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function initDefaultData() {
|
|
87
|
+
try {
|
|
88
|
+
// TODO
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error(error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function hasPermission(sessionToken, key) {
|
|
95
|
+
const result = await new Parse.Query(types_1.Permission)
|
|
96
|
+
.equalTo("key", key)
|
|
97
|
+
.first({ sessionToken });
|
|
98
|
+
return !!result;
|
|
99
|
+
}
|
|
100
|
+
exports.hasPermission = hasPermission;
|
|
101
|
+
async function requirePermission(request, key, message) {
|
|
102
|
+
if (request.master) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (!key) {
|
|
106
|
+
throw new Parse.Error(119, "Missing Permission (1): " + (message || key || "Master Key Only"));
|
|
107
|
+
}
|
|
108
|
+
if (!request.sessionToken) {
|
|
109
|
+
throw new Parse.Error(119, "Missing Permission (2): " + (message || key || "Master Key Only"));
|
|
110
|
+
}
|
|
111
|
+
const p = await hasPermission(request.sessionToken, key);
|
|
112
|
+
if (!p) {
|
|
113
|
+
throw new Parse.Error(119, "Missing Permission (3): " + (message || key || "Master Key Only"));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.requirePermission = requirePermission;
|
|
117
|
+
async function getConfig(key) {
|
|
118
|
+
const result = await new Parse.Query(types_1.Config).equalTo("key", key).first({
|
|
119
|
+
useMasterKey: true,
|
|
120
|
+
});
|
|
121
|
+
const value = result?.get("value");
|
|
122
|
+
console.log("[@openinc/parse-server-opendash][Config]", key, value);
|
|
123
|
+
return value || "";
|
|
124
|
+
}
|
|
125
|
+
exports.getConfig = getConfig;
|
|
126
|
+
async function getConfigBoolean(key) {
|
|
127
|
+
const value = await getConfig(key);
|
|
128
|
+
if (!value || value.toLowerCase() === "false" || value === "0") {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
exports.getConfigBoolean = getConfigBoolean;
|
|
134
|
+
async function ensureRole(name, options) {
|
|
135
|
+
const label = options?.label || undefined;
|
|
136
|
+
const acl = options?.acl || new Parse.ACL();
|
|
137
|
+
const childRoles = options?.childRoles || undefined;
|
|
138
|
+
console.log(`[@openinc/parse-server-opendash] ensureRole(${name})`
|
|
139
|
+
// JSON.stringify({ label, acl, childRoles }, null, 2)
|
|
140
|
+
);
|
|
141
|
+
let role = await new Parse.Query(Parse.Role)
|
|
142
|
+
.equalTo("name", name)
|
|
143
|
+
.first({ useMasterKey: true });
|
|
144
|
+
if (!role) {
|
|
145
|
+
role = new Parse.Role(name, acl);
|
|
146
|
+
role.set("label", label);
|
|
147
|
+
await role.save(null, {
|
|
148
|
+
useMasterKey: true,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
let changed = false;
|
|
152
|
+
if (role.get("label") !== label) {
|
|
153
|
+
role.set("label", label);
|
|
154
|
+
changed = true;
|
|
155
|
+
}
|
|
156
|
+
if (!(0, fast_equals_1.deepEqual)(acl.toJSON(), role.getACL()?.toJSON())) {
|
|
157
|
+
role.setACL(acl);
|
|
158
|
+
changed = true;
|
|
159
|
+
}
|
|
160
|
+
if (Array.isArray(childRoles) && childRoles.length > 0) {
|
|
161
|
+
const relation = role.getRoles();
|
|
162
|
+
const currentChildRoles = await relation
|
|
163
|
+
.query()
|
|
164
|
+
.find({ useMasterKey: true });
|
|
165
|
+
const currentChildRoleNames = currentChildRoles.map((role) => role.get("name"));
|
|
166
|
+
for (const childRoleName of childRoles) {
|
|
167
|
+
if (currentChildRoleNames.includes(childRoleName)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const childRole = await new Parse.Query(Parse.Role)
|
|
171
|
+
.equalTo("name", childRoleName)
|
|
172
|
+
.find({ useMasterKey: true });
|
|
173
|
+
relation.add(childRole);
|
|
174
|
+
changed = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (changed) {
|
|
178
|
+
await role.save(null, { useMasterKey: true });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.ensureRole = ensureRole;
|
|
182
|
+
async function ensureUserRole(user, roleName, add = false) {
|
|
183
|
+
const role = await new Parse.Query(Parse.Role)
|
|
184
|
+
.equalTo("name", roleName)
|
|
185
|
+
.first({ useMasterKey: true });
|
|
186
|
+
if (role) {
|
|
187
|
+
const relation = role.relation("users");
|
|
188
|
+
if (add) {
|
|
189
|
+
relation.add(user);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
relation.remove(user);
|
|
193
|
+
}
|
|
194
|
+
await role.save(null, { useMasterKey: true });
|
|
195
|
+
console.log("userRole", user.get("username"), roleName, add);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.ensureUserRole = ensureUserRole;
|
|
199
|
+
async function immutableField(request, fieldName, permissionName = "parse:edit-immutable-fields") {
|
|
200
|
+
if (!request.original || request.master) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const previousValue = JSON.stringify(request.original.get(fieldName));
|
|
204
|
+
const nextValue = JSON.stringify(request.object.get(fieldName));
|
|
205
|
+
if ((0, fast_equals_1.deepEqual)(previousValue, nextValue)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
await requirePermission(request, permissionName, `You are not allowed to edit the '${fieldName}' field.`);
|
|
209
|
+
}
|
|
210
|
+
exports.immutableField = immutableField;
|
|
211
|
+
async function defaultHandler(request) {
|
|
212
|
+
const className = request.object.className;
|
|
213
|
+
if (request.master) {
|
|
214
|
+
console.log(`[@openinc/parse-server-opendash] Skipping default beforeSave() handler of ${className} for masterkey`);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (!request.user) {
|
|
218
|
+
throw new Error();
|
|
219
|
+
}
|
|
220
|
+
const currentSchema = schema[className];
|
|
221
|
+
if (!currentSchema) {
|
|
222
|
+
console.warn(`[@openinc/parse-server-opendash] Skipping default beforeSave() handler, no schema found for ${className}`);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const userField = !!currentSchema?.fields?.user;
|
|
226
|
+
const tenantField = !!currentSchema?.fields?.tenant;
|
|
227
|
+
if (userField) {
|
|
228
|
+
await immutableField(request, "user");
|
|
229
|
+
}
|
|
230
|
+
if (tenantField) {
|
|
231
|
+
await immutableField(request, "tenant");
|
|
232
|
+
}
|
|
233
|
+
if (!request.original) {
|
|
234
|
+
if (userField) {
|
|
235
|
+
request.object.set("user", request.user);
|
|
236
|
+
}
|
|
237
|
+
if (tenantField) {
|
|
238
|
+
const user = (await request.user?.fetch({
|
|
239
|
+
useMasterKey: true,
|
|
240
|
+
}));
|
|
241
|
+
request.object.set("tenant", user.get("tenant"));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.defaultHandler = defaultHandler;
|
|
246
|
+
async function defaultAclHandler(request, options) {
|
|
247
|
+
const className = request.object.className;
|
|
248
|
+
const currentSchema = schema[className];
|
|
249
|
+
if (!currentSchema) {
|
|
250
|
+
console.warn(`[@openinc/parse-server-opendash] Skipping default beforeSave() ACL handler, no schema found for ${className}`);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const userField = !!currentSchema?.fields?.user;
|
|
254
|
+
const tenantField = !!currentSchema?.fields?.tenant;
|
|
255
|
+
if (!options?.allowCustomACL || !request.object.getACL()) {
|
|
256
|
+
request.object.setACL(new Parse.ACL());
|
|
257
|
+
}
|
|
258
|
+
const acl = request.object.getACL();
|
|
259
|
+
acl.setRoleReadAccess("od-admin", true);
|
|
260
|
+
acl.setRoleWriteAccess("od-admin", true);
|
|
261
|
+
if (userField) {
|
|
262
|
+
const user = request.object.get("user");
|
|
263
|
+
if (user) {
|
|
264
|
+
acl.setReadAccess(user.id, true);
|
|
265
|
+
acl.setWriteAccess(user.id, true);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (tenantField) {
|
|
269
|
+
const tenant = request.object.get("tenant");
|
|
270
|
+
if (tenant) {
|
|
271
|
+
if (!options?.denyTenantUserRead) {
|
|
272
|
+
acl.setRoleReadAccess(`od-tenant-user-${tenant.id}`, true);
|
|
273
|
+
}
|
|
274
|
+
if (options?.allowTenantUserWrite) {
|
|
275
|
+
acl.setRoleWriteAccess(`od-tenant-user-${tenant.id}`, true);
|
|
276
|
+
}
|
|
277
|
+
acl.setRoleReadAccess(`od-tenant-admin-${tenant.id}`, true);
|
|
278
|
+
acl.setRoleWriteAccess(`od-tenant-admin-${tenant.id}`, true);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
exports.defaultAclHandler = defaultAclHandler;
|
|
283
|
+
const beforeSaveHooks = {};
|
|
284
|
+
function beforeSaveHook(target, callback) {
|
|
285
|
+
// @ts-ignore
|
|
286
|
+
const className = typeof target === "string" ? target : target.className;
|
|
287
|
+
if (!beforeSaveHooks[className]) {
|
|
288
|
+
beforeSaveHooks[className] = [];
|
|
289
|
+
Parse.Cloud.beforeSave(className, async function beforeSaveHookFunction(request) {
|
|
290
|
+
const sessionToken = request.user?.getSessionToken();
|
|
291
|
+
const newRequest = { ...request, sessionToken };
|
|
292
|
+
for (const fn of beforeSaveHooks[className]) {
|
|
293
|
+
await fn(newRequest);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
beforeSaveHooks[className].push(callback);
|
|
298
|
+
}
|
|
299
|
+
exports.beforeSaveHook = beforeSaveHook;
|
|
300
|
+
const afterSaveHooks = {};
|
|
301
|
+
function afterSaveHook(target, callback) {
|
|
302
|
+
// @ts-ignore
|
|
303
|
+
const className = typeof target === "string" ? target : target.className;
|
|
304
|
+
if (!afterSaveHooks[className]) {
|
|
305
|
+
afterSaveHooks[className] = [];
|
|
306
|
+
Parse.Cloud.afterSave(className, async function afterSaveHookFunction(request) {
|
|
307
|
+
const sessionToken = request.user?.getSessionToken();
|
|
308
|
+
const newRequest = { ...request, sessionToken };
|
|
309
|
+
for (const fn of afterSaveHooks[className]) {
|
|
310
|
+
await fn(newRequest);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
afterSaveHooks[className].push(callback);
|
|
315
|
+
}
|
|
316
|
+
exports.afterSaveHook = afterSaveHook;
|
|
317
|
+
const beforeDeleteHooks = {};
|
|
318
|
+
function beforeDeleteHook(target, callback) {
|
|
319
|
+
// @ts-ignore
|
|
320
|
+
const className = typeof target === "string" ? target : target.className;
|
|
321
|
+
if (!beforeDeleteHooks[className]) {
|
|
322
|
+
beforeDeleteHooks[className] = [];
|
|
323
|
+
Parse.Cloud.beforeDelete(className, async function beforeDeleteHookFunction(request) {
|
|
324
|
+
const sessionToken = request.user?.getSessionToken();
|
|
325
|
+
const newRequest = { ...request, sessionToken };
|
|
326
|
+
for (const fn of beforeDeleteHooks[className]) {
|
|
327
|
+
await fn(newRequest);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
beforeDeleteHooks[className].push(callback);
|
|
332
|
+
}
|
|
333
|
+
exports.beforeDeleteHook = beforeDeleteHook;
|
|
334
|
+
const afterDeleteHooks = {};
|
|
335
|
+
function afterDeleteHook(target, callback) {
|
|
336
|
+
// @ts-ignore
|
|
337
|
+
const className = typeof target === "string" ? target : target.className;
|
|
338
|
+
if (!afterDeleteHooks[className]) {
|
|
339
|
+
afterDeleteHooks[className] = [];
|
|
340
|
+
Parse.Cloud.afterDelete(className, async function afterDeleteHookFunction(request) {
|
|
341
|
+
const sessionToken = request.user?.getSessionToken();
|
|
342
|
+
const newRequest = { ...request, sessionToken };
|
|
343
|
+
for (const fn of afterDeleteHooks[className]) {
|
|
344
|
+
await fn(newRequest);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
afterDeleteHooks[className].push(callback);
|
|
349
|
+
}
|
|
350
|
+
exports.afterDeleteHook = afterDeleteHook;
|
|
351
|
+
async function autoloadCloudCode(path, regex = /^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$/) {
|
|
352
|
+
const fns = fs_1.default
|
|
353
|
+
.readdirSync(path)
|
|
354
|
+
.filter((filename) => filename.endsWith(".js"))
|
|
355
|
+
.map((filename) => filename.replace(".js", ""))
|
|
356
|
+
.filter((name) => regex.test(name));
|
|
357
|
+
for (const name of fns) {
|
|
358
|
+
const { init } = require((0, path_1.join)(path, name));
|
|
359
|
+
await init(name).catch((e) => console.error(e));
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
exports.autoloadCloudCode = autoloadCloudCode;
|
|
363
|
+
async function initAutoload() {
|
|
364
|
+
const path = config_1.config.get("AUTOLOAD_DIR");
|
|
365
|
+
if (path) {
|
|
366
|
+
await autoloadCloudCode((0, path_1.resolve)(process.cwd(), path));
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.initAutoload = initAutoload;
|
|
370
|
+
function getFeatureForClassName(className) {
|
|
371
|
+
const map = featuremap_json_1.default;
|
|
372
|
+
return map[className] || "unknown";
|
|
373
|
+
}
|
|
374
|
+
function isFeatureEnabled(feature) {
|
|
375
|
+
switch (feature) {
|
|
376
|
+
case "CORE":
|
|
377
|
+
return config_1.config.getBoolean("FEATURE_CORE");
|
|
378
|
+
case "MONITORING":
|
|
379
|
+
return config_1.config.getBoolean("FEATURE_MONITORING");
|
|
380
|
+
case "BDE":
|
|
381
|
+
return config_1.config.getBoolean("FEATURE_BDE");
|
|
382
|
+
case "GTFS":
|
|
383
|
+
return config_1.config.getBoolean("FEATURE_GTFS");
|
|
384
|
+
case "KNOWLEDGE":
|
|
385
|
+
return config_1.config.getBoolean("FEATURE_KNOWLEDGE");
|
|
386
|
+
case "MAINTENANCE":
|
|
387
|
+
return config_1.config.getBoolean("FEATURE_MAINTENANCE");
|
|
388
|
+
case "MIAAS":
|
|
389
|
+
return config_1.config.getBoolean("FEATURE_MIAAS");
|
|
390
|
+
default:
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function isClassEnabled(className) {
|
|
395
|
+
// if (!config.getBoolean("FEATURES_ENABLED")) return true;
|
|
396
|
+
const feature = getFeatureForClassName(className);
|
|
397
|
+
const enabled = isFeatureEnabled(feature);
|
|
398
|
+
return enabled;
|
|
399
|
+
}
|