@sera4/essentia 1.1.60 → 1.1.63

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/health/index.js CHANGED
@@ -105,12 +105,12 @@ class HealthCheck {
105
105
  const result = await hc.healthFunction();
106
106
  if (typeof(result) === "boolean") {
107
107
  if (result === false) {
108
- Object.assign(res, {"result": "fail" })
108
+ res = {"result": "fail", ...res }
109
109
  } else {
110
- Object.assign(res, {"result": "success" })
110
+ res = {"result": "success", ...res }
111
111
  }
112
112
  } else {
113
- Object.assign(res, {"result": "success" })
113
+ res = {"result": "success", ...res }
114
114
  }
115
115
  return res;
116
116
  } catch(e) {
package/index.js CHANGED
@@ -14,3 +14,4 @@ export { default as serializer } from "./serializer/index.js";
14
14
  export * from "./utils/index.js";
15
15
  export * from "./safe_proxy/index.js";
16
16
  export * from "./helpers/index.js";
17
+ export * from "./prompts/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sera4/essentia",
3
- "version": "1.1.60",
3
+ "version": "1.1.63",
4
4
  "description": "A library of utilities for Teleporte Web Services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,6 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "amqplib": "^0.8.0",
31
+ "argparse": "^2.0.1",
31
32
  "async": "^3.2.2",
32
33
  "axios": "^1.7.7",
33
34
  "deep-diff": "^1.0.2",
@@ -36,6 +37,7 @@
36
37
  "git-rev": "^0.2.1",
37
38
  "lodash": "^4.17.21",
38
39
  "morgan": "^1.10.0",
40
+ "prompt": "^1.3.0",
39
41
  "url-parse": "^1.5.10",
40
42
  "uuid": "^9.0.0",
41
43
  "winston": "^3.3.3",
package/package.tar.gz CHANGED
Binary file
@@ -105,8 +105,8 @@ paperTrail.init = (sequelize, sequelizePackage, optionsArg) => {
105
105
  const destroyOperation = operation === 'destroy';
106
106
  const restoreOperation = operation === 'restore';
107
107
 
108
- let previousVersion = {};
109
- let currentVersion = {};
108
+ let previousVersion = _.cloneDeep(instance._previousDataValues);
109
+ let currentVersion = _.cloneDeep(instance.dataValues);
110
110
  if (!destroyOperation && options.enableCompression) {
111
111
  _.forEach(opt.fields, a => {
112
112
  previousVersion[a] = instance._previousDataValues[a];
@@ -0,0 +1,78 @@
1
+ /* Essentia Common Prompt Functions */
2
+ // This file contains common prompt functions that are used in CLI scripts
3
+ // that are run in the each project. These functions are used to
4
+ // prompt the user for input and to wait for the user to press enter
5
+ // before continuing. This is useful for scripts that are run in the
6
+ // command line and need to wait for the user to do something before
7
+ // continuing.
8
+
9
+ import logger from "../logger/s4-logger.js";
10
+ import { ArgumentParser } from 'argparse'
11
+ import prompt from "prompt";
12
+
13
+ // New common argument parser which makes parsing and setting up commandline options easier
14
+ const setupCLIParser = (description) => {
15
+ logger.info(description)
16
+ return new ArgumentParser({ description });
17
+ }
18
+
19
+ // a common init function which waits for the command prompt to be delivered
20
+ // a common use is for the awaiting of the queues to initialize before running
21
+ const commonCLIInit = async(options) => {
22
+ //add in defaults to options if they have not been specified or object is {}
23
+ options = { asyncFcns: [], extraFcns: [], sleepTime: 1000, ...options };
24
+
25
+ // Sleep for 1 second to allow the prompt to be displayed
26
+ // at the end of bootstrap logs
27
+ await cliSleep(options.sleepTime);
28
+
29
+ options.extraFcns.forEach(fcn => {
30
+ fcn();
31
+ });
32
+
33
+ for (const fcn of options.asyncFcns) {
34
+ await fcn();
35
+ }
36
+ }
37
+
38
+ const promptCLIAsync = async (options) => {
39
+ return new Promise((resolve, reject) => {
40
+ prompt.start();
41
+ prompt.get(options, (err, res) => {
42
+ if (err) {
43
+ reject(err);
44
+ } else {
45
+ resolve(res);
46
+ }
47
+ })
48
+ });
49
+ }
50
+
51
+ // A predefined waitPrompt for use at the end of the scripts that use
52
+ // message queues. Message Queues often take a bit to fire
53
+ const waitCLIPrompt = {
54
+ "Push <enter> when done" : {
55
+ type: "boolean"
56
+ }
57
+ };
58
+
59
+ const continueCLIPrompt = {
60
+ "Push <enter> to continue" : {
61
+ type: "boolean"
62
+ }
63
+ };
64
+
65
+ const cliSleep = async(ms) => {
66
+ return new Promise((resolve) => {
67
+ setTimeout(resolve, ms);
68
+ });
69
+ }
70
+
71
+ export {
72
+ commonCLIInit,
73
+ continueCLIPrompt,
74
+ promptCLIAsync,
75
+ setupCLIParser,
76
+ cliSleep,
77
+ waitCLIPrompt
78
+ };