deltachat-jsonrpc: fix "prettier" arguments

**.ts finds .ts files only in the current directory and no *.js files.
This commit is contained in:
link2xt
2023-02-14 20:02:09 +00:00
parent 05f0fe0a88
commit d3e2f38da0
7 changed files with 40 additions and 35 deletions

View File

@@ -68,10 +68,7 @@ async function run() {
null null
); );
for (const [chatId, _messageId] of chats) { for (const [chatId, _messageId] of chats) {
const chat = await client.rpc.getFullChatById( const chat = await client.rpc.getFullChatById(selectedAccount, chatId);
selectedAccount,
chatId
);
write($main, `<h3>${chat.name}</h3>`); write($main, `<h3>${chat.name}</h3>`);
const messageIds = await client.rpc.getMessageIds( const messageIds = await client.rpc.getMessageIds(
selectedAccount, selectedAccount,

View File

@@ -3,24 +3,27 @@ import { DeltaChat } from "../dist/deltachat.js";
run().catch(console.error); run().catch(console.error);
async function run() { async function run() {
const delta = new DeltaChat('ws://localhost:20808/ws'); const delta = new DeltaChat("ws://localhost:20808/ws");
delta.on("event", (event) => { delta.on("event", (event) => {
console.log("event", event.data); console.log("event", event.data);
}); });
const email = process.argv[2] const email = process.argv[2];
const password = process.argv[3] const password = process.argv[3];
if (!email || !password) throw new Error('USAGE: node node-add-account.js <EMAILADDRESS> <PASSWORD>') if (!email || !password)
console.log(`creating acccount for ${email}`) throw new Error(
const id = await delta.rpc.addAccount() "USAGE: node node-add-account.js <EMAILADDRESS> <PASSWORD>"
console.log(`created account id ${id}`) );
console.log(`creating acccount for ${email}`);
const id = await delta.rpc.addAccount();
console.log(`created account id ${id}`);
await delta.rpc.setConfig(id, "addr", email); await delta.rpc.setConfig(id, "addr", email);
await delta.rpc.setConfig(id, "mail_pw", password); await delta.rpc.setConfig(id, "mail_pw", password);
console.log('configuration updated') console.log("configuration updated");
await delta.rpc.configure(id) await delta.rpc.configure(id);
console.log('account configured!') console.log("account configured!");
const accounts = await delta.rpc.getAllAccounts(); const accounts = await delta.rpc.getAllAccounts();
console.log("accounts", accounts); console.log("accounts", accounts);
console.log("waiting for events...") console.log("waiting for events...");
} }

View File

@@ -10,5 +10,5 @@ async function run() {
const accounts = await delta.rpc.getAllAccounts(); const accounts = await delta.rpc.getAllAccounts();
console.log("accounts", accounts); console.log("accounts", accounts);
console.log("waiting for events...") console.log("waiting for events...");
} }

View File

@@ -38,8 +38,8 @@
"example:start": "http-server .", "example:start": "http-server .",
"extract-constants": "node ./scripts/generate-constants.js", "extract-constants": "node ./scripts/generate-constants.js",
"generate-bindings": "cargo test", "generate-bindings": "cargo test",
"prettier:check": "prettier --check **.ts", "prettier:check": "prettier --check .",
"prettier:fix": "prettier --write **.ts", "prettier:fix": "prettier --write .",
"test": "run-s test:prepare test:run-coverage test:report-coverage", "test": "run-s test:prepare test:run-coverage test:report-coverage",
"test:prepare": "cargo build --package deltachat-rpc-server --bin deltachat-rpc-server", "test:prepare": "cargo build --package deltachat-rpc-server --bin deltachat-rpc-server",
"test:report-coverage": "node report_api_coverage.mjs", "test:report-coverage": "node report_api_coverage.mjs",
@@ -49,4 +49,4 @@
"type": "module", "type": "module",
"types": "dist/deltachat.d.ts", "types": "dist/deltachat.d.ts",
"version": "1.108.0" "version": "1.108.0"
} }

View File

@@ -43,7 +43,7 @@ export class BaseDeltaChat<
const method = request.method; const method = request.method;
if (method === "event") { if (method === "event") {
const event = request.params! as DCWireEvent<Event>; const event = request.params! as DCWireEvent<Event>;
//@ts-ignore //@ts-ignore
this.emit(event.event.type, event.contextId, event.event as any); this.emit(event.event.type, event.contextId, event.event as any);
this.emit("ALL", event.contextId, event.event as any); this.emit("ALL", event.contextId, event.event as any);

View File

@@ -4,10 +4,7 @@ import chaiAsPromised from "chai-as-promised";
chai.use(chaiAsPromised); chai.use(chaiAsPromised);
import { StdioDeltaChat as DeltaChat } from "../deltachat.js"; import { StdioDeltaChat as DeltaChat } from "../deltachat.js";
import { import { RpcServerHandle, startServer } from "./test_base.js";
RpcServerHandle,
startServer,
} from "./test_base.js";
describe("basic tests", () => { describe("basic tests", () => {
let serverHandle: RpcServerHandle; let serverHandle: RpcServerHandle;
@@ -15,9 +12,9 @@ describe("basic tests", () => {
before(async () => { before(async () => {
serverHandle = await startServer(); serverHandle = await startServer();
dc = new DeltaChat(serverHandle.stdin, serverHandle.stdout) dc = new DeltaChat(serverHandle.stdin, serverHandle.stdout);
// dc.on("ALL", (event) => { // dc.on("ALL", (event) => {
//console.log("event", event); //console.log("event", event);
// }); // });
}); });
@@ -111,8 +108,8 @@ describe("basic tests", () => {
assert((await dc.rpc.getConfig(accountId, "addr")) == "valid@email"); assert((await dc.rpc.getConfig(accountId, "addr")) == "valid@email");
}); });
it("set invalid key should throw", async function () { it("set invalid key should throw", async function () {
await expect(dc.rpc.setConfig(accountId, "invalid_key", "some value")).to.be await expect(dc.rpc.setConfig(accountId, "invalid_key", "some value")).to
.eventually.rejected; .be.eventually.rejected;
}); });
it("get invalid key should throw", async function () { it("get invalid key should throw", async function () {
await expect(dc.rpc.getConfig(accountId, "invalid_key")).to.be.eventually await expect(dc.rpc.getConfig(accountId, "invalid_key")).to.be.eventually
@@ -125,7 +122,10 @@ describe("basic tests", () => {
it("set and retrive (batch)", async function () { it("set and retrive (batch)", async function () {
const config = { addr: "valid@email", mail_pw: "1234" }; const config = { addr: "valid@email", mail_pw: "1234" };
await dc.rpc.batchSetConfig(accountId, config); await dc.rpc.batchSetConfig(accountId, config);
const retrieved = await dc.rpc.batchGetConfig(accountId, Object.keys(config)); const retrieved = await dc.rpc.batchGetConfig(
accountId,
Object.keys(config)
);
expect(retrieved).to.deep.equal(config); expect(retrieved).to.deep.equal(config);
}); });
it("set and retrive ui.* (batch)", async function () { it("set and retrive ui.* (batch)", async function () {
@@ -134,7 +134,10 @@ describe("basic tests", () => {
"ui.enter_key_sends": "true", "ui.enter_key_sends": "true",
}; };
await dc.rpc.batchSetConfig(accountId, config); await dc.rpc.batchSetConfig(accountId, config);
const retrieved = await dc.rpc.batchGetConfig(accountId, Object.keys(config)); const retrieved = await dc.rpc.batchGetConfig(
accountId,
Object.keys(config)
);
expect(retrieved).to.deep.equal(config); expect(retrieved).to.deep.equal(config);
}); });
it("set and retrive mixed(ui and core) (batch)", async function () { it("set and retrive mixed(ui and core) (batch)", async function () {
@@ -145,7 +148,10 @@ describe("basic tests", () => {
mail_pw: "123456", mail_pw: "123456",
}; };
await dc.rpc.batchSetConfig(accountId, config); await dc.rpc.batchSetConfig(accountId, config);
const retrieved = await dc.rpc.batchGetConfig(accountId, Object.keys(config)); const retrieved = await dc.rpc.batchGetConfig(
accountId,
Object.keys(config)
);
expect(retrieved).to.deep.equal(config); expect(retrieved).to.deep.equal(config);
}); });
}); });

View File

@@ -59,13 +59,13 @@ export async function startServer(): Promise<RpcServerHandle> {
export async function createTempUser(url: string) { export async function createTempUser(url: string) {
const response = await fetch(url, { const response = await fetch(url, {
method: "POST", method: "POST",
headers: { headers: {
"cache-control": "no-cache", "cache-control": "no-cache",
}, },
}); });
if (!response.ok) throw new Error('Received invalid response') if (!response.ok) throw new Error("Received invalid response");
return response.json(); return response.json();
} }
function getTargetDir(): Promise<string> { function getTargetDir(): Promise<string> {
@@ -89,4 +89,3 @@ function getTargetDir(): Promise<string> {
); );
}); });
} }