npm package diff

Package: @forge/storage

Versions: 1.5.15-experimental-f6dcf26 - 1.5.15-experimental-204139e

File: package/out/kvs-transaction-api.js

Index: package/out/kvs-transaction-api.js
===================================================================
--- package/out/kvs-transaction-api.js
+++ package/out/kvs-transaction-api.js
@@ -0,0 +1,30 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.KVSTransactionBuilder = void 0;
+class KVSTransactionBuilder {
+    globalStorage;
+    transactionOptions;
+    constructor(globalStorage, transactionOptions = {}) {
+        this.globalStorage = globalStorage;
+        this.transactionOptions = transactionOptions;
+    }
+    set(key, value) {
+        return new KVSTransactionBuilder(this.globalStorage, {
+            set: [...(this.transactionOptions.set || []), { key, value }],
+            delete: [...(this.transactionOptions.delete || [])]
+        });
+    }
+    delete(key) {
+        return new KVSTransactionBuilder(this.globalStorage, {
+            set: [...(this.transactionOptions.set || [])],
+            delete: [...(this.transactionOptions.delete || []), { key }]
+        });
+    }
+    async execute() {
+        if (!this.transactionOptions.delete?.length && !this.transactionOptions.set?.length) {
+            throw new Error('Nothing to execute');
+        }
+        await this.globalStorage.transaction(this.transactionOptions);
+    }
+}
+exports.KVSTransactionBuilder = KVSTransactionBuilder;