@openinc/parse-server-opendash 2.4.90 → 2.4.91

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 (67) hide show
  1. package/dist/app_types/ConfigKeys.d.ts +9 -0
  2. package/dist/app_types/ConfigKeys.js +14 -0
  3. package/dist/app_types/Notifications.d.ts +10 -0
  4. package/dist/app_types/Notifications.js +16 -0
  5. package/dist/app_types/Permissions.d.ts +42 -0
  6. package/dist/app_types/Permissions.js +61 -0
  7. package/dist/app_types/index.d.ts +3 -0
  8. package/dist/app_types/index.js +9 -0
  9. package/dist/featuremap.json +7 -5
  10. package/dist/functions/openinc-deregister-permission.js +2 -2
  11. package/dist/functions/openinc-openservice-save-ticket-data.d.ts +40 -0
  12. package/dist/functions/openinc-openservice-save-ticket-data.js +328 -0
  13. package/dist/functions/openinc-openservice-ticket-data.js +16 -32
  14. package/dist/functions/openinc-register-permission.js +1 -1
  15. package/dist/functions/openinc-user-roles.js +1 -1
  16. package/dist/helper/TicketData.d.ts +15 -0
  17. package/dist/helper/TicketData.js +2 -0
  18. package/dist/helper/pdf2img.d.ts +4 -1
  19. package/dist/helper/pdf2img.js +151 -104
  20. package/dist/helper/registerNotification.d.ts +25 -0
  21. package/dist/helper/registerNotification.js +61 -0
  22. package/dist/helper/registerPermissions.d.ts +0 -42
  23. package/dist/helper/registerPermissions.js +5 -62
  24. package/dist/hooks/Assets.js +17 -0
  25. package/dist/hooks/Documentation_Category.d.ts +1 -0
  26. package/dist/hooks/Documentation_Category.js +17 -0
  27. package/dist/hooks/Documentation_Document.d.ts +1 -0
  28. package/dist/hooks/Documentation_Document.js +17 -0
  29. package/dist/hooks/Knowledge_Document.js +35 -2
  30. package/dist/hooks/Maintenance_Schedule_Execution.js +4 -4
  31. package/dist/hooks/Maintenance_Schedule_Template.js +19 -8
  32. package/dist/hooks/Maintenance_Ticket.js +1 -4
  33. package/dist/hooks/Maintenance_Ticket_Kanban_State_Current.js +1 -1
  34. package/dist/hooks/Notification_Setting.d.ts +1 -0
  35. package/dist/hooks/Notification_Setting.js +55 -0
  36. package/dist/hooks/User_Setting.d.ts +1 -0
  37. package/dist/hooks/User_Setting.js +17 -0
  38. package/dist/hooks/_User.js +0 -12
  39. package/dist/index.js +12 -0
  40. package/dist/jobs/open_service_notifyOnSchedule.js +125 -20
  41. package/dist/types/Assets.d.ts +27 -0
  42. package/dist/types/Assets.js +41 -0
  43. package/dist/types/Documentation_Document.d.ts +0 -6
  44. package/dist/types/Documentation_Document.js +0 -12
  45. package/dist/types/Knowledge_Document.d.ts +3 -0
  46. package/dist/types/Knowledge_Document.js +6 -0
  47. package/dist/types/Maintenance_Message.d.ts +6 -0
  48. package/dist/types/Maintenance_Message.js +9 -0
  49. package/dist/types/Notification_Setting.d.ts +29 -0
  50. package/dist/types/Notification_Setting.js +41 -0
  51. package/dist/types/User_Setting.d.ts +13 -0
  52. package/dist/types/User_Setting.js +17 -0
  53. package/dist/types/_User.d.ts +2 -0
  54. package/dist/types/index.d.ts +6 -2
  55. package/dist/types/index.js +8 -4
  56. package/package.json +4 -4
  57. package/schema/Assets.json +52 -0
  58. package/schema/Documentation_Document.json +0 -10
  59. package/schema/Knowledge_Document.json +5 -0
  60. package/schema/Maintenance_Message.json +9 -0
  61. package/schema/Notification_Setting.json +57 -0
  62. package/schema/User_Setting.json +35 -0
  63. package/dist/hooks/Group.js +0 -55
  64. package/dist/types/Group.d.ts +0 -31
  65. package/dist/types/Group.js +0 -47
  66. package/schema/Group.json +0 -62
  67. /package/dist/hooks/{Group.d.ts → Assets.d.ts} +0 -0
