fix: return complete sse event in async iterator (#2641)#3018
fix: return complete sse event in async iterator (#2641)#3018Theo-Steiner wants to merge 6385 commits into
Conversation
fix(cli): move cli script to typescript
…hemas Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
…rrors-method-name-builder Export Operation type to fix methodNameBuilder TypeScript errors
…h types
Fixed the Valibot plugin to correctly handle additionalProperties with type definitions. Now generates v.record() instead of v.object({}) to prevent silent data loss.
- Modified object.ts to check for any additionalProperties.type (not just 'object')
- Objects with only additionalProperties: generate v.record(v.string(), <valueSchema>)
- Objects with properties AND additionalProperties: generate v.objectWithRest({properties}, <valueSchema>)
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Updated test snapshots to reflect the corrected behavior for additionalProperties. The fix now properly generates: - v.record() for objects with only additionalProperties - v.objectWithRest() for objects with both properties and additionalProperties This correctly handles free-form objects per OpenAPI spec defaults. Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
refactor: valibot plugin use dsl
refactor: fastify plugin use dsl
refactor: arktype plugin use dsl
refactor: client plugin use dsl
refactor: typescript plugin use dsl
|
|
🦋 Changeset detectedLatest commit: c3aba80 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Theo-Steiner is attempting to deploy a commit to the Hey API Team on Vercel. A member of the Team first needs to authorize it. |
|
@Theo-Steiner run |
|
@mrlubos thank you for your quick reply! // ASIS
export const { stream } = getSse();
for await (const result of stream) {
// `result` is typed as `GetSseResponses`, but the actual result is `GetSseResponses['data']`
console.log(result.event) // event will always be undefined, since we are passed only the data
}
// TOBE
for await (const result of stream) {
// `result` is still typed as `GetSseResponses`, however the actual result is now the complete event (not just it's data property)
console.log(result.event) // logs the actual event
}As you can see, there is currently a bug in the SSE implementation, where the
|
|
I've updated the tests, which sadly bloats the diff of this PR by quite a bit 😅 |
|
❤️ I'm so looking forward to this. Thanks! |
|
@mrlubos Any chance we can look at this as it seriously limits the use of SSE without having access to event name and ID... |
|
@mrlubos Can we take a look at this please? |
Closes #2641
Background
The individual results yielded by the async iterator for the SSE client are just the
datapart of the server sent events.The type however, suggests that it should be the full event.
Description
This PR changes the returned value to be the full event, including
id,event,data&retry.Sinceretryis not part of the actual event, it is not included.Notes
The SDK snapshot tests started failing because they expected the previous function implementation.
Should I update them manually to reflect the new function body or is there a way to regenerate them automatically?