@open-wa/wa-automate 4.76.0 → 5.0.0-alpha.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.
Files changed (125) hide show
  1. package/README.md +14 -165
  2. package/dist/cli-runtime-B7_3MM0c.cjs +798 -0
  3. package/dist/cli-runtime-B7_3MM0c.cjs.map +1 -0
  4. package/dist/cli-runtime-CmpYxFCk.d.cts +31 -0
  5. package/dist/cli-runtime-CmpYxFCk.d.cts.map +1 -0
  6. package/dist/cli.cjs +17 -0
  7. package/dist/cli.cjs.map +1 -0
  8. package/dist/cli.d.cts +2 -0
  9. package/dist/index.cjs +224 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +81 -0
  12. package/dist/index.d.cts.map +1 -0
  13. package/package.json +34 -177
  14. package/CNAME +0 -1
  15. package/_tsconfig.docs.json +0 -140
  16. package/bin/config-schema.json +0 -1
  17. package/bin/oas-type-schemas.json +0 -1
  18. package/bin/server.js +0 -45
  19. package/build/build-config-json-for-bin.ts +0 -56
  20. package/build/generate-oas-types.ts +0 -31
  21. package/dist/api/Client.d.ts +0 -2255
  22. package/dist/api/Client.js +0 -4358
  23. package/dist/api/functions/exposed.enum.d.ts +0 -7
  24. package/dist/api/functions/exposed.enum.js +0 -11
  25. package/dist/api/model/aliases.d.ts +0 -110
  26. package/dist/api/model/aliases.js +0 -3
  27. package/dist/api/model/button.d.ts +0 -24
  28. package/dist/api/model/button.js +0 -2
  29. package/dist/api/model/call.d.ts +0 -51
  30. package/dist/api/model/call.js +0 -18
  31. package/dist/api/model/chat.d.ts +0 -221
  32. package/dist/api/model/chat.js +0 -52
  33. package/dist/api/model/config.d.ts +0 -836
  34. package/dist/api/model/config.js +0 -111
  35. package/dist/api/model/contact.d.ts +0 -143
  36. package/dist/api/model/contact.js +0 -2
  37. package/dist/api/model/errors.d.ts +0 -90
  38. package/dist/api/model/errors.js +0 -117
  39. package/dist/api/model/events.d.ts +0 -120
  40. package/dist/api/model/events.js +0 -127
  41. package/dist/api/model/group-metadata.d.ts +0 -124
  42. package/dist/api/model/group-metadata.js +0 -25
  43. package/dist/api/model/id.d.ts +0 -5
  44. package/dist/api/model/id.js +0 -2
  45. package/dist/api/model/index.d.ts +0 -110
  46. package/dist/api/model/index.js +0 -128
  47. package/dist/api/model/label.d.ts +0 -24
  48. package/dist/api/model/label.js +0 -2
  49. package/dist/api/model/media.d.ts +0 -93
  50. package/dist/api/model/media.js +0 -12
  51. package/dist/api/model/message.d.ts +0 -422
  52. package/dist/api/model/message.js +0 -40
  53. package/dist/api/model/product.d.ts +0 -141
  54. package/dist/api/model/product.js +0 -2
  55. package/dist/api/model/reactions.d.ts +0 -76
  56. package/dist/api/model/reactions.js +0 -2
  57. package/dist/api/model/sessionInfo.d.ts +0 -77
  58. package/dist/api/model/sessionInfo.js +0 -2
  59. package/dist/build/build-postman.d.ts +0 -1
  60. package/dist/build/build-postman.js +0 -262
  61. package/dist/cli/cli-options.d.ts +0 -9
  62. package/dist/cli/cli-options.js +0 -289
  63. package/dist/cli/collections.d.ts +0 -2
  64. package/dist/cli/collections.js +0 -251
  65. package/dist/cli/file-utils.d.ts +0 -1
  66. package/dist/cli/file-utils.js +0 -71
  67. package/dist/cli/index.d.ts +0 -1
  68. package/dist/cli/index.js +0 -231
  69. package/dist/cli/integrations/chatwoot.d.ts +0 -49
  70. package/dist/cli/integrations/chatwoot.js +0 -672
  71. package/dist/cli/integrations/cloudflare.d.ts +0 -6
  72. package/dist/cli/integrations/cloudflare.js +0 -76
  73. package/dist/cli/logo.d.ts +0 -1
  74. package/dist/cli/logo.js +0 -49
  75. package/dist/cli/server.d.ts +0 -24
  76. package/dist/cli/server.js +0 -540
  77. package/dist/cli/setup.d.ts +0 -30
  78. package/dist/cli/setup.js +0 -308
  79. package/dist/config/puppeteer.config.d.ts +0 -11
  80. package/dist/config/puppeteer.config.js +0 -65
  81. package/dist/controllers/auth.d.ts +0 -36
  82. package/dist/controllers/auth.js +0 -322
  83. package/dist/controllers/browser.d.ts +0 -17
  84. package/dist/controllers/browser.js +0 -603
  85. package/dist/controllers/events.d.ts +0 -82
  86. package/dist/controllers/events.js +0 -173
  87. package/dist/controllers/init_patch.d.ts +0 -13
  88. package/dist/controllers/init_patch.js +0 -42
  89. package/dist/controllers/initializer.d.ts +0 -22
  90. package/dist/controllers/initializer.js +0 -511
  91. package/dist/controllers/launch_checks.d.ts +0 -8
  92. package/dist/controllers/launch_checks.js +0 -130
  93. package/dist/controllers/patch_manager.d.ts +0 -37
  94. package/dist/controllers/patch_manager.js +0 -231
  95. package/dist/controllers/popup/index.d.ts +0 -3
  96. package/dist/controllers/popup/index.html +0 -168
  97. package/dist/controllers/popup/index.js +0 -148
  98. package/dist/controllers/script_preloader.d.ts +0 -17
  99. package/dist/controllers/script_preloader.js +0 -88
  100. package/dist/index.d.ts +0 -13
  101. package/dist/index.js +0 -36
  102. package/dist/lib/README.md +0 -5
  103. package/dist/lib/base64.js +0 -1
  104. package/dist/lib/hash.js +0 -1
  105. package/dist/lib/jsSha.min.js +0 -1
  106. package/dist/lib/launch.js +0 -1
  107. package/dist/lib/qr.min.js +0 -1
  108. package/dist/lib/wapi.js +0 -2163
  109. package/dist/logging/custom_transport.d.ts +0 -9
  110. package/dist/logging/custom_transport.js +0 -35
  111. package/dist/logging/logging.d.ts +0 -50
  112. package/dist/logging/logging.js +0 -196
  113. package/dist/structures/Collector.d.ts +0 -202
  114. package/dist/structures/Collector.js +0 -391
  115. package/dist/structures/Dialog.d.ts +0 -55
  116. package/dist/structures/Dialog.js +0 -21
  117. package/dist/structures/MessageCollector.d.ts +0 -78
  118. package/dist/structures/MessageCollector.js +0 -145
  119. package/dist/structures/preProcessors.d.ts +0 -58
  120. package/dist/structures/preProcessors.js +0 -181
  121. package/dist/utils/pid_utils.d.ts +0 -1
  122. package/dist/utils/pid_utils.js +0 -26
  123. package/dist/utils/tools.d.ts +0 -152
  124. package/dist/utils/tools.js +0 -494
  125. package/tos.md +0 -77
