Skip to content

Commit 30d0144

Browse files
author
Jon Bernard
committed
updates
1 parent c6ad69e commit 30d0144

File tree

4 files changed

+310
-29
lines changed

4 files changed

+310
-29
lines changed

ldk/node/examples/whisper-disambiguation/src/index.ts

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,38 @@ class ExampleLoop implements Loop {
2323
const now = moment();
2424
const url = `https://api.fda.gov/food/enforcement.json?search=report_date:[${now.subtract(3, 'months').startOf('month').format('YYYYMMDD')}+TO+${now.endOf("month").format('YYYYMMDD')}]&limit=10`;
2525

26-
logger.info('Emitting list whisper', url);
26+
logger.info('Emitting disambiguation whisper', url);
2727

28-
try {
29-
this.host.network.httpRequest({
30-
url,
31-
method: "GET",
32-
body: "",
33-
}).then((response) => {
34-
const { results } = JSON.parse(Buffer.from(response.data).toString('utf8'));
35-
const itemList = {} as Element;
28+
this.host.network.httpRequest({
29+
url,
30+
method: "GET",
31+
body: "",
32+
}).then((response) => {
33+
const { results } = JSON.parse(Buffer.from(response.data).toString('utf8'));
34+
const itemList = {} as Element;
3635

37-
results.forEach((resultItem: RecallJSON, index: number) => {
38-
itemList[resultItem.recall_number] = {
39-
label: `😝${resultItem.recalling_firm} (${resultItem.recall_initiation_date}) jb`,
40-
order: index + 1,
41-
type: 'option',
42-
}
43-
})
44-
45-
this.host.whisper.disambiguationWhisper({
46-
label: 'Latest FDA Food Recall',
47-
markdown: '',
48-
elements: itemList,
49-
},
50-
// I don't know what goes here (An argument for 'listener' was not provided.)
51-
);
36+
results.forEach((resultItem: RecallJSON, index: number) => {
37+
itemList[resultItem.recall_number] = {
38+
label: `😝${resultItem.recalling_firm} (${resultItem.recall_initiation_date}) jb`,
39+
order: index + 1,
40+
type: 'option',
41+
}
5242
})
53-
} catch (e) {
43+
44+
this.host.whisper.disambiguationWhisper({
45+
label: 'Latest FDA Food Recall',
46+
markdown: '',
47+
elements: itemList,
48+
},
49+
(error, input) => {
50+
if (input) {
51+
logger.info(`Zhu Li Do The Thing With ${input.key}`);
52+
}
53+
},
54+
);
55+
}).catch((e) => {
5456
logger.error('Error using network service', 'error', e.toString());
55-
}
57+
})
5658
}
5759

5860
stop(): void {

ldk/node/src/grpc/network_pb.d.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@
77
import * as jspb from "google-protobuf";
88
import * as session_pb from "./session_pb";
99

10+
export class HTTPHeader extends jspb.Message {
11+
clearValuesList(): void;
12+
getValuesList(): Array<string>;
13+
setValuesList(value: Array<string>): HTTPHeader;
14+
addValues(value: string, index?: number): string;
15+
16+
17+
serializeBinary(): Uint8Array;
18+
toObject(includeInstance?: boolean): HTTPHeader.AsObject;
19+
static toObject(includeInstance: boolean, msg: HTTPHeader): HTTPHeader.AsObject;
20+
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
21+
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
22+
static serializeBinaryToWriter(message: HTTPHeader, writer: jspb.BinaryWriter): void;
23+
static deserializeBinary(bytes: Uint8Array): HTTPHeader;
24+
static deserializeBinaryFromReader(message: HTTPHeader, reader: jspb.BinaryReader): HTTPHeader;
25+
}
26+
27+
export namespace HTTPHeader {
28+
export type AsObject = {
29+
valuesList: Array<string>,
30+
}
31+
}
32+
1033
export class HTTPRequestMsg extends jspb.Message {
1134

1235
hasSession(): boolean;
@@ -26,6 +49,10 @@ export class HTTPRequestMsg extends jspb.Message {
2649
setBody(value: Uint8Array | string): HTTPRequestMsg;
2750

2851

52+
getHeadersMap(): jspb.Map<string, HTTPHeader>;
53+
clearHeadersMap(): void;
54+
55+
2956
serializeBinary(): Uint8Array;
3057
toObject(includeInstance?: boolean): HTTPRequestMsg.AsObject;
3158
static toObject(includeInstance: boolean, msg: HTTPRequestMsg): HTTPRequestMsg.AsObject;
@@ -42,6 +69,8 @@ export namespace HTTPRequestMsg {
4269
url: string,
4370
method: string,
4471
body: Uint8Array | string,
72+
73+
headersMap: Array<[string, HTTPHeader.AsObject]>,
4574
}
4675
}
4776

@@ -55,6 +84,10 @@ export class HTTPResponseMsg extends jspb.Message {
5584
setData(value: Uint8Array | string): HTTPResponseMsg;
5685

5786

87+
getHeadersMap(): jspb.Map<string, HTTPHeader>;
88+
clearHeadersMap(): void;
89+
90+
5891
serializeBinary(): Uint8Array;
5992
toObject(includeInstance?: boolean): HTTPResponseMsg.AsObject;
6093
static toObject(includeInstance: boolean, msg: HTTPResponseMsg): HTTPResponseMsg.AsObject;
@@ -69,5 +102,7 @@ export namespace HTTPResponseMsg {
69102
export type AsObject = {
70103
responsecode: number,
71104
data: Uint8Array | string,
105+
106+
headersMap: Array<[string, HTTPHeader.AsObject]>,
72107
}
73108
}

0 commit comments

Comments
 (0)