🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@forge/react

Package Overview
Dependencies
Maintainers
2
Versions
429
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/react - npm Package Compare versions

Comparing version
9.2.0-next.3
to
9.2.0-next.4
+8
-0
CHANGELOG.md
# @forge/react
## 9.2.0-next.4
### Minor Changes
- c242040: fixes & improvements to property hooks:
- useIssueProperty: fix comments, optimise concrete value update, remove update auto-retries
- useIssueProperty, useSpaceProperty, useContentProperty: handle concurrent create attempts by having failed attempt re-fetch property
## 9.2.0-next.3

@@ -4,0 +12,0 @@

+12
-11

@@ -31,4 +31,5 @@ "use strict";

it('should throw an error if spaceId not available', () => {
expect(() => (0, confluenceEntity_1.confAPIEndpoints)({ entityType: 'Space', context: { extension: {} } })).toThrow('Space properties not available for this app.');
expect(() => (0, confluenceEntity_1.confAPIEndpoints)({ entityType: 'Content', context: { extension: {} } })).toThrow('Content properties not available for this app.');
const emptyContext = { localId: '', extension: {} };
expect(() => (0, confluenceEntity_1.confAPIEndpoints)({ entityType: 'Space', context: emptyContext })).toThrow('Space properties not available for this app.');
expect(() => (0, confluenceEntity_1.confAPIEndpoints)({ entityType: 'Content', context: emptyContext })).toThrow('Content properties not available for this app.');
});

@@ -49,3 +50,3 @@ });

it('should make a GET request with the right URL', async () => {
const contentGetUrl = contentEndpoints.fetch('forge-undefined-MOCK_PROP_KEY');
const contentGetUrl = contentEndpoints.fetch('forge-MOCK_LOCAL_ID-MOCK_PROP_KEY');
const contentGetBody = expect.objectContaining({ method: 'GET' });

@@ -62,3 +63,3 @@ await contentEntity.get();

mockRequestConf.mockResolvedValueOnce(mockPropertyHook_1.mockFailedRes);
await expect(contentEntity.get).rejects.toThrow(`The request to fetch the content property (forge-undefined-MOCK_PROP_KEY) failed with status (400).`);
await expect(contentEntity.get).rejects.toThrow(`The request to fetch the content property (forge-MOCK_LOCAL_ID-MOCK_PROP_KEY) failed with status (400).`);
});

@@ -73,3 +74,3 @@ describe('if the property does not exist, it should create it', () => {

method: 'POST',
body: JSON.stringify({ key: 'forge-undefined-MOCK_PROP_KEY', value: mockPropertyHook_1.DEFAULT_PROP_VALUE })
body: JSON.stringify({ key: 'forge-MOCK_LOCAL_ID-MOCK_PROP_KEY', value: mockPropertyHook_1.DEFAULT_PROP_VALUE })
});

@@ -87,3 +88,3 @@ await contentEntity.get();

mockRequestConf.mockResolvedValueOnce(mockPropertyHook_1.mockConfGetNonExistentRes).mockResolvedValueOnce(mockPropertyHook_1.mockFailedRes);
await expect(contentEntity.get).rejects.toThrow(`The request to create the content property (forge-undefined-MOCK_PROP_KEY) failed with status (400).`);
await expect(contentEntity.get).rejects.toThrow(`The request to create the content property (forge-MOCK_LOCAL_ID-MOCK_PROP_KEY) failed with status (400).`);
});

@@ -97,3 +98,3 @@ });

it('should fetch the original property, then make a PUT request with the right url and body', async () => {
const contentGetUrl = contentEndpoints.fetch('forge-undefined-MOCK_PROP_KEY');
const contentGetUrl = contentEndpoints.fetch('forge-MOCK_LOCAL_ID-MOCK_PROP_KEY');
const contentGetBody = expect.objectContaining({ method: 'GET' });

@@ -113,3 +114,3 @@ const contentPutUrl = contentEndpoints.update('MOCK_PROP_ID');

});
it('should return the value of the UPDATED_PROP_VALUE property when updating with solid value', async () => {
it('should return the value of the UPDATED_PROP_VALUE property when updating with concrete value', async () => {
const valUpdate = await contentEntity.update(mockPropertyHook_1.UPDATED_PROP_VALUE);

@@ -131,3 +132,3 @@ expect(valUpdate).toEqual(mockPropertyHook_1.UPDATED_PROP_VALUE);

mockRequestConf.mockResolvedValueOnce(mockPropertyHook_1.mockConfGetExistingRes).mockResolvedValueOnce(mockPropertyHook_1.mockFailedRes);
await expect(() => contentEntity.update(mockPropertyHook_1.UPDATED_PROP_VALUE)).rejects.toThrow(`The request to update the content property (forge-undefined-MOCK_PROP_KEY) failed with status (400).`);
await expect(() => contentEntity.update(mockPropertyHook_1.UPDATED_PROP_VALUE)).rejects.toThrow(`The request to update the content property (forge-MOCK_LOCAL_ID-MOCK_PROP_KEY) failed with status (400).`);
});

@@ -140,3 +141,3 @@ });

