Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@node-wot/td-tools

Package Overview
Dependencies
Maintainers
4
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-wot/td-tools - npm Package Compare versions

Comparing version 0.6.2 to 0.7.0-SNAPSHOT.1

237

dist/dist/thing-description.d.ts

@@ -1,14 +0,11 @@

import * as WoT from "wot-typescript-definitions";
export declare const DEFAULT_CONTEXT: string;
export declare const DEFAULT_CONTEXT_LANGUAGE: string;
export declare const DEFAULT_THING_TYPE: string;
export declare class VersionInfo implements WoT.VersionInfo {
instance: string;
}
export default class Thing implements WoT.ThingFragment {
export declare type MultiLanguage = any;
export default class Thing {
id: string;
title: string;
titles: WoT.MultiLanguage;
titles: MultiLanguage;
description: string;
descriptions: WoT.MultiLanguage;
descriptions: MultiLanguage;
support: string;

@@ -19,3 +16,3 @@ modified: string;

securityDefinitions: {
[key: string]: WoT.Security;
[key: string]: SecurityScheme;
};

@@ -25,52 +22,54 @@ security: Array<String>;

properties: {
[key: string]: WoT.ThingProperty;
[key: string]: ThingProperty;
};
actions: {
[key: string]: WoT.ThingAction;
[key: string]: ThingAction;
};
events: {
[key: string]: WoT.ThingEvent;
[key: string]: ThingEvent;
};
links: Array<WoT.Link>;
forms: Array<WoT.Form>;
links: Array<Link>;
forms: Array<Form>;
[key: string]: any;
constructor();
}
export declare abstract class ThingInteraction implements WoT.InteractionFragment {
title: string;
titles: WoT.MultiLanguage;
description: string;
descriptions: WoT.MultiLanguage;
scopes: Array<string>;
uriVariables: {
[key: string]: WoT.DataSchema;
export interface ThingInteraction {
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security: Array<string>;
forms: Array<Form>;
security?: Array<string>;
forms?: Array<Form>;
[key: string]: any;
}
export declare class ThingProperty extends ThingInteraction implements WoT.PropertyFragment, WoT.BaseSchema {
observable: boolean;
type: string;
export declare class ExpectedResponse implements ExpectedResponse {
contentType?: string;
}
export declare class ThingAction extends ThingInteraction implements WoT.ActionFragment {
input: WoT.DataSchema;
output: WoT.DataSchema;
safe: boolean;
idempotent: boolean;
export declare class Form implements Form {
href: string;
subprotocol?: string;
op?: string | Array<string>;
contentType?: string;
security?: Array<string>;
scopes?: Array<string>;
response?: ExpectedResponse;
constructor(href: string, contentType?: string);
}
export declare class ThingEvent extends ThingInteraction implements WoT.EventFragment {
subscription: WoT.DataSchema;
data: WoT.DataSchema;
cancellation: WoT.DataSchema;
export interface VersionInfo {
instance?: string;
}
export declare class Security implements WoT.SecurityScheme {
scheme: string;
description: string;
proxyURI?: string;
export interface Link {
href: string;
rel?: string | Array<string>;
type?: string;
anchor?: string;
}
export declare class ExpectedResponse implements WoT.ExpectedResponse {
export interface ExpectedResponse {
contentType?: string;
}
export declare class Form implements WoT.Form {
export interface Form {
href: string;

@@ -83,3 +82,157 @@ subprotocol?: string;

response?: ExpectedResponse;
constructor(href: string, contentType?: string);
}
export declare type DataSchema = BooleanSchema | IntegerSchema | NumberSchema | StringSchema | ObjectSchema | ArraySchema | NullSchema;
export declare class BaseSchema {
type?: string;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
writeOnly?: boolean;
readOnly?: boolean;
oneOf?: Array<DataSchema>;
unit?: string;
const?: any;
enum?: Array<any>;
}
export interface BooleanSchema extends BaseSchema {
type: "boolean";
}
export interface IntegerSchema extends BaseSchema {
type: "integer";
minimum?: number;
maximum?: number;
}
export interface NumberSchema extends BaseSchema {
type: "number";
minimum?: number;
maximum?: number;
}
export interface StringSchema extends BaseSchema {
type: "string";
}
export interface ObjectSchema extends BaseSchema {
type: "object";
properties: {
[key: string]: DataSchema;
};
required?: Array<string>;
}
export interface ArraySchema extends BaseSchema {
type: "array";
items: DataSchema;
minItems?: number;
maxItems?: number;
}
export interface NullSchema extends BaseSchema {
type: "null";
}
export declare type SecurityType = NoSecurityScheme | BasicSecurityScheme | DigestSecurityScheme | BearerSecurityScheme | CertSecurityScheme | PoPSecurityScheme | APIKeySecurityScheme | OAuth2SecurityScheme | PSKSecurityScheme | PublicSecurityScheme;
export interface SecurityScheme {
scheme: string;
description?: string;
proxy?: string;
}
export interface NoSecurityScheme extends SecurityScheme {
scheme: "nosec";
}
export interface BasicSecurityScheme extends SecurityScheme {
scheme: "basic";
in?: string;
name?: string;
}
export interface DigestSecurityScheme extends SecurityScheme {
scheme: "digest";
name?: string;
in?: string;
qop?: string;
}
export interface APIKeySecurityScheme extends SecurityScheme {
scheme: "apikey";
in?: string;
name?: string;
}
export interface BearerSecurityScheme extends SecurityScheme {
scheme: "bearer";
in?: string;
alg?: string;
format?: string;
name?: string;
authorization?: string;
}
export interface CertSecurityScheme extends SecurityScheme {
scheme: "cert";
identity?: string;
}
export interface PSKSecurityScheme extends SecurityScheme {
scheme: "psk";
identity?: string;
}
export interface PublicSecurityScheme extends SecurityScheme {
scheme: "public";
identity?: string;
}
export interface PoPSecurityScheme extends SecurityScheme {
scheme: "pop";
format?: string;
authorization?: string;
alg?: string;
name?: string;
in?: string;
}
export interface OAuth2SecurityScheme extends SecurityScheme {
scheme: "oauth2";
authorization?: string;
flow?: string;
token?: string;
refresh?: string;
scopes?: Array<string>;
}
export declare abstract class ThingProperty extends BaseSchema implements ThingInteraction {
observable?: boolean;
type?: string;
forms?: Array<Form>;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security?: Array<string>;
[key: string]: any;
}
export declare abstract class ThingAction implements ThingInteraction {
input?: DataSchema;
output?: DataSchema;
safe?: boolean;
idempotent?: boolean;
forms?: Array<Form>;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security?: Array<string>;
[key: string]: any;
}
export declare abstract class ThingEvent implements ThingInteraction {
subscription?: DataSchema;
data?: DataSchema;
cancellation?: DataSchema;
forms?: Array<Form>;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security?: Array<string>;
[key: string]: any;
}

2

dist/node-wot-td-tools.bundle.js

@@ -1,1 +0,1 @@

var TDTools=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=7)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONTEXT="https://www.w3.org/2019/wot/td/v1",t.DEFAULT_CONTEXT_LANGUAGE="en",t.DEFAULT_THING_TYPE="Thing";var o=function(){return function(){}}();t.VersionInfo=o;var i=function(){return function(){this["@context"]=t.DEFAULT_CONTEXT,this["@type"]=t.DEFAULT_THING_TYPE,this.security=[],this.properties={},this.actions={},this.events={},this.links=[]}}();t.default=i;var a=function(){return function(){}}();t.ThingInteraction=a;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(a);t.ThingProperty=s;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(a);t.ThingAction=u;var p=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(a);t.ThingEvent=p;var l=function(){return function(){}}();t.Security=l;var f=function(){return function(){}}();t.ExpectedResponse=f;var c=function(){return function(e,t){this.href=e,t&&(this.contentType=t)}}();t.Form=c},function(e,t,r){"use strict";function n(e){var t=JSON.parse(e);return console.log("NO TD MODIFICATIONS DONE YET!!!!!"),t}function o(e){var t=JSON.parse(e);if(null!=t.base&&(t.uris=[],t.uris.push(t.base),delete t.base),null!=t.interactions&&Array.isArray(t.interactions)){for(var r=0,n=t.interactions;r<n.length;r++){var o=n[r];null!=o["@type"]&&Array.isArray(o["@type"])&&(o["@type"].indexOf("Property")>=0&&(null==t.properties&&(t.properties=[]),t.properties.push(o),null!=o.outputData&&null!=o.outputData.valueType&&(o.valueType=o.outputData.valueType,delete o.outputData),i(t,o)),o["@type"].indexOf("Action")>=0&&(null==t.actions&&(t.actions=[]),t.actions.push(o),i(t,o)),o["@type"].indexOf("Event")>=0&&(null==t.events&&(t.events=[]),t.events.push(o),null!=o.outputData&&null!=o.outputData.valueType&&(o.valueType=o.outputData.valueType,delete o.outputData),i(t,o)))}delete t.interactions}return t}function i(e,t){if(null!=t.links&&Array.isArray(t.links)){for(var r=0,n=t.links;r<n.length;r++){var o=n[r];null==t.hrefs&&(t.hrefs=[]),t.hrefs.push(o.href),null==e.encodings&&(e.encodings=[]),e.encodings.indexOf(o.mediaType)<0&&e.encodings.push(o.mediaType)}delete t.links}}function a(e){var t=JSON.parse(e);if(null!=t.base&&(t.uris=[],t.uris.push(t.base),delete t.base),null!=t.interaction&&Array.isArray(t.interaction)){for(var r=0,n=t.interaction;r<n.length;r++){var o=n[r];null!=o["@type"]&&Array.isArray(o["@type"])&&(o["@type"].indexOf("Property")>=0&&(null==t.properties&&(t.properties=[]),t.properties.push(o),null!=o.outputData&&(o.valueType=o.outputData,delete o.outputData),s(t,o)),o["@type"].indexOf("Action")>=0&&(null==t.actions&&(t.actions=[]),t.actions.push(o),null!=o.outputData&&null!=o.outputData.type&&(o.outputData.valueType={},o.outputData.valueType.type=o.outputData.type,delete o.outputData.type),null!=o.inputData&&null!=o.inputData.type&&(o.inputData.valueType={},o.inputData.valueType.type=o.inputData.type,delete o.inputData.type),s(t,o)),o["@type"].indexOf("Event")>=0&&(null==t.events&&(t.events=[]),t.events.push(o),null!=o.outputData&&(o.valueType=o.outputData,delete o.outputData),s(t,o)))}delete t.interaction}return t}function s(e,t){if(null!=t.link&&Array.isArray(t.link)){for(var r=0,n=t.link;r<n.length;r++){var o=n[r];null==t.hrefs&&(t.hrefs=[]),t.hrefs.push(o.href),null==e.encodings&&(e.encodings=[]),e.encodings.indexOf(o.mediaType)<0&&e.encodings.push(o.mediaType)}delete t.links}}Object.defineProperty(t,"__esModule",{value:!0}),t.transformTDV1StringToV2String=n,t.transformTDV1ObjToV2Obj=function(e){return n(JSON.stringify(e))},t.transformTDV2StringToV1String=o,t.transformTDV2ObjToV1Obj=function(e){return o(JSON.stringify(e))},t.transformTDV3StringToV1String=a,t.transformTDV3ObjToV1Obj=function(e){return a(JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findProtocol=function(e){var t=e.base,r=t.indexOf(":");return t.substring(0,r)},t.findPort=function(e){var t=e.base,r=t.indexOf(":",6),n=t.indexOf("/",r),o=t.substring(r+1,n);return parseInt(o)}},function(e,t,r){!function(t){var r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/?#]*)(.*)$/,o=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,a={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");return o.path=a.normalizePath(o.path),a.buildURLFromParts(o)}var i=a.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=a.normalizePath(i.path),a.buildURLFromParts(i)):t;var s=a.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var u=n.exec(s.path);s.netLoc=u[1],s.path=u[2]}s.netLoc&&!s.path&&(s.path="/");var p={scheme:s.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(p.netLoc=s.netLoc,"/"!==i.path[0]))if(i.path){var l=s.path,f=l.substring(0,l.lastIndexOf("/")+1)+i.path;p.path=a.normalizePath(f)}else p.path=s.path,i.params||(p.params=s.params,i.query||(p.query=s.query));return null===p.path&&(p.path=r.alwaysNormalize?a.normalizePath(i.path):i.path),a.buildURLFromParts(p)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(o,"");e.length!==(e=e.replace(i,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=a}()},function(e,t,r){"use strict";e.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return/^[a-z][a-z0-9+.-]*:/.test(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(4),i=r(3);t.parseTD=function(e,t){console.debug("parseTD() parsing\n```\n"+e+"\n```");var r=JSON.parse(e.replace(/^\uFEFF/,""));if(void 0===r["@context"])r["@context"]=[n.DEFAULT_CONTEXT];else if(Array.isArray(r["@context"]))-1===(a=r["@context"]).indexOf(n.DEFAULT_CONTEXT)&&a.push(n.DEFAULT_CONTEXT);else if(r["@context"]!==n.DEFAULT_CONTEXT){var a=r["@context"];r["@context"]=[a,n.DEFAULT_CONTEXT]}if(function(e){if(Array.isArray(e["@context"])){for(var t=e["@context"],r=!1,o=0,i=t;o<i.length;o++){var a=i[o];"object"==typeof a&&void 0!==a["@language"]&&(r=!0)}r||t.push({"@language":n.DEFAULT_CONTEXT_LANGUAGE})}}(r),void 0===r["@type"])r["@type"]=n.DEFAULT_THING_TYPE;else if(Array.isArray(r["@type"])){var s=r["@type"];-1===s.indexOf(n.DEFAULT_THING_TYPE)&&s.unshift(n.DEFAULT_THING_TYPE)}else if(r["@type"]!==n.DEFAULT_THING_TYPE){var u=r["@type"];r["@type"]=[n.DEFAULT_THING_TYPE,u]}if(void 0!==r.properties&&r.properties instanceof Object)for(var p in r.properties){var l=r.properties[p];void 0!==l.readOnly&&"boolean"==typeof l.readOnly||(l.readOnly=!1),void 0!==l.writeOnly&&"boolean"==typeof l.writeOnly||(l.writeOnly=!1),void 0!=l.observable&&"boolean"==typeof l.observable||(l.observable=!1)}if(void 0!==r.actions&&r.actions instanceof Object)for(var f in r.actions){var c=r.actions[f];void 0!==c.safe&&"boolean"==typeof c.safe||(c.safe=!1),void 0!==c.idempotent&&"boolean"==typeof c.idempotent||(c.idempotent=!1)}"object"==typeof r.properties&&null!==r.properties||(r.properties={}),"object"==typeof r.actions&&null!==r.actions||(r.actions={}),"object"==typeof r.events&&null!==r.events||(r.events={}),void 0===r.security&&console.warn("parseTD() found no security metadata"),"string"==typeof r.security&&(r.security=[r.security]);var y=[],v={properties:"Property",actions:"Action",events:"Event"};for(var h in v)for(var d in r[h]){if(!r[h][d].hasOwnProperty("forms"))throw new Error(v[h]+" '"+d+"' has no forms field");Array.isArray(r[h][d].forms)||(r[h][d].forms=[r[h][d].forms]);for(var T=0,b=r[h][d].forms;T<b.length;T++){if(!(m=b[T]).hasOwnProperty("href"))throw new Error("Form of "+v[h]+" '"+d+"' has no href field");if(!o(m.href)&&!r.hasOwnProperty("base"))throw new Error("Form of "+v[h]+" '"+d+"' has relative URI while TD has no base field");y.push(m)}}if(r.hasOwnProperty("base")&&(void 0===t||!0===t)){console.log("parseTD() normalizing 'base' into 'forms'");for(var O=0,g=y;O<g.length;O++){var m;(m=g[O]).href.match(/^([a-z0-9\+-\.]+\:).+/i)||(console.debug("parseTDString() applying base '"+r.base+"' to '"+m.href+"'"),m.href=i.buildAbsoluteURL(r.base,m.href))}}return r},t.serializeTD=function(e){var t=JSON.parse(JSON.stringify(e));if(t.security&&0!==t.security.length||(t.securityDefinitions={nosec_sc:{scheme:"nosec"}},t.security=["nosec_sc"]),t.forms&&0===t.forms.length&&delete t.forms,t.properties&&0===Object.keys(t.properties).length)delete t.properties;else if(t.properties)for(var r in t.properties){var n=t.properties[r];void 0!==n.readOnly&&"boolean"==typeof n.readOnly||(n.readOnly=!1),void 0!==n.writeOnly&&"boolean"==typeof n.writeOnly||(n.writeOnly=!1),void 0!=n.observable&&"boolean"==typeof n.observable||(n.observable=!1)}if(t.actions&&0===Object.keys(t.actions).length)delete t.actions;else if(t.actions)for(var o in t.actions){var i=t.actions[o];void 0!==i.idempotent&&"boolean"==typeof i.idempotent||(i.idempotent=!1),void 0!==i.safe&&"boolean"==typeof i.safe||(i.safe=!1)}t.events&&0===Object.keys(t.events).length&&delete t.events,t.links&&0===t.links.length&&delete t.links;var a=JSON.stringify(t);return console.debug("serializeTD() produced\n```\n"+a+"\n```"),a}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.tdRepoURI=e}return e.prototype.addNewTD=function(e,t){return""},e.prototype.deleteTD=function(e){return!0},e.prototype.checkIfTDisInRepo=function(e){return""},e.prototype.freeTextSearch=function(e){return[]},e.prototype.tripleSearch=function(e){return[]},e}();t.default=n},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0);t.Thing=o.default;var i=r(6);t.TDRepository=i.default,n(r(0)),n(r(5)),n(r(2)),n(r(1))}]);
var TDTools=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=7)}([function(e,t,r){"use strict";var n=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_CONTEXT="https://www.w3.org/2019/wot/td/v1",t.DEFAULT_CONTEXT_LANGUAGE="en",t.DEFAULT_THING_TYPE="Thing";var o=function(){return function(){this["@context"]=t.DEFAULT_CONTEXT,this["@type"]=t.DEFAULT_THING_TYPE,this.security=[],this.properties={},this.actions={},this.events={},this.links=[]}}();t.default=o;var a=function(){return function(){}}();t.ExpectedResponse=a;var i=function(){return function(e,t){this.href=e,t&&(this.contentType=t)}}();t.Form=i;var s=function(){return function(){}}();t.BaseSchema=s;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(s);t.ThingProperty=u;var p=function(){return function(){}}();t.ThingAction=p;var l=function(){return function(){}}();t.ThingEvent=l},function(e,t,r){"use strict";function n(e){var t=JSON.parse(e);return console.log("NO TD MODIFICATIONS DONE YET!!!!!"),t}function o(e){var t=JSON.parse(e);if(null!=t.base&&(t.uris=[],t.uris.push(t.base),delete t.base),null!=t.interactions&&Array.isArray(t.interactions)){for(var r=0,n=t.interactions;r<n.length;r++){var o=n[r];null!=o["@type"]&&Array.isArray(o["@type"])&&(o["@type"].indexOf("Property")>=0&&(null==t.properties&&(t.properties=[]),t.properties.push(o),null!=o.outputData&&null!=o.outputData.valueType&&(o.valueType=o.outputData.valueType,delete o.outputData),a(t,o)),o["@type"].indexOf("Action")>=0&&(null==t.actions&&(t.actions=[]),t.actions.push(o),a(t,o)),o["@type"].indexOf("Event")>=0&&(null==t.events&&(t.events=[]),t.events.push(o),null!=o.outputData&&null!=o.outputData.valueType&&(o.valueType=o.outputData.valueType,delete o.outputData),a(t,o)))}delete t.interactions}return t}function a(e,t){if(null!=t.links&&Array.isArray(t.links)){for(var r=0,n=t.links;r<n.length;r++){var o=n[r];null==t.hrefs&&(t.hrefs=[]),t.hrefs.push(o.href),null==e.encodings&&(e.encodings=[]),e.encodings.indexOf(o.mediaType)<0&&e.encodings.push(o.mediaType)}delete t.links}}function i(e){var t=JSON.parse(e);if(null!=t.base&&(t.uris=[],t.uris.push(t.base),delete t.base),null!=t.interaction&&Array.isArray(t.interaction)){for(var r=0,n=t.interaction;r<n.length;r++){var o=n[r];null!=o["@type"]&&Array.isArray(o["@type"])&&(o["@type"].indexOf("Property")>=0&&(null==t.properties&&(t.properties=[]),t.properties.push(o),null!=o.outputData&&(o.valueType=o.outputData,delete o.outputData),s(t,o)),o["@type"].indexOf("Action")>=0&&(null==t.actions&&(t.actions=[]),t.actions.push(o),null!=o.outputData&&null!=o.outputData.type&&(o.outputData.valueType={},o.outputData.valueType.type=o.outputData.type,delete o.outputData.type),null!=o.inputData&&null!=o.inputData.type&&(o.inputData.valueType={},o.inputData.valueType.type=o.inputData.type,delete o.inputData.type),s(t,o)),o["@type"].indexOf("Event")>=0&&(null==t.events&&(t.events=[]),t.events.push(o),null!=o.outputData&&(o.valueType=o.outputData,delete o.outputData),s(t,o)))}delete t.interaction}return t}function s(e,t){if(null!=t.link&&Array.isArray(t.link)){for(var r=0,n=t.link;r<n.length;r++){var o=n[r];null==t.hrefs&&(t.hrefs=[]),t.hrefs.push(o.href),null==e.encodings&&(e.encodings=[]),e.encodings.indexOf(o.mediaType)<0&&e.encodings.push(o.mediaType)}delete t.links}}Object.defineProperty(t,"__esModule",{value:!0}),t.transformTDV1StringToV2String=n,t.transformTDV1ObjToV2Obj=function(e){return n(JSON.stringify(e))},t.transformTDV2StringToV1String=o,t.transformTDV2ObjToV1Obj=function(e){return o(JSON.stringify(e))},t.transformTDV3StringToV1String=i,t.transformTDV3ObjToV1Obj=function(e){return i(JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.findProtocol=function(e){var t=e.base,r=t.indexOf(":");return t.substring(0,r)},t.findPort=function(e){var t=e.base,r=t.indexOf(":",6),n=t.indexOf("/",r),o=t.substring(r+1,n);return parseInt(o)}},function(e,t,r){!function(t){var r=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/\?#]*\/)*.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,n=/^([^\/?#]*)(.*)$/,o=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,i={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var o=i.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");return o.path=i.normalizePath(o.path),i.buildURLFromParts(o)}var a=i.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=i.normalizePath(a.path),i.buildURLFromParts(a)):t;var s=i.parseURL(e);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var u=n.exec(s.path);s.netLoc=u[1],s.path=u[2]}s.netLoc&&!s.path&&(s.path="/");var p={scheme:s.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(p.netLoc=s.netLoc,"/"!==a.path[0]))if(a.path){var l=s.path,f=l.substring(0,l.lastIndexOf("/")+1)+a.path;p.path=i.normalizePath(f)}else p.path=s.path,a.params||(p.params=s.params,a.query||(p.query=s.query));return null===p.path&&(p.path=r.alwaysNormalize?i.normalizePath(a.path):a.path),i.buildURLFromParts(p)},parseURL:function(e){var t=r.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(o,"");e.length!==(e=e.replace(a,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=i}()},function(e,t,r){"use strict";e.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return/^[a-z][a-z0-9+.-]*:/.test(e)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),o=r(4),a=r(3);t.parseTD=function(e,t){console.debug("parseTD() parsing\n```\n"+e+"\n```");var r=JSON.parse(e.replace(/^\uFEFF/,""));if(void 0===r["@context"])r["@context"]=[n.DEFAULT_CONTEXT];else if(Array.isArray(r["@context"]))-1===(i=r["@context"]).indexOf(n.DEFAULT_CONTEXT)&&i.push(n.DEFAULT_CONTEXT);else if(r["@context"]!==n.DEFAULT_CONTEXT){var i=r["@context"];r["@context"]=[i,n.DEFAULT_CONTEXT]}if(function(e){if(Array.isArray(e["@context"])){for(var t=e["@context"],r=!1,o=0,a=t;o<a.length;o++){var i=a[o];"object"==typeof i&&void 0!==i["@language"]&&(r=!0)}r||t.push({"@language":n.DEFAULT_CONTEXT_LANGUAGE})}}(r),void 0===r["@type"])r["@type"]=n.DEFAULT_THING_TYPE;else if(Array.isArray(r["@type"])){var s=r["@type"];-1===s.indexOf(n.DEFAULT_THING_TYPE)&&s.unshift(n.DEFAULT_THING_TYPE)}else if(r["@type"]!==n.DEFAULT_THING_TYPE){var u=r["@type"];r["@type"]=[n.DEFAULT_THING_TYPE,u]}if(void 0!==r.properties&&r.properties instanceof Object)for(var p in r.properties){var l=r.properties[p];void 0!==l.readOnly&&"boolean"==typeof l.readOnly||(l.readOnly=!1),void 0!==l.writeOnly&&"boolean"==typeof l.writeOnly||(l.writeOnly=!1),void 0!=l.observable&&"boolean"==typeof l.observable||(l.observable=!1)}if(void 0!==r.actions&&r.actions instanceof Object)for(var f in r.actions){var c=r.actions[f];void 0!==c.safe&&"boolean"==typeof c.safe||(c.safe=!1),void 0!==c.idempotent&&"boolean"==typeof c.idempotent||(c.idempotent=!1)}"object"==typeof r.properties&&null!==r.properties||(r.properties={}),"object"==typeof r.actions&&null!==r.actions||(r.actions={}),"object"==typeof r.events&&null!==r.events||(r.events={}),void 0===r.security&&console.warn("parseTD() found no security metadata"),"string"==typeof r.security&&(r.security=[r.security]);var y=[],v={properties:"Property",actions:"Action",events:"Event"};for(var d in v)for(var h in r[d]){if(!r[d][h].hasOwnProperty("forms"))throw new Error(v[d]+" '"+h+"' has no forms field");Array.isArray(r[d][h].forms)||(r[d][h].forms=[r[d][h].forms]);for(var T=0,b=r[d][h].forms;T<b.length;T++){if(!(m=b[T]).hasOwnProperty("href"))throw new Error("Form of "+v[d]+" '"+h+"' has no href field");if(!o(m.href)&&!r.hasOwnProperty("base"))throw new Error("Form of "+v[d]+" '"+h+"' has relative URI while TD has no base field");y.push(m)}}if(r.hasOwnProperty("base")&&(void 0===t||!0===t)){console.log("parseTD() normalizing 'base' into 'forms'");for(var O=0,g=y;O<g.length;O++){var m;(m=g[O]).href.match(/^([a-z0-9\+-\.]+\:).+/i)||(console.debug("parseTDString() applying base '"+r.base+"' to '"+m.href+"'"),m.href=a.buildAbsoluteURL(r.base,m.href))}}return r},t.serializeTD=function(e){var t=JSON.parse(JSON.stringify(e));if(t.security&&0!==t.security.length||(t.securityDefinitions={nosec_sc:{scheme:"nosec"}},t.security=["nosec_sc"]),t.forms&&0===t.forms.length&&delete t.forms,t.properties&&0===Object.keys(t.properties).length)delete t.properties;else if(t.properties)for(var r in t.properties){var n=t.properties[r];void 0!==n.readOnly&&"boolean"==typeof n.readOnly||(n.readOnly=!1),void 0!==n.writeOnly&&"boolean"==typeof n.writeOnly||(n.writeOnly=!1),void 0!=n.observable&&"boolean"==typeof n.observable||(n.observable=!1)}if(t.actions&&0===Object.keys(t.actions).length)delete t.actions;else if(t.actions)for(var o in t.actions){var a=t.actions[o];void 0!==a.idempotent&&"boolean"==typeof a.idempotent||(a.idempotent=!1),void 0!==a.safe&&"boolean"==typeof a.safe||(a.safe=!1)}t.events&&0===Object.keys(t.events).length&&delete t.events,t.links&&0===t.links.length&&delete t.links;var i=JSON.stringify(t);return console.debug("serializeTD() produced\n```\n"+i+"\n```"),i}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e){this.tdRepoURI=e}return e.prototype.addNewTD=function(e,t){return""},e.prototype.deleteTD=function(e){return!0},e.prototype.checkIfTDisInRepo=function(e){return""},e.prototype.freeTextSearch=function(e){return[]},e.prototype.tripleSearch=function(e){return[]},e}();t.default=n},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0});var o=r(0);t.Thing=o.default;var a=r(6);t.TDRepository=a.default,n(r(0)),n(r(5)),n(r(2)),n(r(1))}]);

@@ -1,14 +0,11 @@

import * as WoT from "wot-typescript-definitions";
export declare const DEFAULT_CONTEXT: string;
export declare const DEFAULT_CONTEXT_LANGUAGE: string;
export declare const DEFAULT_THING_TYPE: string;
export declare class VersionInfo implements WoT.VersionInfo {
instance: string;
}
export default class Thing implements WoT.ThingFragment {
export declare type MultiLanguage = any;
export default class Thing {
id: string;
title: string;
titles: WoT.MultiLanguage;
titles: MultiLanguage;
description: string;
descriptions: WoT.MultiLanguage;
descriptions: MultiLanguage;
support: string;

@@ -19,3 +16,3 @@ modified: string;

securityDefinitions: {
[key: string]: WoT.Security;
[key: string]: SecurityScheme;
};

@@ -25,52 +22,54 @@ security: Array<String>;

properties: {
[key: string]: WoT.ThingProperty;
[key: string]: ThingProperty;
};
actions: {
[key: string]: WoT.ThingAction;
[key: string]: ThingAction;
};
events: {
[key: string]: WoT.ThingEvent;
[key: string]: ThingEvent;
};
links: Array<WoT.Link>;
forms: Array<WoT.Form>;
links: Array<Link>;
forms: Array<Form>;
[key: string]: any;
constructor();
}
export declare abstract class ThingInteraction implements WoT.InteractionFragment {
title: string;
titles: WoT.MultiLanguage;
description: string;
descriptions: WoT.MultiLanguage;
scopes: Array<string>;
uriVariables: {
[key: string]: WoT.DataSchema;
export interface ThingInteraction {
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security: Array<string>;
forms: Array<Form>;
security?: Array<string>;
forms?: Array<Form>;
[key: string]: any;
}
export declare class ThingProperty extends ThingInteraction implements WoT.PropertyFragment, WoT.BaseSchema {
observable: boolean;
type: string;
export declare class ExpectedResponse implements ExpectedResponse {
contentType?: string;
}
export declare class ThingAction extends ThingInteraction implements WoT.ActionFragment {
input: WoT.DataSchema;
output: WoT.DataSchema;
safe: boolean;
idempotent: boolean;
export declare class Form implements Form {
href: string;
subprotocol?: string;
op?: string | Array<string>;
contentType?: string;
security?: Array<string>;
scopes?: Array<string>;
response?: ExpectedResponse;
constructor(href: string, contentType?: string);
}
export declare class ThingEvent extends ThingInteraction implements WoT.EventFragment {
subscription: WoT.DataSchema;
data: WoT.DataSchema;
cancellation: WoT.DataSchema;
export interface VersionInfo {
instance?: string;
}
export declare class Security implements WoT.SecurityScheme {
scheme: string;
description: string;
proxyURI?: string;
export interface Link {
href: string;
rel?: string | Array<string>;
type?: string;
anchor?: string;
}
export declare class ExpectedResponse implements WoT.ExpectedResponse {
export interface ExpectedResponse {
contentType?: string;
}
export declare class Form implements WoT.Form {
export interface Form {
href: string;

@@ -83,3 +82,157 @@ subprotocol?: string;

response?: ExpectedResponse;
constructor(href: string, contentType?: string);
}
export declare type DataSchema = BooleanSchema | IntegerSchema | NumberSchema | StringSchema | ObjectSchema | ArraySchema | NullSchema;
export declare class BaseSchema {
type?: string;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
writeOnly?: boolean;
readOnly?: boolean;
oneOf?: Array<DataSchema>;
unit?: string;
const?: any;
enum?: Array<any>;
}
export interface BooleanSchema extends BaseSchema {
type: "boolean";
}
export interface IntegerSchema extends BaseSchema {
type: "integer";
minimum?: number;
maximum?: number;
}
export interface NumberSchema extends BaseSchema {
type: "number";
minimum?: number;
maximum?: number;
}
export interface StringSchema extends BaseSchema {
type: "string";
}
export interface ObjectSchema extends BaseSchema {
type: "object";
properties: {
[key: string]: DataSchema;
};
required?: Array<string>;
}
export interface ArraySchema extends BaseSchema {
type: "array";
items: DataSchema;
minItems?: number;
maxItems?: number;
}
export interface NullSchema extends BaseSchema {
type: "null";
}
export declare type SecurityType = NoSecurityScheme | BasicSecurityScheme | DigestSecurityScheme | BearerSecurityScheme | CertSecurityScheme | PoPSecurityScheme | APIKeySecurityScheme | OAuth2SecurityScheme | PSKSecurityScheme | PublicSecurityScheme;
export interface SecurityScheme {
scheme: string;
description?: string;
proxy?: string;
}
export interface NoSecurityScheme extends SecurityScheme {
scheme: "nosec";
}
export interface BasicSecurityScheme extends SecurityScheme {
scheme: "basic";
in?: string;
name?: string;
}
export interface DigestSecurityScheme extends SecurityScheme {
scheme: "digest";
name?: string;
in?: string;
qop?: string;
}
export interface APIKeySecurityScheme extends SecurityScheme {
scheme: "apikey";
in?: string;
name?: string;
}
export interface BearerSecurityScheme extends SecurityScheme {
scheme: "bearer";
in?: string;
alg?: string;
format?: string;
name?: string;
authorization?: string;
}
export interface CertSecurityScheme extends SecurityScheme {
scheme: "cert";
identity?: string;
}
export interface PSKSecurityScheme extends SecurityScheme {
scheme: "psk";
identity?: string;
}
export interface PublicSecurityScheme extends SecurityScheme {
scheme: "public";
identity?: string;
}
export interface PoPSecurityScheme extends SecurityScheme {
scheme: "pop";
format?: string;
authorization?: string;
alg?: string;
name?: string;
in?: string;
}
export interface OAuth2SecurityScheme extends SecurityScheme {
scheme: "oauth2";
authorization?: string;
flow?: string;
token?: string;
refresh?: string;
scopes?: Array<string>;
}
export declare abstract class ThingProperty extends BaseSchema implements ThingInteraction {
observable?: boolean;
type?: string;
forms?: Array<Form>;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security?: Array<string>;
[key: string]: any;
}
export declare abstract class ThingAction implements ThingInteraction {
input?: DataSchema;
output?: DataSchema;
safe?: boolean;
idempotent?: boolean;
forms?: Array<Form>;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security?: Array<string>;
[key: string]: any;
}
export declare abstract class ThingEvent implements ThingInteraction {
subscription?: DataSchema;
data?: DataSchema;
cancellation?: DataSchema;
forms?: Array<Form>;
title?: string;
titles?: MultiLanguage;
description?: string;
descriptions?: MultiLanguage;
scopes?: Array<string>;
uriVariables?: {
[key: string]: DataSchema;
};
security?: Array<string>;
[key: string]: any;
}

@@ -16,8 +16,2 @@ "use strict";

exports.DEFAULT_THING_TYPE = "Thing";
var VersionInfo = (function () {
function VersionInfo() {
}
return VersionInfo;
}());
exports.VersionInfo = VersionInfo;
var Thing = (function () {

@@ -36,8 +30,23 @@ function Thing() {

exports.default = Thing;
var ThingInteraction = (function () {
function ThingInteraction() {
var ExpectedResponse = (function () {
function ExpectedResponse() {
}
return ThingInteraction;
return ExpectedResponse;
}());
exports.ThingInteraction = ThingInteraction;
exports.ExpectedResponse = ExpectedResponse;
var Form = (function () {
function Form(href, contentType) {
this.href = href;
if (contentType)
this.contentType = contentType;
}
return Form;
}());
exports.Form = Form;
var BaseSchema = (function () {
function BaseSchema() {
}
return BaseSchema;
}());
exports.BaseSchema = BaseSchema;
var ThingProperty = (function (_super) {

@@ -49,41 +58,16 @@ __extends(ThingProperty, _super);

return ThingProperty;
}(ThingInteraction));
}(BaseSchema));
exports.ThingProperty = ThingProperty;
var ThingAction = (function (_super) {
__extends(ThingAction, _super);
var ThingAction = (function () {
function ThingAction() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ThingAction;
}(ThingInteraction));
}());
exports.ThingAction = ThingAction;
var ThingEvent = (function (_super) {
__extends(ThingEvent, _super);
var ThingEvent = (function () {
function ThingEvent() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ThingEvent;
}(ThingInteraction));
}());
exports.ThingEvent = ThingEvent;
var Security = (function () {
function Security() {
}
return Security;
}());
exports.Security = Security;
var ExpectedResponse = (function () {
function ExpectedResponse() {
}
return ExpectedResponse;
}());
exports.ExpectedResponse = ExpectedResponse;
var Form = (function () {
function Form(href, contentType) {
this.href = href;
if (contentType)
this.contentType = contentType;
}
return Form;
}());
exports.Form = Form;
//# sourceMappingURL=thing-description.js.map
{
"name": "@node-wot/td-tools",
"version": "0.6.2",
"version": "0.7.0-SNAPSHOT.1",
"description": "W3C Web of Things (WoT) Thing Description parser, serializer, and other tools",

@@ -30,3 +30,3 @@ "author": "Eclipse Thingweb <thingweb-dev@eclipse.org> (https://thingweb.io/)",

"dependencies": {
"wot-typescript-definitions": "0.6.2",
"wot-typescript-definitions": "0.7.0-NEXT-SNAPSHOT.16",
"is-absolute-url": "2.1.0",

@@ -33,0 +33,0 @@ "url-toolkit": "2.1.6"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc