Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/apis/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2535,8 +2535,8 @@ components:
event:
nullable: true
oneOf:
- $ref: "#/components/schemas/EventSummary"
- $ref: "#/components/schemas/EventFull"
- $ref: "#/components/schemas/EventSummary"
description: The associated event object. Only present when include=event or include=event.data.
destination:
nullable: true
Expand Down
42 changes: 38 additions & 4 deletions spec-sdk-tests/tests/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ describe('Events (PR #491)', () => {
limit: 5,
});
expect(response).to.not.be.undefined;
expect(response?.models).to.be.an('array');
expect(response?.result?.models).to.be.an('array');
});

it('should list events by tenant', async function () {
Expand All @@ -191,7 +191,7 @@ describe('Events (PR #491)', () => {
const response = await sdk.events.list({
tenantId: client.getTenantId(),
});
return response?.models || [];
return response?.result?.models || [];
},
30000,
5000
Expand All @@ -209,7 +209,7 @@ describe('Events (PR #491)', () => {
const response = await sdk.events.list({
tenantId: client.getTenantId(),
});
const events = response?.models || [];
const events = response?.result?.models || [];

if (events.length === 0) {
console.warn('No events found - skipping single event test');
Expand Down Expand Up @@ -253,7 +253,7 @@ describe('Events (PR #491)', () => {
destinationId: destinationId,
eventId,
});
return response?.models ?? [];
return response?.result?.models ?? [];
},
45000,
5000
Expand All @@ -265,5 +265,39 @@ describe('Events (PR #491)', () => {
expect(attempt.status).to.equal('success', 'Delivery to mock.hookdeck.com should succeed');
console.log(`Event ${eventId} generated attempt; status: ${attempt.status}`);
});

it('listAttempts with include=event.data should expose event.data on the parsed attempt', async function () {
this.timeout(60000);

const sdk: Outpost = client.getSDK();

const payload = { marker: `include-event-data-${Date.now()}` };
const publishResponse = await sdk.publish({
tenantId: client.getTenantId(),
topic: TEST_TOPICS[0],
data: payload,
});
const eventId = publishResponse.id;

const attempts = await pollForAttempts(
async () => {
const response = await sdk.destinations.listAttempts({
tenantId: client.getTenantId(),
destinationId: destinationId,
eventId,
include: ['event.data', 'response_data'],
});
return response?.result?.models ?? [];
},
45000,
5000
);

expect(attempts.length).to.be.at.least(1, 'Expected at least one attempt');
const attempt = attempts[0];
expect(attempt.responseData, 'response_data should be populated when include=response_data').to.exist;
expect(attempt.event, 'event should be populated when include=event.data').to.exist;
expect((attempt.event as { data?: unknown }).data, 'event.data should be populated when include=event.data').to.deep.equal(payload);
});
});
});
4 changes: 2 additions & 2 deletions spec-sdk-tests/tests/tenants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe('Tenants - List with request object', () => {
const result = await sdk.tenants.list({ limit: 5 });

expect(result).to.not.be.undefined;
expect(result?.models).to.be.an('array');
(result?.models ?? []).forEach((t: { id?: string }, i: number) => {
expect(result?.result?.models).to.be.an('array');
(result?.result?.models ?? []).forEach((t: { id?: string }, i: number) => {
expect(t, `tenant[${i}]`).to.be.an('object');
if (t.id != null) expect(t.id, `tenant[${i}].id`).to.be.a('string');
});
Expand Down
Loading