chore: move proto into a separate package (#1057)

* chore: move proto into a separate package

* fix: proto dir

* fix: build

* fix: ci

* add: index for proto

* fix: ci

* Update packages/proto/package.json

Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com>

Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com>
This commit is contained in:
Danish Arora 2022-12-07 10:19:40 +05:30 committed by GitHub
parent 03e00225bd
commit 56009d3b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 231 additions and 36 deletions

90
package-lock.json generated
View File

@ -6,11 +6,12 @@
"": {
"name": "@waku/root",
"workspaces": [
"packages/proto",
"packages/byte-utils",
"packages/enr",
"packages/interfaces",
"packages/libp2p-utils",
"packages/core",
"packages/enr",
"packages/dns-discovery",
"packages/message-encryption",
"packages/create",
@ -3219,6 +3220,10 @@
"resolved": "packages/message-encryption",
"link": true
},
"node_modules/@waku/proto": {
"resolved": "packages/proto",
"link": true
},
"node_modules/@waku/tests": {
"resolved": "packages/tests",
"link": true
@ -5347,9 +5352,9 @@
}
},
"node_modules/engine.io": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.2.0.tgz",
"integrity": "sha512-4KzwW3F3bk+KlzSOY57fj/Jx6LyRQ1nbcyIadehl+AnXjKT7gDO0ORdRi/84ixvMKTym6ZKuxvbzN62HDDU1Lg==",
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.2.1.tgz",
"integrity": "sha512-ECceEFcAaNRybd3lsGQKas3ZlMVjN3cyWwMP25D2i0zWfyiytVbTpRPa34qrr+FHddtpBVOmq4H/DCv1O0lZRA==",
"dev": true,
"dependencies": {
"@types/cookie": "^0.4.1",
@ -17232,7 +17237,6 @@
"it-pipe": "^2.0.4",
"libp2p": "0.40.0",
"p-event": "^5.0.1",
"protons-runtime": "^3.1.0",
"uint8arraylist": "^2.3.2",
"uint8arrays": "^4.0.2",
"uuid": "^9.0.0"
@ -17275,7 +17279,6 @@
"portfinder": "^1.0.28",
"prettier": "^2.1.1",
"process": "^0.11.10",
"protons": "^5.1.0",
"puppeteer": "^13.0.1",
"rollup": "^2.75.0",
"tail": "^2.2.0",
@ -17466,6 +17469,14 @@
"name": "@waku/libp2p-utils",
"version": "0.0.2",
"license": "MIT OR Apache-2.0",
"dependencies": {
"@libp2p/interface-connection": "^3.0.3",
"@libp2p/interface-peer-id": "^1.0.6",
"@libp2p/interface-peer-info": "^1.0.1",
"@libp2p/interface-peer-store": "^1.2.3",
"@libp2p/peer-id": "^1.1.10",
"@multiformats/multiaddr": "^11.0.6"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
@ -17524,6 +17535,36 @@
"node": ">=16"
}
},
"packages/proto": {
"name": "@waku/proto",
"version": "0.0.1",
"license": "MIT OR Apache-2.0",
"dependencies": {
"protons-runtime": "^3.1.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"cspell": "^5.14.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^4.0.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"protons": "^5.1.0",
"rollup": "^2.75.0",
"typescript": "^4.6.3"
},
"engines": {
"node": ">=16"
}
},
"packages/tests": {
"name": "@waku/tests",
"version": "0.0.1",
@ -20162,8 +20203,6 @@
"portfinder": "^1.0.28",
"prettier": "^2.1.1",
"process": "^0.11.10",
"protons": "^5.1.0",
"protons-runtime": "^3.1.0",
"puppeteer": "^13.0.1",
"rollup": "^2.75.0",
"tail": "^2.2.0",
@ -20316,6 +20355,12 @@
"@waku/libp2p-utils": {
"version": "file:packages/libp2p-utils",
"requires": {
"@libp2p/interface-connection": "^3.0.3",
"@libp2p/interface-peer-id": "^1.0.6",
"@libp2p/interface-peer-info": "^1.0.1",
"@libp2p/interface-peer-store": "^1.2.3",
"@libp2p/peer-id": "^1.1.10",
"@multiformats/multiaddr": "^11.0.6",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
@ -20363,6 +20408,29 @@
"typescript": "^4.6.3"
}
},
"@waku/proto": {
"version": "file:packages/proto",
"requires": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"cspell": "^5.14.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^4.0.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"protons": "^5.1.0",
"protons-runtime": "^3.1.0",
"rollup": "^2.75.0",
"typescript": "^4.6.3"
}
},
"@waku/tests": {
"version": "file:packages/tests",
"requires": {
@ -22054,9 +22122,9 @@
}
},
"engine.io": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.2.0.tgz",
"integrity": "sha512-4KzwW3F3bk+KlzSOY57fj/Jx6LyRQ1nbcyIadehl+AnXjKT7gDO0ORdRi/84ixvMKTym6ZKuxvbzN62HDDU1Lg==",
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.2.1.tgz",
"integrity": "sha512-ECceEFcAaNRybd3lsGQKas3ZlMVjN3cyWwMP25D2i0zWfyiytVbTpRPa34qrr+FHddtpBVOmq4H/DCv1O0lZRA==",
"dev": true,
"requires": {
"@types/cookie": "^0.4.1",

View File

@ -3,11 +3,12 @@
"private": true,
"type": "module",
"workspaces": [
"packages/proto",
"packages/byte-utils",
"packages/enr",
"packages/interfaces",
"packages/libp2p-utils",
"packages/core",
"packages/enr",
"packages/dns-discovery",
"packages/message-encryption",
"packages/create",

View File

@ -67,7 +67,6 @@
"test": "run-s test:*",
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
"test:browser": "karma start karma.conf.cjs",
"proto": "rimraf src/proto/*.ts; protons src/proto/*.proto",
"watch:build": "tsc -p tsconfig.json -w",
"watch:test": "mocha --watch",
"prepublish": "npm run build",
@ -97,7 +96,6 @@
"it-pipe": "^2.0.4",
"libp2p": "0.40.0",
"p-event": "^5.0.1",
"protons-runtime": "^3.1.0",
"uint8arraylist": "^2.3.2",
"uint8arrays": "^4.0.2",
"uuid": "^9.0.0"
@ -140,7 +138,6 @@
"portfinder": "^1.0.28",
"prettier": "^2.1.1",
"process": "^0.11.10",
"protons": "^5.1.0",
"puppeteer": "^13.0.1",
"rollup": "^2.75.0",
"tail": "^2.2.0",
@ -164,7 +161,6 @@
"bundle",
"src/*.ts",
"src/lib/**/*.ts",
"src/proto/**/*.ts",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",

View File

@ -1,9 +1,6 @@
export { DefaultPubSubTopic } from "./lib/constants.js";
export { DefaultUserAgent } from "./lib/waku.js";
export * as proto_message from "./proto/message.js";
export * as proto_topic_only_message from "./proto/topic_only_message.js";
export {
createEncoder,
createDecoder,

View File

@ -1,7 +1,6 @@
import { WakuMessage as WakuMessageProto } from "@waku/proto";
import { expect } from "chai";
import { WakuMessage as WakuMessageProto } from "../proto/message.js";
import { toProtoMessage } from "./to_proto_message.js";
describe("to proto message", () => {

View File

@ -1,6 +1,5 @@
import { ProtoMessage } from "@waku/interfaces";
import { WakuMessage as WakuMessageProto } from "../proto/message.js";
import { WakuMessage as WakuMessageProto } from "@waku/proto";
const EmptyMessage: ProtoMessage = {
payload: undefined,

View File

@ -1,7 +1,6 @@
import { proto_filter as proto } from "@waku/proto";
import { v4 as uuid } from "uuid";
import * as proto from "../../proto/filter.js";
export type ContentFilter = {
contentTopic: string;
};

View File

@ -19,12 +19,12 @@ import {
selectPeerForProtocol,
selectRandomPeer,
} from "@waku/libp2p-utils";
import { WakuMessage as WakuMessageProto } from "@waku/proto";
import debug from "debug";
import all from "it-all";
import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe";
import { WakuMessage as WakuMessageProto } from "../../proto/message.js";
import { DefaultPubSubTopic } from "../constants.js";
import { groupByContentTopic } from "../group_by.js";
import { toProtoMessage } from "../to_proto_message.js";

View File

@ -15,13 +15,13 @@ import {
selectPeerForProtocol,
selectRandomPeer,
} from "@waku/libp2p-utils";
import { PushResponse } from "@waku/proto";
import debug from "debug";
import all from "it-all";
import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe";
import { Uint8ArrayList } from "uint8arraylist";
import { PushResponse } from "../../proto/light_push.js";
import { DefaultPubSubTopic } from "../constants.js";
import { PushRPC } from "./push_rpc.js";

View File

@ -1,8 +1,7 @@
import { proto_lightpush as proto } from "@waku/proto";
import type { Uint8ArrayList } from "uint8arraylist";
import { v4 as uuid } from "uuid";
import * as proto from "../../proto/light_push.js";
export class PushRPC {
public constructor(public proto: proto.PushRPC) {}

View File

@ -1,8 +1,7 @@
import type { DecodedMessage, Decoder, ProtoMessage } from "@waku/interfaces";
import { proto_topic_only_message as proto } from "@waku/proto";
import debug from "debug";
import * as proto from "../../proto/topic_only_message.js";
const log = debug("waku:message:topic-only");
export class TopicOnlyMessage implements DecodedMessage {

View File

@ -6,10 +6,9 @@ import type {
ProtoMessage,
RateLimitProof,
} from "@waku/interfaces";
import { proto_message as proto } from "@waku/proto";
import debug from "debug";
import * as proto from "../../proto/message.js";
const log = debug("waku:message:version-0");
const OneMillion = BigInt(1_000_000);

View File

@ -1,8 +1,7 @@
import { proto_store as proto } from "@waku/proto";
import type { Uint8ArrayList } from "uint8arraylist";
import { v4 as uuid } from "uuid";
import * as proto from "../../proto/store.js";
const OneMillion = BigInt(1_000_000);
export enum PageDirection {

View File

@ -16,13 +16,13 @@ import {
selectConnection,
selectPeerForProtocol,
} from "@waku/libp2p-utils";
import { proto_store as proto } from "@waku/proto";
import debug from "debug";
import all from "it-all";
import * as lp from "it-length-prefixed";
import { pipe } from "it-pipe";
import { Uint8ArrayList } from "uint8arraylist";
import * as proto from "../../proto/store.js";
import { DefaultPubSubTopic } from "../constants.js";
import { toProtoMessage } from "../to_proto_message.js";

View File

@ -0,0 +1,6 @@
module.exports = {
parserOptions: {
tsconfigRootDir: __dirname,
project: "./tsconfig.dev.json",
},
};

View File

@ -0,0 +1,4 @@
build
bundle
dist
node_modules

View File

@ -0,0 +1,85 @@
{
"name": "@waku/proto",
"version": "0.0.1",
"description": "Protobuf definitions for Waku",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"type": "module",
"author": "Waku Team",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/proto#readme",
"repository": {
"type": "git",
"url": "https://github.com/waku-org/js-waku.git"
},
"bugs": {
"url": "https://github.com/waku-org/js-waku/issues"
},
"license": "MIT OR Apache-2.0",
"keywords": [
"waku",
"decentralized",
"secure",
"communication",
"web3",
"ethereum",
"dapps",
"privacy"
],
"scripts": {
"build": "run-s build:**",
"build:esm": "tsc",
"build:bundle": "rollup --config rollup.config.js",
"proto": "rimraf src/lib/*.ts; protons src/lib/*.proto",
"check:tsc": "tsc -p tsconfig.dev.json",
"prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
"fix": "run-s fix:*",
"fix:prettier": "prettier . --write",
"fix:lint": "eslint src/*.ts --fix"
},
"engines": {
"node": ">=16"
},
"dependencies": {
"protons-runtime": "^3.1.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"cspell": "^5.14.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-functional": "^4.0.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.1",
"rollup": "^2.75.0",
"typescript": "^4.6.3",
"protons": "^5.1.0"
},
"typedoc": {
"entryPoint": "./src/index.ts"
},
"files": [
"dist",
"bundle",
"src/*.ts",
"src/**/*.ts",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
"LICENSE",
"README.md"
]
}

View File

@ -0,0 +1,21 @@
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import { nodeResolve } from "@rollup/plugin-node-resolve";
export default {
input: {
index: "dist/index.js",
},
output: {
dir: "bundle",
format: "esm",
},
plugins: [
commonjs(),
json(),
nodeResolve({
browser: true,
preferBuiltins: false,
}),
],
};

View File

@ -0,0 +1,11 @@
export * as proto_message from "./lib/message.js";
export { WakuMessage } from "./lib/filter.js";
export * as proto_topic_only_message from "./lib/topic_only_message.js";
export * as proto_filter from "./lib/filter.js";
export * as proto_lightpush from "./lib/light_push.js";
export { PushResponse } from "./lib/light_push.js";
export * as proto_store from "./lib/store.js";

View File

@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.dev"
}

View File

@ -0,0 +1,10 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "dist/",
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo"
},
"include": ["src"],
"exclude": ["src/**/*.spec.ts", "src/test_utils"]
}