Skip to content

Commit d0313fd

Browse files
feat!(typescript): align TypeScript definitions with Discovery API (#513)
* feat!(typescript): align TypeScript definitions with Discovery API * fixup! feat!(typescript): align TypeScript definitions with Discovery API * fixup! feat!(typescript): align TypeScript definitions with Discovery AP… * fixup! feat!(typescript): align TypeScript definitions with Discovery API Co-authored-by: danielpeintner <[email protected]> * fixup! feat!(typescript): align TypeScript definitions with Discovery API * fixup! feat!(typescript): align TypeScript definitions with Discovery API * chore(typescript): bump version number --------- Co-authored-by: danielpeintner <[email protected]>
1 parent 6d348ff commit d0313fd

File tree

2 files changed

+25
-33
lines changed

2 files changed

+25
-33
lines changed

typescript/scripting-api/index.d.ts

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,30 @@ type DeepPartial<T> = T extends object ? {
66
declare namespace WoT {
77

88
/**
9-
* Starts the discovery process that will provide ConsumedThing
10-
*
9+
* Starts the discovery process that will provide {@link ThingDescription}
10+
* objects for Thing Descriptions that match an optional {@link filter}
11+
* argument of type {@link ThingFilter}.
12+
*
13+
* @param filter represents the constraints for discovering Things as key-value pairs
14+
*/
15+
export function discover(filter?: ThingFilter): Promise<ThingDiscoveryProcess>;
16+
17+
/**
18+
* Starts the discovery process that, given a TD Directory {@link url}, will
19+
* provide {@link ThingDescription} objects for Thing Descriptions that
20+
* match an optional {@link filter} argument of type {@link ThingFilter}.
21+
*
22+
* @param url URL pointing to a TD Directory.
1123
* @param filter represents the constraints for discovering Things as key-value pairs
1224
*/
13-
export function discover(filter?: ThingFilter): ThingDiscovery;
25+
export function exploreDirectory(url: string, filter?: ThingFilter): Promise<ThingDiscoveryProcess>;
26+
27+
/**
28+
* Requests a {@link ThingDescription} from the given {@link url}.
29+
*
30+
* @param url The URL to request the Thing Description from.
31+
*/
32+
export function requestThingDescription(url: string): Promise<ThingDescription>;
1433

1534
/**
1635
* Accepts a ThingDescription and returns a ConsumedThing
@@ -31,47 +50,20 @@ declare namespace WoT {
3150
* Dictionary that represents the constraints for discovering Things as key-value pairs.
3251
*/
3352
export interface ThingFilter {
34-
/**
35-
* The method field represents the discovery type that should be used in the discovery process. The possible values are defined by the DiscoveryMethod enumeration that can be extended by string values defined by solutions (with no guarantee of interoperability).
36-
*/
37-
method?: DiscoveryMethod | string; // default value "any", DOMString
38-
/**
39-
* The url field represents additional information for the discovery method, such as the URL of the target entity serving the discovery request, such as a Thing Directory or a Thing.
40-
*/
41-
url?: string;
42-
/**
43-
* The query field represents a query string accepted by the implementation, for instance a SPARQL query.
44-
*/
45-
query?: string;
4653
/**
4754
* The fragment field represents a template object used for matching against discovered Things.
4855
*/
4956
fragment?: object;
5057
}
5158

52-
/** The DiscoveryMethod enumeration represents the discovery type to be used */
53-
export enum DiscoveryMethod {
54-
/** does not restrict */
55-
"any",
56-
/** for discovering Things defined in the same Servient */
57-
"local",
58-
/** for discovery based on a service provided by a Thing Directory */
59-
"directory",
60-
/** for discovering Things in the same/reachable network by using a supported multicast protocol */
61-
"multicast"
62-
}
63-
6459
/**
6560
* The ThingDiscovery object is constructed given a filter and provides the properties and methods
6661
* controlling the discovery process.
6762
*/
68-
export interface ThingDiscovery {
63+
export interface ThingDiscoveryProcess extends AsyncIterable<ThingDescription> {
6964
filter?: ThingFilter;
70-
active: boolean;
7165
done: boolean;
7266
error?: Error;
73-
start(): void;
74-
next(): Promise<ThingDescription>;
7567
stop(): void;
7668
}
7769

@@ -300,4 +292,4 @@ declare namespace WoT {
300292

301293
declare module "wot-typescript-definitions" {
302294
export = WoT;
303-
}
295+
}

typescript/scripting-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wot-typescript-definitions",
3-
"version": "0.8.0-SNAPSHOT.28",
3+
"version": "0.8.0-SNAPSHOT.29",
44
"description": "TypeScript definitions for the W3C WoT Scripting API",
55
"author": "W3C Web of Things Working Group",
66
"license": "W3C-20150513",

0 commit comments

Comments
 (0)