Skip to content

Commit 915c111

Browse files
authored
Merge pull request #1312 from danielpeintner/issue-1311
Remove dependencies from td-tool package
2 parents 274bf4a + 8c1e059 commit 915c111

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1752
-222
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
> A fast and extensible framework to connect any device with your application
1010
1111
[![Default CI Pipeline](https://github.com/eclipse-thingweb/node-wot/actions/workflows/ci.yaml/badge.svg)](https://github.com/eclipse-thingweb/node-wot/actions/workflows/ci.yaml)
12-
[<img alt="npm" src="https://img.shields.io/npm/dw/@node-wot/td-tools">](https://npm-stat.com/charts.html?package=%40node-wot%2Ftd-tools)
12+
[<img alt="npm" src="https://img.shields.io/npm/dw/@node-wot/core">](https://npm-stat.com/charts.html?package=%40node-wot%2Fcore)
1313
[![codecov](https://codecov.io/gh/eclipse-thingweb/node-wot/branch/master/graph/badge.svg)](https://codecov.io/gh/eclipse-thingweb/node-wot)
1414
[![Telegram Group](https://img.shields.io/endpoint?color=neon&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fnodewot)](https://t.me/nodewot)
1515
[![Discord](https://img.shields.io/badge/Discord-7289DA?logo=discord&logoColor=white&label=node-wot)](https://discord.gg/JXY2Jzefz3)
@@ -59,7 +59,7 @@ The framework can be used in two ways: as a library or as a CLI tool. In this se
5959

6060
### As a library
6161

62-
The framework is composed by different packages that users can use as they please. The core package is `@node-wot/core` and it is the only mandatory package to install. The other packages are bindings that allow the framework to communicate with different protocols and optionally we offer a set of tools in the `@node-wot/td-tools` package.
62+
The framework is composed by different packages that users can use as they please. The core package is `@node-wot/core` and it is the only mandatory package to install. The other packages are bindings that allow the framework to communicate with different protocols.
6363

6464
#### Node.js
6565

package-lock.json

Lines changed: 41 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/binding-coap/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"types": "dist/coap.d.ts",
1616
"dependencies": {
1717
"@node-wot/core": "0.8.15",
18-
"@node-wot/td-tools": "0.8.15",
1918
"@types/node": "16.18.35",
2019
"coap": "^1.4.0",
2120
"multicast-dns": "^7.2.5",

packages/binding-coap/src/coap-client.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ import * as net from "net";
2222

2323
import { Subscription } from "rxjs/Subscription";
2424

25-
// for Security definition
26-
import * as TD from "@node-wot/td-tools";
27-
28-
import { ProtocolClient, Content, ContentSerdes, createLoggers } from "@node-wot/core";
25+
import { ProtocolClient, Content, ContentSerdes, SecurityScheme, createLoggers } from "@node-wot/core";
2926
import { BlockSize, blockSizeToOptionValue, CoapForm, CoapMethodName } from "./coap";
3027
import CoapServer from "./coap-server";
3128
import { Readable } from "stream";
@@ -209,7 +206,7 @@ export default class CoapClient implements ProtocolClient {
209206
this.agent.close();
210207
}
211208

212-
public setSecurity = (metadata: Array<TD.SecurityScheme>): boolean => true;
209+
public setSecurity = (metadata: Array<SecurityScheme>): boolean => true;
213210

214211
private uriToOptions(uri: string): CoapRequestParams {
215212
// eslint-disable-next-line n/no-deprecated-api

packages/binding-coap/src/coap-server.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* CoAP Server based on coap by mcollina
1818
*/
1919

20-
import * as TD from "@node-wot/td-tools";
2120
import Servient, {
2221
ProtocolServer,
2322
ContentSerdes,
@@ -26,6 +25,7 @@ import Servient, {
2625
ProtocolHelpers,
2726
Content,
2827
createLoggers,
28+
Form,
2929
} from "@node-wot/core";
3030
import { Socket } from "dgram";
3131
import { Server, createServer, registerFormat, IncomingMessage, OutgoingMessage } from "coap";
@@ -231,7 +231,7 @@ export default class CoapServer implements ProtocolServer {
231231
return opValues;
232232
}
233233

234-
private addFormToAffordance(form: TD.Form, affordance: AffordanceElement): void {
234+
private addFormToAffordance(form: Form, affordance: AffordanceElement): void {
235235
const affordanceForms = affordance.forms;
236236
if (affordanceForms == null) {
237237
affordance.forms = [form];
@@ -317,7 +317,7 @@ export default class CoapServer implements ProtocolServer {
317317
affordanceName?: string,
318318
affordanceUriVariables?: PropertyElement["uriVariables"],
319319
subprotocol?: string
320-
): TD.Form {
320+
): Form {
321321
const affordanceNamePattern = Helpers.updateInteractionNameWithUriVariablePattern(
322322
affordanceName ?? "",
323323
affordanceUriVariables,
@@ -330,14 +330,14 @@ export default class CoapServer implements ProtocolServer {
330330
href += `/${encodeURIComponent(affordanceNamePattern)}`;
331331
}
332332

333-
const form = new TD.Form(href, offeredMediaType);
333+
const form = new Form(href, offeredMediaType);
334334
form.op = opValues;
335335
form.subprotocol = subprotocol;
336336

337337
return form;
338338
}
339339

340-
private logHrefAssignment(form: TD.Form, affordanceType: string, affordanceName: string) {
340+
private logHrefAssignment(form: Form, affordanceType: string, affordanceName: string) {
341341
debug(`CoapServer on port ${this.port} assigns '${form.href}' to ${affordanceType} '${affordanceName}'`);
342342
}
343343

@@ -610,7 +610,7 @@ export default class CoapServer implements ProtocolServer {
610610
}
611611

612612
private async handleReadMultipleProperties(
613-
forms: TD.Form[],
613+
forms: Form[],
614614
req: IncomingMessage,
615615
contentType: string,
616616
thing: ExposedThing,
@@ -817,7 +817,7 @@ export default class CoapServer implements ProtocolServer {
817817
}
818818

819819
private createInteractionOptions(
820-
forms: TD.Form[],
820+
forms: Form[],
821821
thing: ExposedThing,
822822
req: IncomingMessage,
823823
contentType: string,

packages/binding-coap/src/coap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
1414
********************************************************************************/
1515

16-
import { Form } from "@node-wot/td-tools";
16+
import { Form } from "@node-wot/core";
1717

1818
export { default as CoapServer } from "./coap-server";
1919
export { default as CoapClientFactory } from "./coap-client-factory";

packages/binding-coap/src/coaps-client.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
* CoAPS client based on node-coap-client by AlCalzone
1818
*/
1919

20-
import * as TD from "@node-wot/td-tools";
21-
2220
import { Subscription } from "rxjs/Subscription";
2321

24-
import { ProtocolClient, Content, createLoggers, ContentSerdes } from "@node-wot/core";
22+
import { ProtocolClient, Content, createLoggers, ContentSerdes, SecurityScheme } from "@node-wot/core";
2523
import { CoapForm, CoapMethodName, isValidCoapMethod, isSupportedCoapMethod } from "./coap";
2624
import { CoapClient as coaps, CoapResponse, RequestMethod, SecurityParameters } from "node-coap-client";
2725
import { Readable } from "stream";
@@ -164,13 +162,13 @@ export default class CoapsClient implements ProtocolClient {
164162
// FIXME coap does not provide proper API to close Agent
165163
}
166164

167-
public setSecurity(metadata: Array<TD.SecurityScheme>, credentials?: pskSecurityParameters): boolean {
165+
public setSecurity(metadata: Array<SecurityScheme>, credentials?: pskSecurityParameters): boolean {
168166
if (metadata === undefined || !Array.isArray(metadata) || metadata.length === 0) {
169167
warn(`CoapsClient received empty security metadata`);
170168
return false;
171169
}
172170

173-
const security: TD.SecurityScheme = metadata[0];
171+
const security: SecurityScheme = metadata[0];
174172

175173
if (security.scheme === "psk" && credentials != null) {
176174
this.authorization = { psk: {} };

0 commit comments

Comments
 (0)