work-dispatcher 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,13 @@
1
- declare function sayHello(name: string): string;
2
- export { sayHello };
1
+ export { getDispatcherVersion } from './utils/version.js';
2
+ export { fine, debug, info, warn, error } from './utils/logging.js';
3
+ export { SPACE, QUOTATION, HASHTAG, AMPERSAND, APOSTROPHE, BRACKET_OPEN, BRACKET_CLOSE, SMALLER, EQUALS, TILDE, AE } from './utils/HTMLHelper.js';
4
+ export { sleep, pad, waitSyncMS } from './utils/generalUtil.js';
5
+ export { dateToIsoString, dateToICALString, dateToJQLString, getDateByDayAndSetPos, getNextWeekday, getPreviousWeekday, getDateFromString, getStringFromDate, cloneDate, minutesToString, dateToWeekNumber } from './utils/dateHelper.js';
6
+ export { dispatcherConfig } from './config/config.js';
7
+ export { _callUrl } from './utils/httpHelper.js';
8
+ export { Feature, FEATURE_STATUS } from './work/featureClass.js';
9
+ export { addFeaturesToQ, terminate, resetQ, addEventToList, getCurrentQ, getPastQ, getCurrentFeature, startWorking, setCurrentlyWorkingOn, currentlyWorkingOn, cancelFeatureRequested, setFeatureResult, addToFeatureResult, skipCurrentlyWorkingFeature, } from './work/workQ.js';
10
+ export { getHealth } from './work/health.js';
11
+ export { pauseFeature } from './work/pause.js';
12
+ export declare function init(handlers: any, allFeatureSet: any[]): void;
3
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAClJ,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC1O,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EACL,cAAc,EACd,SAAS,EACT,MAAM,EACN,cAAc,EACd,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,wBAAgB,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,QAiBvD"}
package/dist/index.js CHANGED
@@ -1,6 +1,35 @@
1
- console.log('Work Dispatcher Module Loaded');
2
- function sayHello(name) {
3
- return `Hello, ${name}! Sam says`;
1
+ import { dispatcherConfig } from './config/config.js';
2
+ import { error, info } from './utils/logging.js';
3
+ import { getDispatcherVersion } from './utils/version.js';
4
+ export { getDispatcherVersion } from './utils/version.js';
5
+ export { fine, debug, info, warn, error } from './utils/logging.js';
6
+ export { SPACE, QUOTATION, HASHTAG, AMPERSAND, APOSTROPHE, BRACKET_OPEN, BRACKET_CLOSE, SMALLER, EQUALS, TILDE, AE } from './utils/HTMLHelper.js';
7
+ export { sleep, pad, waitSyncMS } from './utils/generalUtil.js';
8
+ export { dateToIsoString, dateToICALString, dateToJQLString, getDateByDayAndSetPos, getNextWeekday, getPreviousWeekday, getDateFromString, getStringFromDate, cloneDate, minutesToString, dateToWeekNumber } from './utils/dateHelper.js';
9
+ export { dispatcherConfig } from './config/config.js';
10
+ export { _callUrl } from './utils/httpHelper.js';
11
+ export { Feature, FEATURE_STATUS } from './work/featureClass.js';
12
+ export { addFeaturesToQ, terminate, resetQ, addEventToList, getCurrentQ, getPastQ, getCurrentFeature, startWorking, setCurrentlyWorkingOn, currentlyWorkingOn, cancelFeatureRequested, setFeatureResult, addToFeatureResult, skipCurrentlyWorkingFeature, } from './work/workQ.js';
13
+ export { getHealth } from './work/health.js';
14
+ export { pauseFeature } from './work/pause.js';
15
+ export function init(handlers, allFeatureSet) {
16
+ info('DISPATCHER.JS', 'Now initializing');
17
+ info('DISPATCHER.JS', 'Currently running with work-dispatcher version', getDispatcherVersion());
18
+ if (!handlers.errorHandler) {
19
+ error('DISPATCHER.JS', 'No errorHandler was provided which is needed for dispatcher.js to start. Application will now exit');
20
+ process.exit(1);
21
+ }
22
+ if (!handlers.emptyQHandler) {
23
+ handlers.emptyQHandler = doNothing;
24
+ }
25
+ dispatcherConfig.handlers = handlers;
26
+ dispatcherConfig.allFeatureSet = allFeatureSet;
27
+ if (process.env['DOCKER_ENV'] === 'ci-test') {
28
+ info('DISPATCHER.JS', 'Running in CI test mode, not starting server or cron jobs.');
29
+ process.exit(0);
30
+ }
31
+ }
32
+ async function doNothing() {
33
+ // intentionally empty
4
34
  }
5
- export { sayHello };
6
35
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAE7C,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,UAAU,IAAI,YAAY,CAAC;AACpC,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAClJ,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC1O,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB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
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Typescript library to handle task or work scheduling",
5
5
  "keywords": [
6
6
  "typescript"
@@ -16,10 +16,11 @@
16
16
  "license": "GPL-3.0",
17
17
  "author": "PhilippAuch",
18
18
  "type": "module",
19
- "main": "index.ts",
19
+ "main": "dist/index.js",
20
+ "types": "dist/index.d.ts",
20
21
  "scripts": {
21
22
  "build": "tsc",
22
- "test": "NODE_ENV=TEST vitest"
23
+ "test": "NODE_ENV=TEST vitest --coverage"
23
24
  },
24
25
  "release": {
25
26
  "branches": [
@@ -28,6 +29,7 @@
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/node": "^25.0.3",
32
+ "@vitest/coverage-v8": "^4.0.16",
31
33
  "semantic-release": "^25.0.2",
32
34
  "typescript": "^5.9.3",
33
35
  "vitest": "^4.0.16"
@@ -0,0 +1,129 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title><%= pageTitle; %></title>
7
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed" />
8
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />
9
+ <link rel="stylesheet" href="status.css" />
10
+ <script>
11
+ document.addEventListener('DOMContentLoaded', function (event) {
12
+ var scrollpos = localStorage.getItem('scrollpos');
13
+ if (scrollpos) window.scrollTo(0, scrollpos);
14
+
15
+ setTimeout(function () {
16
+ localStorage.setItem('scrollpos', window.scrollY);
17
+ window.location.href = window.location.pathname; // This removes query parameters
18
+ }, 2000); // 2 seconds, same as your meta refresh
19
+ });
20
+
21
+ window.onbeforeunload = function (e) {
22
+ localStorage.setItem('scrollpos', window.scrollY);
23
+ };
24
+ </script>
25
+ </head>
26
+
27
+ <body>
28
+ <p style="text-align: center"><%= pageTitle; %> <%= softwareVersion; %> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Startup: <%= startupTime; %> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dispatcher.js <%= dispatcherVersion; %></p>
29
+
30
+ <div style="display: flex; justify-content: center; gap: 2em">
31
+ <div>
32
+ <form action="/trigger" method="get" id="triggerForm">
33
+ <button type="submit" class="btn btn-outline-primary btn-sm" form="triggerForm">TRIGGER</button>
34
+ </form>
35
+ </div>
36
+ <div>
37
+ <form action="/skip" method="get" id="skipForm">
38
+ <button type="submit" class="btn btn-outline-primary btn-sm" form="skipForm">SKIP</button>
39
+ </form>
40
+ </div>
41
+ <div>
42
+ <form action="/pause" method="get" id="pauseForm">
43
+ <button type="submit" class="btn btn-outline-primary btn-sm" form="pauseForm">PAUSE</button>
44
+ </form>
45
+ </div>
46
+ <div>
47
+ <form action="/reset" method="get" id="resetForm">
48
+ <button type="submit" class="btn btn-outline-primary btn-sm" form="resetForm">RESET</button>
49
+ </form>
50
+ </div>
51
+ <div>
52
+ <form action="/reboot" method="get" id="rebootForm">
53
+ <button type="submit" class="btn btn-outline-primary btn-sm" form="rebootForm">REBOOT</button>
54
+ </form>
55
+ </div>
56
+ </div>
57
+
58
+ <br />
59
+
60
+ <!-- current feature -->
61
+ <% if (currentFeature) { %>
62
+ <div class="flexContainer currentFeature">
63
+ <%= currentFeature.name; %>
64
+ <b> <%= currentFeature.getDurationString(); %> </b>
65
+ <% if (currentFeature.params) { %>
66
+ <br /><span>Params: <%= currentFeature.params; %></span>
67
+ <% } %>
68
+ <span style="font-size: 0.5rem">Added: <%= currentFeature.timeAdded.toLocaleDateString(undefined, dateOptions); %></span>
69
+
70
+ <% if (currentlyWorkingOn.length> 0) { %>
71
+ <br /><span>CWO: <%= currentlyWorkingOn; %></span>
72
+ <% } %> <% if (currentFeature.result && currentFeature.result.length> 0) { %>
73
+ <br /><span
74
+ ><b>Result</b><br />
75
+ <%- currentFeature.result; %></span
76
+ >
77
+ <% } %>
78
+ </div>
79
+ <% } %>
80
+
81
+ <div class="leftHalf">
82
+ <span class="counter">Counter: <%= currentQ.length; %></span>
83
+ <ul>
84
+ <% for(var i=0; i < currentQ.length; i++) { %>
85
+ <li class="flexContainer currentQ<%= (currentQ[i].type === 'EVENT') ? ' eventType' : '' %>">
86
+ <span style="flex: 1 0 45%"> <%= currentQ[i].name; %> </span>
87
+ <% if (currentQ[i].params) { %>
88
+ <br /><span>Params: <%= currentQ[i].params; %></span>
89
+ <% } %>
90
+ <span style="flex: 1 0 45%; font-size: 0.5rem; text-align: right">Added: <%= currentQ[i].timeAdded.toLocaleDateString( undefined, dateOptions); %></span>
91
+ </li>
92
+ <% } %>
93
+ </ul>
94
+ </div>
95
+
96
+ <div class="rightHalf">
97
+ <span class="counter">Counter: <%= pastQ.length; %></span>
98
+ <ul>
99
+ <% for(var i=0; i < pastQ.length; i++) { %>
100
+ <li
101
+ class="flexContainer <%= (pastQ[i].errorForFeature && pastQ[i].errorForFeature.length > 0) ? 'pastError' : (pastQ[i].result && pastQ[i].result.length > 0) ? 'pastResult' : 'pastQ' %> <%= (pastQ[i].type === 'EVENT') ? ' eventType' : '' %>"
102
+ >
103
+ <span style="flex: 2 0 40%"> <%= pastQ[i].name; %> </span>
104
+ <span style="flex: 1 0 20%; text-align: right"><b> <%= pastQ[i].durationString; %> </b></span>
105
+ <% if (pastQ[i].params) { %>
106
+ <br /><span>Params: <%= pastQ[i].params; %></span>
107
+ <% } %>
108
+
109
+ <span style="flex: 1 0 20%; font-size: 0.5rem; text-align: right">
110
+ Added: <%= pastQ[i].timeAdded.toLocaleDateString( undefined, dateOptions); %> <br />
111
+ Finished: <%= new Date(pastQ[i].startDate).toLocaleDateString(undefined, dateOptions); %>
112
+ </span>
113
+ <% if (pastQ[i].result && pastQ[i].result.length> 0) { %>
114
+ <span>
115
+ <b>Result</b><br />
116
+ <%- pastQ[i].result; %>
117
+ </span>
118
+ <% } %> <% if (pastQ[i].errorForFeature && pastQ[i].errorForFeature.length > 0) { %>
119
+ <span>
120
+ <b>Error</b><br />
121
+ <%- pastQ[i].errorForFeature; %>
122
+ </span>
123
+ <% } %>
124
+ </li>
125
+ <% } %>
126
+ </ul>
127
+ </div>
128
+ </body>
129
+ </html>