Skip to content

Commit

Permalink
refactor: extend TDT.Form(ElementBase) instead of redefining it
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpeintner committed May 5, 2022
1 parent d46badc commit 41bfc81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/td-tools/src/td-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function parseTD(td: string, normalize?: boolean): Thing {
}

// collect all forms for normalization and use iterations also for checking
const allForms: TD.Form[] = [];
const allForms = [];
// properties
for (const propName in thing.properties) {
const prop: TD.ThingProperty = thing.properties[propName];
Expand Down
28 changes: 10 additions & 18 deletions packages/td-tools/src/thing-description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,35 +65,27 @@ export interface ThingInteraction {
}

/** Implements the Interaction Form description */
export class Form implements Form {
href: string;
subprotocol?: string;
op?: string | Array<string>;
export class Form implements TDT.FormElementBase {
op?: string | string[];
href: TDT.AnyUri;
contentType?: string;
security?: Array<string>; // WoT.Security;
scopes?: Array<string>;
response?: ExpectedResponse;
contentCoding?: string;
subprotocol?: TDT.Subprotocol;
security?: TDT.Security;
scopes?: TDT.Scopes;
response?: TDT.ExpectedResponse;
additionalResponses?: TDT.AdditionalResponsesDefinition;
[k: string]: unknown;

constructor(href: string, contentType?: string) {
this.href = href;
if (contentType) this.contentType = contentType;
}
}

export interface ExpectedResponse {
contentType?: string;
}

export interface Form {
href: string;
subprotocol?: string;
op?: string | Array<string>;
contentType?: string; // media type + parameter(s), e.g., text/plain;charset=utf8
security?: Array<string>; // Set of security definition names, chosen from those defined in securityDefinitions // Security;
scopes?: Array<string>;
response?: ExpectedResponse;
}

export type DataSchema = WoT.DataSchema &
(BooleanSchema | IntegerSchema | NumberSchema | StringSchema | ObjectSchema | ArraySchema | NullSchema);

Expand Down

0 comments on commit 41bfc81

Please sign in to comment.