chore: new @waku/interfaces package

This commit is contained in:
fryorcraken.eth 2022-11-01 14:48:52 +11:00
parent 8a84cd07b3
commit 16eaa911a9
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
15 changed files with 329 additions and 43 deletions

65
package-lock.json generated
View File

@ -5279,6 +5279,10 @@
"resolved": "packages/create",
"link": true
},
"node_modules/@waku/interfaces": {
"resolved": "packages/interfaces",
"link": true
},
"node_modules/@webassemblyjs/ast": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz",
@ -22391,6 +22395,7 @@
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"@waku/create": "*",
"app-root-path": "^3.0.0",
"chai": "^4.3.4",
"cspell": "^5.14.0",
@ -22488,6 +22493,7 @@
"@semantic-release/release-notes-generator": "^10.0.3",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"@waku/interfaces": "*",
"cspell": "^5.14.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
@ -22506,6 +22512,37 @@
"engines": {
"node": ">=16"
}
},
"packages/interfaces": {
"name": "@waku/interfaces",
"version": "0.0.1",
"license": "MIT OR Apache-2.0",
"devDependencies": {
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.6",
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@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",
"semantic-release": "^19.0.5",
"semantic-release-monorepo": "^7.0.5",
"typedoc": "^0.23.10",
"typescript": "^4.6.3"
},
"engines": {
"node": ">=16"
}
}
},
"dependencies": {
@ -26745,6 +26782,7 @@
"@types/uuid": "^8.3.0",
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"@waku/create": "*",
"app-root-path": "^3.0.0",
"chai": "^4.3.4",
"cspell": "^5.14.0",
@ -26840,6 +26878,7 @@
"@typescript-eslint/eslint-plugin": "^5.8.1",
"@typescript-eslint/parser": "^5.8.1",
"@waku/core": "*",
"@waku/interfaces": "*",
"cspell": "^5.14.0",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
@ -26856,6 +26895,32 @@
"typescript": "^4.6.3"
}
},
"@waku/interfaces": {
"version": "file:packages/interfaces",
"requires": {
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.6",
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@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",
"semantic-release": "^19.0.5",
"semantic-release-monorepo": "^7.0.5",
"typedoc": "^0.23.10",
"typescript": "^4.6.3"
}
},
"@webassemblyjs/ast": {
"version": "1.11.1",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz",

View File

@ -135,6 +135,8 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@waku/create": "*",
"@waku/interfaces": "*",
"@libp2p/peer-id-factory": "^1.0.15",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",

View File

@ -1,15 +1,15 @@
import { createLightNode } from "@waku/create";
import { expect } from "chai";
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../../test_utils";
import { createWaku } from "../create_waku";
import type { Waku } from "../interfaces";
import type { WakuLight } from "../interfaces";
import { waitForRemotePeer } from "../wait_for_remote_peer";
import { Protocols } from "../waku";
import { ENR } from "./enr";
describe("ENR Interop: nwaku", function () {
let waku: Waku;
let waku: WakuLight;
let nwaku: Nwaku;
afterEach(async function () {
@ -28,7 +28,7 @@ describe("ENR Interop: nwaku", function () {
});
const multiAddrWithId = await nwaku.getMultiaddrWithId();
waku = await createWaku({
waku = await createLightNode({
staticNoiseKey: NOISE_KEY_1,
});
await waku.start();
@ -60,7 +60,7 @@ describe("ENR Interop: nwaku", function () {
});
const multiAddrWithId = await nwaku.getMultiaddrWithId();
waku = await createWaku({
waku = await createLightNode({
staticNoiseKey: NOISE_KEY_1,
});
await waku.start();

View File

@ -1,9 +1,9 @@
import { createLightNode, createPrivacyNode } from "@waku/create";
import { expect } from "chai";
import { makeLogFileName, NOISE_KEY_1, Nwaku } from "../test_utils";
import { delay } from "../test_utils/delay";
import { createLightNode, createPrivacyNode } from "./create_waku";
import type { WakuLight, WakuPrivacy } from "./interfaces";
import { waitForRemotePeer } from "./wait_for_remote_peer";
import { Protocols } from "./waku";

View File

@ -1,4 +1,5 @@
import type { PeerId } from "@libp2p/interface-peer-id";
import { createLightNode, createPrivacyNode } from "@waku/create";
import { expect } from "chai";
import {
@ -8,7 +9,6 @@ import {
Nwaku,
} from "../test_utils/";
import { createLightNode, createPrivacyNode } from "./create_waku";
import { generateSymmetricKey } from "./crypto";
import type { Message, Waku, WakuLight, WakuPrivacy } from "./interfaces";
import { PeerDiscoveryStaticPeers } from "./peer_discovery_static_list";

View File

@ -1,7 +1,7 @@
import type { PeerId } from "@libp2p/interface-peer-id";
import { createWaku } from "@waku/create";
import { expect } from "chai";
import { createWaku } from "./create_waku";
import type { Waku } from "./interfaces";
describe("Waku Dial", function () {

View File

@ -66,6 +66,7 @@
"@waku/core": "*"
},
"devDependencies": {
"@waku/interfaces": "*",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",

View File

@ -12,14 +12,9 @@ import {
WakuRelay,
WakuStore,
} from "@waku/core";
import type {
Waku,
WakuFull,
WakuLight,
WakuPrivacy,
} from "@waku/core/lib/interfaces";
import { PeerDiscoveryStaticPeers } from "@waku/core/lib/peer_discovery_static_list";
import { getPredefinedBootstrapNodes } from "@waku/core/lib/predefined_bootstrap_nodes";
import type { WakuFull, WakuLight, WakuPrivacy } from "@waku/interfaces";
import type { Libp2p } from "libp2p";
import { createLibp2p, Libp2pOptions } from "libp2p";
@ -150,35 +145,6 @@ export async function createFullNode(
) as WakuFull;
}
/**
* @deprecated use { @link createLightNode }, { @link createPrivacyNode } or
* { @link index.waku.WakuNode.constructor } instead.
*/
export async function createWaku(
options?: CreateOptions & WakuOptions & Partial<RelayCreateOptions>
): Promise<Waku> {
const libp2pOptions = options?.libp2p ?? {};
const peerDiscovery = libp2pOptions.peerDiscovery ?? [];
if (options?.defaultBootstrap) {
peerDiscovery.push(defaultPeerDiscovery());
Object.assign(libp2pOptions, { peerDiscovery });
}
const libp2p = await defaultLibp2p(new WakuRelay(options), libp2pOptions);
const wakuStore = new WakuStore(libp2p, options);
const wakuLightPush = new WakuLightPush(libp2p, options);
const wakuFilter = new WakuFilter(libp2p, options);
return new WakuNode(
options ?? {},
libp2p,
wakuStore,
wakuLightPush,
wakuFilter
);
}
export function defaultPeerDiscovery(): PeerDiscovery {
return new PeerDiscoveryStaticPeers(getPredefinedBootstrapNodes());
}

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,170 @@
{
"name": "@waku/interfaces",
"version": "0.0.1",
"description": "Definition of Waku interfaces",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts"
}
},
"type": "module",
"author": "Waku Team",
"homepage": "https://github.com/waku-org/js-waku/tree/master/packages/interfaces#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": "exit 0",
"fix": "run-s fix:*",
"fix:prettier": "prettier . --write",
"fix:lint": "eslint src --ext .ts --ext .cjs --fix",
"check": "run-s check:*",
"check:lint": "eslint src --ext .ts",
"check:prettier": "prettier . --list-different",
"check:spelling": "cspell \"{README.md,src/**/*.ts}\"",
"check:tsc": "tsc -p tsconfig.dev.json",
"test": "exit 0 # Tested in @waku/core",
"proto": "exit 0 # no proto",
"doc": "run-s doc:*",
"doc:html": "typedoc --treatWarningsAsErrors",
"prepublish": "npm run build",
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build",
"release": "semantic-release"
},
"engines": {
"node": ">=16"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/commit-analyzer": "^9.0.2",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^8.0.6",
"@semantic-release/npm": "^9.0.1",
"@semantic-release/release-notes-generator": "^10.0.3",
"@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",
"semantic-release": "^19.0.5",
"semantic-release-monorepo": "^7.0.5",
"typedoc": "^0.23.10",
"typescript": "^4.6.3"
},
"release": {
"branches": [
"master"
],
"extends": "semantic-release-monorepo",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "doc",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"scope": "deps",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "doc",
"section": "Documentation"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
},
"files": [
"dist",
"bundle",
"src/*.ts",
"src/lib/**/*.ts",
"src/proto/**/*.ts",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
"LICENSE",
"README.md"
]
}

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "esnext",
"noEmit": true
},
"exclude": []
}

View File

@ -0,0 +1,54 @@
{
"compilerOptions": {
"incremental": true,
"target": "es2020",
"outDir": "dist/",
"rootDir": "src",
"moduleResolution": "node",
"module": "es2020",
"declaration": true,
"sourceMap": true,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"resolveJsonModule": true /* Include modules imported with .json extension. */,
"tsBuildInfoFile": "dist/.tsbuildinfo",
"strict": true /* Enable all strict type-checking options. */,
/* Strict Type-Checking Options */
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
"strictNullChecks": true /* Enable strict null checks. */,
"strictFunctionTypes": true /* Enable strict checking of function types. */,
"strictPropertyInitialization": true /* Enable strict checking of property initialization in classes. */,
"noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */,
"alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */,
/* Additional Checks */
"noUnusedLocals": true /* Report errors on unused locals. */,
"noUnusedParameters": true /* Report errors on unused parameters. */,
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
"forceConsistentCasingInFileNames": true,
/* Debugging Options */
"traceResolution": false /* Report module resolution log messages. */,
"listEmittedFiles": false /* Print names of generated files part of the compilation. */,
"listFiles": false /* Print names of files part of the compilation. */,
"pretty": true /* Stylize errors and messages using color and context. */,
// Due to broken types in indirect dependencies
"skipLibCheck": true,
/* Experimental Options */
// "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */,
// "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
"lib": ["es2020", "dom"],
"types": ["node", "mocha"],
"typeRoots": ["node_modules/@types", "src/types"]
},
"include": ["src"],
"exclude": ["src/**/*.spec.ts", "src/test_utils"],
"compileOnSave": false,
"ts-node": {
"files": true
}
}

View File

@ -0,0 +1,10 @@
{
"entryPoints": ["./src/index.ts"],
"out": "build/docs",
"exclude": ["**/*.spec.ts"],
"excludeInternal": true,
"validation": {
"invalidLink": true,
"notExported": true
}
}