@openinc/parse-server-opendash 1.13.5 → 1.14.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.
Files changed (137) hide show
  1. package/dist/config.d.ts +2 -0
  2. package/dist/config.js +142 -0
  3. package/dist/featuremap.json +69 -0
  4. package/dist/functions/opendash-geo-features.js +5 -5
  5. package/dist/functions/opendash-geo-google-autocomplete.js +2 -2
  6. package/dist/functions/opendash-geo-graphhopper-geocode-reverse.js +3 -3
  7. package/dist/functions/opendash-geo-graphhopper-geocode.js +3 -3
  8. package/dist/helper/Config.d.ts +22 -0
  9. package/dist/helper/Config.js +108 -0
  10. package/dist/hooks/Alarm.js +3 -2
  11. package/dist/hooks/BDE_Form.js +21 -35
  12. package/dist/hooks/BDE_Page.js +24 -3
  13. package/dist/hooks/BDE_Result.js +15 -20
  14. package/dist/index.d.ts +7 -7
  15. package/dist/index.js +73 -25
  16. package/dist/ow.d.ts +0 -1
  17. package/dist/ow.js +10 -10
  18. package/dist/types/AlarmAction.d.ts +3 -0
  19. package/dist/types/AlarmAction.js +6 -0
  20. package/dist/types/BDE_Form.d.ts +3 -0
  21. package/dist/types/BDE_Form.js +6 -0
  22. package/dist/types/GTFS_Agency.d.ts +35 -0
  23. package/dist/types/GTFS_Agency.js +59 -0
  24. package/dist/types/GTFS_Calendar.d.ts +38 -0
  25. package/dist/types/GTFS_Calendar.js +65 -0
  26. package/dist/types/GTFS_Level.d.ts +17 -0
  27. package/dist/types/GTFS_Level.js +23 -0
  28. package/dist/types/GTFS_Location_Type.d.ts +20 -0
  29. package/dist/types/GTFS_Location_Type.js +29 -0
  30. package/dist/types/GTFS_Route.d.ts +42 -0
  31. package/dist/types/GTFS_Route.js +71 -0
  32. package/dist/types/GTFS_Route_Type.d.ts +20 -0
  33. package/dist/types/GTFS_Route_Type.js +29 -0
  34. package/dist/types/GTFS_Stop.d.ts +56 -0
  35. package/dist/types/GTFS_Stop.js +95 -0
  36. package/dist/types/GTFS_Stop_Times.d.ts +28 -0
  37. package/dist/types/GTFS_Stop_Times.js +41 -0
  38. package/dist/types/GTFS_Trip.d.ts +34 -0
  39. package/dist/types/GTFS_Trip.js +53 -0
  40. package/dist/types/GTFS_Wheelchair_Boarding.d.ts +20 -0
  41. package/dist/types/GTFS_Wheelchair_Boarding.js +29 -0
  42. package/dist/types/Group.d.ts +2 -0
  43. package/dist/types/Group.js +3 -0
  44. package/dist/types/Log.d.ts +17 -0
  45. package/dist/types/Log.js +23 -0
  46. package/dist/types/MIAAS_MDSEndpoint.d.ts +26 -0
  47. package/dist/types/MIAAS_MDSEndpoint.js +41 -0
  48. package/dist/types/Maintenance_Duedate.d.ts +6 -6
  49. package/dist/types/Maintenance_Order.d.ts +24 -0
  50. package/dist/types/Maintenance_Order.js +32 -0
  51. package/dist/types/Maintenance_Schedule_Execution.d.ts +4 -0
  52. package/dist/types/Maintenance_Schedule_Execution.js +6 -0
  53. package/dist/types/Maintenance_Schedule_Execution_Step.d.ts +4 -0
  54. package/dist/types/Maintenance_Schedule_Execution_Step.js +6 -0
  55. package/dist/types/Maintenance_Schedule_Step.d.ts +4 -0
  56. package/dist/types/Maintenance_Schedule_Step.js +6 -0
  57. package/dist/types/Maintenance_Ticket.d.ts +5 -0
  58. package/dist/types/Maintenance_Ticket.js +6 -0
  59. package/dist/types/MiaasMDSEndpoint.d.ts +26 -0
  60. package/dist/types/MiaasMDSEndpoint.js +41 -0
  61. package/dist/types/Slideshow.d.ts +20 -0
  62. package/dist/types/Slideshow.js +26 -0
  63. package/dist/types/SourceMeta.d.ts +6 -0
  64. package/dist/types/SourceMeta.js +12 -0
  65. package/dist/types/Tenant.d.ts +3 -0
  66. package/dist/types/Tenant.js +6 -0
  67. package/dist/types/VirtualKPI.d.ts +21 -0
  68. package/dist/types/VirtualKPI.js +29 -0
  69. package/dist/types/_Role.d.ts +1 -1
  70. package/dist/types/_Session.d.ts +1 -1
  71. package/dist/types/_User.d.ts +2 -1
  72. package/dist/types/index.d.ts +30 -0
  73. package/dist/types/index.js +32 -2
  74. package/package.json +6 -6
  75. package/schema/Alarm.json +12 -12
  76. package/schema/AlarmAction.json +32 -21
  77. package/schema/AlarmWebhook.json +17 -17
  78. package/schema/Attachment.json +5 -5
  79. package/schema/BDE_Form.json +17 -6
  80. package/schema/BDE_ListEntry.json +4 -4
  81. package/schema/BDE_Page.json +3 -3
  82. package/schema/BDE_Result.json +2 -2
  83. package/schema/BDE_Unit.json +9 -6
  84. package/schema/Config.json +4 -4
  85. package/schema/Dashboard.json +13 -13
  86. package/schema/GTFS_Agency.json +60 -0
  87. package/schema/GTFS_Calendar.json +66 -0
  88. package/schema/GTFS_Level.json +38 -0
  89. package/schema/GTFS_Location_Type.json +40 -0
  90. package/schema/GTFS_Route.json +69 -0
  91. package/schema/GTFS_Route_Type.json +40 -0
  92. package/schema/GTFS_Stop.json +88 -0
  93. package/schema/GTFS_Stop_Times.json +53 -0
  94. package/schema/GTFS_Trip.json +60 -0
  95. package/schema/GTFS_Wheelchair_Boarding.json +42 -0
  96. package/schema/Group.json +13 -8
  97. package/schema/Knowledge_Article.json +7 -7
  98. package/schema/Knowledge_Category.json +8 -8
  99. package/schema/Knowledge_Document.json +9 -9
  100. package/schema/Knowledge_DocumentPage.json +9 -9
  101. package/schema/Knowledge_Video.json +13 -13
  102. package/schema/Log.json +39 -0
  103. package/schema/MIAAS_MDSEndpoint.json +51 -0
  104. package/schema/Maintenance_Article.json +9 -9
  105. package/schema/Maintenance_Downtime.json +8 -8
  106. package/schema/Maintenance_Duedate.json +12 -12
  107. package/schema/Maintenance_Frequency.json +8 -8
  108. package/schema/Maintenance_Issuecategory.json +9 -9
  109. package/schema/Maintenance_Kanban_State.json +11 -11
  110. package/schema/Maintenance_Media.json +4 -4
  111. package/schema/Maintenance_Order.json +46 -0
  112. package/schema/Maintenance_Priority.json +8 -8
  113. package/schema/Maintenance_Restriction.json +8 -8
  114. package/schema/Maintenance_Schedule.json +13 -13
  115. package/schema/Maintenance_Schedule_Execution.json +20 -15
  116. package/schema/Maintenance_Schedule_Execution_Step.json +19 -14
  117. package/schema/Maintenance_Schedule_Step.json +15 -10
  118. package/schema/Maintenance_Ticket.json +12 -2
  119. package/schema/Maintenance_Ticket_Issuecategory.json +5 -5
  120. package/schema/Maintenance_Ticket_Kanban_State.json +5 -5
  121. package/schema/Maintenance_Ticket_Source.json +5 -5
  122. package/schema/NavigationGroup.json +4 -4
  123. package/schema/NavigationItem.json +20 -20
  124. package/schema/Notification.json +12 -12
  125. package/schema/Push.json +10 -10
  126. package/schema/Report.json +2 -2
  127. package/schema/Share.json +19 -19
  128. package/schema/Slideshow.json +44 -0
  129. package/schema/Source.json +6 -6
  130. package/schema/SourceMeta.json +11 -2
  131. package/schema/Tenant.json +9 -4
  132. package/schema/TenantTrustedDomain.json +4 -4
  133. package/schema/UserData.json +3 -3
  134. package/schema/VirtualKPI.json +47 -0
  135. package/schema/WebPush.json +5 -5
  136. package/schema/Widget.json +3 -3
  137. package/schema/WidgetPreset.json +20 -20
