From 0cb6c0ce635918cd7f73bb22c924d432dfcab647 Mon Sep 17 00:00:00 2001
From: Marin Karamihalev <marin.karamihalev@iopsys.eu>
Date: Fri, 10 Nov 2023 11:21:13 +0000
Subject: [PATCH] Add persist and enable options to subscribe

---
 package.json                      | 2 +-
 src/commands/recipes/subscribe.ts | 6 +++---
 src/types.ts                      | 2 ++
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/package.json b/package.json
index e3468a1..f9d690e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "usp-js",
-  "version": "0.4.7",
+  "version": "0.4.8",
   "description": "Library for easy usp(TR-369) communication using mqtt or ws.",
   "main": "node/index.js",
   "browser": "web/index.js",
diff --git a/src/commands/recipes/subscribe.ts b/src/commands/recipes/subscribe.ts
index 9635838..346e348 100644
--- a/src/commands/recipes/subscribe.ts
+++ b/src/commands/recipes/subscribe.ts
@@ -14,12 +14,12 @@ const make: MakeFn =
     const newSubPath = await call("ADD", {
       path: subscriptionPath,
       value: {
-        Enable: true,
+        Enable: opts.enable ?? true,
         ID: id,
         NotifType: opts.notif,
-        NotifRetry: "retry" in opts ? opts.retry : true,
+        NotifRetry: opts.retry ?? true,
         ReferenceList: refList,
-        Persistent: false,
+        Persistent: opts.persist ?? false,
       },
     });
 
diff --git a/src/types.ts b/src/types.ts
index a1efb7a..6bf2d6d 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -693,6 +693,8 @@ export interface SubscriptionOptions {
   notif: NotifType;
   retry?: boolean;
   reference: string | string[];
+  persist?: boolean;
+  enable?: boolean;
 }
 
 export type SubscriptionCallback = (
-- 
GitLab