@open-wa/wa-automate 4.27.9 → 4.28.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.
@@ -68,7 +68,7 @@ const MessageCollector_1 = require("../structures/MessageCollector");
68
68
  const init_patch_1 = require("../controllers/init_patch");
69
69
  const preProcessors_1 = require("../structures/preProcessors");
70
70
  const tools_1 = require("../utils/tools");
71
- const logging_1 = require("../utils/logging");
71
+ const logging_1 = require("../logging/logging");
72
72
  /** @ignore */
73
73
  const pkg = (0, fs_extra_1.readJsonSync)(path.join(__dirname, '../../package.json'));
74
74
  var namespace;
@@ -1,6 +1,6 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { PREPROCESSORS } from '../../structures/preProcessors';
3
- import { ConfigLogTransport } from '../../utils/logging';
3
+ import { ConfigLogTransport } from '../../logging/logging';
4
4
  import { Base64 } from "./aliases";
5
5
  import { SimpleListener } from './events';
6
6
  /**
package/dist/cli/setup.js CHANGED
@@ -43,7 +43,7 @@ const uuid_apikey_1 = __importDefault(require("uuid-apikey"));
43
43
  const events_1 = require("../controllers/events");
44
44
  const is_url_superb_1 = __importDefault(require("is-url-superb"));
45
45
  const path = __importStar(require("path"));
46
- const logging_1 = require("../utils/logging");
46
+ const logging_1 = require("../logging/logging");
47
47
  let checkUrl = url => typeof url === 'string' ? (0, is_url_superb_1.default)(url) : false;
48
48
  const configWithCases = (0, fs_extra_1.readJsonSync)(path.join(__dirname, '../../bin/config-schema.json'));
49
49
  const optionList = [{
@@ -39,7 +39,7 @@ const initializer_1 = require("./initializer");
39
39
  const tools_1 = require("../utils/tools");
40
40
  const browser_1 = require("./browser");
41
41
  const axios_1 = __importDefault(require("axios"));
42
- const logging_1 = require("../utils/logging");
42
+ const logging_1 = require("../logging/logging");
43
43
  const timeout = ms => new Promise(resolve => setTimeout(resolve, ms, 'timeout'));
44
44
  /**
45
45
  * Validates if client is authenticated
@@ -42,7 +42,7 @@ const pico_s3_1 = require("pico-s3");
42
42
  // eslint-disable-next-line @typescript-eslint/no-var-requires
43
43
  const puppeteer = require('puppeteer-extra');
44
44
  const tree_kill_1 = __importDefault(require("tree-kill"));
45
- const logging_1 = require("../utils/logging");
45
+ const logging_1 = require("../logging/logging");
46
46
  let browser;
47
47
  function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth) {
48
48
  var _a, _b, _c, _d, _e;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Spin = exports.EvEmitter = exports.ev = void 0;
7
7
  const eventemitter2_1 = require("eventemitter2");
8
8
  const spinnies_1 = __importDefault(require("spinnies"));
9
- const logging_1 = require("../utils/logging");
9
+ const logging_1 = require("../logging/logging");
10
10
  const spinner = {
11
11
  "interval": 80,
12
12
  "frames": [
@@ -61,7 +61,7 @@ const fs_extra_1 = require("fs-extra");
61
61
  const pico_s3_1 = require("pico-s3");
62
62
  const init_patch_1 = require("./init_patch");
63
63
  const patch_manager_1 = require("./patch_manager");
64
- const logging_1 = require("../utils/logging");
64
+ const logging_1 = require("../logging/logging");
65
65
  const timeout = (ms) => {
66
66
  return new Promise(resolve => setTimeout(resolve, ms, 'timeout'));
67
67
  };
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { create } from './controllers/initializer';
4
4
  export * from '@open-wa/wa-decrypt';
5
5
  export { ev, Spin } from './controllers/events';
6
6
  export * from './utils/tools';
7
+ export * from './logging/logging';
7
8
  export * from './structures/preProcessors';
8
9
  export * from './connect';
9
10
  export * from './build/build-postman';
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var events_1 = require("./controllers/events");
20
20
  Object.defineProperty(exports, "ev", { enumerable: true, get: function () { return events_1.ev; } });
21
21
  Object.defineProperty(exports, "Spin", { enumerable: true, get: function () { return events_1.Spin; } });
22
22
  __exportStar(require("./utils/tools"), exports);
23
+ __exportStar(require("./logging/logging"), exports);
23
24
  __exportStar(require("./structures/preProcessors"), exports);
24
25
  __exportStar(require("./connect"), exports);
25
26
  //dont need to export this
File without changes
File without changes
@@ -0,0 +1,50 @@
1
+ import * as winston from 'winston';
2
+ /**
3
+ * You can access the log in your code and add your own custom transports
4
+ * https://github.com/winstonjs/winston#transports
5
+ * see [Logger](https://github.com/winstonjs/winston#transports) for more details.
6
+ *
7
+ * Here is an example of adding the GCP stackdriver transport:
8
+ *
9
+ * ```
10
+ * import { log } from '@open-wa/wa-automate'
11
+ * import { LoggingWinston } from '@google-cloud/logging-winston';
12
+ *
13
+ * const gcpTransport = new LoggingWinston({
14
+ * projectId: 'your-project-id',
15
+ * keyFilename: '/path/to/keyfile.json'
16
+ * });
17
+ *
18
+ * ...
19
+ * log.add(
20
+ * gcpTransport
21
+ * )
22
+ *
23
+ * //Congrats! Now all of your session logs will also go to GCP Stackdriver
24
+ * ```
25
+ */
26
+ export declare const log: winston.Logger;
27
+ export declare const addRotateFileLogTransport: (options?: any) => void;
28
+ /**
29
+ * @private
30
+ */
31
+ export declare const addSysLogTransport: (options?: any) => void;
32
+ export declare type ConfigLogTransport = {
33
+ /**
34
+ * The type of winston transport. At the moment only `file`, `console`, `ev` and `syslog` are supported.
35
+ */
36
+ type: 'syslog' | 'console' | 'file' | 'ev';
37
+ /**
38
+ * The options for the transport. Generally only required for syslog but you can use this to override default options for other types of transports.
39
+ */
40
+ options?: any;
41
+ /**
42
+ * If the transport has already been added to the logger. The logging set up command handles this for you.
43
+ * @readonly
44
+ */
45
+ done?: boolean;
46
+ };
47
+ /**
48
+ * @private
49
+ */
50
+ export declare const setupLogging: (logging: ConfigLogTransport[], sessionId?: string) => ConfigLogTransport[];
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.setupLogging = exports.addRotateFileLogTransport = exports.log = void 0;
25
+ exports.setupLogging = exports.addSysLogTransport = exports.addRotateFileLogTransport = exports.log = void 0;
26
26
  const os_1 = __importDefault(require("os"));
