@open-wa/cli 5.3.0 → 5.5.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.
package/dist/bin.cjs
CHANGED
|
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
//#endregion
|
|
24
|
-
const require_event_projection_store = require("./event-projection-store-
|
|
24
|
+
const require_event_projection_store = require("./event-projection-store-C-W1A_Mi.cjs");
|
|
25
25
|
let _open_wa_wa_automate = require("@open-wa/wa-automate");
|
|
26
26
|
let ws = require("ws");
|
|
27
27
|
ws = __toESM(ws, 1);
|
|
@@ -116,13 +116,20 @@ var TunnelClient = class {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
async handleRpcAsHttp(msg) {
|
|
119
|
-
const
|
|
119
|
+
const refreshControl = msg.method === "requestRefresh" || msg.method === "getRefreshStatus";
|
|
120
|
+
const localUrl = `http://localhost:${this.options.localSessionPort}${refreshControl ? "/api/session/refresh" : `/api/${msg.method}`}`;
|
|
120
121
|
try {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
const method = msg.method === "getRefreshStatus" ? "GET" : "POST";
|
|
123
|
+
const res = await fetch(localUrl, {
|
|
124
|
+
method,
|
|
125
|
+
headers: {
|
|
126
|
+
"Content-Type": "application/json",
|
|
127
|
+
...refreshControl && this.options.localApiKey ? { "X-API-Key": this.options.localApiKey } : {}
|
|
128
|
+
},
|
|
129
|
+
...method === "POST" ? { body: JSON.stringify(refreshControl ? msg.args ?? {} : { args: msg.args }) } : {}
|
|
130
|
+
});
|
|
131
|
+
const resData = await res.json();
|
|
132
|
+
if (refreshControl && !res.ok) throw new Error(resData.error || "Session controls are unavailable.");
|
|
126
133
|
const responseMsg = {
|
|
127
134
|
type: "rpc_response",
|
|
128
135
|
id: msg.id,
|
|
@@ -227,6 +234,16 @@ var InteractiveTerminalPresenter = class {
|
|
|
227
234
|
this.ink?.unmount();
|
|
228
235
|
this.ink = void 0;
|
|
229
236
|
}
|
|
237
|
+
async withPrompt(prompt) {
|
|
238
|
+
this.stop();
|
|
239
|
+
try {
|
|
240
|
+
return await prompt();
|
|
241
|
+
} finally {
|
|
242
|
+
this.started = false;
|
|
243
|
+
this.stopped = false;
|
|
244
|
+
await this.start();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
230
247
|
async handleSnapshot(snapshot) {
|
|
231
248
|
if (this.stopped) return;
|
|
232
249
|
this.snapshot = snapshot;
|
|
@@ -256,8 +273,11 @@ var InteractiveTerminalPresenter = class {
|
|
|
256
273
|
};
|
|
257
274
|
//#endregion
|
|
258
275
|
//#region src/runtime/interactive-session.ts
|
|
259
|
-
function createBrokeredSink(broker, store) {
|
|
276
|
+
function createBrokeredSink(broker, store, presenter) {
|
|
260
277
|
return {
|
|
278
|
+
promptChoice(question, choices) {
|
|
279
|
+
return presenter.withPrompt(() => (0, _open_wa_wa_automate.createConsoleOutputSink)().promptChoice(question, choices));
|
|
280
|
+
},
|
|
261
281
|
write(entry) {
|
|
262
282
|
broker.write(entry.level, entry.message);
|
|
263
283
|
},
|
|
@@ -295,7 +315,7 @@ async function createInteractiveCliSession() {
|
|
|
295
315
|
broker,
|
|
296
316
|
store,
|
|
297
317
|
presenter,
|
|
298
|
-
sink: createBrokeredSink(broker, store),
|
|
318
|
+
sink: createBrokeredSink(broker, store, presenter),
|
|
299
319
|
cleanup: (options = {}) => {
|
|
300
320
|
detachLogs();
|
|
301
321
|
presenter.stop({ clear: options.clearPresenter ?? true });
|
|
@@ -375,6 +395,7 @@ async function main() {
|
|
|
375
395
|
proxyToken: runtime.config.proxyToken,
|
|
376
396
|
sessionId: runtime.config.sessionId,
|
|
377
397
|
localSessionPort: runtime.config.port,
|
|
398
|
+
localApiKey: runtime.config.apiKey,
|
|
378
399
|
log
|
|
379
400
|
});
|
|
380
401
|
tunnelClient.connect();
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_event_projection_store = require("./event-projection-store-
|
|
2
|
+
const require_event_projection_store = require("./event-projection-store-C-W1A_Mi.cjs");
|
|
3
3
|
let _open_wa_wa_automate = require("@open-wa/wa-automate");
|
|
4
4
|
exports.CliShutdownError = require_event_projection_store.CliShutdownError;
|
|
5
5
|
exports.EventProjectionStore = require_event_projection_store.EventProjectionStore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-wa/cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "CLI for @open-wa WhatsApp automation - Easy API mode",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.cjs",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@open-wa/core": "5.
|
|
22
|
-
"@open-wa/hyperemitter": "5.
|
|
23
|
-
"@open-wa/wa-automate": "5.
|
|
21
|
+
"@open-wa/core": "5.5.0",
|
|
22
|
+
"@open-wa/hyperemitter": "5.5.0",
|
|
23
|
+
"@open-wa/wa-automate": "5.5.0",
|
|
24
24
|
"ink": "^7.1.1",
|
|
25
25
|
"qrcode": "^1.5.4",
|
|
26
26
|
"react": "^19.3.0",
|