@openinc/parse-server-opendash 3.4.0 → 3.4.1

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.
@@ -49,7 +49,6 @@
49
49
  "OD3_Maintenance_Kanban_State": "MAINTENANCE",
50
50
  "OD3_Maintenance_Media": "MAINTENANCE",
51
51
  "OD3_Maintenance_Message": "MAINTENANCE",
52
- "OD3_Maintenance_Message_Body": "MAINTENANCE",
53
52
  "OD3_Maintenance_Order": "MAINTENANCE",
54
53
  "OD3_Maintenance_Priority": "MAINTENANCE",
55
54
  "OD3_Maintenance_Project": "MAINTENANCE",
@@ -68,6 +67,7 @@
68
67
  "OD3_Maintenance_Ticket_Kanban_State_Current": "MAINTENANCE",
69
68
  "OD3_Maintenance_Ticket_Material": "MAINTENANCE",
70
69
  "OD3_Maintenance_Ticket_Project": "MAINTENANCE",
70
+ "OD3_Maintenance_Ticket_QR_Code": "MAINTENANCE",
71
71
  "OD3_Maintenance_Ticket_Source": "MAINTENANCE",
72
72
  "OD3_Maintenance_Ticket_Title": "MAINTENANCE",
73
73
  "OD3_MES_Article": "MONITORING",
@@ -1 +1,5 @@
1
1
  export { ScheduleCronObjectType, ScheduleType } from "./types/CRON_Types";