27
27
  const winston = __importStar(require("winston"));
28
28
  const winston_daily_rotate_file_1 = __importDefault(require("winston-daily-rotate-file"));
@@ -80,6 +80,27 @@ const makeLogger = () => winston.createLogger({
80
80
  });
81
81
  /**
82
82
  * You can access the log in your code and add your own custom transports
83
+ * https://github.com/winstonjs/winston#transports
84
+ * see [Logger](https://github.com/winstonjs/winston#transports) for more details.
85
+ *
86
+ * Here is an example of adding the GCP stackdriver transport:
87
+ *
88
+ * ```
89
+ * import { log } from '@open-wa/wa-automate'
90
+ * import { LoggingWinston } from '@google-cloud/logging-winston';
91
+ *
92
+ * const gcpTransport = new LoggingWinston({
93
+ * projectId: 'your-project-id',
94
+ * keyFilename: '/path/to/keyfile.json'
95
+ * });
96
+ *
97
+ * ...
98
+ * log.add(
99
+ * gcpTransport
100
+ * )
101
+ *
102
+ * //Congrats! Now all of your session logs will also go to GCP Stackdriver
103
+ * ```
83
104
  */
84
105
  exports.log = makeLogger();
85
106
  if (exports.log.warning && !exports.log.warn)
@@ -90,9 +111,13 @@ const addRotateFileLogTransport = (options = {}) => {
90
111
  exports.log.add(new winston_daily_rotate_file_1.default(Object.assign({ filename: 'application-%DATE%.log', datePattern: 'YYYY-MM-DD-HH', zippedArchive: true, maxSize: '2m', maxFiles: '14d' }, options)));
91
112
  };
92
113
  exports.addRotateFileLogTransport = addRotateFileLogTransport;
114
+ /**
115
+ * @private
116
+ */
93
117
  const addSysLogTransport = (options = {}) => {
94
118
  exports.log.add(new winston_syslog_1.Syslog(Object.assign({ localhost: os_1.default.hostname() }, options)));
95
119
  };
120
+ exports.addSysLogTransport = addSysLogTransport;
96
121
  const enableConsoleLogger = (options = {}) => {
97
122
  if (_consoleSet)
98
123
  return;
@@ -105,6 +130,9 @@ function enableLogToEv(options = {}) {
105
130
  exports.log.add(new custom_transport_1.LogToEvTransport(Object.assign({ format: winston.format.json() }, options)));
106
131
  _evSet = true;
107
132
  }
133
+ /**
134
+ * @private
135
+ */
108
136
  const setupLogging = (logging, sessionId = "session") => {
109
137
  const currentlySetup = [];
110
138
  const _logging = logging.map((l) => {
@@ -120,7 +148,7 @@ const setupLogging = (logging, sessionId = "session") => {
120
148
  (0, exports.addRotateFileLogTransport)(Object.assign({}, (l.options || {})));
121
149
  }
122
150
  else if (l.type === 'syslog') {
123
- addSysLogTransport(Object.assign(Object.assign({}, (l.options || {})), { appName: `owa-${sessionId}-${d}` }));
151
+ (0, exports.addSysLogTransport)(Object.assign(Object.assign({}, (l.options || {})), { appName: `owa-${sessionId}-${d}` }));
124
152
  }
125
153
  currentlySetup.push(l);
126
154
  return Object.assign(Object.assign({}, l), { done: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-wa/wa-automate",
3
- "version": "4.27.9",
3
+ "version": "4.28.0",
4
4
  "licenseCheckUrl": "https://openwa.dev/license-check",
5
5
  "brokenMethodReportUrl": "https://openwa.dev/report-bm",
6
6
  "patches": "https://cdn.openwa.dev/patches.json",
@@ -1,18 +0,0 @@
1
- import * as winston from 'winston';
2
- /**
3
- * You can access the log in your code and add your own custom transports
4
- */
5
- export declare const log: winston.Logger;
6
- export declare const addRotateFileLogTransport: (options?: any) => void;
7
- export declare type ConfigLogTransport = {
8
- /**
9
- * The type of winston transport. At the moment only file, console, ev and syslog are supported.
10
- */
11
- type: 'syslog' | 'console' | 'file' | 'ev';
12
- /**
13
- * The options for the transport. Generally only required for syslog but you can use this to override default options for other types of transports.
14
- */
15
- options?: any;
16
- done?: boolean;
17
- };
18
- export declare const setupLogging: (logging: ConfigLogTransport[], sessionId?: string) => ConfigLogTransport[];