Repository navigation
feat(ir)!: say what starts and ends a stream or a page walk - #1367
Open
OmarAlJarrah wants to merge 7 commits into
Open
OmarAlJarrah wants to merge 7 commits into
OmarAlJarrah wants to merge 7 commits into
Conversation
Declared pagination and event-stream APIs state facts the IR had no field for, so each emitter would guess them. - ParamPath becomes InputPath, whose Param is optional: nil roots the path in the request body, where a search endpoint takes its cursor or page size. pass.Validate holds a path naming a parameter to the operation's own, as it held ParamPath, and irverify reports one naming nothing (ir/input-path-empty). - Pagination gains TotalPages, counting pages where TotalCount counts items, and Stop, the closed empty | no_next | short | total conditions that end iteration (ir/unknown-page-stop for another). - StreamDetail gains Terminator, the frame data that ends a stream and is no element, as an SSE data: [DONE] is, and Condition, the request input and value that ask for a stream an operation sends only when asked. Lowering such an operation to two sharing one route was weighed and declined: it mints an operation no position names. - The stream plan reads both: a terminator frame ends the stream undecoded, and a conditional stream is two methods of one operation. No compiler fills these yet; they are the shape a declaring format or a promotion fills. BREAKING CHANGE: IRVersion moves to 0.31.0. A consumer pinned to 0.30.0 refuses a document that sets one of these, and finds a body input's param absent where it required one. ParamPath is now InputPath in Go.
5 of 6 tasks
… feat/ir-stream-and-page-inputs
The validator reads the input a request or response stream is selected by as a reference to the operation's own parameters, but no test built a stream with a condition, so neither read was reached.
17 tasks done
The JSON contract test kept the name and wording of ParamPath, the type InputPath replaced.
… feat/ir-stream-and-page-inputs # Conflicts: # ir/document.go
… feat/ir-stream-and-page-inputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Declared pagination and event-stream APIs state facts the IR had no field for, so every emitter would hard-code or guess them.
ParamPathbecomesInputPath, whoseParamis optional: nil roots the path in the request body, where a search endpoint takes its cursor or page size. Parameter identity was already aParamID(ir: parameters are bound by name, so same-named parameters in different locations are ambiguous #596).PaginationgainsTotalPages, counting pages whereTotalCountcounts items. It also gainsStop, the conditions that end iteration, a closedempty | no_next | short | total, any one ending the loop. An emptyStopstates no rule, and the plan guesses none.pass.Validateholds a path naming a parameter to the operation's own, as it heldParamPath.irverifyreports a path naming nothing (ir/input-path-empty) and an undeclared stop (ir/unknown-page-stop).PagePlancarries the input path and the stop rules.StreamDetail.Terminatorholds the frame data that ends a stream verbatim, a sentinel that is no element, as an SSEdata: [DONE]is. It sits besideVariant.Event.Terminal, which marks an event that is a variant. The stream plan compares each frame's data with it, and a frame matching it ends the stream undecoded.StreamDetail.Conditionholds the request input and the value asking for the stream, as a body'sstream: truedoes. The operation otherwise returns its non-streaming contents. The issue's second option was weighed and declined: lowering the operation to two operations sharing one route mints an operation no position names, and a selector type the document never wrote. The stream plan offers the pair as two methods of one operation, each setting the input itself.docs/ir/interaction-patterns.mdstates each rule, anddocs/compilers/planned-lowerings.mdnotes that TypeSpec's body-level pagination decorators fill the body form.No compiler fills these yet. The OpenAPI compiler reads no pagination or stream extension, which a promotion would do. On the golden spec (spec @319dc756), one operation offers JSON beside an event stream, none selects the stream with a body flag, no stream ends on
[DONE], and two operations carry a pagination extension. That is the measurement behind #665's P2 and the others' P3.Closes #665
Closes #666
Closes #667
Breaking
IRVersionmoves to 0.33.0, after #1366's 0.32.0. A consumer pinned to the generation before this one refuses a document that sets any of these, and finds a body input'sparamabsent where it required one. In Go,ParamPathis nowInputPath, and itsParamis a*ParamID.Stack
Base: #1366, on #1361 and the rest of the IR stack. Merge in order.
Test plan
go testonir/...,pass/...,compilers/openapi/e2e,internal/...andcmd/.... The shape pin and the census were regenerated.irverify.TestVerify_AnInputPathNamesARequestValue: a parameter, a body member, and neither, as a cursor and as a stream's condition.irverify.TestVerify_APaginationStopIsOneIRDeclares.StreamCondition.Valuejoins the value-carrier cases, so the payload rules reach it.PageStopis classified among the IR's named string types.skills_lintclean.