@@ -1,58 +0,0 @@
1
- import { Client } from "../api/Client";
2
- import { Message } from "../api/model/message";
3
- /**
4
- * A function that takes a message and returns a message.
5
- *
6
- * @param message The message to be processed
7
- * @param client The client that received the message
8
- * @param alreadyProcessed Whether the message has already been processed by another preprocessor. (This is useful in cases where you want to mutate the message for both onMessage and onAnyMessage events but only want to do the actual process, like uploading to s3, once.)
9
- * @param source The source of the message. This is useful for knowing if the message is from onMessage or onAnyMessage. Only processing one source will prevent duplicate processing.
10
- */
11
- export type MessagePreProcessor = (message: Message, client?: Client, alreadyProcessed?: boolean, source?: 'onMessage' | 'onAnyMessage') => Promise<Message>;
12
- /**
13
- * An object that contains all available [[PREPROCESSORS]].
14
- *
15
- * [Check out the processor code here](https://github.com/open-wa/wa-automate-nodejs/blob/master/src/structures/preProcessors.ts)
16
- */
17
- export declare const MessagePreprocessors: {
18
- [processorName: string]: MessagePreProcessor;
19
- };
20
- /**
21
- * A set of easy to use, built-in message processors.
22
- *
23
- * [Check out the processor code here](https://github.com/open-wa/wa-automate-nodejs/blob/master/src/structures/preProcessors.ts)
24
- *
25
- */
26
- export declare enum PREPROCESSORS {
27
- /**
28
- * This preprocessor scrubs `body` and `content` from media messages.
29
- * This would be useful if you want to reduce the message object size because neither of these values represent the actual file, only the thumbnail.
30
- */
31
- SCRUB = "SCRUB",
32
- /**
33
- * A preprocessor that limits the amount of base64 data is present in the message object by removing duplication of `body` in `content` by replacing `content` with `""`.
34
- */
35
- BODY_ONLY = "BODY_ONLY",
36
- /**
37
- * Replaces the media thumbnail base64 in `body` with the actual file's DataURL.
38
- */
39
- AUTO_DECRYPT = "AUTO_DECRYPT",
40
- /**
41
- * Automatically saves the file in a folder named `/media` relative to the process working directory.
42
- *
43
- * PLEASE NOTE, YOU WILL NEED TO MANUALLY CLEAR THIS FOLDER!!!
44
- */
45
- AUTO_DECRYPT_SAVE = "AUTO_DECRYPT_SAVE",
46
- /**
47
- *
48
- * Uploads file to a cloud storage provider (GCP/AWS for now).
49
- *
50
- * If this preprocessor is set then you have to also set [`cloudUploadOptions`](https://docs.openwa.dev/docs/reference/api/model/config/interfaces/ConfigObject#clouduploadoptions) in the config.
51
- *
52
- */
53
- UPLOAD_CLOUD = "UPLOAD_CLOUD"
54
- }
55
- /**
56
- * The actual type for [config.messagePreprocessor](/docs/api/interfaces/api_model_config.ConfigObject#messagepreprocessor)
57
- */
58
- export type MPConfigType = PREPROCESSORS | MessagePreProcessor | (PREPROCESSORS | MessagePreProcessor)[];
@@ -1,181 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.PREPROCESSORS = exports.MessagePreprocessors = void 0;
16
- const mime_1 = __importDefault(require("mime"));
17
- const fs_extra_1 = require("fs-extra");
18
- const config_1 = require("../api/model/config");
19
- const p_queue_1 = __importDefault(require("p-queue"));
20
- const pico_s3_1 = require("pico-s3");
21
- const processedFiles = {};
22
- let uploadQueue;
23
- const SCRUB = (message) => __awaiter(void 0, void 0, void 0, function* () {
24
- if (message.deprecatedMms3Url && message.mimetype)
25
- return Object.assign(Object.assign({}, message), { content: "", body: "" });
26
- return message;
27
- });
28
- const BODY_ONLY = (message) => __awaiter(void 0, void 0, void 0, function* () {
29
- if (message.deprecatedMms3Url && message.mimetype)
30
- return Object.assign(Object.assign({}, message), { content: "" });
31
- return message;
32
- });
33
- const AUTO_DECRYPT = (message, client) => __awaiter(void 0, void 0, void 0, function* () {
34
- if (message.deprecatedMms3Url && message.mimetype)
35
- return Object.assign(Object.assign({}, message), { body: yield client.decryptMedia(message) });
36
- return message;
37
- });
38
- const AUTO_DECRYPT_SAVE = (message, client, alreadyBeingProcessed) => __awaiter(void 0, void 0, void 0, function* () {
39
- if (message.deprecatedMms3Url && message.mimetype) {
40
- const filename = `${message.mId}.${mime_1.default.getExtension(message.mimetype)}`;
41
- const filePath = `media/${filename}`;
42
- if (alreadyBeingProcessed) {
43
- return Object.assign(Object.assign({}, message), { body: filename, content: "", filePath });
44
- }
45
- try {
46
- const mediaData = yield client.decryptMedia(message);
47
- (0, fs_extra_1.outputFileSync)(filePath, Buffer.from(mediaData.split(",")[1], "base64"));
48
- }
49
- catch (error) {
50
- console.error(error);
51
- return message;
52
- }
53
- return Object.assign(Object.assign({}, message), { body: filename, content: "", filePath });
54
- }
55
- return message;
56
- });
57
- const UPLOAD_CLOUD = (message, client, alreadyBeingProcessed) => __awaiter(void 0, void 0, void 0, function* () {
58
- if ((message === null || message === void 0 ? void 0 : message.deprecatedMms3Url) && message.mimetype) {
59
- const { cloudUploadOptions } = client.getConfig();
60
- if (message.fromMe && (cloudUploadOptions.ignoreHostAccount || process.env.OW_CLOUD_IGNORE_HOST))
61
- return message;
62
- if (!uploadQueue) {
63
- uploadQueue = new p_queue_1.default({ concurrency: 2, interval: 1000, carryoverConcurrencyCount: true, intervalCap: 2 });
64
- }
65
- const filename = `${message.mId || `${Date.now()}`}.${mime_1.default.getExtension(message.mimetype)}`;
66
- const mediaData = yield client.decryptMedia(message);
67
- if (!cloudUploadOptions)
68
- return message;
69
- const provider = (process.env.OW_CLOUD_PROVIDER || cloudUploadOptions.provider);
70
- const opts = {
71
- file: mediaData,
72
- filename,
73
- provider,
74
- accessKeyId: process.env.OW_CLOUD_ACCESS_KEY_ID || cloudUploadOptions.accessKeyId,
75
- secretAccessKey: process.env.OW_CLOUD_SECRET_ACCESS_KEY || cloudUploadOptions.secretAccessKey,
76
- bucket: process.env.OW_CLOUD_BUCKET || cloudUploadOptions.bucket,
77
- region: process.env.OW_CLOUD_REGION || cloudUploadOptions.region,
78
- public: process.env.OW_CLOUD_PUBLIC && true || cloudUploadOptions.public,
79
- headers: cloudUploadOptions.headers,
80
- };
81
- const dirStrat = process.env.OW_DIRECTORY || cloudUploadOptions.directory;
82
- if (dirStrat) {
83
- let directory = '';
84
- switch (dirStrat) {
85
- case config_1.DIRECTORY_STRATEGY.DATE:
86
- directory = `${new Date().toISOString().slice(0, 10)}`;
87
- break;
88
- case config_1.DIRECTORY_STRATEGY.CHAT:
89
- directory = `${message.from.replace("@c.us", "").replace("@g.us", "")}`;
90
- break;
91
- case config_1.DIRECTORY_STRATEGY.DATE_CHAT:
92
- directory = `${new Date().toISOString().slice(0, 10)}/${message.from.replace("@c.us", "").replace("@g.us", "")}`;
93
- break;
94
- case config_1.DIRECTORY_STRATEGY.CHAT_DATE:
95
- directory = `${message.from.replace("@c.us", "").replace("@g.us", "")}/${new Date().toISOString().slice(0, 10)}`;
96
- break;
97
- default:
98
- directory = dirStrat;
99
- break;
100
- }
101
- opts.directory = directory;
102
- }
103
- if (!opts.accessKeyId) {
104
- console.error("UPLOAD ERROR: No accessKeyId provided. If you're using the CLI, set env var OW_CLOUD_ACCESS_KEY_ID");
105
- return message;
106
- }
107
- if (!opts.secretAccessKey) {
108
- console.error("UPLOAD ERROR: No secretAccessKey provided. If you're using the CLI, set env var OW_CLOUD_SECRET_ACCESS_KEY");
109
- return message;
110
- }
111
- if (!opts.bucket) {
112
- console.error("UPLOAD ERROR: No bucket provided. If you're using the CLI, set env var OW_CLOUD_BUCKET");
113
- return message;
114
- }
115
- if (!opts.provider) {
116
- console.error("UPLOAD ERROR: No provider provided. If you're using the CLI, set env var OW_CLOUD_PROVIDER");
117
- return message;
118
- }
119
- const url = (0, pico_s3_1.getCloudUrl)(opts);
120
- if (!processedFiles[filename] && !alreadyBeingProcessed) {
121
- processedFiles[filename] = true;
122
- try {
123
- yield uploadQueue.add(() => (0, pico_s3_1.upload)(opts).catch(() => { }));
124
- }
125
- catch (error) {
126
- console.error(error);
127
- return message;
128
- }
129
- }
130
- return Object.assign(Object.assign({}, message), { cloudUrl: url });
131
- }
132
- return message;
133
- });
134
- /**
135
- * An object that contains all available [[PREPROCESSORS]].
136
- *
137
- * [Check out the processor code here](https://github.com/open-wa/wa-automate-nodejs/blob/master/src/structures/preProcessors.ts)
138
- */
139
- exports.MessagePreprocessors = {
140
- AUTO_DECRYPT_SAVE,
141
- AUTO_DECRYPT,
142
- BODY_ONLY,
143
- SCRUB,
144
- UPLOAD_CLOUD
145
- };
146
- /**
147
- * A set of easy to use, built-in message processors.
148
- *
149
- * [Check out the processor code here](https://github.com/open-wa/wa-automate-nodejs/blob/master/src/structures/preProcessors.ts)
150
- *
151
- */
152
- var PREPROCESSORS;
153
- (function (PREPROCESSORS) {
154
- /**
155
- * This preprocessor scrubs `body` and `content` from media messages.
156
- * This would be useful if you want to reduce the message object size because neither of these values represent the actual file, only the thumbnail.
157
- */
158
- PREPROCESSORS["SCRUB"] = "SCRUB";
159
- /**
160
- * A preprocessor that limits the amount of base64 data is present in the message object by removing duplication of `body` in `content` by replacing `content` with `""`.
161
- */
162
- PREPROCESSORS["BODY_ONLY"] = "BODY_ONLY";
163
- /**
164
- * Replaces the media thumbnail base64 in `body` with the actual file's DataURL.
165
- */
166
- PREPROCESSORS["AUTO_DECRYPT"] = "AUTO_DECRYPT";
167
- /**
168
- * Automatically saves the file in a folder named `/media` relative to the process working directory.
169
- *
170
- * PLEASE NOTE, YOU WILL NEED TO MANUALLY CLEAR THIS FOLDER!!!
171
- */
172
- PREPROCESSORS["AUTO_DECRYPT_SAVE"] = "AUTO_DECRYPT_SAVE";
173
- /**
174
- *
175
- * Uploads file to a cloud storage provider (GCP/AWS for now).
176
- *
177
- * If this preprocessor is set then you have to also set [`cloudUploadOptions`](https://docs.openwa.dev/docs/reference/api/model/config/interfaces/ConfigObject#clouduploadoptions) in the config.
178
- *
179
- */
180
- PREPROCESSORS["UPLOAD_CLOUD"] = "UPLOAD_CLOUD";
181
- })(PREPROCESSORS = exports.PREPROCESSORS || (exports.PREPROCESSORS = {}));
@@ -1 +0,0 @@
1
- export declare const pidTreeUsage: (pid: any) => Promise<any>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.pidTreeUsage = void 0;
16
- const pidtree_1 = __importDefault(require("pidtree"));
17
- const pidusage_1 = __importDefault(require("pidusage"));
18
- const pidTreeUsage = (pid) => __awaiter(void 0, void 0, void 0, function* () {
19
- if (!Array.isArray(pid)) {
20
- pid = [pid];
21
- }
22
- const pids = (yield Promise.all(pid.map(pidtree_1.default))).flat();
23
- const stats = yield (0, pidusage_1.default)(pids);
24
- return stats;
25
- });
26
- exports.pidTreeUsage = pidTreeUsage;
@@ -1,152 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { AdvancedFile, ConfigObject, DataURL } from '../api/model';
5
- import { AxiosRequestConfig } from 'axios';
6
- import { SessionInfo } from '../api/model/sessionInfo';
7
- import { Readable } from "stream";
8
- export declare const timeout: (ms: any) => Promise<unknown>;
9
- /**
10
- * Use this to generate a more likely valid user agent. It makes sure it has the WA part and replaces any windows or linux os info with mac.
11
- * @param useragent Your custom user agent
12
- * @param v The WA version from the debug info. This is optional. default is 2.2117.5
13
- */
14
- export declare const smartUserAgent: (ua: string, version?: string) => string;
15
- export declare const getConfigFromProcessEnv: any;
16
- /**
17
- * Remove the key from the object and return the rest of the object.
18
- * @param {JsonObject} obj - The object to be filtered.
19
- * @param {string} key - The key to discard.
20
- * @returns The object without the key.
21
- */
22
- export declare const without: any;
23
- export declare const camelize: (str: string) => string;
24
- /**
25
- * Check if a string is Base64
26
- * @param str string
27
- * @returns
28
- */
29
- export declare const isBase64: (str: string) => boolean;
30
- /**
31
- * Check if a string is a DataURL
32
- * @param s string
33
- * @returns
34
- */
35
- export declare const isDataURL: (s: string) => boolean;
36
- /**
37
- * @internal
38
- * A convinience method to download the buffer of a downloaded file
39
- * @param url The url
40
- * @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
41
- */
42
- export declare const getBufferFromUrl: (url: string, optionsOverride?: any) => Promise<[Buffer, any]>;
43
- /**
44
- * @internal
45
- * A convinience method to download the [[DataURL]] of a file
46
- * @param url The url
47
- * @param optionsOverride You can use this to override the [axios request config](https://github.com/axios/axios#request-config)
48
- */
49
- export declare const getDUrl: (url: string, optionsOverride?: AxiosRequestConfig) => Promise<DataURL>;
50
- /**
51
- * @internal
52
- * Use this to extract the mime type from a [[DataURL]]
53
- */
54
- export declare const base64MimeType: (dUrl: DataURL) => string;
55
- /**
56
- * If process.send is defined, send the message three times
57
- * @param {string} message - The message to send to the parent process.
58
- * @returns Nothing.
59
- */
60
- export declare const processSend: (message: string) => void;
61
- /**
62
- * Return the performance object if it is available, otherwise return the Date object
63
- */
64
- export declare const perf: () => DateConstructor | import("perf_hooks").Performance;
65
- /**
66
- * Return the current time in milliseconds
67
- */
68
- export declare const now: () => number;
69
- /**
70
- * `timePromise` returns a promise that resolves to the time it took to run the function passed to it
71
- * @param fn - the function to be timed.
72
- * @returns A string.
73
- */
74
- export declare function timePromise(fn: () => Promise<any>): Promise<string>;
75
- /**
76
- * It sends a message to the parent process.
77
- * @param {any} data - The data to be sent to the parent process.
78
- * @returns Nothing.
79
- */
80
- export declare const processSendData: (data?: any) => boolean;
81
- /**
82
- * It generates a link to the GitHub issue template for the current session
83
- * @param {ConfigObject} config - the config object
84
- * @param {SessionInfo} sessionInfo - The sessionInfo object from the CLI
85
- * @param {any} extras - any
86
- * @returns A link to the issue tracker for the current session.
87
- */
88
- export declare const generateGHIssueLink: (config: ConfigObject, sessionInfo: SessionInfo, extras?: any) => string;
89
- /**
90
- * If the file is a DataURL, return it. If it's a file, convert it to a DataURL. If it's a URL,
91
- * download it and convert it to a DataURL. If Base64, returns it.
92
- * @param {string} file - The file to be converted to a DataURL.
93
- * @param {AxiosRequestConfig} requestConfig - AxiosRequestConfig = {}
94
- * @param {string} filename - Filename with an extension so a datauri mimetype can be inferred.
95
- * @returns A DataURL
96
- */
97
- export declare const ensureDUrl: (file: string | Buffer, requestConfig?: AxiosRequestConfig, filename?: string) => Promise<string>;
98
- export declare const FileInputTypes: {
99
- VALIDATED_FILE_PATH: string;
100
- URL: string;
101
- DATA_URL: string;
102
- BASE_64: string;
103
- BUFFER: string;
104
- READ_STREAM: string;
105
- };
106
- export declare const FileOutputTypes: {
107
- TEMP_FILE_PATH: string;
108
- VALIDATED_FILE_PATH: string;
109
- URL: string;
110
- DATA_URL: string;
111
- BASE_64: string;
112
- BUFFER: string;
113
- READ_STREAM: string;
114
- };
115
- /**
116
- * Remove file asynchronously
117
- * @param file Filepath
118
- * @returns
119
- */
120
- export declare function rmFileAsync(file: string): Promise<unknown>;
121
- /**
122
- * Takes a file parameter and consistently returns the desired type of file.
123
- * @param file The file path, URL, base64 or DataURL string of the file
124
- * @param outfileName The ouput filename of the file
125
- * @param desiredOutputType The type of file output required from this function
126
- * @param requestConfig optional axios config if file parameter is a url
127
- */
128
- export declare const assertFile: (file: AdvancedFile | Buffer, outfileName: string, desiredOutputType: keyof typeof FileOutputTypes, requestConfig?: any) => Promise<string | Buffer | Readable>;
129
- /**
130
- * Checks if a given path exists.
131
- *
132
- * If exists, returns the resolved absolute path. Otherwise returns false.
133
- *
134
- * @param _path a relative, absolute or homedir path to a folder or a file
135
- * @param failSilent If you're expecting for the file to not exist and just want the `false` response then set this to true to prevent false-positive error messages in the logs.
136
- * @returns string | false
137
- */
138
- export declare const pathExists: (_path: string, failSilent?: boolean) => Promise<string | false>;
139
- /**
140
- * Returns an absolute file path reference
141
- * @param _path a relative, absolute or homedir path to a folder or a file
142
- * @returns string
143
- */
144
- export declare const fixPath: (_path: string) => string;
145
- /**
146
- *
147
- * Accented filenames break file sending in docker containers. This is used to replace accented chars in strings to prevent file sending failures.
148
- *
149
- * @param input The raw string
150
- * @returns A sanitized string with all accented chars removed
151
- */
152
- export declare const sanitizeAccentedChars: (input: string) => string;