@openxiot/xiot-core-spec-ts 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xiot/core/spec/codec/definition/ActionDefinitionCodec.js +8 -1
- package/dist/xiot/core/spec/codec/definition/DeviceDefinitionCodec.js +8 -1
- package/dist/xiot/core/spec/codec/definition/EventDefinitionCodec.js +8 -1
- package/dist/xiot/core/spec/codec/definition/FormatDefinitionCodec.js +10 -2
- package/dist/xiot/core/spec/codec/definition/NamespaceDefinitionCodec.js +1 -1
- package/dist/xiot/core/spec/codec/definition/PropertyDefinitionCodec.js +6 -0
- package/dist/xiot/core/spec/codec/definition/ServiceDefinitionCodec.js +8 -1
- package/dist/xiot/core/spec/codec/definition/UnitDefinitionCodec.js +10 -2
- package/dist/xiot/core/spec/typedef/constant/Spec.d.ts +1 -0
- package/dist/xiot/core/spec/typedef/constant/Spec.js +1 -0
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ const ActionType_1 = require("../../typedef/definition/urn/ActionType");
|
|
|
6
6
|
const DescriptionCodec_1 = require("./DescriptionCodec");
|
|
7
7
|
const Spec_1 = require("../../typedef/constant/Spec");
|
|
8
8
|
const ArgumentDefinitionCodec_1 = require("./ArgumentDefinitionCodec");
|
|
9
|
+
const Lifecycle_1 = require("@openxiot/xiot-core-spec-ts/xiot/core/spec/typedef/lifecycle/Lifecycle");
|
|
9
10
|
class ActionDefinitionCodec {
|
|
10
11
|
static decodeArray(list) {
|
|
11
12
|
const array = [];
|
|
@@ -15,11 +16,14 @@ class ActionDefinitionCodec {
|
|
|
15
16
|
return array;
|
|
16
17
|
}
|
|
17
18
|
static decode(o) {
|
|
19
|
+
const lifecycle = (0, Lifecycle_1.LifeCycleFromString)(o[Spec_1.Spec.LIFECYCLE]);
|
|
18
20
|
const type = new ActionType_1.ActionType(o[Spec_1.Spec.TYPE]);
|
|
19
21
|
const description = DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]);
|
|
20
22
|
const argumentsIn = ArgumentDefinitionCodec_1.ArgumentDefinitionCodec.decodeArray(o[Spec_1.Spec.IN]);
|
|
21
23
|
const argumentsOut = ArgumentDefinitionCodec_1.ArgumentDefinitionCodec.decodeArray(o[Spec_1.Spec.OUT]);
|
|
22
|
-
|
|
24
|
+
const def = new ActionDefinition_1.ActionDefinition(type, description, argumentsIn, argumentsOut);
|
|
25
|
+
def.lifecycle = lifecycle;
|
|
26
|
+
return def;
|
|
23
27
|
}
|
|
24
28
|
static encode(def) {
|
|
25
29
|
const o = {
|
|
@@ -32,6 +36,9 @@ class ActionDefinitionCodec {
|
|
|
32
36
|
if (def.out.length > 0) {
|
|
33
37
|
o[Spec_1.Spec.OUT] = ArgumentDefinitionCodec_1.ArgumentDefinitionCodec.encodeArray(def.out);
|
|
34
38
|
}
|
|
39
|
+
if (def.lifecycle !== undefined) {
|
|
40
|
+
o[Spec_1.Spec.LIFECYCLE] = def.lifecycle.toString();
|
|
41
|
+
}
|
|
35
42
|
return o;
|
|
36
43
|
}
|
|
37
44
|
static encodeArray(list) {
|
|
@@ -5,6 +5,7 @@ const Spec_1 = require("../../typedef/constant/Spec");
|
|
|
5
5
|
const DeviceDefinition_1 = require("../../typedef/definition/DeviceDefinition");
|
|
6
6
|
const DeviceType_1 = require("../../typedef/definition/urn/DeviceType");
|
|
7
7
|
const DescriptionCodec_1 = require("./DescriptionCodec");
|
|
8
|
+
const Lifecycle_1 = require("@openxiot/xiot-core-spec-ts/xiot/core/spec/typedef/lifecycle/Lifecycle");
|
|
8
9
|
class DeviceDefinitionCodec {
|
|
9
10
|
static decodeArray(list) {
|
|
10
11
|
const array = [];
|
|
@@ -14,10 +15,13 @@ class DeviceDefinitionCodec {
|
|
|
14
15
|
return array;
|
|
15
16
|
}
|
|
16
17
|
static decode(o) {
|
|
18
|
+
const lifecycle = (0, Lifecycle_1.LifeCycleFromString)(o[Spec_1.Spec.LIFECYCLE]);
|
|
17
19
|
const category = o.category;
|
|
18
20
|
const type = new DeviceType_1.DeviceType(o[Spec_1.Spec.TYPE]);
|
|
19
21
|
const description = DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]);
|
|
20
|
-
|
|
22
|
+
const def = new DeviceDefinition_1.DeviceDefinition(category, type, description);
|
|
23
|
+
def.lifecycle = lifecycle;
|
|
24
|
+
return def;
|
|
21
25
|
}
|
|
22
26
|
static encode(def) {
|
|
23
27
|
const o = {
|
|
@@ -27,6 +31,9 @@ class DeviceDefinitionCodec {
|
|
|
27
31
|
if (def.category != null) {
|
|
28
32
|
o.category = def.category;
|
|
29
33
|
}
|
|
34
|
+
if (def.lifecycle !== undefined) {
|
|
35
|
+
o[Spec_1.Spec.LIFECYCLE] = def.lifecycle.toString();
|
|
36
|
+
}
|
|
30
37
|
return o;
|
|
31
38
|
}
|
|
32
39
|
static encodeArray(list) {
|
|
@@ -6,6 +6,7 @@ const EventType_1 = require("../../typedef/definition/urn/EventType");
|
|
|
6
6
|
const DescriptionCodec_1 = require("./DescriptionCodec");
|
|
7
7
|
const ArgumentDefinitionCodec_1 = require("./ArgumentDefinitionCodec");
|
|
8
8
|
const Spec_1 = require("../../typedef/constant/Spec");
|
|
9
|
+
const Lifecycle_1 = require("@openxiot/xiot-core-spec-ts/xiot/core/spec/typedef/lifecycle/Lifecycle");
|
|
9
10
|
class EventDefinitionCodec {
|
|
10
11
|
static decodeArray(list) {
|
|
11
12
|
const array = [];
|
|
@@ -15,10 +16,13 @@ class EventDefinitionCodec {
|
|
|
15
16
|
return array;
|
|
16
17
|
}
|
|
17
18
|
static decode(o) {
|
|
19
|
+
const lifecycle = (0, Lifecycle_1.LifeCycleFromString)(o[Spec_1.Spec.LIFECYCLE]);
|
|
18
20
|
const type = new EventType_1.EventType(o[Spec_1.Spec.TYPE]);
|
|
19
21
|
const description = DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]);
|
|
20
22
|
const list = ArgumentDefinitionCodec_1.ArgumentDefinitionCodec.decodeArray(o[Spec_1.Spec.ARGUMENTS]);
|
|
21
|
-
|
|
23
|
+
const def = new EventDefinition_1.EventDefinition(type, description, list);
|
|
24
|
+
def.lifecycle = lifecycle;
|
|
25
|
+
return def;
|
|
22
26
|
}
|
|
23
27
|
static encode(def) {
|
|
24
28
|
const o = {
|
|
@@ -28,6 +32,9 @@ class EventDefinitionCodec {
|
|
|
28
32
|
if (def.arguments.length > 0) {
|
|
29
33
|
o[Spec_1.Spec.ARGUMENTS] = ArgumentDefinitionCodec_1.ArgumentDefinitionCodec.encodeArray(def.arguments);
|
|
30
34
|
}
|
|
35
|
+
if (def.lifecycle !== undefined) {
|
|
36
|
+
o[Spec_1.Spec.LIFECYCLE] = def.lifecycle.toString();
|
|
37
|
+
}
|
|
31
38
|
return o;
|
|
32
39
|
}
|
|
33
40
|
static encodeArray(list) {
|
|
@@ -5,6 +5,7 @@ const FormatDefinition_1 = require("../../typedef/definition/FormatDefinition");
|
|
|
5
5
|
const FormatType_1 = require("../../typedef/definition/urn/FormatType");
|
|
6
6
|
const DescriptionCodec_1 = require("./DescriptionCodec");
|
|
7
7
|
const Spec_1 = require("../../typedef/constant/Spec");
|
|
8
|
+
const Lifecycle_1 = require("@openxiot/xiot-core-spec-ts/xiot/core/spec/typedef/lifecycle/Lifecycle");
|
|
8
9
|
class FormatDefinitionCodec {
|
|
9
10
|
static decodeArray(list) {
|
|
10
11
|
const array = [];
|
|
@@ -16,14 +17,21 @@ class FormatDefinitionCodec {
|
|
|
16
17
|
return array;
|
|
17
18
|
}
|
|
18
19
|
static decode(o) {
|
|
20
|
+
const lifecycle = (0, Lifecycle_1.LifeCycleFromString)(o[Spec_1.Spec.LIFECYCLE]);
|
|
19
21
|
const type = FormatType_1.FormatType.parse(o[Spec_1.Spec.TYPE] || '');
|
|
20
|
-
|
|
22
|
+
const def = new FormatDefinition_1.FormatDefinition(type, DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]));
|
|
23
|
+
def.lifecycle = lifecycle;
|
|
24
|
+
return def;
|
|
21
25
|
}
|
|
22
26
|
static encode(def) {
|
|
23
|
-
|
|
27
|
+
const o = {
|
|
24
28
|
type: def.type.toString(),
|
|
25
29
|
description: DescriptionCodec_1.DescriptionCodec.encode(def.description)
|
|
26
30
|
};
|
|
31
|
+
if (def.lifecycle !== undefined) {
|
|
32
|
+
o[Spec_1.Spec.LIFECYCLE] = def.lifecycle.toString();
|
|
33
|
+
}
|
|
34
|
+
return o;
|
|
27
35
|
}
|
|
28
36
|
static encodeArray(list) {
|
|
29
37
|
return list.map(x => {
|
|
@@ -29,7 +29,7 @@ class NamespaceDefinitionCodec {
|
|
|
29
29
|
description: DescriptionCodec_1.DescriptionCodec.encode(def.description),
|
|
30
30
|
organization: def.organization
|
|
31
31
|
};
|
|
32
|
-
if (def.visibility
|
|
32
|
+
if (def.visibility !== Visibility_1.Visibility.UNDEFINED) {
|
|
33
33
|
o[Spec_1.Spec.VISIBILITY] = def.visibility;
|
|
34
34
|
}
|
|
35
35
|
return o;
|
|
@@ -12,6 +12,7 @@ const ValueRangeCodec_1 = require("./ValueRangeCodec");
|
|
|
12
12
|
const ValueList_1 = require("../../typedef/definition/property/ValueList");
|
|
13
13
|
const ValueRange_1 = require("../../typedef/definition/property/ValueRange");
|
|
14
14
|
const PropertyTypeCodec_1 = require("./type/PropertyTypeCodec");
|
|
15
|
+
const Lifecycle_1 = require("@openxiot/xiot-core-spec-ts/xiot/core/spec/typedef/lifecycle/Lifecycle");
|
|
15
16
|
class PropertyDefinitionCodec {
|
|
16
17
|
static decodeMembers(array) {
|
|
17
18
|
const list = [];
|
|
@@ -35,9 +36,11 @@ class PropertyDefinitionCodec {
|
|
|
35
36
|
return array;
|
|
36
37
|
}
|
|
37
38
|
static decode(o) {
|
|
39
|
+
const lifecycle = (0, Lifecycle_1.LifeCycleFromString)(o[Spec_1.Spec.LIFECYCLE]);
|
|
38
40
|
const type = new PropertyType_1.PropertyType(o[Spec_1.Spec.TYPE]);
|
|
39
41
|
const description = DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]);
|
|
40
42
|
const def = new PropertyDefinition_1.PropertyDefinition(type, description);
|
|
43
|
+
def.lifecycle = lifecycle;
|
|
41
44
|
def.format = (0, DataFormat_1.DataFormatFromString)(o[Spec_1.Spec.FORMAT]);
|
|
42
45
|
def.access = Access_1.Access.create(o[Spec_1.Spec.ACCESS]);
|
|
43
46
|
def.unit = o[Spec_1.Spec.UNIT];
|
|
@@ -84,6 +87,9 @@ class PropertyDefinitionCodec {
|
|
|
84
87
|
o[Spec_1.Spec.MEMBERS] = def.members;
|
|
85
88
|
}
|
|
86
89
|
}
|
|
90
|
+
if (def.lifecycle !== undefined) {
|
|
91
|
+
o[Spec_1.Spec.LIFECYCLE] = def.lifecycle.toString();
|
|
92
|
+
}
|
|
87
93
|
return o;
|
|
88
94
|
}
|
|
89
95
|
static encodeArray(list) {
|
|
@@ -8,6 +8,7 @@ const PropertyTypeCodec_1 = require("./type/PropertyTypeCodec");
|
|
|
8
8
|
const ActionTypeCodec_1 = require("./type/ActionTypeCodec");
|
|
9
9
|
const EventTypeCodec_1 = require("./type/EventTypeCodec");
|
|
10
10
|
const Spec_1 = require("../../typedef/constant/Spec");
|
|
11
|
+
const Lifecycle_1 = require("@openxiot/xiot-core-spec-ts/xiot/core/spec/typedef/lifecycle/Lifecycle");
|
|
11
12
|
class ServiceDefinitionCodec {
|
|
12
13
|
static decodeArray(list) {
|
|
13
14
|
const array = [];
|
|
@@ -17,6 +18,7 @@ class ServiceDefinitionCodec {
|
|
|
17
18
|
return array;
|
|
18
19
|
}
|
|
19
20
|
static decode(o) {
|
|
21
|
+
const lifecycle = (0, Lifecycle_1.LifeCycleFromString)(o[Spec_1.Spec.LIFECYCLE]);
|
|
20
22
|
const type = new ServiceType_1.ServiceType(o[Spec_1.Spec.TYPE]);
|
|
21
23
|
const description = DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]);
|
|
22
24
|
const requiredProperties = PropertyTypeCodec_1.PropertyTypeCodec.decodeArray(o[Spec_1.Spec.REQUIRED_PROPERTIES]);
|
|
@@ -35,7 +37,9 @@ class ServiceDefinitionCodec {
|
|
|
35
37
|
type._action_addable = true;
|
|
36
38
|
type._event_addable = true;
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
const def = new ServiceDefinition_1.ServiceDefinition(type, description, requiredProperties, optionalProperties, requiredActions, optionalActions, requiredEvents, optionalEvents);
|
|
41
|
+
def.lifecycle = lifecycle;
|
|
42
|
+
return def;
|
|
39
43
|
}
|
|
40
44
|
static encode(def) {
|
|
41
45
|
const o = {
|
|
@@ -60,6 +64,9 @@ class ServiceDefinitionCodec {
|
|
|
60
64
|
if (def.optionalEvents.length > 0) {
|
|
61
65
|
o[Spec_1.Spec.OPTIONAL_EVENTS] = EventTypeCodec_1.EventTypeCodec.encodeArray(def.optionalEvents);
|
|
62
66
|
}
|
|
67
|
+
if (def.lifecycle !== undefined) {
|
|
68
|
+
o[Spec_1.Spec.LIFECYCLE] = def.lifecycle.toString();
|
|
69
|
+
}
|
|
63
70
|
return o;
|
|
64
71
|
}
|
|
65
72
|
static encodeArray(list) {
|
|
@@ -5,6 +5,7 @@ const Spec_1 = require("../../typedef/constant/Spec");
|
|
|
5
5
|
const UnitDefinition_1 = require("../../typedef/definition/UnitDefinition");
|
|
6
6
|
const UnitType_1 = require("../../typedef/definition/urn/UnitType");
|
|
7
7
|
const DescriptionCodec_1 = require("./DescriptionCodec");
|
|
8
|
+
const Lifecycle_1 = require("@openxiot/xiot-core-spec-ts/xiot/core/spec/typedef/lifecycle/Lifecycle");
|
|
8
9
|
class UnitDefinitionCodec {
|
|
9
10
|
static decodeArray(list) {
|
|
10
11
|
const array = [];
|
|
@@ -16,14 +17,21 @@ class UnitDefinitionCodec {
|
|
|
16
17
|
return array;
|
|
17
18
|
}
|
|
18
19
|
static decode(o) {
|
|
20
|
+
const lifecycle = (0, Lifecycle_1.LifeCycleFromString)(o[Spec_1.Spec.LIFECYCLE]);
|
|
19
21
|
const type = UnitType_1.UnitType.parse(o[Spec_1.Spec.TYPE] || '');
|
|
20
|
-
|
|
22
|
+
const def = new UnitDefinition_1.UnitDefinition(type, DescriptionCodec_1.DescriptionCodec.decode(o[Spec_1.Spec.DESCRIPTION]));
|
|
23
|
+
def.lifecycle = lifecycle;
|
|
24
|
+
return def;
|
|
21
25
|
}
|
|
22
26
|
static encode(def) {
|
|
23
|
-
|
|
27
|
+
const o = {
|
|
24
28
|
type: def.type.toString(),
|
|
25
29
|
description: DescriptionCodec_1.DescriptionCodec.encode(def.description)
|
|
26
30
|
};
|
|
31
|
+
if (def.lifecycle !== undefined) {
|
|
32
|
+
o[Spec_1.Spec.LIFECYCLE] = def.lifecycle.toString();
|
|
33
|
+
}
|
|
34
|
+
return o;
|
|
27
35
|
}
|
|
28
36
|
static encodeArray(list) {
|
|
29
37
|
return list.map(x => {
|