Skip to content

Commit

Permalink
expose thing definition
Browse files Browse the repository at this point in the history
Signed-off-by: Dirk Van Haerenborgh <dirk.vanhaerenborgh@aloxy.io>
  • Loading branch information
vhdirk committed Feb 5, 2021
1 parent d1536f6 commit b987ba9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions javascript/lib/api/src/model/things.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class Thing extends EntityWithId {
private readonly _features?: Features,
private readonly __revision?: number,
private readonly __modified?: string,
private readonly _acl?: Acl) {
private readonly _acl?: Acl,
private readonly _definition?: string) {
super();
}

Expand All @@ -43,7 +44,8 @@ export class Thing extends EntityWithId {
// @ts-ignore
return new Thing(o['thingId'], o['policyId'], o['attributes'],
// @ts-ignore
Features.fromObject(o['features']), o['_revision'], o['_modified'], Acl.fromObject(o['acl']));
Features.fromObject(o['features']), o['_revision'], o['_modified'], Acl.fromObject(o['acl']),
o['definition']);
}

public static empty(): Thing {
Expand All @@ -60,7 +62,8 @@ export class Thing extends EntityWithId {
['features', featuresObj],
['_revision', this._revision],
['_modified', this._modified],
['acl', aclObj]
['acl', aclObj],
['definition', this._definition]
]));
}

Expand Down Expand Up @@ -104,6 +107,10 @@ export class Thing extends EntityWithId {
return this.separateNamespaceAndThingId().name;
}

get definition(): string | undefined {
return this._definition;
}

private separateNamespaceAndThingId(): { namespace: string, name: string } {
const indexOfFirstColon = this.thingId.indexOf(':');
if (indexOfFirstColon >= 0) {
Expand Down

0 comments on commit b987ba9

Please sign in to comment.