npm package diff
Package: @forge/jira-bridge
Versions: 0.34.1-next.0 - 0.34.1-next.1
File: package/out/ui-modifications/onChange.js
Index: package/out/ui-modifications/onChange.js
===================================================================
--- package/out/ui-modifications/onChange.js
+++ package/out/ui-modifications/onChange.js
@@ -1,56 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.onChange = void 0;
-const tslib_1 = require("tslib");
const apiBuilder_1 = require("./apiBuilder");
const featureFlags_1 = require("./featureFlags");
const getInternalAPI_1 = require("./getInternalAPI");
const errors_1 = require("../errors");
-function onChange(onChangeCallback, registerOnChangeFieldsCallback) {
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
- const { data: { featureFlags }, actions: { submit, registerFields, subscribeToChanges, onBridgeError } } = yield (0, getInternalAPI_1.getInternalAPI)();
- return subscribeToChanges(({ changedFieldId, changeId, currentFormState, currentScreenTabsState = [], uiModifications }) => tslib_1.__awaiter(this, void 0, void 0, function* () {
+async function onChange(onChangeCallback, registerOnChangeFieldsCallback) {
+ const { data: { featureFlags }, actions: { submit, registerFields, subscribeToChanges, onBridgeError } } = await (0, getInternalAPI_1.getInternalAPI)();
+ return subscribeToChanges(async ({ changedFieldId, changeId, currentFormState, currentScreenTabsState = [], uiModifications }) => {
+ try {
+ const builder = new apiBuilder_1.ApiBuilder(currentFormState, currentScreenTabsState, featureFlags);
+ const api = builder.build();
+ const fieldChange = {
+ current: api.getFieldById(changedFieldId)
+ };
+ let fieldsDeclared;
+ const payload = {
+ fieldsChanges: {},
+ screenTabsChanges: [],
+ changeId
+ };
try {
- const builder = new apiBuilder_1.ApiBuilder(currentFormState, currentScreenTabsState, featureFlags);
- const api = builder.build();
- const fieldChange = {
- current: api.getFieldById(changedFieldId)
- };
- let fieldsDeclared;
- const payload = {
- fieldsChanges: {},
- screenTabsChanges: [],
- changeId
- };
- try {
- fieldsDeclared = registerOnChangeFieldsCallback({ uiModifications, change: fieldChange });
- }
- catch (error) {
- void submit(payload);
- throw new errors_1.AppExecutionError(error);
- }
- void registerFields({ fields: fieldsDeclared, changeId: changeId });
- try {
- yield onChangeCallback({ uiModifications, change: fieldChange, api });
- }
- catch (error) {
- void submit(payload);
- throw new errors_1.AppExecutionError(error);
- }
- const buffer = builder.getBuffer();
- return submit({
- fieldsChanges: buffer.getFormChanges(),
- screenTabsChanges: (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags[featureFlags_1.SCREEN_TABS_SUPPORT]) ? buffer.getScreenTabsChanges() : [],
- changeId
- });
+ fieldsDeclared = registerOnChangeFieldsCallback({ uiModifications, change: fieldChange });
}
catch (error) {
- if (onBridgeError && !(error instanceof errors_1.AppExecutionError)) {
- onBridgeError({ error: errors_1.SUBSCRIBE_TO_CHANGES_ERROR, changeId });
- }
- throw error;
+ void submit(payload);
+ throw new errors_1.AppExecutionError(error);
}
- }));
+ void registerFields({ fields: fieldsDeclared, changeId: changeId });
+ try {
+ await onChangeCallback({ uiModifications, change: fieldChange, api });
+ }
+ catch (error) {
+ void submit(payload);
+ throw new errors_1.AppExecutionError(error);
+ }
+ const buffer = builder.getBuffer();
+ return submit({
+ fieldsChanges: buffer.getFormChanges(),
+ screenTabsChanges: (featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags[featureFlags_1.SCREEN_TABS_SUPPORT]) ? buffer.getScreenTabsChanges() : [],
+ changeId
+ });
+ }
+ catch (error) {
+ if (onBridgeError && !(error instanceof errors_1.AppExecutionError)) {
+ onBridgeError({ error: errors_1.SUBSCRIBE_TO_CHANGES_ERROR, changeId });
+ }
+ throw error;
+ }
});
}
exports.onChange = onChange;