Skip to content

Commit 8fb41b8

Browse files
committed
feat: Add patch property to device configs
1 parent 57b01a6 commit 8fb41b8

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/endpoint/presentation.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ import {
1212
CapabilityAutomationAction} from './capabilities'
1313

1414

15+
export enum PatchItemOpEnum {
16+
ADD = 'add',
17+
REPLACE = 'replace',
18+
REMOVE = 'remove'
19+
}
20+
export interface PatchItem {
21+
/**
22+
* Operation objects MUST have exactly one \"op\" member, whose value indicates the operation to perform
23+
*/
24+
op: PatchItemOpEnum
25+
26+
/**
27+
* path specifies a string format for identifying a specific value within a JSON document. It is used by all operations in patch to specify the part of the document to operate on.
28+
*/
29+
path: string
30+
31+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
32+
value?: any
33+
}
34+
1535
export interface PresentationDeviceConfigEntry {
1636
component: string
1737
capability: string
@@ -34,6 +54,7 @@ export interface PresentationDeviceConfigEntry {
3454
*/
3555
step?: number
3656
}[]
57+
patch?: PatchItem[]
3758
visibleCondition?: CapabilityVisibleCondition
3859
}
3960

test/unit/data/presentation/presentation.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
CapabilityPresentationOperator,
33
CapabilityVisibleCondition,
4+
PatchItemOpEnum,
45
PresentationDeviceConfig,
56
PresentationDeviceConfigEntry,
67
PresentationDPInfo,
@@ -24,6 +25,9 @@ const data = {
2425
'values': [
2526
{ 'key': 'keyName' },
2627
],
28+
'patch': [
29+
{'op': PatchItemOpEnum.REPLACE, 'path': '/0/main/1/value', 'value': 'New Value'},
30+
],
2731
'visibleCondition': {
2832
'component': 'component',
2933
'version': 1,
@@ -41,6 +45,9 @@ const data = {
4145
'values': [
4246
{ 'key': 'keyName' },
4347
],
48+
'patch': [
49+
{'op': PatchItemOpEnum.REPLACE, 'path': '/0/main/1/value', 'value': 'New Value'},
50+
],
4451
'visibleCondition': {
4552
'component': 'component',
4653
'version': 1,
@@ -59,6 +66,9 @@ const data = {
5966
'values': [
6067
{ 'key': 'keyName' },
6168
],
69+
'patch': [
70+
{'op': PatchItemOpEnum.REPLACE, 'path': '/0/main/1/value', 'value': 'New Value'},
71+
],
6272
'visibleCondition': {
6373
'component': 'component',
6474
'version': 1,
@@ -77,6 +87,9 @@ const data = {
7787
'values': [
7888
{ 'key': 'keyName' },
7989
],
90+
'patch': [
91+
{'op': PatchItemOpEnum.REPLACE, 'path': '/0/main/1/value', 'value': 'New Value'},
92+
],
8093
'visibleCondition': {
8194
'component': 'component',
8295
'version': 1,
@@ -94,6 +107,9 @@ const data = {
94107
'values': [
95108
{ 'key': 'keyName' },
96109
],
110+
'patch': [
111+
{'op': PatchItemOpEnum.REPLACE, 'path': '/0/main/1/value', 'value': 'New Value'},
112+
],
97113
'visibleCondition': {
98114
'component': 'component',
99115
'version': 1,

0 commit comments

Comments
 (0)