Repository navigation
feat: describe reactor contracts for SDK generation - #3259
Open
neelneelneel wants to merge 3 commits into
Open
neelneelneel wants to merge 3 commits into
neelneelneel wants to merge 3 commits into
Conversation
Add AbstractReactor2<Input, Output>, so a reactor declares its inputs once as a record. keysToGet, keyRequired, key descriptions, MCP types and the typed input are all derived from it, and the return value is wrapped in a NounMetadata. --help, asMcpTool() and positional inputs keep working. - Move Echo, GetCurrentInsightId and StopPixelExecution onto AbstractReactor2, with the same outputs and messages. - Add @internal (prerna.openapi) to mark a reactor or REST operation as not for general use. Monolith publishes it as x-internal. - Add @DynamicOutput for reactors whose output has no fixed type. - Add the swagger-annotations-jakarta dependency and AbstractReactor2Test.
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
Author
|
Depends on SEMOSS/semoss-ui#3850 |
Reactors no longer have to change to be published. ReactorContract reads a contract from what every reactor already declares: - inputs from keysToGet (canonical names); - requiredness from keyRequired (none means nothing is required, as organizeKeys() checks); - input types from getKeyTypeForMCP; - descriptions from getDescriptionForKey and getReactorDescription. Annotations in prerna.openapi refine what inference cannot see: @PixelOutput declares a reactor's output, and @PixelInput (repeatable) refines one input. Naming a key the reactor does not declare is an error. - Roll back AbstractReactor2, NoInput and DynamicOutput, and restore Echo, StopPixelExecution and GetCurrentInsightId, now annotated so their published types are unchanged. - Move ReactorFactory's Pixel-name and frame-type rules into ReactorNames, shared with the contract reader. Registration is unchanged. - Add ReactorContractTest. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Description
The backend now owns the API contract, and the SDK is generated from it. Monolith exports one OpenAPI 3.1 document, built from its REST annotations and from every Semoss reactor. Each reactor's contract is inferred from what it already declares, and annotations refine it where inference can't see. The TypeScript SDK in
libs/sdkgenerates typed REST calls and a types-only Pixel catalog from that document; a Python SDK can later read the same file.Everything is opt-in. Existing SDK calls keep their behavior and types, and no reactor has to change to be published.
This change spans three repositories:
@semoss/sdk) generates the calls and adds typed hooks.Changes Made
Semoss
ReactorContractreads each reactor's contract from what it already declares. It constructs the reactor to do this but never executes it.keysToGet, by canonical name.keyRequired. With none, nothing is required, which is howorganizeKeys()checks at runtime.getKeyTypeForMCP.getDescriptionForKeyandgetReactorDescription, with placeholders where they're missing.prerna.openapi:@PixelOutputdeclares a reactor's output.@PixelInput(repeatable) refines one input's type, item type, description or requiredness.@Internalmarks a reactor or REST operation as not for general use.ReactorNamesnow holds the Pixel-name and frame-type rules, andReactorFactoryuses it too. Registration is unchanged.Echo,StopPixelExecutionandGetCurrentInsightIdare annotated so their published types are pinned. An earlierAbstractReactor2base class from this branch has been rolled back in favor of inference.swagger-annotations-jakartadependency andReactorContractTest.Monolith
OpenApiExporterandscripts/generate-apiwritetarget/generator/openapi.json. Nothing is listed by hand:@Operationmethod in the servlets' JAX-RS applications is published.x-semoss-pixels. The ~150 frame-specific versions are left out, since the frame picks the implementation at runtime.@Hiddenleaves a REST method or a reactor out.@Internaladdsx-internal(plusx-internal-reasonwhen given). A contract with anything inferred getsx-semoss-inferred.x-semoss-servletsnames each servlet's SDK module.target/generator/skipped.txt. That covers a failing constructor, a duplicate key, a non-identifier name, or a name two classes share. The list is the same on every run. An annotated reactor that can't be read fails the export instead.operationIds.GET /api/config: described by aServerConfigrecord.ServerConfigContractTestkeeps the record in step with what the resource puts, and the response itself is unchanged.openapiMaven profile builds intotarget/openapi-build, apart from IDE output intarget/classes.OpenApiExporterTestwith fixtures (test/openapi/fixtures,test/openapi/badfixtures), anddocs/openapi.md.semoss-ui (
@semoss/sdk)scripts/sdk-generator):pnpm generate --openapi FILEwritessrc/generated/. REST calls are plainasyncfunctions over the existingget/post, with inline types and TSDoc.pnpm generate:check --openapi FILEreports drift without writing anything.@internalforx-internal, and a note on inferred reactors.@semoss/sdk/api/*, starting withconfigfrom@semoss/sdk/api/monolith.PixelCatalogis types only, so it adds no bundle size at any number of reactors.buildPixelis checked against it at compile time and escapes every value.readPixelOutputthrowsPixelErrorwhen the backend reported an error.runPixel,usePixel,useIteratorPixel,runPixelAsyncandgetPixelAsyncResultget typed overloads. Plain strings and explicit type arguments keep the legacy types.useAPI(fn, input, options)passes anAbortSignal, compares its input by value, and takesenabled.useIteratorApican page a generated call directly: it fills inlimitandoffset, acceptsselect, and starts again from page 0 when the input changes, with no deps array. The existing(fetchPage, options, deps)form still works.*.test-d.tswithtsconfig.typecheck.json) and@testing-library/reactfor the hook tests.How to Test