2
+ export { JobTypes } from "./types/jobTypes";
3
+ export { TimespanFieldType, TimeUnit } from "./types/notifyBeforeDue";
4
+ export { default } from "./states/BreeInstance";
5
+ export { initBree } from "./services/initBree";
@@ -1,2 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initBree = exports.default = exports.TimeUnit = void 0;
7
+ var notifyBeforeDue_1 = require("./types/notifyBeforeDue");
8
+ Object.defineProperty(exports, "TimeUnit", { enumerable: true, get: function () { return notifyBeforeDue_1.TimeUnit; } });
9
+ var BreeInstance_1 = require("./states/BreeInstance");
10
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(BreeInstance_1).default; } });
11
+ var initBree_1 = require("./services/initBree");
12
+ Object.defineProperty(exports, "initBree", { enumerable: true, get: function () { return initBree_1.initBree; } });
@@ -0,0 +1 @@
1
+ export declare function initBree(): Promise<void>;
@@ -0,0 +1,19 @@
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.initBree = initBree;
7
+ const __1 = __importDefault(require(".."));
8
+ async function initBree() {
9
+ const bree = __1.default.getBree();
10
+ //Start bree object
11
+ // const graceful = new Graceful({ brees: [bree] });
12
+ // graceful.listen();
13
+ (async () => {
14
+ console.log("[@openinc/parse-server-opendash] Starting bree");
15
+ await bree.start();
16
+ const jobs = __1.default.getAllJobs();
17
+ console.log("[@openinc/parse-server-opendash] Number of Bree jobs in initialization:", jobs.length);
18
+ })();
19
+ }
@@ -0,0 +1,32 @@
1
+ import Bree from "bree";
2
+ import { JobTypes, TimespanFieldType } from "..";
3
+ export default class BreeInstance {
4
+ private static instance;
5
+ private static jobs;
6
+ private constructor();
7
+ static getBree(): Bree;
8
+ static getAllJobs(): Bree.Job[];
9
+ /**
10
+ * Converts a cron-like string into a human-readable format.
11
+ *
12
+ * @param value - The cron-like string to convert.
13
+ * @returns A human-readable string representing the cron-like schedule.
14
+ */
15
+ static createHumanReadableFormat(value: string): string;
16
+ /**
17
+ * Calculates how much earlier a job should be scheduled based on the user input.
18
+ * Users can set an offset like "2 weeks" or "3 days" to schedule the job earlier.
19
+ * This function will substract the offset from startdate and return a new date.
20
+ */
21
+ static calculateOffsetToExecution(startdate: Date, notifyBeforeDue: TimespanFieldType): Date;
22
+ static addJob(newjob: Bree.Job | Omit<Bree.Job, "timeout"> | undefined): Promise<void>;
23
+ static removeJob(jobName: string): Promise<void>;
24
+ static getJobByName(jobName: string): Bree.Job | undefined;
25
+ /**
26
+ * Constructs a job name based on the schedule ID and job type.
27
+ * @param id - The ID of the schedule.
28
+ * @param jobType - The type of the job (e.g., "notification before due").
29
+ * @returns A string representing the constructed job name.
30
+ */
31
+ static constructJobName(id: string, jobType: JobTypes): string;
32
+ }
@@ -4,9 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const bree_1 = __importDefault(require("bree"));
7
+ const dayjs_1 = __importDefault(require("dayjs"));
8
+ const duration_1 = __importDefault(require("dayjs/plugin/duration"));
9
+ dayjs_1.default.extend(duration_1.default);
7
10
  class BreeInstance {
8
11
  constructor() { }
9
- static getInstance() {
12
+ static getBree() {
10
13
  if (this.instance === null) {
11
14
  // Create a new instance of Bree
12
15
  this.instance = new bree_1.default({
@@ -72,6 +75,58 @@ class BreeInstance {
72
75
  }
73
76
  return returnArray.join(", ");
74
77
  }
78
+ /**
79
+ * Calculates how much earlier a job should be scheduled based on the user input.
80
+ * Users can set an offset like "2 weeks" or "3 days" to schedule the job earlier.
81
+ * This function will substract the offset from startdate and return a new date.
82
+ */
83
+ static calculateOffsetToExecution(startdate, notifyBeforeDue) {
84
+ const result = (0, dayjs_1.default)(startdate).subtract(dayjs_1.default.duration({ days: notifyBeforeDue.value }));
85
+ return result.toDate();
86
+ }
87
+ static async addJob(newjob) {
88
+ if (newjob === undefined) {
89
+ console.error("newjob is undefined");
90
+ return;
91
+ }
92
+ //Get all jobs from bree and check whether the job already exists
93
+ const jobs = BreeInstance.getAllJobs();
94
+ let jobExists = false;
95
+ for (const job of jobs) {
96
+ if (job.name === newjob.name) {
97
+ jobExists = true;
98
+ break;
99
+ }
100
+ }
101
+ if (jobExists) {
102
+ console.log(`Job with name ${newjob.name} already exists`);
103
+ return;
104
+ }
105
+ console.log(`Adding job with jobname ${newjob.name}`);
106
+ return await BreeInstance.getBree().add(newjob);
107
+ }
108
+ static async removeJob(jobName) {
109
+ console.log(`Removing job with jobname ${jobName}`);
110
+ return BreeInstance.getBree().remove(jobName);
111
+ }
112
+ static getJobByName(jobName) {
113
+ const jobs = BreeInstance.getAllJobs();
114
+ for (const job of jobs) {
115
+ if (job.name === jobName) {
116
+ return job;
117
+ }
118
+ }
119
+ return undefined;
120
+ }
121
+ /**
122
+ * Constructs a job name based on the schedule ID and job type.
123
+ * @param id - The ID of the schedule.
124
+ * @param jobType - The type of the job (e.g., "notification before due").
125
+ * @returns A string representing the constructed job name.
126
+ */
127
+ static constructJobName(id, jobType) {
128
+ return `${id}_${jobType}`;
129
+ }
75
130
  }
76
131
  BreeInstance.instance = null;
77
132
  BreeInstance.jobs = [];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @description
3
+ * This file contains the types for the job types used in the cron jobs.
4
+ */
5
+ export type JobTypes = "Maintenance_Schedule" | "Maintenance_Schedule_Notification_Before_Due";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ export declare enum TimeUnit {
2
+ milliseconds = "milliseconds",
3
+ seconds = "seconds",
4
+ minutes = "minutes",
5
+ hours = "hours",
6
+ days = "days",
7
+ weeks = "weeks",
8
+ months = "months",
9
+ years = "years"
10
+ }
11
+ export type TimespanFieldType = {
12
+ value: number;
13
+ unit: TimeUnit;
14
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TimeUnit = void 0;
4
+ var TimeUnit;
5
+ (function (TimeUnit) {
6
+ TimeUnit["milliseconds"] = "milliseconds";
7
+ TimeUnit["seconds"] = "seconds";
8
+ TimeUnit["minutes"] = "minutes";
9
+ TimeUnit["hours"] = "hours";
10
+ TimeUnit["days"] = "days";
11
+ TimeUnit["weeks"] = "weeks";
12
+ TimeUnit["months"] = "months";
13
+ TimeUnit["years"] = "years";
14
+ })(TimeUnit || (exports.TimeUnit = TimeUnit = {}));
@@ -10,7 +10,7 @@ const ensureSettings_1 = require("../helper/ensureSettings");
10
10
  *
11
11
  * @returns {Promise<void>}
12
12
  */
13
- function initUserSettings() {
13
+ async function initUserSettings() {
14
14
  console.log("[@openinc/parse-server-opendash] Init user settings for all users");
15
15
  return new Parse.Query(parse_1.User).each(async (user) => await (0, ensureSettings_1.ensureSettings)(user), { useMasterKey: true });
16
16
  }
@@ -7,7 +7,7 @@ exports.init = init;
7
7
  const bree_1 = __importDefault(require("bree"));
8
8
  const node_path_1 = __importDefault(require("node:path"));
9
9
  const __1 = require("..");
10
- const BreeInstance_1 = __importDefault(require("../helper/BreeInstance"));
10
+ const cron_1 = __importDefault(require("../features/cron"));
11
11
  const catchError_1 = require("../helper/catchError");
12
12
  const types_1 = require("../types");
13
13
  bree_1.default.extend(require("@breejs/ts-worker"));
@@ -22,6 +22,17 @@ async function init() {
22
22
  const { object, original, user } = request;
23
23
  await addJobToBree([object]);
24
24
  });
25
+ (0, __1.beforeDeleteHook)(types_1.Maintenance_Schedule_Template, async (request) => {
26
+ const { object, original, user } = request;
27
+ //Check if a prenotification is scheduled
28
+ const notifyBeforeDue = object.get("notifyBeforeDue");
29
+ // If the notifyBeforeDue field is set, we will schedule a job to run before the due date
30
+ if (notifyBeforeDue && notifyBeforeDue.value > 0) {
31
+ await cron_1.default.removeJob(cron_1.default.constructJobName(object.id, "Maintenance_Schedule_Notification_Before_Due"));
32
+ }
33
+ await cron_1.default.removeJob(cron_1.default.constructJobName(object.id, "Maintenance_Schedule"));
34
+ });
35
+ (0, __1.afterDeleteHook)(types_1.Maintenance_Schedule_Template, async (request) => { });
25
36
  /**
26
37
  * This function is called upon initialization and uses bree to schedule all jobs.
27
38
  */
@@ -40,17 +51,42 @@ async function init() {
40
51
  }
41
52
  async function addJobToBree(query) {
42
53
  for (const schedule of query) {
43
- console.log(`Adding job for schedule ${schedule.id}`);
44
54
  const cron = schedule.get("cron");
55
+ const notifyBeforeDue = schedule.get("notifyBeforeDue");
56
+ // If the notifyBeforeDue field is set, we will schedule a job to run before the due date
57
+ if (notifyBeforeDue && notifyBeforeDue.value > 0) {
58
+ // Calculate the offset from the start date
59
+ const startdate = cron_1.default.calculateOffsetToExecution(schedule.get("cron").run_startdate, notifyBeforeDue);
60
+ //Add a job to bree to run at the calculated date
61
+ const newjob = {
62
+ name: cron_1.default.constructJobName(schedule.id, "Maintenance_Schedule_Notification_Before_Due"),
63
+ path: node_path_1.default.join(__dirname, "..", "jobs", "open_service_notifyBeforeSchedule.js"),
64
+ date: startdate,
65
+ interval: cron.is_one_time
66
+ ? 0
67
+ : cron_1.default.createHumanReadableFormat(cron.run_cron),
68
+ hasSeconds: true,
69
+ worker: {
70
+ workerData: {
71
+ scheduleId: schedule.id,
72
+ ParseAppId: Parse.applicationId,
73
+ ParseJSKey: Parse.javaScriptKey,
74
+ ParseMasterKey: Parse.masterKey,
75
+ ParseServerURL: Parse.serverURL,
76
+ },
77
+ },
78
+ };
79
+ await cron_1.default.addJob(newjob);
80
+ }
45
81
  try {
46
82
  let newjob = undefined;
47
83
  if (cron.is_one_time === false) {
48
84
  if (cron.scheduletype === "human") {
49
85
  newjob = {
50
- name: `Schedule ${schedule.id}`,
86
+ name: cron_1.default.constructJobName(schedule.id, "Maintenance_Schedule"),
87
+ date: cron.run_startdate,
51
88
  path: node_path_1.default.join(__dirname, "..", "jobs", "open_service_notifyOnSchedule.js"),
52
- timeout: 0,
53
- interval: BreeInstance_1.default.createHumanReadableFormat(cron.run_cron),
89
+ interval: cron_1.default.createHumanReadableFormat(cron.run_cron),
54
90
  hasSeconds: true,
55
91
  worker: {
56
92
  workerData: {
@@ -65,7 +101,7 @@ async function init() {
65
101
  }
66
102
  else if (cron.scheduletype === "quartz") {
67
103
  newjob = {
68
- name: `Schedule ${schedule.id}`,
104
+ name: cron_1.default.constructJobName(schedule.id, "Maintenance_Schedule"),
69
105
  cron: cron.run_cron,
70
106
  path: node_path_1.default.join(__dirname, "..", "jobs", "open_service_notifyOnSchedule.js"),
71
107
  timeout: 0,
@@ -86,7 +122,7 @@ async function init() {
86
122
  else {
87
123
  // If the job is a one time job, we will schedule it to run once
88
124
  newjob = {
89
- name: `Schedule ${schedule.id}`,
125
+ name: cron_1.default.constructJobName(schedule.id, "Maintenance_Schedule"),
90
126
  date: cron.run_startdate,
91
127
  path: node_path_1.default.join(__dirname, "..", "jobs", "open_service_notifyOnSchedule.js"),
92
128
  interval: 0,
@@ -102,24 +138,7 @@ async function init() {
102
138
  },
103
139
  };
104
140
  }
105
- if (newjob === undefined) {
106
- console.error("newjob is undefined");
107
- return;
108
- }
109
- //Get all jobs from bree and check whether the job already exists
110
- const jobs = BreeInstance_1.default.getAllJobs();
111
- let jobExists = false;
112
- for (const job of jobs) {
113
- if (job.name === newjob.name) {
114
- jobExists = true;
115
- break;
116
- }
117
- }
118
- if (jobExists) {
119
- console.log(`Job for schedule ${schedule.id} already exists`);
120
- return;
121
- }
122
- await BreeInstance_1.default.getInstance().add(newjob);
141
+ await cron_1.default.addJob(newjob);
123
142
  }
124
143
  catch (error) {
125
144
  console.warn(`Error while adding job for schedule ${schedule.id}`, error);
package/dist/index.js CHANGED
@@ -27,11 +27,11 @@ const path_1 = require("path");
27
27
  const web_push_1 = __importDefault(require("web-push"));
28
28
  const featuremap_json_1 = __importDefault(require("./featuremap.json"));
29
29
  const config_1 = require("./features/config");
30
+ const cron_1 = require("./features/cron");
30
31
  const notifications_1 = require("./features/notifications");
31
32
  const permissions_1 = require("./features/permissions");
32
33
  const settings_1 = require("./features/user/settings");
33
34
  const _init_1 = require("./functions/_init");
34
- const BreeInstance_1 = __importDefault(require("./helper/BreeInstance"));
35
35
  const createRandomPassword_1 = require("./helper/createRandomPassword");
36
36
  const Core_Email_1 = require("./hooks/Core_Email");
37
37
  const _init_2 = require("./hooks/_init");
@@ -60,7 +60,7 @@ async function init() {
60
60
  catch (error) { }
61
61
  config = config_1.ConfigInstance.getInstance();
62
62
  await config.init(true);
63
- await initBree();
63
+ await (0, cron_1.initBree)();
64
64
  await initTranslations();
65
65
  await (0, Core_Email_1.initEmailTransport)();
66
66
  await initWebPush();
@@ -74,18 +74,6 @@ async function init() {
74
74
  await (0, notifications_1.initNotifications)();
75
75
  await (0, settings_1.initUserSettings)();
76
76
  }
77
- async function initBree() {
78
- const bree = BreeInstance_1.default.getInstance();
79
- //Start bree object
80
- // const graceful = new Graceful({ brees: [bree] });
81
- // graceful.listen();
82
- (async () => {
83
- console.log("[@openinc/parse-server-opendash] Starting bree");
84
- await bree.start();
85
- const jobs = BreeInstance_1.default.getAllJobs();
86
- console.log("[@openinc/parse-server-opendash] Number of Bree jobs in initialization:", jobs.length);
87
- })();
88
- }
89
77
  async function initTranslations() {
90
78
  // try {
91
79
  // console.log("init translations");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,140 @@
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
+ // import {
7
+ // changeLanguage,
8
+ // getCurrentLanguageSync,
9
+ // useTranslation,
10
+ // } from "@opendash/i18n";
11
+ const node_process_1 = __importDefault(require("node:process"));
12
+ const node_worker_threads_1 = require("node:worker_threads");
13
+ const node_js_1 = __importDefault(require("parse/node.js"));
14
+ const index_js_1 = require("../features/config/index.js");
15
+ const index_js_2 = require("../features/notifications/index.js");
16
+ const openinc_openservice_save_ticket_data_js_1 = require("../functions/openinc-openservice-save-ticket-data.js");
17
+ const catchError_js_1 = require("../helper/catchError.js");
18
+ const Config_js_1 = require("../types/Config.js");
19
+ const Maintenance_Schedule_Template_js_1 = require("../types/Maintenance_Schedule_Template.js");
20
+ const Notification_js_1 = require("../types/Notification.js");
21
+ const Notification_Setting_js_1 = require("../types/Notification_Setting.js");
22
+ function l(message) {
23
+ if (node_worker_threads_1.parentPort) {
24
+ node_worker_threads_1.parentPort.postMessage(message);
25
+ }
26
+ }
27
+ (async () => {
28
+ l("Initializing Parse with worker data: " + JSON.stringify(node_worker_threads_1.workerData));
29
+ node_js_1.default.initialize(node_worker_threads_1.workerData.ParseAppId, node_worker_threads_1.workerData.ParseJSKey !== "unused" ? node_worker_threads_1.workerData.ParseJSKey : undefined, node_worker_threads_1.workerData.ParseMasterKey);
30
+ node_js_1.default.serverURL = node_worker_threads_1.workerData.ParseServerURL;
31
+ l("Schedule is due.");
32
+ // Check OD3_Config class for key ConfigKeys.OpenService.createTicketOnSchedule. If value is true, proceed with ticket creation
33
+ const [configError, config] = await (0, catchError_js_1.catchError)(new node_js_1.default.Query(Config_js_1.Config.className)
34
+ .equalTo("key", index_js_1.ConfigKeys.OpenService.createTicketOnSchedule)
35
+ .first({ useMasterKey: true }));
36
+ //Get schedule object from worker data
37
+ const [scheduleError, schedule] = await (0, catchError_js_1.catchError)(new node_js_1.default.Query(Maintenance_Schedule_Template_js_1.Maintenance_Schedule_Template.className).get(node_worker_threads_1.workerData.scheduleId, { useMasterKey: true }));
38
+ if (configError) {
39
+ l("Error while querying OD3_Config for 'createTicketOnSchedule' key: " +
40
+ configError);
41
+ return;
42
+ }
43
+ if (scheduleError || schedule === undefined) {
44
+ l("Error while querying Maintenance_Schedule_Template object: " +
45
+ scheduleError);
46
+ return;
47
+ }
48
+ if (config === undefined || !/true/.test(config.get("value"))) {
49
+ l("Config 'createTicketOnSchedule' not set or false, skipping ticket creation for schedule.");
50
+ }
51
+ else {
52
+ //Get all sources from schedule object
53
+ const [sourcesError, sources] = await (0, catchError_js_1.catchError)(schedule
54
+ .relation("sources")
55
+ .query()
56
+ .find({ useMasterKey: true }));
57
+ if (sourcesError) {
58
+ l("Error while querying sources from Maintenance_Schedule_Template object: " +
59
+ sourcesError);
60
+ return;
61
+ }
62
+ for await (const source of sources) {
63
+ //Create a new ticket
64
+ await (0, openinc_openservice_save_ticket_data_js_1.saveTicketData)({
65
+ title: "",
66
+ source: source.id,
67
+ });
68
+ }
69
+ }
70
+ l("Config 'createTicketOnSchedule' is true, creating new ticket object");
71
+ const [notificationSettingsError, notificationSettings] = await (0, catchError_js_1.catchError)(new node_js_1.default.Query(Notification_Setting_js_1.Notification_Setting)
72
+ .equalTo("key", index_js_2.Notifications.OpenService.schedule_due)
73
+ .find({ useMasterKey: true }));
74
+ if (notificationSettingsError) {
75
+ l("Error while querying Notification_Setting for 'Notifications.OpenService.schedule_due' key: " +
76
+ notificationSettingsError);
77
+ return;
78
+ }
79
+ const recipients = [];
80
+ const users = notificationSettings.map((setting) => setting
81
+ .relation("users")
82
+ .query()
83
+ .include("settings")
84
+ .find({ useMasterKey: true }));
85
+ for await (const user of users) {
86
+ recipients.push(...user);
87
+ }
88
+ const rolesPromises = notificationSettings.map((setting) => setting.relation("roles").query().find({ useMasterKey: true }));
89
+ for await (const roles of rolesPromises) {
90
+ const usersFromRoles = roles.map((role) => role
91
+ .relation("users")
92
+ .query()
93
+ .include("settings")
94
+ .find({ useMasterKey: true }));
95
+ for await (const usersFromRole of usersFromRoles) {
96
+ recipients.push(...usersFromRole);
97
+ }
98
+ }
99
+ //Filter out duplicates
100
+ recipients.filter((user, index, self) => {
101
+ return (index ===
102
+ self.findIndex((t) => t.id === user.id && t.className === user.className));
103
+ });
104
+ l("Recipients for notification: " + JSON.stringify(recipients));
105
+ //TODO: When available as ESM, use i18n module to get the correct language for the user
106
+ for await (const recipient of recipients) {
107
+ l("Creating new notification object for user: " + recipient.id);
108
+ //Get preferred_language from user object
109
+ const language = recipient.get("settings")
110
+ ? recipient.get("settings").get("preferred_language")
111
+ : "deu";
112
+ // if (getCurrentLanguageSync() !== language) {
113
+ // changeLanguage(language);
114
+ // }
115
+ //Get the correct notification title and description based on the user's preferred language
116
+ // const t = useTranslation();
117
+ const findtitle = require(`../i18n/${language}.json`)["maintenance.schedule.notification.title"];
118
+ const finddescription = require(`../i18n/${language}.json`)["maintenance.schedule.notification.description"];
119
+ //Create a new notification object in the database, class name: OD3_Notification
120
+ const notificationObject = new node_js_1.default.Object(Notification_js_1.Notification.className);
121
+ notificationObject.set("title",
122
+ // t("server:maintenance.schedule.notification.title")
123
+ findtitle);
124
+ notificationObject.set("description",
125
+ // t("server:maintenance.schedule.notification.description", {
126
+ // schedule:
127
+ // schedule.get("title") !== undefined ? schedule.get("title")! : "",
128
+ // })
129
+ finddescription);
130
+ notificationObject.set("user", recipient);
131
+ await notificationObject.save(null, { useMasterKey: true });
132
+ }
133
+ // signal to parent that the job is done
134
+ if (node_worker_threads_1.parentPort) {
135
+ l("done");
136
+ }
137
+ else {
138
+ node_process_1.default.exit(0);
139
+ }
140
+ })();
@@ -0,0 +1,24 @@
1
+ import type { Tenant } from "./Tenant";
2
+ import type { _User } from "./_User";
3
+ export interface Maintenance_Ticket_QR_CodeAttributes {
4
+ id: string;
5
+ objectId: string;
6
+ createdAt: Date;
7
+ updatedAt: Date;
8
+ code: string;
9
+ name?: string;
10
+ tenant?: Tenant;
11
+ user?: _User;
12
+ }
13
+ export declare class Maintenance_Ticket_QR_Code extends Parse.Object<Maintenance_Ticket_QR_CodeAttributes> {
14
+ static className: string;
15
+ constructor(data?: Partial<Maintenance_Ticket_QR_CodeAttributes>);
16
+ get code(): string;
17
+ set code(value: string);
18
+ get name(): string | undefined;
19
+ set name(value: string | undefined);
20
+ get tenant(): Tenant | undefined;
21
+ set tenant(value: Tenant | undefined);
22
+ get user(): _User | undefined;
23
+ set user(value: _User | undefined);
24
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Maintenance_Ticket_QR_Code = void 0;
4
+ class Maintenance_Ticket_QR_Code extends Parse.Object {
5
+ constructor(data) {
6
+ super("OD3_Maintenance_Ticket_QR_Code", data);
7
+ }
8
+ get code() {
9
+ return super.get("code");
10
+ }
11
+ set code(value) {
12
+ super.set("code", value);
13
+ }
14
+ get name() {
15
+ return super.get("name");
16
+ }
17
+ set name(value) {
18
+ super.set("name", value);
19
+ }
20
+ get tenant() {
21
+ return super.get("tenant");
22
+ }
23
+ set tenant(value) {
24
+ super.set("tenant", value);
25
+ }
26
+ get user() {
27
+ return super.get("user");
28
+ }
29
+ set user(value) {
30
+ super.set("user", value);
31
+ }
32
+ }
33
+ exports.Maintenance_Ticket_QR_Code = Maintenance_Ticket_QR_Code;
34
+ Maintenance_Ticket_QR_Code.className = "OD3_Maintenance_Ticket_QR_Code";
35
+ Parse.Object.registerSubclass("OD3_Maintenance_Ticket_QR_Code", Maintenance_Ticket_QR_Code);
@@ -108,8 +108,6 @@ export { Maintenance_Media } from "./Maintenance_Media";
108
108
  export type { Maintenance_MediaAttributes } from "./Maintenance_Media";
109
109
  export { Maintenance_Message } from "./Maintenance_Message";
110
110
  export type { Maintenance_MessageAttributes } from "./Maintenance_Message";
111
- export { Maintenance_Message_Body } from "./Maintenance_Message_Body";
112
- export type { Maintenance_Message_BodyAttributes } from "./Maintenance_Message_Body";
113
111
  export { Maintenance_Order } from "./Maintenance_Order";
114
112
  export type { Maintenance_OrderAttributes } from "./Maintenance_Order";
115
113
  export { Maintenance_Priority } from "./Maintenance_Priority";
@@ -146,6 +144,8 @@ export { Maintenance_Ticket_Material } from "./Maintenance_Ticket_Material";
146
144
  export type { Maintenance_Ticket_MaterialAttributes } from "./Maintenance_Ticket_Material";
147
145
  export { Maintenance_Ticket_Project } from "./Maintenance_Ticket_Project";
148
146
  export type { Maintenance_Ticket_ProjectAttributes } from "./Maintenance_Ticket_Project";
147
+ export { Maintenance_Ticket_QR_Code } from "./Maintenance_Ticket_QR_Code";
148
+ export type { Maintenance_Ticket_QR_CodeAttributes } from "./Maintenance_Ticket_QR_Code";
149
149
  export { Maintenance_Ticket_Source } from "./Maintenance_Ticket_Source";
150
150
  export type { Maintenance_Ticket_SourceAttributes } from "./Maintenance_Ticket_Source";
151
151
  export { Maintenance_Ticket_Title } from "./Maintenance_Ticket_Title";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Maintenance_Frequency = exports.Maintenance_Duedate = exports.Maintenance_Downtime = exports.MailTemplate = exports.ML_DataSelection = exports.MIAAS_MDSEndpoint = exports.MES_OrderPlan = exports.MES_Order = exports.MES_Article = exports.Log = exports.Language = exports.Knowledge_Video = exports.Knowledge_DocumentPage = exports.Knowledge_Document = exports.Knowledge_ChatMessage = exports.Knowledge_Chat = exports.Knowledge_Category = exports.Knowledge_Article = exports.GTFS_Wheelchair_Boarding = exports.GTFS_Wheelchair_Accessible = exports.GTFS_Trip = exports.GTFS_Stop_Times = exports.GTFS_Stop = exports.GTFS_Route_Type = exports.GTFS_Route = exports.GTFS_Location_Type = exports.GTFS_Level = exports.GTFS_Direction = exports.GTFS_Calendar = exports.GTFS_Bikes_Allowed = exports.GTFS_Agency = exports.Documentation_Document = exports.Documentation_Category = exports.Dashboard = exports.Core_Token = exports.Core_Email = exports.Contact = exports.Config = exports.Company = exports.BDE_Unit = exports.BDE_Result = exports.BDE_Page = exports.BDE_ListEntry = exports.BDE_List = exports.BDE_Form = exports.Attachment = exports.Assets = exports.AlarmWebhook = exports.AlarmAction = exports.Alarm = void 0;
4
- exports.WebPush = exports.VirtualKPI = exports.User_Setting = exports.UserData = exports.TenantTrustedDomain = exports.TenantMeta = exports.Tenant = exports.SourceMeta = exports.Source = exports.Share = exports.Report = exports.Push = exports.Permission = exports.OWPlcItem = exports.OWPlcDevice = exports.Notification_Setting = exports.Notification = exports.NavigationItem = exports.NavigationGroup = exports.Monitoring_Slideshow = exports.Monitoring_ReportImage = exports.Monitoring_ParseTableSensor = exports.Monitoring_Jobs = exports.Monitoring_DataHierachies = exports.Maintenance_Ticket_Title = exports.Maintenance_Ticket_Source = exports.Maintenance_Ticket_Project = exports.Maintenance_Ticket_Material = exports.Maintenance_Ticket_Kanban_State_Current = exports.Maintenance_Ticket_Kanban_State = exports.Maintenance_Ticket_Issuecategory = exports.Maintenance_Ticket_FormConfig = exports.Maintenance_Ticket_Assignment = exports.Maintenance_Ticket = exports.Maintenance_Source_File = exports.Maintenance_SourceMeta = exports.Maintenance_Schedule_Template = exports.Maintenance_Schedule_Step = exports.Maintenance_Schedule_Execution_Step = exports.Maintenance_Schedule_Execution = exports.Maintenance_Restriction = exports.Maintenance_Project = exports.Maintenance_Priority = exports.Maintenance_Order = exports.Maintenance_Message_Body = exports.Maintenance_Message = exports.Maintenance_Media = exports.Maintenance_Kanban_State = exports.Maintenance_Item = exports.Maintenance_Issuecategory = void 0;
4
+ exports.WebPush = exports.VirtualKPI = exports.User_Setting = exports.UserData = exports.TenantTrustedDomain = exports.TenantMeta = exports.Tenant = exports.SourceMeta = exports.Source = exports.Share = exports.Report = exports.Push = exports.Permission = exports.OWPlcItem = exports.OWPlcDevice = exports.Notification_Setting = exports.Notification = exports.NavigationItem = exports.NavigationGroup = exports.Monitoring_Slideshow = exports.Monitoring_ReportImage = exports.Monitoring_ParseTableSensor = exports.Monitoring_Jobs = exports.Monitoring_DataHierachies = exports.Maintenance_Ticket_Title = exports.Maintenance_Ticket_Source = exports.Maintenance_Ticket_QR_Code = exports.Maintenance_Ticket_Project = exports.Maintenance_Ticket_Material = exports.Maintenance_Ticket_Kanban_State_Current = exports.Maintenance_Ticket_Kanban_State = exports.Maintenance_Ticket_Issuecategory = exports.Maintenance_Ticket_FormConfig = exports.Maintenance_Ticket_Assignment = exports.Maintenance_Ticket = exports.Maintenance_Source_File = exports.Maintenance_SourceMeta = exports.Maintenance_Schedule_Template = exports.Maintenance_Schedule_Step = exports.Maintenance_Schedule_Execution_Step = exports.Maintenance_Schedule_Execution = exports.Maintenance_Restriction = exports.Maintenance_Project = exports.Maintenance_Priority = exports.Maintenance_Order = exports.Maintenance_Message = exports.Maintenance_Media = exports.Maintenance_Kanban_State = exports.Maintenance_Item = exports.Maintenance_Issuecategory = void 0;
5
5
  exports.WidgetPreset = exports.Widget = void 0;
6
6
  var Alarm_1 = require("./Alarm");
7
7
  Object.defineProperty(exports, "Alarm", { enumerable: true, get: function () { return Alarm_1.Alarm; } });
@@ -113,8 +113,6 @@ var Maintenance_Media_1 = require("./Maintenance_Media");
113
113
  Object.defineProperty(exports, "Maintenance_Media", { enumerable: true, get: function () { return Maintenance_Media_1.Maintenance_Media; } });
114
114
  var Maintenance_Message_1 = require("./Maintenance_Message");
115
115
  Object.defineProperty(exports, "Maintenance_Message", { enumerable: true, get: function () { return Maintenance_Message_1.Maintenance_Message; } });
116
- var Maintenance_Message_Body_1 = require("./Maintenance_Message_Body");
117
- Object.defineProperty(exports, "Maintenance_Message_Body", { enumerable: true, get: function () { return Maintenance_Message_Body_1.Maintenance_Message_Body; } });
118
116
  var Maintenance_Order_1 = require("./Maintenance_Order");
119
117
  Object.defineProperty(exports, "Maintenance_Order", { enumerable: true, get: function () { return Maintenance_Order_1.Maintenance_Order; } });
120
118
  var Maintenance_Priority_1 = require("./Maintenance_Priority");
@@ -151,6 +149,8 @@ var Maintenance_Ticket_Material_1 = require("./Maintenance_Ticket_Material");
151
149
  Object.defineProperty(exports, "Maintenance_Ticket_Material", { enumerable: true, get: function () { return Maintenance_Ticket_Material_1.Maintenance_Ticket_Material; } });
152
150
  var Maintenance_Ticket_Project_1 = require("./Maintenance_Ticket_Project");
153
151
  Object.defineProperty(exports, "Maintenance_Ticket_Project", { enumerable: true, get: function () { return Maintenance_Ticket_Project_1.Maintenance_Ticket_Project; } });
152
+ var Maintenance_Ticket_QR_Code_1 = require("./Maintenance_Ticket_QR_Code");
153
+ Object.defineProperty(exports, "Maintenance_Ticket_QR_Code", { enumerable: true, get: function () { return Maintenance_Ticket_QR_Code_1.Maintenance_Ticket_QR_Code; } });
154
154
  var Maintenance_Ticket_Source_1 = require("./Maintenance_Ticket_Source");
155
155
  Object.defineProperty(exports, "Maintenance_Ticket_Source", { enumerable: true, get: function () { return Maintenance_Ticket_Source_1.Maintenance_Ticket_Source; } });
156
156
  var Maintenance_Ticket_Title_1 = require("./Maintenance_Ticket_Title");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.8.1",
6
6
  "keywords": [
@@ -65,6 +65,7 @@
65
65
  "bree": "^9.2.4",
66
66
  "cabin": "^14.0.0",
67
67
  "cron": "^4.3.0",
68
+ "dayjs": "^1.11.13",
68
69
  "fast-equals": "^5.2.2",
69
70
  "jsonwebtoken": "^9.0.2",
70
71
  "node-fetch": "^3.3.2",
@@ -1,20 +1,11 @@
1
1
  {
2
2
  "fields": {
3
- "content": {
3
+ "code": {
4
4
  "type": "String",
5
- "required": false
6
- },
7
- "data": {
8
- "type": "Object",
9
- "required": false
10
- },
11
- "displayAt": {
12
- "type": "Date",
13
- "required": false
5
+ "required": true
14
6
  },
15
- "message": {
16
- "type": "Pointer",
17
- "targetClass": "{{PREFIX}}Maintenance_Message",
7
+ "name": {
8
+ "type": "String",
18
9
  "required": false
19
10
  },
20
11
  "tenant": {
@@ -29,25 +20,33 @@
29
20
  }
30
21
  },
31
22
  "classLevelPermissions": {
23
+ "ACL": {
24
+ "*": {
25
+ "read": true,
26
+ "write": true
27
+ }
28
+ },
32
29
  "find": {
33
- "requiresAuthentication": true
30
+ "*": true
34
31
  },
35
32
  "count": {
36
- "requiresAuthentication": true
33
+ "*": true
37
34
  },
38
35
  "get": {
39
- "requiresAuthentication": true
36
+ "*": true
40
37
  },
41
38
  "create": {
42
- "requiresAuthentication": true
39
+ "*": true
43
40
  },
44
41
  "update": {
45
- "requiresAuthentication": true
42
+ "*": true
46
43
  },
47
44
  "delete": {
48
- "requiresAuthentication": true
45
+ "*": true
46
+ },
47
+ "addField": {
48
+ "*": true
49
49
  },
50
- "addField": {},
51
50
  "protectedFields": {
52
51
  "*": []
53
52
  }
@@ -1,16 +0,0 @@
1
- import Bree from "bree";
2
- declare class BreeInstance {
3
- private static instance;
4
- private static jobs;
5
- private constructor();
6
- static getInstance(): Bree;
7
- static getAllJobs(): Bree.Job[];
8
- /**
9
- * Converts a cron-like string into a human-readable format.
10
- *
11
- * @param value - The cron-like string to convert.
12
- * @returns A human-readable string representing the cron-like schedule.
13
- */
14
- static createHumanReadableFormat(value: string): string;
15
- }
16
- export default BreeInstance;
@@ -1,31 +0,0 @@
1
- import type { Maintenance_Message } from "./Maintenance_Message";
2
- import type { Tenant } from "./Tenant";
3
- import type { _User } from "./_User";
4
- export interface Maintenance_Message_BodyAttributes {
5
- id: string;
6
- objectId: string;
7
- createdAt: Date;
8
- updatedAt: Date;
9
- content?: string;
10
- data?: any;
11
- displayAt?: Date;
12
- message?: Maintenance_Message;
13
- tenant?: Tenant;
14
- user?: _User;
15
- }
16
- export declare class Maintenance_Message_Body extends Parse.Object<Maintenance_Message_BodyAttributes> {
17
- static className: string;
18
- constructor(data?: Partial<Maintenance_Message_BodyAttributes>);
19
- get content(): string | undefined;
20
- set content(value: string | undefined);
21
- get data(): any | undefined;
22
- set data(value: any | undefined);
23
- get displayAt(): Date | undefined;
24
- set displayAt(value: Date | undefined);
25
- get message(): Maintenance_Message | undefined;
26
- set message(value: Maintenance_Message | undefined);
27
- get tenant(): Tenant | undefined;
28
- set tenant(value: Tenant | undefined);
29
- get user(): _User | undefined;
30
- set user(value: _User | undefined);
31
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Maintenance_Message_Body = void 0;
4
- class Maintenance_Message_Body extends Parse.Object {
5
- constructor(data) {
6
- super("OD3_Maintenance_Message_Body", data);
7
- }
8
- get content() {
9
- return super.get("content");
10
- }
11
- set content(value) {
12
- super.set("content", value);
13
- }
14
- get data() {
15
- return super.get("data");
16
- }
17
- set data(value) {
18
- super.set("data", value);
19
- }
20
- get displayAt() {
21
- return super.get("displayAt");
22
- }
23
- set displayAt(value) {
24
- super.set("displayAt", value);
25
- }
26
- get message() {
27
- return super.get("message");
28
- }
29
- set message(value) {
30
- super.set("message", value);
31
- }
32
- get tenant() {
33
- return super.get("tenant");
34
- }
35
- set tenant(value) {
36
- super.set("tenant", value);
37
- }
38
- get user() {
39
- return super.get("user");
40
- }
41
- set user(value) {
42
- super.set("user", value);
43
- }
44
- }
45
- exports.Maintenance_Message_Body = Maintenance_Message_Body;
46
- Maintenance_Message_Body.className = "OD3_Maintenance_Message_Body";
47
- Parse.Object.registerSubclass("OD3_Maintenance_Message_Body", Maintenance_Message_Body);