it('should fetch the original property, then make a DELETE request with the right url', async () => {
const contentGetUrl = contentEndpoints.fetch('forge-undefined-MOCK_PROP_KEY');
const contentGetUrl = contentEndpoints.fetch('forge-MOCK_LOCAL_ID-MOCK_PROP_KEY');
const contentGetBody = expect.objectContaining({ method: 'GET' });

@@ -154,5 +155,5 @@ const contentDeleteUrl = contentEndpoints.delete('MOCK_PROP_ID');

mockRequestConf.mockResolvedValueOnce(mockPropertyHook_1.mockConfGetExistingRes).mockResolvedValueOnce(mockPropertyHook_1.mockFailedRes);
await expect(contentEntity.delete).rejects.toThrow(`The request to delete the content property (forge-undefined-MOCK_PROP_KEY) failed with status (400).`);
await expect(contentEntity.delete).rejects.toThrow(`The request to delete the content property (forge-MOCK_LOCAL_ID-MOCK_PROP_KEY) failed with status (400).`);
});
});
});

@@ -26,3 +26,4 @@ "use strict";

it('should throw an error if issueId not available', () => {
expect(() => (0, jiraEntity_1.issueAPIEndpoints)({ extension: {} })).toThrow('Issue properties not available for this app.');
const emptyContext = { localId: '', extension: {} };
expect(() => (0, jiraEntity_1.issueAPIEndpoints)(emptyContext)).toThrow('Issue properties not available for this app.');
});

