Skip to content

Commit 8a05b90

Browse files
refactor: introduce anonymous InteractionOutput options parameter
1 parent 4708fe7 commit 8a05b90

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/core/src/consumed-thing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ export default class ConsumedThing extends TD.Thing implements IConsumedThing {
584584
);
585585
}
586586
}
587-
return new InteractionOutput(content, form, outputDataSchema, ignoreValidation);
587+
return new InteractionOutput(content, form, outputDataSchema, { ignoreValidation: ignoreValidation ?? false });
588588
}
589589

590590
async _readProperties(propertyNames: string[]): Promise<WoT.PropertyReadMap> {

packages/core/src/interaction-output.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ export class InteractionOutput implements WoT.InteractionOutput {
5858
return (this.#stream = ProtocolHelpers.toWoTStream(this.#content.body) as ReadableStream);
5959
}
6060

61-
constructor(content: Content, form?: WoT.Form, schema?: WoT.DataSchema, ignoreValidation?: boolean) {
61+
constructor(content: Content, form?: WoT.Form, schema?: WoT.DataSchema, options = { ignoreValidation: false }) {
6262
this.#content = content;
6363
this.form = form;
6464
this.schema = schema;
65-
this.ignoreValidation = ignoreValidation ?? false;
65+
this.ignoreValidation = options.ignoreValidation ?? false;
6666
this.dataUsed = false;
6767
}
6868

packages/core/test/InteractionOutputTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class InteractionOutputTests {
126126
const stream = Readable.from(Buffer.from("not boolean", "utf-8"));
127127
const content = new Content("application/json", stream);
128128

129-
const out = new InteractionOutput(content, {}, { type: "boolean" }, true);
129+
const out = new InteractionOutput(content, {}, { type: "boolean" }, { ignoreValidation: true });
130130
const result = await out.value();
131131
expect(result).to.eql("not boolean");
132132
}

0 commit comments

Comments
 (0)