@@ -0,0 +1,2 @@
1
+ import { Config } from "./helper/Config";
2
+ export declare const config: Config<"FEATURES_ENABLED" | "FEATURE_CORE" | "FEATURE_MONITORING" | "FEATURE_BDE" | "FEATURE_GTFS" | "FEATURE_KNOWLEDGE" | "FEATURE_MAINTENANCE" | "FEATURE_MIAAS" | "AUTOLOAD_DIR" | "OPENWARE" | "OPENWARE_BASEURL" | "OPENWARE_JWT_SECRET" | "OPENWARE_JWT_ISS" | "OPENWARE_JWT_ADMIN_EMAIL" | "OPENWARE_JWT_TOKEN" | "GEO_VECTOR_STYLE" | "GEO_GOOGLE_API_KEY" | "GEO_GRAPHHOPPER_HOST" | "GEO_GRAPHHOPPER_API_KEY">;
package/dist/config.js ADDED
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ const Config_1 = require("./helper/Config");
5
+ const options = {
6
+ FEATURES_ENABLED: {
7
+ env: "OPENINC_PARSE_FEATURES_ENABLED",
8
+ type: "boolean",
9
+ required: false,
10
+ secret: false,
11
+ description: "If this option is true, only classes for the features matching OPENINC_PARSE_FEATURE_* are created and used for Cloud Code.",
12
+ },
13
+ FEATURE_CORE: {
14
+ env: "OPENINC_PARSE_FEATURE_CORE",
15
+ type: "boolean",
16
+ required: false,
17
+ secret: false,
18
+ description: "Enable Parse Classes and Cloud Code for core features.",
19
+ },
20
+ FEATURE_MONITORING: {
21
+ env: "OPENINC_PARSE_FEATURE_MONITORING",
22
+ type: "boolean",
23
+ required: false,
24
+ secret: false,
25
+ description: "Enable Parse Classes and Cloud Code for the Monitoring plugin.",
26
+ },
27
+ FEATURE_BDE: {
28
+ env: "OPENINC_PARSE_FEATURE_BDE",
29
+ type: "boolean",
30
+ required: false,
31
+ secret: false,
32
+ description: "Enable Parse Classes and Cloud Code for the BDE plugin.",
33
+ },
34
+ FEATURE_GTFS: {
35
+ env: "OPENINC_PARSE_FEATURE_GTFS",
36
+ type: "boolean",
37
+ required: false,
38
+ secret: false,
39
+ description: "Enable Parse Classes and Cloud Code for the GTFS plugin.",
40
+ },
41
+ FEATURE_KNOWLEDGE: {
42
+ env: "OPENINC_PARSE_FEATURE_KNOWLEDGE",
43
+ type: "boolean",
44
+ required: false,
45
+ secret: false,
46
+ description: "Enable Parse Classes and Cloud Code for the open.KNOWLEDGE plugin.",
47
+ },
48
+ FEATURE_MAINTENANCE: {
49
+ env: "OPENINC_PARSE_FEATURE_MAINTENANCE",
50
+ type: "boolean",
51
+ required: false,
52
+ secret: false,
53
+ description: "Enable Parse Classes and Cloud Code for the open.SERVICE plugin.",
54
+ },
55
+ FEATURE_MIAAS: {
56
+ env: "OPENINC_PARSE_FEATURE_MIAAS",
57
+ type: "boolean",
58
+ required: false,
59
+ secret: false,
60
+ description: "Enable Parse Classes and Cloud Code for the MIAAS plugin.",
61
+ },
62
+ AUTOLOAD_DIR: {
63
+ env: "OPENINC_PARSE_CLOUDCODE_AUTOLOAD_DIR",
64
+ type: "string",
65
+ required: false,
66
+ secret: false,
67
+ description: "Autoload every .js file in the given directory as Parse Server Cloud Code. Just export a async init() function in every file and it will be called.",
68
+ },
69
+ OPENWARE: {
70
+ env: "PARSE_SERVER_OPENWARE",
71
+ type: "boolean",
72
+ required: false,
73
+ secret: false,
74
+ description: "Enable open.WARE Cloud Code features.",
75
+ },
76
+ OPENWARE_BASEURL: {
77
+ env: "PARSE_SERVER_OPENWARE_BASEURL",
78
+ type: "string",
79
+ required: false,
80
+ secret: false,
81
+ description: "Enter a description here...",
82
+ },
83
+ OPENWARE_JWT_SECRET: {
84
+ env: "PARSE_SERVER_OPENWARE_JWT_SECRET",
85
+ type: "string",
86
+ required: false,
87
+ secret: false,
88
+ description: "Enter a description here...",
89
+ },
90
+ OPENWARE_JWT_ISS: {
91
+ env: "PARSE_SERVER_OPENWARE_JWT_ISS",
92
+ type: "string",
93
+ required: false,
94
+ secret: false,
95
+ description: "Enter a description here...",
96
+ },
97
+ OPENWARE_JWT_ADMIN_EMAIL: {
98
+ env: "PARSE_SERVER_OPENWARE_JWT_ADMIN_EMAIL",
99
+ type: "string",
100
+ required: false,
101
+ secret: false,
102
+ description: "Enter a description here...",
103
+ },
104
+ OPENWARE_JWT_TOKEN: {
105
+ env: "PARSE_SERVER_OPENWARE_JWT_TOKEN",
106
+ type: "string",
107
+ required: false,
108
+ secret: false,
109
+ description: "Enter a description here...",
110
+ },
111
+ GEO_VECTOR_STYLE: {
112
+ env: "PARSE_SERVER_GEO_VECTOR_STYLE",
113
+ type: "string",
114
+ required: false,
115
+ secret: false,
116
+ description: "Enter a description here...",
117
+ },
118
+ GEO_GOOGLE_API_KEY: {
119
+ env: "PARSE_SERVER_GEO_GOOGLE_API_KEY",
120
+ type: "string",
121
+ required: false,
122
+ secret: false,
123
+ description: "Enter a description here...",
124
+ },
125
+ GEO_GRAPHHOPPER_HOST: {
126
+ env: "PARSE_SERVER_GEO_GRAPHHOPPER_HOST",
127
+ type: "string",
128
+ required: false,
129
+ secret: false,
130
+ description: "Enter a description here...",
131
+ },
132
+ GEO_GRAPHHOPPER_API_KEY: {
133
+ env: "PARSE_SERVER_GEO_GRAPHHOPPER_API_KEY",
134
+ type: "string",
135
+ required: false,
136
+ secret: false,
137
+ description: "Enter a description here...",
138
+ },
139
+ };
140
+ exports.config = new Config_1.Config(
141
+ // @ts-ignore
142
+ options);
@@ -0,0 +1,69 @@
1
+ {
2
+ "OD3_Alarm": "MONITORING",
3
+ "OD3_AlarmAction": "MONITORING",
4
+ "OD3_AlarmWebhook": "MONITORING",
5
+ "OD3_Attachment": "CORE",
6
+ "OD3_BDE_Form": "BDE",
7
+ "OD3_BDE_List": "BDE",
8
+ "OD3_BDE_ListEntry": "BDE",
9
+ "OD3_BDE_Page": "BDE",
10
+ "OD3_BDE_Result": "BDE",
11
+ "OD3_BDE_Unit": "BDE",
12
+ "OD3_Config": "CORE",
13
+ "OD3_Dashboard": "MONITORING",
14
+ "OD3_Group": "CORE",
15
+ "OD3_GTFS_Agency": "GTFS",
16
+ "OD3_GTFS_Calendar": "GTFS",
17
+ "OD3_GTFS_Level": "GTFS",
18
+ "OD3_GTFS_Location_Type": "GTFS",
19
+ "OD3_GTFS_Route": "GTFS",
20
+ "OD3_GTFS_Route_Type": "GTFS",
21
+ "OD3_GTFS_Stop": "GTFS",
22
+ "OD3_GTFS_Stop_Times": "GTFS",
23
+ "OD3_GTFS_Trip": "GTFS",
24
+ "OD3_GTFS_Wheelchair_Boarding": "GTFS",
25
+ "OD3_Knowledge_Article": "KNOWLEDGE",
26
+ "OD3_Knowledge_Category": "KNOWLEDGE",
27
+ "OD3_Knowledge_Document": "KNOWLEDGE",
28
+ "OD3_Knowledge_DocumentPage": "KNOWLEDGE",
29
+ "OD3_Knowledge_Video": "KNOWLEDGE",
30
+ "OD3_Language": "CORE",
31
+ "OD3_Log": "CORE",
32
+ "OD3_Maintenance_Article": "MAINTENANCE",
33
+ "OD3_Maintenance_Downtime": "MAINTENANCE",
34
+ "OD3_Maintenance_Duedate": "MAINTENANCE",
35
+ "OD3_Maintenance_Frequency": "MAINTENANCE",
36
+ "OD3_Maintenance_Issuecategory": "MAINTENANCE",
37
+ "OD3_Maintenance_Kanban_State": "MAINTENANCE",
38
+ "OD3_Maintenance_Media": "MAINTENANCE",
39
+ "OD3_Maintenance_Order": "MAINTENANCE",
40
+ "OD3_Maintenance_Priority": "MAINTENANCE",
41
+ "OD3_Maintenance_Restriction": "MAINTENANCE",
42
+ "OD3_Maintenance_Schedule": "MAINTENANCE",
43
+ "OD3_Maintenance_Schedule_Execution": "MAINTENANCE",
44
+ "OD3_Maintenance_Schedule_Execution_Step": "MAINTENANCE",
45
+ "OD3_Maintenance_Schedule_Step": "MAINTENANCE",
46
+ "OD3_Maintenance_Ticket": "MAINTENANCE",
47
+ "OD3_Maintenance_Ticket_Issuecategory": "MAINTENANCE",
48
+ "OD3_Maintenance_Ticket_Kanban_State": "MAINTENANCE",
49
+ "OD3_Maintenance_Ticket_Source": "MAINTENANCE",
50
+ "OD3_MIAAS_MDSEndpoint": "MIAAS",
51
+ "OD3_NavigationGroup": "CORE",
52
+ "OD3_NavigationItem": "CORE",
53
+ "OD3_Notification": "CORE",
54
+ "OD3_Permission": "CORE",
55
+ "OD3_Push": "CORE",
56
+ "OD3_Report": "CORE",
57
+ "OD3_Share": "CORE",
58
+ "OD3_Slideshow": "MONITORING",
59
+ "OD3_Source": "CORE",
60
+ "OD3_SourceMeta": "CORE",
61
+ "OD3_Tenant": "CORE",
62
+ "OD3_TenantMeta": "CORE",
63
+ "OD3_TenantTrustedDomain": "CORE",
64
+ "OD3_UserData": "CORE",
65
+ "OD3_VirtualKPI": "MONITORING",
66
+ "OD3_WebPush": "CORE",
67
+ "OD3_Widget": "MONITORING",
68
+ "OD3_WidgetPreset": "MONITORING"
69
+ }
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = void 0;
4
- const __1 = require("..");
4
+ const config_1 = require("../config");
5
5
  async function init(name) {
6
6
  Parse.Cloud.define(name, async (request) => {
7
- const style = (0, __1.getEnv)("PARSE_SERVER_GEO_VECTOR_STYLE");
8
- const GoK = (0, __1.getEnv)("PARSE_SERVER_GEO_GOOGLE_API_KEY");
9
- const GHH = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_HOST");
10
- const GHK = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_API_KEY");
7
+ const style = config_1.config.get("GEO_VECTOR_STYLE");
8
+ const GoK = config_1.config.get("GEO_GOOGLE_API_KEY");
9
+ const GHH = config_1.config.get("GEO_GRAPHHOPPER_HOST");
10
+ const GHK = config_1.config.get("GEO_GRAPHHOPPER_API_KEY");
11
11
  return {
12
12
  "vector-style": style,
13
13
  "opendash-geo-google-autocomplete": !!GoK,
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = void 0;
4
- const __1 = require("..");
4
+ const config_1 = require("../config");
5
5
  async function init(name) {
6
6
  Parse.Cloud.define(name, async (request) => {
7
- const API_KEY = (0, __1.getEnv)("PARSE_SERVER_GEO_GOOGLE_API_KEY");
7
+ const API_KEY = config_1.config.get("GEO_GOOGLE_API_KEY");
8
8
  if (!API_KEY) {
9
9
  throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-1]`);
10
10
  }
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = void 0;
4
- const __1 = require("..");
4
+ const config_1 = require("../config");
5
5
  const opendash_geo_graphhopper_geocode_1 = require("./opendash-geo-graphhopper-geocode");
6
6
  async function init(name) {
7
7
  Parse.Cloud.define(name, async function (request) {
8
- const GRAPHHOPPER_HOST = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_HOST");
8
+ const GRAPHHOPPER_HOST = config_1.config.get("GEO_GRAPHHOPPER_HOST");
9
9
  if (!GRAPHHOPPER_HOST) {
10
10
  throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-1]`);
11
11
  }
12
- const GRAPHHOPPER_API_KEY = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_API_KEY");
12
+ const GRAPHHOPPER_API_KEY = config_1.config.get("GEO_GRAPHHOPPER_API_KEY");
13
13
  if (!GRAPHHOPPER_API_KEY) {
14
14
  throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-2]`);
15
15
  }
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getGeoCodingResult = exports.init = void 0;
4
- const __1 = require("..");
4
+ const config_1 = require("../config");
5
5
  async function init(name) {
6
6
  Parse.Cloud.define(name, async function (request) {
7
- const GRAPHHOPPER_HOST = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_HOST");
7
+ const GRAPHHOPPER_HOST = config_1.config.get("GEO_GRAPHHOPPER_HOST");
8
8
  if (!GRAPHHOPPER_HOST) {
9
9
  throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-1]`);
10
10
  }
11
- const GRAPHHOPPER_API_KEY = (0, __1.getEnv)("PARSE_SERVER_GEO_GRAPHHOPPER_API_KEY");
11
+ const GRAPHHOPPER_API_KEY = config_1.config.get("GEO_GRAPHHOPPER_API_KEY");
12
12
  if (!GRAPHHOPPER_API_KEY) {
13
13
  throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `Feature not enabled [${name}-2]`);
14
14
  }
@@ -0,0 +1,22 @@
1
+ interface ConfigValue {
2
+ env: string;
3
+ type: "string" | "int" | "float" | "boolean";
4
+ }
5
+ interface ConfigMap {
6
+ [key: string]: ConfigValue;
7
+ }
8
+ export declare class Config<T extends string> {
9
+ private configs;
10
+ private values;
11
+ constructor(configs: ConfigMap);
12
+ init(): Promise<void>;
13
+ get(key: T): string;
14
+ getBoolean(key: T): boolean;
15
+ getNumber(key: T): number;
16
+ log(): void;
17
+ }
18
+ export declare function getEnv(key: string): string | undefined;
19
+ export declare function getEnvInt(key: string): number;
20
+ export declare function getEnvFloat(key: string): number;
21
+ export declare function getEnvBoolean(key: string): boolean;
22
+ export {};
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnvBoolean = exports.getEnvFloat = exports.getEnvInt = exports.getEnv = exports.Config = void 0;
4
+ class Config {
5
+ constructor(configs) {
6
+ this.values = {};
7
+ this.configs = configs;
8
+ this.init();
9
+ }
10
+ async init() {
11
+ for (const [key, c] of Object.entries(this.configs)) {
12
+ if (c.type === "string") {
13
+ this.values[key] = getEnv(c.env);
14
+ }
15
+ if (c.type === "int") {
16
+ this.values[key] = getEnvInt(c.env);
17
+ }
18
+ if (c.type === "float") {
19
+ this.values[key] = getEnvFloat(c.env);
20
+ }
21
+ if (c.type === "boolean") {
22
+ this.values[key] = getEnvBoolean(c.env);
23
+ }
24
+ }
25
+ }
26
+ get(key) {
27
+ return this.values[key];
28
+ }
29
+ getBoolean(key) {
30
+ return this.values[key];
31
+ }
32
+ getNumber(key) {
33
+ return this.values[key];
34
+ }
35
+ log() {
36
+ const table = [];
37
+ const colWidth = {};
38
+ for (const [key, c] of Object.entries(this.configs)) {
39
+ table.push({
40
+ key,
41
+ env: c.env,
42
+ type: c.type,
43
+ value: this.values[key]?.toString() || "undefined",
44
+ });
45
+ }
46
+ for (const x of table) {
47
+ for (const [key, value] of Object.entries(x)) {
48
+ const length = value.length;
49
+ if ((colWidth[key] && colWidth[key] < length) || !colWidth[key]) {
50
+ colWidth[key] = length;
51
+ }
52
+ }
53
+ }
54
+ for (const x of table) {
55
+ for (const [key, value] of Object.entries(x)) {
56
+ x[key] = value.padEnd(colWidth[key], " ");
57
+ }
58
+ }
59
+ let result = "";
60
+ result += "┌─";
61
+ result += Object.keys(colWidth)
62
+ .map((key) => "─".repeat(colWidth[key]))
63
+ .join("─┬─");
64
+ result += "─┐\n";
65
+ result += "│ ";
66
+ result += Object.keys(colWidth)
67
+ .map((key) => key.padEnd(colWidth[key], " "))
68
+ .join(" │ ");
69
+ result += " │\n";
70
+ result += "├─";
71
+ result += Object.keys(colWidth)
72
+ .map((key) => "─".repeat(colWidth[key]))
73
+ .join("─┼─");
74
+ result += "─┤\n";
75
+ for (const row of table) {
76
+ result += "│ ";
77
+ result += Object.values(row).join(" │ ");
78
+ result += " │\n";
79
+ }
80
+ result += "└─";
81
+ result += Object.keys(colWidth)
82
+ .map((key) => "─".repeat(colWidth[key]))
83
+ .join("─┴─");
84
+ result += "─┘\n";
85
+ console.log(result);
86
+ }
87
+ }
88
+ exports.Config = Config;
89
+ function getEnv(key) {
90
+ return process.env[key];
91
+ }
92
+ exports.getEnv = getEnv;
93
+ function getEnvInt(key) {
94
+ return parseInt(getEnv(key) || "");
95
+ }
96
+ exports.getEnvInt = getEnvInt;
97
+ function getEnvFloat(key) {
98
+ return parseFloat(getEnv(key) || "");
99
+ }
100
+ exports.getEnvFloat = getEnvFloat;
101
+ function getEnvBoolean(key) {
102
+ const value = getEnv(key);
103
+ if (!value || value.toLowerCase() === "false" || value === "0") {
104
+ return false;
105
+ }
106
+ return true;
107
+ }
108
+ exports.getEnvBoolean = getEnvBoolean;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.init = void 0;
7
7
  const node_fetch_1 = __importDefault(require("node-fetch"));
8
8
  const __1 = require("..");
9
+ const config_1 = require("../config");
9
10
  const types_1 = require("../types");
10
11
  async function init() {
11
12
  (0, __1.beforeSaveHook)(types_1.Alarm, async (request) => {
@@ -14,9 +15,9 @@ async function init() {
14
15
  // TODO
15
16
  });
16
17
  (0, __1.afterSaveHook)(types_1.Alarm, async ({ object, original, user }) => {
17
- if ((0, __1.getEnvBoolean)("PARSE_SERVER_OPENWARE")) {
18
+ if ((0, __1.getEnvBoolean)("OPENWARE")) {
18
19
  const username = user?.get("username");
19
- const baseurl = (0, __1.getEnv)("PARSE_SERVER_OPENWARE_BASEURL");
20
+ const baseurl = config_1.config.get("OPENWARE_BASEURL");
20
21
  const headers = {
21
22
  "content-type": "application/json",
22
23
  "od-session": user?.getSessionToken() || "",
@@ -6,13 +6,20 @@ const types_1 = require("../types");
6
6
  async function init() {
7
7
  (0, __1.beforeSaveHook)(types_1.BDE_Form, async (request) => {
8
8
  const { object, original, user } = request;
9
- const entries = object.get("entries");
9
+ const pages = object.get("entries");
10
10
  const form = object.get("form");
11
- if (entries) {
12
- const Entry = Parse.Object.extend(__1.PREFIX + "BDE_Page");
13
- const promises = entries.map((entry) => {
14
- return Entry.createWithoutData(entry).fetch({ useMasterKey: true });
15
- });
11
+ const acl = object.getACL();
12
+ if (pages) {
13
+ const res = [];
14
+ for (const page of pages) {
15
+ try {
16
+ const fetchedPage = (await types_1.BDE_Page.createWithoutData(page).fetch({ useMasterKey: true }));
17
+ res.push(fetchedPage);
18
+ }
19
+ catch (error) {
20
+ console.error("Could not load BDE_Page", error);
21
+ }
22
+ }
16
23
  Object.keys(form).forEach((key) => {
17
24
  if (key.startsWith("step")) {
18
25
  delete form[key];
@@ -22,46 +29,25 @@ async function init() {
22
29
  delete form.next;
23
30
  }
24
31
  object.set("form", {});
25
- const res = await allSettled(promises);
26
32
  let sCount = 1;
27
33
  const newEntries = [];
28
34
  res.forEach((element, idx) => {
29
- console.log(JSON.stringify(element) + "\n\n\n");
30
- if (element.code && element.code === 101) {
31
- }
32
- else {
33
- newEntries.push(entries[idx]);
34
- form["step" + sCount++] = element.get("data");
35
- if (idx < res.length - 1) {
36
- form["step" + (sCount - 1)].next = "step" + sCount;
37
- }
35
+ newEntries.push(pages[idx]);
36
+ form["step" + sCount++] = element.get("data");
37
+ if (idx < res.length - 1) {
38
+ form["step" + (sCount - 1)].next = "step" + sCount;
38
39
  }
39
40
  });
41
+ request.context.pages = res;
40
42
  object.set("entries", newEntries);
41
43
  object.set("form", form);
42
44
  }
43
45
  });
44
46
  (0, __1.afterSaveHook)(types_1.BDE_Form, async (request) => {
45
47
  const { object, original, user } = request;
46
- // TODO
48
+ for (const page of request.context.pages) {
49
+ page.save(null, { useMasterKey: true });
50
+ }
47
51
  });
48
52
  }
49
53
  exports.init = init;
50
- async function allSettled(promises) {
51
- return new Promise((resolve, reject) => {
52
- const results = [];
53
- let count = 0;
54
- promises.forEach((promise, idx) => {
55
- promise
56
- .catch((err) => {
57
- return err;
58
- })
59
- .then((valueOrError) => {
60
- results[idx] = valueOrError;
61
- count += 1;
62
- if (count === promises.length)
63
- resolve(results);
64
- });
65
- });
66
- });
67
- }
@@ -6,14 +6,35 @@ const types_1 = require("../types");
6
6
  async function init() {
7
7
  (0, __1.beforeSaveHook)(types_1.BDE_Page, async (request) => {
8
8
  const { object, original, user } = request;
9
- // await defaultHandler(request);
10
- // TODO
9
+ request.context.dirtyKeys = object.dirtyKeys();
10
+ const query = new Parse.Query(__1.PREFIX + "BDE_Form").equalTo("entries", object.id);
11
+ const affectedForms = await query.find({ useMasterKey: true });
12
+ const aclCandidates = {};
13
+ affectedForms.forEach((form) => {
14
+ const formAcl = form.getACL()?.toJSON();
15
+ const keys = Object.keys(formAcl);
16
+ for (const userOrRole of keys) {
17
+ if (!aclCandidates[userOrRole]) {
18
+ aclCandidates[userOrRole] = { read: false, write: false };
19
+ }
20
+ aclCandidates[userOrRole].read =
21
+ formAcl[userOrRole].read || aclCandidates[userOrRole].read;
22
+ aclCandidates[userOrRole].write =
23
+ formAcl[userOrRole].write || aclCandidates[userOrRole].write;
24
+ }
25
+ console.log(aclCandidates);
26
+ const newAcl = new Parse.ACL(aclCandidates);
27
+ object.setACL(newAcl);
28
+ });
11
29
  });
12
30
  (0, __1.afterSaveHook)(types_1.BDE_Page, async (request) => {
13
31
  const { object, original, user } = request;
32
+ console.log("Dirty Keys", request.context.dirtyKeys);
14
33
  const query = new Parse.Query(__1.PREFIX + "BDE_Form").equalTo("entries", object.id);
15
34
  const affectedForms = await query.find({ useMasterKey: true });
16
- await Parse.Object.saveAll(affectedForms, { useMasterKey: true });
35
+ const dirtyKeys = request.context.dirtyKeys;
36
+ if (dirtyKeys.length > 0 && dirtyKeys[0] !== "acl")
37
+ await Parse.Object.saveAll(affectedForms, { useMasterKey: true });
17
38
  });
18
39
  (0, __1.afterDeleteHook)(types_1.BDE_Page, async (request) => {
19
40
  const { object, original, user } = request;
@@ -16,7 +16,7 @@ async function init() {
16
16
  const saveDateTimestamp = data.saveDate;
17
17
  const values = [];
18
18
  const valueTypes = [];
19
- Object.keys(data.pages)
19
+ Object.keys(data.form?.form || data.pages)
20
20
  //Nur Steps Objekte
21
21
  .filter((page) => page.startsWith("step"))
22
22
  // die steps sortieren
@@ -25,7 +25,7 @@ async function init() {
25
25
  })
26
26
  //die Steps auswerten
27
27
  .forEach((key) => {
28
- const fields = data.pages[key].fields;
28
+ const fields = data.form.form[key].fields;
29
29
  fields.forEach((field) => {
30
30
  if (field.type.toLowerCase() === "text" ||
31
31
  field.type.toLowerCase() === "select" ||
@@ -55,7 +55,7 @@ async function init() {
55
55
  if (field.type === "choose_image") {
56
56
  values.push(field.value);
57
57
  valueTypes.push({
58
- name: "Medien",
58
+ name: "Media",
59
59
  unit: "",
60
60
  type: "String",
61
61
  });
@@ -106,25 +106,20 @@ async function init() {
106
106
  });
107
107
  //STEP
108
108
  });
109
- // values.push(data.duration / 1000);
110
- // valueTypes.push({
111
- // name: "Dauer",
112
- // unit: "Sekunden",
113
- // type: "Number",
114
- // });
115
- values.push(data.user.username + " (" + data.user.objectId + ")");
116
- valueTypes.push({
117
- name: "Nutzer",
118
- unit: "",
119
- type: "String",
120
- });
109
+ if (data.form?.storeUserInfo || false) {
110
+ values.push(data.user.username + " (" + data.user.objectId + ")");
111
+ valueTypes.push({
112
+ name: "Nutzer",
113
+ unit: "",
114
+ type: "String",
115
+ });
116
+ }
121
117
  await (0, ow_1.publishDataItem)({
122
- id: data.source + data.formID,
123
- user: data.source,
124
- reference: data.reference,
118
+ id: data.form?.RID || data.formID,
119
+ user: data.source.source || data.source,
120
+ reference: data.reference !== null ? data.reference : undefined,
125
121
  meta: {},
126
- parent: [],
127
- name: data.title,
122
+ name: data.form.name || data.title,
128
123
  valueTypes: valueTypes,
129
124
  values: [{ date: saveDateTimestamp, value: values }],
130
125
  }, data.user.email);