Skip to content

Commit

Permalink
Merge #892 #893
Browse files Browse the repository at this point in the history
892: fix: type export via `typesVersions` r=fryorcraken a=filoozom

## Problem

Importing anything from TypeScript in `js-waku/lib/` (`v0.25.0-rc.0`) does not work. It can't find the types despite the `exports.*.types` in `package.json`.

## Solution

This solution was inspired by `libp2p` ([example in ``@libp2p/interfaces`](https://github.com/libp2p/js-libp2p-interfaces/blob/master/packages/interfaces/package.json#L24-L39)),` and just adds `typesVersions` to `package.json`.

Documentation: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#folder-redirects-using-

## Notes

- See #891 (comment)


893: fix: do not throw on lack of response r=fryorcraken a=fryorcraken

Expected proto3 behaviour, just no message returned.

Co-authored-by: Philippe Schommers <philippe@schommers.be>
Co-authored-by: fryorcraken.eth <git@fryorcraken.xyz>
  • Loading branch information
3 people committed Aug 17, 2022
3 parents 28cb144 + 2a8d82b + 28f77ec commit e5368ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
"import": "./dist/lib/peer_discovery_dns/index.js"
}
},
"typesVersions": {
"*": {
"lib/*": [
"dist/lib/*"
]
}
},
"type": "module",
"repository": "https://github.com/status-im/js-waku",
"license": "MIT OR Apache-2.0",
Expand Down
8 changes: 4 additions & 4 deletions src/lib/waku_store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export class WakuStore {
const reply = historyRpcQuery.decode(bytes);

if (!reply.response) {
throw "History response misses response field";
dbg("No message returned from store: `response` field missing");
}

const response = reply.response as protoV2Beta4.HistoryResponse;
Expand All @@ -227,7 +227,7 @@ export class WakuStore {

if (!response.messages || !response.messages.length) {
// No messages left (or stored)
console.log("No messages present in HistoryRPC response");
dbg("No message returned from store: `messages` array empty");
return messages;
}

Expand Down Expand Up @@ -265,8 +265,8 @@ export class WakuStore {
cursor = response.pagingInfo?.cursor;
if (cursor === undefined) {
// If the server does not return cursor then there is an issue,
// Need to abort or we end up in an infinite loop
console.log("No cursor returned by peer.");
// Need to abort, or we end up in an infinite loop
dbg("Store response does not contain a cursor, stopping pagination");
return messages;
}
}
Expand Down

0 comments on commit e5368ec

Please sign in to comment.