npm package diff
Package: @forge/react
Versions: 10.10.2-next.0-experimental-d6acbbd - 10.10.3-next.0
File: package/out/hooks/confluenceEntity.js
Index: package/out/hooks/confluenceEntity.js
===================================================================
--- package/out/hooks/confluenceEntity.js
+++ package/out/hooks/confluenceEntity.js
@@ -68,32 +68,28 @@
const url = endpointFactory.delete(propertyId);
const response = await (0, apiRequestUtils_1.makeRequest)({ url, apiMethod, method: 'DELETE' });
(0, apiRequestUtils_1.assertSuccessfulResponse)({ entityType, propertyKey, operation: 'delete', response });
};
- const get = async ({ endpointFactory, propertyKey }) => {
+ const getProp = async ({ endpointFactory, propertyKey }) => {
const existingProp = await fetchOriginal({ endpointFactory, propertyKey });
if (existingProp) {
- return existingProp.value;
+ return existingProp;
}
// if property doesn't exist, create it
const resolvedInitVal = await (0, valueUtils_1.resolveValue)(initValue);
const url = endpointFactory.create();
const body = JSON.stringify({ key: propertyKey, value: resolvedInitVal });
const response = await (0, apiRequestUtils_1.makeRequest)({ url, apiMethod, method: 'POST', body });
(0, apiRequestUtils_1.assertSuccessfulResponse)({ entityType, propertyKey, operation: 'create', response });
- return (await (0, apiRequestUtils_1.getJSONData)(response)).value;
+ return await (0, apiRequestUtils_1.getJSONData)(response);
};
+ const get = async ({ endpointFactory, propertyKey }) => {
+ const propData = await getProp({ endpointFactory, propertyKey });
+ return propData.value;
+ };
const update = async ({ endpointFactory, propertyKey }, valueUpdate) => {
// fetch original prop first to update based on its value + version + id
- const originalProp = await fetchOriginal({ endpointFactory, propertyKey });
- if (!originalProp) {
- throw new types_1.EntityPropertyRequestFailedError({
- entityType,
- propertyKey,
- operation: 'update',
- status: 404
- });
- }
+ const originalProp = await getProp({ endpointFactory, propertyKey });
const newValue = valueUpdate instanceof Function ? valueUpdate(originalProp.value) : valueUpdate;
const propertyId = originalProp.id;
const origVersion = originalProp?.version?.number;
const url = endpointFactory.update(propertyId);