@forge/jira-bridge

0.40.0-next.0-experimental-90651450.40.0-next.1
out/custom-field/getFieldData.js
out/custom-field/getFieldData.js
+28
Index: package/out/custom-field/getFieldData.js
===================================================================
--- package/out/custom-field/getFieldData.js
+++ package/out/custom-field/getFieldData.js
@@ -0,0 +1,28 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.getFieldData = void 0;
+const errors_1 = require("../errors");
+const getCustomFieldInternalAPI_1 = require("./getCustomFieldInternalAPI");
+async function getFieldData(callback) {
+    const { actions: { onFieldDataChange, onBridgeError } } = await (0, getCustomFieldInternalAPI_1.getCustomFieldInternalAPI)();
+    try {
+        if (!callback || typeof callback !== 'function') {
+            throw new Error('getFieldData requires a callback method');
+        }
+        return Promise.resolve(onFieldDataChange((fieldData) => {
+            try {
+                callback(fieldData);
+            }
+            catch (error) {
+                throw new errors_1.AppExecutionError(error);
+            }
+        }));
+    }
+    catch (error) {
+        if (onBridgeError && !(error instanceof errors_1.AppExecutionError)) {
+            onBridgeError({ error: errors_1.ON_FIELD_DATA_CHANGE_ERROR, cause: error });
+        }
+        throw error;
+    }
+}
+exports.getFieldData = getFieldData;