@@ -9,7 +9,7 @@ async function init(name) {
9
9
  });
10
10
  }
11
11
  async function handleRequest(request) {
12
- if (typeof request.user === "undefined") {
12
+ if (request.user === undefined) {
13
13
  return { success: false, error: "User not found" };
14
14
  }
15
15
  console.log("openinc-openservice-ticket-data: Handling request with", request.params);
@@ -49,14 +49,16 @@ async function handleRequest(request) {
49
49
  }
50
50
  }
51
51
  // get total count of tickets before applying pagination
52
- const totalCount = await ticketQuery.count({ useMasterKey: true });
52
+ const totalCount = await ticketQuery.count({
53
+ sessionToken: request.user.getSessionToken(),
54
+ });
53
55
  if (request.params.config[0].skip !== undefined &&
54
56
  request.params.config[0].limit !== undefined) {
55
57
  ticketQuery = ticketQuery
56
58
  .skip(request.params.config[0].skip)
57
59
  .limit(request.params.config[0].limit);
58
60
  }
59
- const [ticketError, ticketsResult] = await (0, catchError_1.catchError)(ticketQuery.find({ useMasterKey: true }));
61
+ const [ticketError, ticketsResult] = await (0, catchError_1.catchError)(ticketQuery.find({ sessionToken: request.user.getSessionToken() }));
60
62
  if (ticketError) {
61
63
  throw ticketError;
62
64
  }
@@ -80,12 +82,12 @@ async function getTicketData(tickets) {
80
82
  const ticketDataPromises = tickets.map(async (ticket) => {
81
83
  let assignedusers = [];
82
84
  let assignedroles = [];
83
- if (typeof ticket.assignedusers !== "undefined") {
85
+ if (ticket.assignedusers !== undefined) {
84
86
  assignedusers = await ticket.assignedusers
85
87
  .query()
86
88
  .find({ useMasterKey: true });
87
89
  }
88
- if (typeof ticket.assignedroles !== "undefined") {
90
+ if (ticket.assignedroles !== undefined) {
89
91
  assignedroles = await ticket.assignedroles
90
92
  .query()
91
93
  .find({ useMasterKey: true });
@@ -124,7 +126,6 @@ async function getTicketData(tickets) {
124
126
  state: dataPromises[7]?.get("state"),
125
127
  dailySchedule: dataPromises[8],
126
128
  messages: dataPromises[9].messages,
127
- messageBodies: dataPromises[9].messageBodies,
128
129
  assignedTo: [...assignedusers, ...assignedroles],
129
130
  };
130
131
  });
@@ -212,20 +213,11 @@ async function getState(ticket) {
212
213
  * @param ticketIds
213
214
  */
214
215
  async function getMessages(ticket) {
215
- const messageBodies = await new Parse.Query(types_1.Maintenance_Message_Body)
216
- .include("message")
217
- .matchesQuery("message", new Parse.Query(types_1.Maintenance_Message)
216
+ const messages = await new Parse.Query(types_1.Maintenance_Message)
218
217
  .descending("updatedAt")
219
- .equalTo("referencedObjectId", ticket.id))
220
- .limit(1000000)
218
+ .equalTo("referencedObjectId", ticket.id)
221
219
  .find({ useMasterKey: true });
222
- const messages = messageBodies
223
- .map((msgB) => msgB.message)
224
- .filter((msg) => !!msg);
225
- return {
226
- messages: messages.filter((msg) => msg?.get("referencedObjectId") === ticket.id),
227
- messageBodies: messageBodies.filter((msgB) => messages?.some((msg) => msg.id === msgB.get("message")?.id)),
228
- };
220
+ return { messages };
229
221
  }
230
222
  /**
231
223
  * Fetches the issuecategory for a ticket
@@ -272,7 +264,7 @@ async function getDailySchedule(ticket) {
272
264
  .find({ useMasterKey: true }),
273
265
  };
274
266
  }));
275
- return scheduleTickets.find((scheduleTicket) => scheduleTicket.tickets.some((ticket) => ticket.id === ticket.id))?.schedule;
267
+ return scheduleTickets.find((scheduleTicket) => scheduleTicket.tickets.some((t) => t.id === ticket.id))?.schedule;
276
268
  }
277
269
  /**
278
270
  * Used to filter tickets based on the filterBy attribute
@@ -292,9 +284,9 @@ const filterQueryMap = {
292
284
  .matchesQuery("ticket", query)
293
285
  .includeAll()
294
286
  .find({ useMasterKey: true });
295
- const filteredTicketSources = arrayToDistinct(allTicketSources, (ts) => ts.get("ticket").id, (ts) => ts.get("source").id === value);
287
+ const filteredTicketSources = arrayToDistinct(allTicketSources, (ts) => ts?.get("ticket")?.id, (ts) => ts?.get("source")?.id === value);
296
288
  // @ts-ignore
297
- query.containedIn("objectId", filteredTicketSources.map((ts) => ts.get("ticket").id));
289
+ query.containedIn("objectId", filteredTicketSources.map((ts) => ts.get("ticket")?.id));
298
290
  },
299
291
  issuecategory: async (query, value) => {
300
292
  const ticketIssuecategories = await new Parse.Query(types_1.Maintenance_Ticket_Issuecategory)
@@ -302,9 +294,10 @@ const filterQueryMap = {
302
294
  .descending("createdAt")
303
295
  .includeAll()
304
296
  .find({ useMasterKey: true });
305
- const filteredTicketIssuecategories = arrayToDistinct(ticketIssuecategories, (tic) => tic.get("ticket").id, (tic) => tic.get("issuecategory").id === value);
297
+ const filteredTicketIssuecategories = arrayToDistinct(ticketIssuecategories, (tic) => tic.get("ticket")?.id, (tic) => tic.get("issuecategory")?.id === value &&
298
+ tic.get("ticket")?.id !== undefined);
306
299
  // @ts-ignore
307
- query.containedIn("objectId", filteredTicketIssuecategories.map((tic) => tic.get("ticket").id));
300
+ query.containedIn("objectId", filteredTicketIssuecategories.map((tic) => tic.get("ticket")?.id));
308
301
  },
309
302
  user: async (query, value) => {
310
303
  const userQuery = new Parse.Query(Parse.User).equalTo("objectId", value);
@@ -339,12 +332,3 @@ function arrayToDistinct(arr, getId, filter) {
339
332
  const array = Array.from(map.values());
340
333
  return filter ? array.filter(filter) : array;
341
334
  }
342
- function findSortByValue(sortBy, obj) {
343
- if (!sortBy)
344
- return "";
345
- const keyChain = sortBy.split(".");
346
- let currentValue = obj;
347
- for (const key of keyChain)
348
- currentValue = currentValue[key];
349
- return currentValue;
350
- }
@@ -8,7 +8,7 @@ const types_1 = require("../types");
8
8
  */
9
9
  async function init(name) {
10
10
  Parse.Cloud.define(name, async function (request) {
11
- if (typeof request.user === "undefined") {
11
+ if (request.user === undefined) {
12
12
  return { success: false, error: "User is not provided." };
13
13
  }
14
14
  //Get the current user
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.init = init;
4
4
  async function init(name) {
5
5
  Parse.Cloud.define(name, async function (request) {
6
- if (typeof request.user === "undefined") {
6
+ if (request.user === undefined) {
7
7
  return { success: false, error: "User not found" };
8
8
  }
9
9
  const user = await new Parse.Query(Parse.User).get(request.user.id, {
@@ -0,0 +1,15 @@
1
+ import { Maintenance_Ticket, Maintenance_DailySchedule, Maintenance_Downtime, Maintenance_Duedate, Maintenance_Frequency, Maintenance_Issuecategory, Maintenance_Kanban_State, Maintenance_Message, Maintenance_Priority, Maintenance_Restriction, Source } from "../types";
2
+ export type TicketData = {
3
+ ticket: Maintenance_Ticket;
4
+ dailySchedule?: Maintenance_DailySchedule;
5
+ downtime?: Maintenance_Downtime;
6
+ duedate?: Maintenance_Duedate;
7
+ frequency?: Maintenance_Frequency;
8
+ issuecategory?: Maintenance_Issuecategory;
9
+ state?: Maintenance_Kanban_State;
10
+ messages?: Maintenance_Message[];
11
+ priority?: Maintenance_Priority;
12
+ restriction?: Maintenance_Restriction;
13
+ source?: Source;
14
+ assignedTo?: Array<Parse.User | Parse.Role>;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -8,5 +8,8 @@ interface Options {
8
8
  /** Output as base64 */
9
9
  base64?: boolean;
10
10
  }
11
- export declare function convert(pdf: string, conversion_config?: Options): Promise<any[]>;
11
+ /**
12
+ * @deprecated This should be deleted as pdf-img-converter can be used directly
13
+ */
14
+ export declare function convert(pdf: string, conversion_config?: Options): Promise<string[] | Uint8Array<ArrayBufferLike>[]>;
12
15
  export {};
@@ -1,110 +1,157 @@
1
1
  "use strict";
2
- // @ts-nocheck
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.convert = convert;
8
2
  // Fork of: https://www.npmjs.com/package/pdf-img-convert
9
3
  // node_modules/pdf-img-convert/pdf-img-convert.js
10
- const node_fetch_1 = __importDefault(require("node-fetch"));
11
- const strict_1 = __importDefault(require("assert/strict"));
12
- // import pdfjs from "pdfjs-dist/legacy/build/pdf.js";
13
- // import Canvas from "canvas";
14
- // Somehow the import does not work
15
- const pdfjs = require("pdfjs-dist/legacy/build/pdf.js");
16
- const Canvas = require("canvas");
17
- function NodeCanvasFactory() { }
18
- NodeCanvasFactory.prototype = {
19
- create: function NodeCanvasFactory_create(width, height) {
20
- (0, strict_1.default)(width > 0 && height > 0, "Invalid canvas size");
21
- var canvas = Canvas.createCanvas(width, height);
22
- var context = canvas.getContext("2d");
23
- return {
24
- canvas: canvas,
25
- context: context,
4
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5
+ if (k2 === undefined) k2 = k;
6
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
8
+ desc = { enumerable: true, get: function() { return m[k]; } };
9
+ }
10
+ Object.defineProperty(o, k2, desc);
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
26
  };
27
- },
28
- reset: function NodeCanvasFactory_reset(canvasAndContext, width, height) {
29
- (0, strict_1.default)(canvasAndContext.canvas, "Canvas is not specified");
30
- (0, strict_1.default)(width > 0 && height > 0, "Invalid canvas size");
31
- canvasAndContext.canvas.width = width;
32
- canvasAndContext.canvas.height = height;
33
- },
34
- destroy: function NodeCanvasFactory_destroy(canvasAndContext) {
35
- (0, strict_1.default)(canvasAndContext.canvas, "Canvas is not specified");
36
- // Zeroing the width and height cause Firefox to release graphics
37
- // resources immediately, which can greatly reduce memory consumption.
38
- canvasAndContext.canvas.width = 0;
39
- canvasAndContext.canvas.height = 0;
40
- canvasAndContext.canvas = null;
41
- canvasAndContext.context = null;
42
- },
43
- };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.convert = convert;
39
+ // class NodeCanvasFactory {
40
+ // constructor() {}
41
+ // create(width: number, height: number) {
42
+ // assert(width > 0 && height > 0, "Invalid canvas size");
43
+ // var canvas = Canvas.createCanvas(width, height);
44
+ // var context = canvas.getContext("2d");
45
+ // return {
46
+ // canvas: canvas,
47
+ // context: context,
48
+ // };
49
+ // }
50
+ // reset(canvasAndContext: any, width: number, height: number) {
51
+ // assert(canvasAndContext.canvas, "Canvas is not specified");
52
+ // assert(width > 0 && height > 0, "Invalid canvas size");
53
+ // canvasAndContext.canvas.width = width;
54
+ // canvasAndContext.canvas.height = height;
55
+ // }
56
+ // destroy(canvasAndContext: any) {
57
+ // assert(canvasAndContext.canvas, "Canvas is not specified");
58
+ // // Zeroing the width and height cause Firefox to release graphics
59
+ // // resources immediately, which can greatly reduce memory consumption.
60
+ // canvasAndContext.canvas.width = 0;
61
+ // canvasAndContext.canvas.height = 0;
62
+ // canvasAndContext.canvas = null;
63
+ // canvasAndContext.context = null;
64
+ // }
65
+ // }
66
+ /**
67
+ * @deprecated This should be deleted as pdf-img-converter can be used directly
68
+ */
44
69
  async function convert(pdf, conversion_config = {}) {
45
- // Get the PDF in Uint8Array form
46
- const resp = await (0, node_fetch_1.default)(pdf);
47
- const pdfData = new Uint8Array(await resp.arrayBuffer());
48
- var outputPages = [];
49
- var loadingTask = pdfjs.getDocument({ data: pdfData, verbosity: 0 });
50
- var pdfDocument = await loadingTask.promise;
51
- var canvasFactory = new NodeCanvasFactory();
52
- if (conversion_config.height <= 0 || conversion_config.width <= 0)
53
- console.error("Negative viewport dimension given. Defaulting to 100% scale.");
54
- // If there are page numbers supplied in the conversion config
55
- if (conversion_config.page_numbers)
56
- for (let i = 0; i < conversion_config.page_numbers.length; i++) {
57
- // This just pushes a render of the page to the array
58
- let currentPage = await doc_render(pdfDocument, conversion_config.page_numbers[i], canvasFactory, conversion_config);
59
- if (currentPage != null) {
60
- // This allows for base64 conversion of output images
61
- if (conversion_config.base64)
62
- outputPages.push(currentPage.toString("base64"));
63
- else
64
- outputPages.push(new Uint8Array(currentPage));
65
- }
66
- }
67
- // Otherwise just loop the whole doc
68
- else
69
- for (let i = 1; i <= pdfDocument.numPages; i++) {
70
- let currentPage = await doc_render(pdfDocument, i, canvasFactory, conversion_config);
71
- if (currentPage != null) {
72
- // This allows for base64 conversion of output images
73
- if (conversion_config.base64)
74
- outputPages.push(currentPage.toString("base64"));
75
- else
76
- outputPages.push(new Uint8Array(currentPage));
77
- }
78
- }
79
- return outputPages;
70
+ const pdf2img = await Promise.resolve().then(() => __importStar(require("pdf-img-convert")));
71
+ const output = await pdf2img.convert(pdf, {
72
+ base64: conversion_config.base64,
73
+ width: conversion_config.width,
74
+ height: conversion_config.height,
75
+ page_numbers: conversion_config.page_numbers,
76
+ });
77
+ return output;
78
+ // const resp = await fetch(pdf);
79
+ // const pdfData = new Uint8Array(await resp.arrayBuffer());
80
+ // var outputPages = [];
81
+ // var loadingTask = pdfjs.getDocument({ data: pdfData, verbosity: 0 });
82
+ // var pdfDocument = await loadingTask.promise;
83
+ // var canvasFactory = new NodeCanvasFactory();
84
+ // if (conversion_config.height <= 0 || conversion_config.width <= 0)
85
+ // console.error(
86
+ // "Negative viewport dimension given. Defaulting to 100% scale."
87
+ // );
88
+ // // If there are page numbers supplied in the conversion config
89
+ // if (conversion_config.page_numbers)
90
+ // for (let i = 0; i < conversion_config.page_numbers.length; i++) {
91
+ // // This just pushes a render of the page to the array
92
+ // let currentPage = await doc_render(
93
+ // pdfDocument,
94
+ // conversion_config.page_numbers[i],
95
+ // canvasFactory,
96
+ // conversion_config
97
+ // );
98
+ // if (currentPage != null) {
99
+ // // This allows for base64 conversion of output images
100
+ // if (conversion_config.base64)
101
+ // outputPages.push(currentPage.toString("base64"));
102
+ // else outputPages.push(new Uint8Array(currentPage));
103
+ // }
104
+ // }
105
+ // // Otherwise just loop the whole doc
106
+ // else
107
+ // for (let i = 1; i <= pdfDocument.numPages; i++) {
108
+ // let currentPage = await doc_render(
109
+ // pdfDocument,
110
+ // i,
111
+ // canvasFactory,
112
+ // conversion_config
113
+ // );
114
+ // if (currentPage != null) {
115
+ // // This allows for base64 conversion of output images
116
+ // if (conversion_config.base64)
117
+ // outputPages.push(currentPage.toString("base64"));
118
+ // else outputPages.push(new Uint8Array(currentPage));
119
+ // }
120
+ // }
121
+ // return outputPages;
80
122
  } // convert method
81
- async function doc_render(pdfDocument, pageNo, canvasFactory, conversion_config) {
82
- // Page number sanity check
83
- if (pageNo < 1 || pageNo > pdfDocument.numPages) {
84
- console.error("Invalid page number " + pageNo);
85
- return;
86
- }
87
- // Get the page
88
- let page = await pdfDocument.getPage(pageNo);
89
- // Create a viewport at 100% scale
90
- let outputScale = 1.0;
91
- let viewport = page.getViewport({ scale: outputScale });
92
- // Scale it up / down dependent on the sizes given in the config (if there
93
- // are any)
94
- if (conversion_config.width)
95
- outputScale = conversion_config.width / viewport.width;
96
- else if (conversion_config.height)
97
- outputScale = conversion_config.height / viewport.height;
98
- if (outputScale != 1 && outputScale > 0)
99
- viewport = page.getViewport({ scale: outputScale });
100
- let canvasAndContext = canvasFactory.create(viewport.width, viewport.height);
101
- let renderContext = {
102
- canvasContext: canvasAndContext.context,
103
- viewport: viewport,
104
- canvasFactory: canvasFactory,
105
- };
106
- let renderTask = await page.render(renderContext).promise;
107
- // Convert the canvas to an image buffer.
108
- let image = canvasAndContext.canvas.toBuffer();
109
- return image;
110
- } // doc_render
123
+ // async function doc_render(
124
+ // pdfDocument: PDFDocumentProxy,
125
+ // pageNo: number,
126
+ // canvasFactory: { create: (arg0: any, arg1: any) => any },
127
+ // conversion_config: Options
128
+ // ) {
129
+ // // Page number sanity check
130
+ // if (pageNo < 1 || pageNo > pdfDocument.numPages) {
131
+ // console.error("Invalid page number " + pageNo);
132
+ // return;
133
+ // }
134
+ // // Get the page
135
+ // let page = await pdfDocument.getPage(pageNo);
136
+ // // Create a viewport at 100% scale
137
+ // let outputScale = 1.0;
138
+ // let viewport = page.getViewport({ scale: outputScale });
139
+ // // Scale it up / down dependent on the sizes given in the config (if there
140
+ // // are any)
141
+ // if (conversion_config.width)
142
+ // outputScale = conversion_config.width / viewport.width;
143
+ // else if (conversion_config.height)
144
+ // outputScale = conversion_config.height / viewport.height;
145
+ // if (outputScale != 1 && outputScale > 0)
146
+ // viewport = page.getViewport({ scale: outputScale });
147
+ // let canvasAndContext = canvasFactory.create(viewport.width, viewport.height);
148
+ // let renderContext = {
149
+ // canvasContext: canvasAndContext.context,
150
+ // viewport: viewport,
151
+ // canvasFactory: canvasFactory,
152
+ // };
153
+ // let renderTask = await page.render(renderContext).promise;
154
+ // // Convert the canvas to an image buffer.
155
+ // let image = canvasAndContext.canvas.toBuffer();
156
+ // return image;
157
+ // } // doc_render
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Gets all registered notifications.
3
+ */
4
+ /**
5
+ * Returns all notifications from the OpenService plugin defined in types/config.ts as an array of Notification objects.
6
+ * @returns all notifications from the OpenService plugin
7
+ */
8
+ export declare function getAllNotifications(): RegisteredNotification[];
9
+ interface NotificationInterface {
10
+ label: string;
11
+ description: string;
12
+ key: string;
13
+ }
14
+ type FunctionKeys<T> = {
15
+ [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
16
+ }[keyof T];
17
+ export declare class RegisteredNotification implements NotificationInterface {
18
+ key: string;
19
+ label: string;
20
+ description: string;
21
+ constructor(key: string, label: string, description: string);
22
+ get<T extends Exclude<keyof RegisteredNotification, FunctionKeys<RegisteredNotification>>>(attribute: T): (typeof this)[T];
23
+ set<T extends Exclude<keyof RegisteredNotification, FunctionKeys<RegisteredNotification>>>(attribute: T, value: (typeof this)[T]): this;
24
+ }
25
+ export {};
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Gets all registered notifications.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RegisteredNotification = void 0;
7
+ exports.getAllNotifications = getAllNotifications;
8
+ const index_js_1 = require("../app_types/index.js");
9
+ /**
10
+ * Returns all notifications from the OpenService plugin defined in types/config.ts as an array of Notification objects.
11
+ * @returns all notifications from the OpenService plugin
12
+ */
13
+ function getAllNotifications() {
14
+ const notifications = []; // stores all notifications
15
+ for (const key in index_js_1.Notifications) {
16
+ // iterate over the objects / enums of the Notifications namespace
17
+ if (Object.prototype.hasOwnProperty.call(index_js_1.Notifications, key)) {
18
+ const element = index_js_1.Notifications[key]; // get the object / enum
19
+ const createdNotification = createNotification(element); // create Notification objects recursively
20
+ notifications.push(...createdNotification);
21
+ }
22
+ }
23
+ return notifications;
24
+ }
25
+ class RegisteredNotification {
26
+ constructor(key, label, description) {
27
+ this.key = key;
28
+ this.label = label;
29
+ this.description = description;
30
+ }
31
+ get(attribute) {
32
+ return this[attribute];
33
+ }
34
+ set(attribute, value) {
35
+ this[attribute] = value;
36
+ return this;
37
+ }
38
+ }
39
+ exports.RegisteredNotification = RegisteredNotification;
40
+ /**
41
+ * Recursively creates Notification objects from the input object.
42
+ * @param input a string from an enum or an enum itself
43
+ * @returns an array of Notification objects
44
+ */
45
+ function createNotification(input) {
46
+ const notifications = []; // all notification objects created from the input
47
+ if (typeof input === "string") {
48
+ // if the input is a string, create a Notification object from it
49
+ notifications.push(new RegisteredNotification(input, input + ".label", input + ".description"));
50
+ }
51
+ else {
52
+ // if the input is an object, iterate over its keys and create Notification objects from the values
53
+ for (const key in input) {
54
+ if (Object.prototype.hasOwnProperty.call(input, key)) {
55
+ const element = input[key];
56
+ notifications.push(...createNotification(element));
57
+ }
58
+ }
59
+ }
60
+ return notifications;
61
+ }
@@ -1,45 +1,3 @@
1
- /**
2
- * Permissions that should be registered in the database by default when the server starts.
3
- * The ACLs are set to od-admin only.
4
- * Adding new Permissions here requires the server to restart for registering those.
5
- */
6
- export declare namespace Permissions {
7
- enum OpenService {
8
- ticket = "maintenance:can-create-ticket",
9
- schedule = "maintenance:can-create-schedule",
10
- message = "maintenance:can-create-message",
11
- machinelog_ticket = "maintenance:can-create-machinelog-ticket",
12
- machinelog_schedule = "maintenance:can-create-machinelog-schedule",
13
- machinelog_message = "maintenance:can-create-machinelog-message",
14
- global = "maintenance:can-access-global",
15
- monitor = "maintenance:can-access-monitor",
16
- material = "maintenance:can-access-material",
17
- scheduletemplate = "maintenance:can-access-scheduletemplate",
18
- dailySchedule = "maintenance:can-access-dailySchedule",
19
- downtime = "maintenance:can-access-downtime",
20
- restriction = "maintenance:can-access-restriction",
21
- frequency = "maintenance:can-access-frequency",
22
- downtimeField0 = "maintenance:can-access-downtime-field-0",
23
- downtimeField1 = "maintenance:can-access-downtime-field-1",
24
- downtimeField2 = "maintenance:can-access-downtime-field-2",
25
- downtimeField3 = "maintenance:can-access-downtime-field-3",
26
- downtimeField4 = "maintenance:can-access-downtime-field-4",
27
- restrictionField0 = "maintenance:can-access-restriction-field-0",
28
- restrictionField1 = "maintenance:can-access-restriction-field-1",
29
- restrictionField2 = "maintenance:can-access-restriction-field-2",
30
- frequencyField0 = "maintenance:can-access-frequency-field-0",
31
- frequencyField1 = "maintenance:can-access-frequency-field-1",
32
- frequencyField2 = "maintenance:can-access-frequency-field-2",
33
- frequencyField3 = "maintenance:can-access-frequency-field-3",
34
- frequencyField4 = "maintenance:can-access-frequency-field-4",
35
- priority = "maintenance:can-access-priority",
36
- priorityNumber = "maintenance:can-access-priority-number",
37
- priorityLabel = "maintenance:can-access-priority-label",
38
- issuecategory = "maintenance:can-update-issuecategory",
39
- monitorstate = "maintenance:can-update-monitorstate",
40
- kanban_view = "maintenance:can-update-kanban-view"
41
- }
42
- }
43
1
  /**
44
2
  * Returns all permissions from the OpenService plugin defined in types/config.ts as an array of Permission objects.
45
3
  * @returns all permissions from the OpenService plugin