npm package diff

Package: @forge/storage

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

File: package/out/transaction-api.js

Index: package/out/transaction-api.js
===================================================================
--- package/out/transaction-api.js
+++ package/out/transaction-api.js
@@ -0,0 +1,32 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.DefaultTransactionBuilder = void 0;
+const custom_entity_transaction_api_1 = require("./entity-storage/custom-entity-transaction-api");
+const kvs_transaction_api_1 = require("./kvs-transaction-api");
+class DefaultTransactionBuilder {
+    globalStorage;
+    transactionOptions;
+    constructor(globalStorage, transactionOptions = {}) {
+        this.globalStorage = globalStorage;
+        this.transactionOptions = transactionOptions;
+    }
+    entity(name) {
+        if (this.transactionOptions.delete?.length || this.transactionOptions.set?.length) {
+            throw new Error('Cannot set transaction for Custom entities and KVS at the same time');
+        }
+        return new custom_entity_transaction_api_1.DefaultCustomEntityTransactionBuilder(this.globalStorage, name, {});
+    }
+    set(key, value) {
+        return new kvs_transaction_api_1.KVSTransactionBuilder(this.globalStorage, {
+            set: [...(this.transactionOptions.set || []), { key, value }],
+            delete: [...(this.transactionOptions.delete || [])]
+        });
+    }
+    delete(key) {
+        return new kvs_transaction_api_1.KVSTransactionBuilder(this.globalStorage, {
+            set: [...(this.transactionOptions.set || [])],
+            delete: [...(this.transactionOptions.delete || []), { key }]
+        });
+    }
+}
+exports.DefaultTransactionBuilder = DefaultTransactionBuilder;