@@ -89,19 +90,18 @@ });

});
it('should fetch the original property, then make a PUT request with the right url and body', async () => {
const issueGetUrl = issueEndpoints.fetch('forge-MOCK_PROP_KEY');
const issueGetBody = expect.objectContaining({ method: 'GET' });
const issuePutUrl = issueEndpoints.update('forge-MOCK_PROP_KEY');
const issuePutBody = expect.objectContaining({
body: JSON.stringify(mockPropertyHook_1.UPDATED_PROP_VALUE)
describe('when updating with a concrete value', () => {
it('should make a PUT request with the right url and body', async () => {
const issuePutUrl = issueEndpoints.update('forge-MOCK_PROP_KEY');
const issuePutBody = expect.objectContaining({
body: JSON.stringify(mockPropertyHook_1.UPDATED_PROP_VALUE)
});
await issueProps.update(mockPropertyHook_1.UPDATED_PROP_VALUE);
expect(mockRequestJira).toHaveBeenCalledTimes(1);
expect(mockRequestJira).toHaveBeenNthCalledWith(1, issuePutUrl, issuePutBody);
});
await issueProps.update(mockPropertyHook_1.UPDATED_PROP_VALUE);
expect(mockRequestJira).toHaveBeenCalledTimes(2);
expect(mockRequestJira).toHaveBeenNthCalledWith(1, issueGetUrl, issueGetBody);
expect(mockRequestJira).toHaveBeenNthCalledWith(2, issuePutUrl, issuePutBody);
it('should return the value of the UPDATED_PROP_VALUE property when updating with concrete value', async () => {
const valUpdate = await issueProps.update(mockPropertyHook_1.UPDATED_PROP_VALUE);
expect(valUpdate).toEqual(mockPropertyHook_1.UPDATED_PROP_VALUE);
});
});
it('should return the value of the UPDATED_PROP_VALUE property when updating with solid value', async () => {
const valUpdate = await issueProps.update(mockPropertyHook_1.UPDATED_PROP_VALUE);
expect(valUpdate).toEqual(mockPropertyHook_1.UPDATED_PROP_VALUE);
});
it('should return the value of the UPDATED_PROP_VALUE property when updating with setter function', async () => {
describe('when updating with a setter function', () => {
const updateCBFunc = (existingVal) => {

@@ -111,8 +111,22 @@ return existingVal * mockPropertyHook_1.UPDATED_PROP_VALUE;

const expectedResult = mockPropertyHook_1.EXISTING_PROP_VALUE * mockPropertyHook_1.UPDATED_PROP_VALUE;
const funcUpdate = await issueProps.update(updateCBFunc);
expect(funcUpdate).toEqual(expectedResult);
it('should fetch the original property, then make a PUT request with the right url and body', async () => {
const issueGetUrl = issueEndpoints.fetch('forge-MOCK_PROP_KEY');
const issueGetBody = expect.objectContaining({ method: 'GET' });
const issuePutUrl = issueEndpoints.update('forge-MOCK_PROP_KEY');
const issuePutBody = expect.objectContaining({
body: JSON.stringify(updateCBFunc(mockPropertyHook_1.EXISTING_PROP_VALUE))
});
await issueProps.update(updateCBFunc);
expect(mockRequestJira).toHaveBeenCalledTimes(2);
expect(mockRequestJira).toHaveBeenNthCalledWith(1, issueGetUrl, issueGetBody);
expect(mockRequestJira).toHaveBeenNthCalledWith(2, issuePutUrl, issuePutBody);
});
it('should return the value of the UPDATED_PROP_VALUE property when updating with setter function', async () => {
const funcUpdate = await issueProps.update(updateCBFunc);
expect(funcUpdate).toEqual(expectedResult);
});
});
it('should throw an error if the PUT request fails', async () => {
mockRequestJira.mockReset();
mockRequestJira.mockResolvedValueOnce(mockPropertyHook_1.mockJiraGetExistingRes).mockResolvedValueOnce(mockPropertyHook_1.mockFailedRes);
mockRequestJira.mockResolvedValue(mockPropertyHook_1.mockFailedRes);
await expect(() => issueProps.update(mockPropertyHook_1.UPDATED_PROP_VALUE)).rejects.toThrow(`The request to update the issue property (forge-MOCK_PROP_KEY) failed with status (400).`);

@@ -119,0 +133,0 @@ });

@@ -1,2 +0,2 @@

import { EntityContext } from '../types';
import type { EntityContext } from '../types';
export declare const DEFAULT_PROP_VALUE: number, EXISTING_PROP_VALUE: number, UPDATED_PROP_VALUE: number;

@@ -3,0 +3,0 @@ export declare const mockConfContext: EntityContext;

@@ -1,1 +0,1 @@

{"version":3,"file":"mockPropertyHook.d.ts","sourceRoot":"","sources":["../../../src/hooks/__test__/mockPropertyHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,eAAO,MAAO,kBAAkB,UAAE,mBAAmB,UAAE,kBAAkB,QAAa,CAAC;AAEvF,eAAO,MAAM,eAAe,EAAE,aAS7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,aAM7B,CAAC;AAKF,eAAO,MAAM,aAAa;;;CAGzB,CAAC;AACF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;CAMlC,CAAC;AACF,eAAO,MAAM,yBAAyB;;;;;;CAMrC,CAAC;AACF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AACF,eAAO,MAAM,sBAAsB;;;;;;;CAIlC,CAAC;AACF,eAAO,MAAM,yBAAyB;;;;;;;CAIrC,CAAC;AACF,eAAO,MAAM,iBAAiB;;;CAG7B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AACF,eAAO,MAAM,sBAAsB;;;;;;;CAIlC,CAAC;AACF,eAAO,MAAM,yBAAyB;;;CAGrC,CAAC"}
{"version":3,"file":"mockPropertyHook.d.ts","sourceRoot":"","sources":["../../../src/hooks/__test__/mockPropertyHook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAG9C,eAAO,MAAO,kBAAkB,UAAE,mBAAmB,UAAE,kBAAkB,QAAa,CAAC;AAEvF,eAAO,MAAM,eAAe,EAAE,aAU7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,aAO7B,CAAC;AAKF,eAAO,MAAM,aAAa;;;CAGzB,CAAC;AACF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;CAMlC,CAAC;AACF,eAAO,MAAM,yBAAyB;;;;;;CAMrC,CAAC;AACF,eAAO,MAAM,iBAAiB;;;;;;;CAI7B,CAAC;AACF,eAAO,MAAM,sBAAsB;;;;;;;CAIlC,CAAC;AACF,eAAO,MAAM,yBAAyB;;;;;;;CAIrC,CAAC;AACF,eAAO,MAAM,iBAAiB;;;CAG7B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AACF,eAAO,MAAM,sBAAsB;;;;;;;CAIlC,CAAC;AACF,eAAO,MAAM,yBAAyB;;;CAGrC,CAAC"}

@@ -7,2 +7,3 @@ "use strict";

exports.mockConfContext = {
localId: 'MOCK_LOCAL_ID',
extension: {

@@ -18,2 +19,3 @@ space: {

exports.mockJiraContext = {
localId: 'MOCK_LOCAL_ID',
extension: {

@@ -20,0 +22,0 @@ issue: {

@@ -27,5 +27,5 @@ "use strict";

});
const useMockEntityProperty = () => {
const useMockEntityProperty = (defaultRetryCount = 2) => {
const entityManager = (0, react_1.useMemo)(mockEntity, []);
return (0, useEntityProperty_1.useEntityProperty)(entityManager);
return (0, useEntityProperty_1.useEntityProperty)({ entityManager, defaultRetryCount });
};

@@ -39,10 +39,11 @@ const propListener = jest.fn();

})(renderActions || (renderActions = {}));
;
const renderTest = async (action = renderActions.noAction, retryCount) => {
const Test = () => {
const [prop, setProp, delProp] = useMockEntityProperty();
const [prop, setProp, delProp] = useMockEntityProperty(retryCount);
(0, react_1.useEffect)(() => propListener(prop), [prop]);
(0, react_1.useEffect)(() => {
if (action === renderActions.toUpdate) {
void setProp(mockPropertyHook_1.UPDATED_PROP_VALUE, retryCount);
setProp(mockPropertyHook_1.UPDATED_PROP_VALUE, retryCount).catch((err) => {
console.error(err);
});
}

@@ -49,0 +50,0 @@ if (action === renderActions.toDelete) {

@@ -1,2 +0,2 @@

import { ConfEndpointInitializer, ManagePropsData, ConfluenceEntityType, EntityManager } from './types';
import type { ConfEndpointInitializer, ManagePropsData, ConfluenceEntityType, EntityManager } from './types';
export declare const confAPIEndpoints: ({ entityType, context }: ConfEndpointInitializer) => {

@@ -3,0 +3,0 @@ create: () => string;

@@ -1,1 +0,1 @@

{"version":3,"file":"confluenceEntity.d.ts","sourceRoot":"","sources":["../../src/hooks/confluenceEntity.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,uBAAuB,EAEvB,eAAe,EACf,oBAAoB,EACpB,aAAa,EAEd,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,gBAAgB,4BAA6B,uBAAuB;;yBAqBxD,MAAM;yBACN,MAAM;yBACN,MAAM;CAE9B,CAAC;AAEF,eAAO,MAAM,gBAAgB;gBAIiB,oBAAoB;8BAqGjE,CAAC"}
{"version":3,"file":"confluenceEntity.d.ts","sourceRoot":"","sources":["../../src/hooks/confluenceEntity.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,uBAAuB,EAEvB,eAAe,EACf,oBAAoB,EACpB,aAAa,EAEd,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,gBAAgB,4BAA6B,uBAAuB;;yBAqBxD,MAAM;yBACN,MAAM;yBACN,MAAM;CAE9B,CAAC;AAEF,eAAO,MAAM,gBAAgB;gBAIiB,oBAAoB;8BAqGjE,CAAC"}

@@ -1,2 +0,2 @@

import { EntityContext, ManagePropsData } from './types';
import type { EntityContext, ManagePropsData } from './types';
export declare const issueAPIEndpoints: (context: EntityContext) => {

@@ -3,0 +3,0 @@ create: () => string;

@@ -1,1 +0,1 @@

{"version":3,"file":"jiraEntity.d.ts","sourceRoot":"","sources":["../../src/hooks/jiraEntity.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,aAAa,EAEb,eAAe,EAEhB,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,iBAAiB,YAAa,aAAa;;yBAM/B,MAAM;0BACL,MAAM;0BACN,MAAM;CAE/B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;CAoGjC,CAAC"}
{"version":3,"file":"jiraEntity.d.ts","sourceRoot":"","sources":["../../src/hooks/jiraEntity.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAe,eAAe,EAAyB,MAAM,SAAS,CAAC;AAMlG,eAAO,MAAM,iBAAiB,YAAa,aAAa;;yBAM/B,MAAM;0BACL,MAAM;0BACN,MAAM;CAE/B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;CA6GjC,CAAC"}

@@ -79,12 +79,18 @@ "use strict";

const update = async ({ endpointFactory, propertyKey, context }, valueUpdate) => {
const originalProp = await fetchOriginal({ endpointFactory, propertyKey, context });
if (!originalProp) {
throw new types_1.EntityPropertyRequestFailedError({
entityType,
propertyKey,
operation: 'update',
status: 404
});
}
const newValue = valueUpdate instanceof Function ? valueUpdate(originalProp.value) : valueUpdate;
const newValueOrRunUpdaterOnOriginal = async (valueUpdate) => {
if (!(valueUpdate instanceof Function)) {
return valueUpdate;
}
const originalProp = await fetchOriginal({ endpointFactory, propertyKey, context });
if (!originalProp) {
throw new types_1.EntityPropertyRequestFailedError({
entityType,
propertyKey,
operation: 'update',
status: 404
});
}
return valueUpdate(originalProp.value);
};
const newValue = await newValueOrRunUpdaterOnOriginal(valueUpdate);
const url = endpointFactory.update(propertyKey);

@@ -91,0 +97,0 @@ const body = JSON.stringify(newValue);

import { ConfluenceEntityType, JiraEntityType } from '.';
export declare type PropOperation = 'fetch' | 'create' | 'update' | 'delete';
export declare type EntityPropertyUseParams<PropValue> = {
entityManager: EntityManager<PropValue>;
defaultRetryCount?: number;
};
export declare type EntityManager<PropValue> = {

@@ -29,2 +33,3 @@ get: () => Promise<PropValue>;

export declare type EntityContext = {
localId: string;
extension: {

@@ -31,0 +36,0 @@ [entityType: string]: {

@@ -1,1 +0,1 @@

{"version":3,"file":"entityProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/types/entityProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAGzD,oBAAY,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErE,oBAAY,aAAa,CAAC,SAAS,IAAI;IACrC,GAAG,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9B,MAAM,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IACpE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B,CAAC;AAEF,oBAAY,eAAe,CAAC,SAAS,IAAI;IACvC,UAAU,EAAE,oBAAoB,GAAG,cAAc,CAAC;IAClD,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,aAAK,eAAe,GAAG;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,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AqB,CAAC;IACxD,UAAU,EAAE,oBAAoB,GAAG,cAAc,CAAC;IAClD,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}

@@ -13,4 +13,4 @@ "use strict";

}), []);
return (0, useEntityProperty_1.useEntityProperty)(entityManager);
return (0, useEntityProperty_1.useEntityProperty)({ entityManager });
};
exports.useContentProperty = useContentProperty;

@@ -1,3 +0,3 @@

import { ValueUpdate, EntityManager } from './types';
export declare const useEntityProperty: <PropValue>(entityManager: EntityManager<PropValue>) => readonly [PropValue | undefined, (valueUpdate: ValueUpdate<PropValue>, retryCount?: number) => Promise<void>, () => Promise<void>];
import type { ValueUpdate, EntityPropertyUseParams } from './types';
export declare const useEntityProperty: <PropValue>({ entityManager, defaultRetryCount }: EntityPropertyUseParams<PropValue>) => readonly [PropValue | undefined, (valueUpdate: ValueUpdate<PropValue>, retryCount?: number) => Promise<void>, () => Promise<void>];
//# sourceMappingURL=useEntityProperty.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"useEntityProperty.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityProperty.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGrD,eAAO,MAAM,iBAAiB,4LAwC7B,CAAC"}
{"version":3,"file":"useEntityProperty.d.ts","sourceRoot":"","sources":["../../src/hooks/useEntityProperty.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGpE,eAAO,MAAM,iBAAiB,6NAgD7B,CAAC"}

@@ -5,13 +5,16 @@ "use strict";

const react_1 = require("react");
const useEntityProperty = (entityManager) => {
const useEntityProperty = ({ entityManager, defaultRetryCount = 2 }) => {
const [propValue, setPropValue] = (0, react_1.useState)();
(0, react_1.useEffect)(() => {
entityManager
.get()
.then((val) => setPropValue(val))
.catch((err) => {
throw err;
const getProp = async () => {
const currentVal = await entityManager.get();
setPropValue(currentVal);
};
getProp().catch(() => {
getProp().catch((secondErr) => {
throw secondErr;
});
});
}, []);
const updateProp = (0, react_1.useCallback)(async (valueUpdate, retryCount = 2) => {
const updateProp = (0, react_1.useCallback)(async (valueUpdate, retryCount = defaultRetryCount) => {
let success = false;

@@ -18,0 +21,0 @@ let tryCounts = 0;

@@ -13,4 +13,4 @@ "use strict";

}), []);
return (0, useEntityProperty_1.useEntityProperty)(entityManager);
return (0, useEntityProperty_1.useEntityProperty)({ entityManager, defaultRetryCount: 0 });
};
exports.useIssueProperty = useIssueProperty;

@@ -1,3 +0,3 @@

import { FullContext } from '@forge/bridge/out/types';
import type { FullContext } from '@forge/bridge/out/types';
export declare const useProductContext: () => FullContext | undefined;
//# sourceMappingURL=useProductContext.d.ts.map

@@ -1,1 +0,1 @@

{"version":3,"file":"useProductContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useProductContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,eAAO,MAAM,iBAAiB,+BAa7B,CAAC"}
{"version":3,"file":"useProductContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useProductContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,eAAO,MAAM,iBAAiB,+BAa7B,CAAC"}

@@ -13,4 +13,4 @@ "use strict";

}), []);
return (0, useEntityProperty_1.useEntityProperty)(entityManager);
return (0, useEntityProperty_1.useEntityProperty)({ entityManager });
};
exports.useSpaceProperty = useSpaceProperty;

@@ -1,3 +0,2 @@

import { RequestData, ResponseAssertData } from '../types/entityProps';
import { EndpointContextData } from '../types';
import type { EndpointContextData, RequestData, ResponseAssertData } from '../types';
export declare const FETCH_HEADERS: {

@@ -4,0 +3,0 @@ Accept: string;

@@ -1,1 +0,1 @@

{"version":3,"file":"apiRequestUtils.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/apiRequestUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAoC,WAAW,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,eAAO,MAAM,aAAa;;;CAGzB,CAAC;AAGF,eAAO,MAAM,WAAW,qEAC6C,mBAAmB,eACtE,OAAO,EAAE,iBAexB,CAAC;AAEJ,eAAO,MAAM,WAAW,qCAA4C,WAAW,sBAQ9E,CAAC;AAEF,eAAO,MAAM,WAAW,aAAoB,QAAQ,iBAOnD,CAAC;AAGF,eAAO,MAAM,wBAAwB,qDAAsD,kBAAkB,SAI5G,CAAC"}
{"version":3,"file":"apiRequestUtils.d.ts","sourceRoot":"","sources":["../../../src/hooks/utils/apiRequestUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAErF,eAAO,MAAM,aAAa;;;CAGzB,CAAC;AAGF,eAAO,MAAM,WAAW,qEAC6C,mBAAmB,eACtE,OAAO,EAAE,iBAcxB,CAAC;AAEJ,eAAO,MAAM,WAAW,qCAA4C,WAAW,sBAQ9E,CAAC;AAEF,eAAO,MAAM,WAAW,aAAoB,QAAQ,iBAOnD,CAAC;AAGF,eAAO,MAAM,wBAAwB,qDAAsD,kBAAkB,SAI5G,CAAC"}

@@ -5,3 +5,3 @@ "use strict";

const bridge_1 = require("@forge/bridge");
const entityProps_1 = require("../types/entityProps");
const types_1 = require("../types/");
exports.FETCH_HEADERS = {

@@ -13,5 +13,5 @@ Accept: 'application/json',

const context = await bridge_1.view.getContext();
const propertyKey = entityType === 'Content' ? `forge-${context.localId}-${origPropertyKey}` : `forge-${origPropertyKey}`;
if (entityType === 'Space' || entityType === 'Content') {
const endpointFactory = apiEndpoints({ entityType, context });
const propertyKey = entityType === 'Content' ? `forge-${context.localId}-${origPropertyKey}` : `forge-${origPropertyKey}`;
return originalOperation({ endpointFactory, propertyKey }, ...args);

@@ -21,3 +21,2 @@ }

const endpointFactory = apiEndpoints(context);
const propertyKey = `forge-${origPropertyKey}`;
return originalOperation({ endpointFactory, propertyKey, context }, ...args);

@@ -52,5 +51,5 @@ }

if (!response.ok) {
throw new entityProps_1.EntityPropertyRequestFailedError({ entityType, propertyKey, operation, status: response.status });
throw new types_1.EntityPropertyRequestFailedError({ entityType, propertyKey, operation, status: response.status });
}
};
exports.assertSuccessfulResponse = assertSuccessfulResponse;
{
"name": "@forge/react",
"version": "9.2.0-next.3",
"version": "9.2.0-next.4",
"description": "Forge React reconciler",

@@ -5,0 +5,0 @@ "author": "Atlassian",

Sorry, the diff of this file is not supported yet