Skip to content

Commit 5ee913b

Browse files
fix: move app-action-call status, result, and error to sys [EXT-6783] (#2766)
1 parent e5042cf commit 5ee913b

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

lib/adapters/REST/endpoints/app-action-call.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ async function pollStructuredAppActionCall(
151151

152152
// If backend has not yet written the record, keep polling up to retries
153153
// Otherwise, resolve when status is terminal
154-
if (result?.status === 'succeeded' || result?.status === 'failed') {
154+
if (result?.sys.status === 'succeeded' || result?.sys.status === 'failed') {
155155
resolve(result)
156-
} else if (result?.status === 'processing' && checkCount < retries) {
156+
} else if (result?.sys.status === 'processing' && checkCount < retries) {
157157
checkCount++
158158
await waitFor(retryInterval)
159159
poll()

lib/entities/app-action-call.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ export type AppActionCallProps = {
5353
* System metadata
5454
*/
5555
sys: AppActionCallSys
56-
status: AppActionCallStatus
57-
result?: JsonValue
58-
error?: AppActionCallErrorProps
5956
}
6057

6158
export type CreateAppActionCallProps = {
@@ -86,6 +83,7 @@ export interface AppActionCallRawResponseProps {
8683
appInstallation: SysLink
8784
appAction: SysLink
8885
createdAt: string
86+
createdBy: SysLink
8987
}
9088
response: {
9189
headers?: { contentType?: string }

test/unit/adapters/REST/endpoints/app-action-call.test.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ function setup(promise, mockName, params = {}) {
1616
}
1717

1818
describe('Rest App Action Call', { concurrent: true }, () => {
19-
it('should get structured App Action Call via new route', async () => {
19+
it('should get structured App Action Call', async () => {
2020
const structuredCall: any = {
21-
sys: { id: 'call-id', type: 'AppActionCall' },
22-
status: 'processing',
21+
sys: { id: 'call-id', type: 'AppActionCall', status: 'processing' },
2322
}
2423

2524
const { httpMock } = setup(Promise.resolve({ data: structuredCall }), 'appActionCallResponse')
@@ -38,7 +37,7 @@ describe('Rest App Action Call', { concurrent: true }, () => {
3837
)
3938
})
4039

41-
it('should get raw response via new route', async () => {
40+
it('should get raw response', async () => {
4241
const rawResponse: any = {
4342
sys: { id: 'call-id', type: 'AppActionCallResponse' },
4443
response: { body: 'OK', headers: { contentType: 'application/json' } },
@@ -61,16 +60,13 @@ describe('Rest App Action Call', { concurrent: true }, () => {
6160
})
6261

6362
it('should create with result and poll until completion', async () => {
64-
// First POST returns the created call with sys.id; then GET returns processing, then succeeded
65-
const createdCall: any = { sys: { id: 'call-id', type: 'AppActionCall' } }
66-
const processing: any = { sys: { id: 'call-id', type: 'AppActionCall' }, status: 'processing' }
63+
// First POST and next GET returns processing call with sys.id; , then succeeded
64+
const processing: any = { sys: { id: 'call-id', type: 'AppActionCall', status: 'processing' } }
6765
const succeeded: any = {
68-
sys: { id: 'call-id', type: 'AppActionCall' },
69-
status: 'succeeded',
70-
result: { ok: true },
66+
sys: { id: 'call-id', type: 'AppActionCall', status: 'succeeded', result: { ok: true } },
7167
}
7268

73-
const { httpMock } = setup(Promise.resolve({ data: createdCall }), 'appActionCallResponse')
69+
const { httpMock } = setup(Promise.resolve({ data: processing }), 'appActionCallResponse')
7470

7571
httpMock.get
7672
.mockImplementationOnce(() => Promise.resolve({ data: processing }))
@@ -105,10 +101,9 @@ describe('Rest App Action Call', { concurrent: true }, () => {
105101
})
106102

107103
it('createWithResult times out when status stays processing', async () => {
108-
const createdCall: any = { sys: { id: 'call-id', type: 'AppActionCall' } }
109-
const processing: any = { sys: { id: 'call-id', type: 'AppActionCall' }, status: 'processing' }
104+
const processing: any = { sys: { id: 'call-id', type: 'AppActionCall', status: 'processing' } }
110105

111-
const { httpMock } = setup(Promise.resolve({ data: createdCall }), 'appActionCallResponse')
106+
const { httpMock } = setup(Promise.resolve({ data: processing }), 'appActionCallResponse')
112107

113108
// Always return processing to trigger timeout
114109
httpMock.get.mockImplementation(() => Promise.resolve({ data: processing }))
@@ -140,11 +135,14 @@ describe('Rest App Action Call', { concurrent: true }, () => {
140135
})
141136

142137
it('createWithResult resolves with failed status and error intact', async () => {
143-
const createdCall: any = { sys: { id: 'call-id', type: 'AppActionCall' } }
138+
const createdCall: any = { sys: { id: 'call-id', type: 'AppActionCall', status: 'processing' } }
144139
const failed: any = {
145-
sys: { id: 'call-id', type: 'AppActionCall' },
146-
status: 'failed',
147-
error: { sys: { type: 'Error', id: 'ValidationError' }, message: 'invalid' },
140+
sys: {
141+
id: 'call-id',
142+
type: 'AppActionCall',
143+
status: 'failed',
144+
error: { sys: { type: 'Error', id: 'ValidationError' }, message: 'invalid' },
145+
},
148146
}
149147

150148
const { httpMock } = setup(Promise.resolve({ data: createdCall }), 'appActionCallResponse')
@@ -167,7 +165,7 @@ describe('Rest App Action Call', { concurrent: true }, () => {
167165
})
168166

169167
it('createWithResult retries on thrown GET errors then times out', async () => {
170-
const createdCall: any = { sys: { id: 'call-id', type: 'AppActionCall' } }
168+
const createdCall: any = { sys: { id: 'call-id', type: 'AppActionCall', status: 'processing' } }
171169
const { httpMock } = setup(Promise.resolve({ data: createdCall }), 'appActionCallResponse')
172170

173171
httpMock.get.mockRejectedValue(new Error('not ready'))

0 commit comments

Comments
 (0)