Repository navigation
Feat cleanup api - #3796
Open
neelneelneel wants to merge 11 commits into
Open
Feat cleanup api#3796neelneelneel wants to merge 11 commits into
neelneelneel wants to merge 11 commits into
Conversation
Bundle the typed Monolith REST client into the SDK, so any app, including ones built on the published npm SDK, can call every endpoint. The routes are configured by Env and tree-shakable. The SDK's own functions and the apps are not migrated yet. @semoss/sdk - New exports: @semoss/sdk/monolith (ApiClient, ApiError, UnauthorizedError, RequestOptions) and @semoss/sdk/monolith/<route>, one subpath per backend resource (e.g. @semoss/sdk/monolith/api/auth/admin/project). - One build entry per monolith route file. preserveModules with libs/ as the root, so dist/ mirrors libs/ (dist/sdk/src/..., dist/monolith/src/..., the same under dist/types/). Consumers bundle only what they import (one route is about 5 KB). main, module, types and exports point at the new paths; import specifiers are unchanged. - @semoss/monolith is a bundled devDependency, never external, so a page has one ApiClient. tsconfig rootDir is .., and it includes ../monolith/src. - Every Env.update also sets ApiClient's basePath (MODULE) and auth (BEARER_TOKEN, else ACCESS_KEY/SECRET_KEY). In the browser, an auth redirect goes to REDIRECT_URL when set. @semoss/monolith - Source only: no Vite build or dist. exports point at src, with relative imports. - ApiClient.configure clears the CSRF token and cookies only when basePath or auth change. - Add UnauthorizedError (an ApiError) for redirects. Detect redirects that fetch followed to an HTML page, and read errorMessage, message or error from failed responses. - login, loginLDAP, loginLinOTP and logout send disableRedirect by default. - Route type and JSDoc updates (e.g. fields the backend omits are optional, not null). @semoss/config - createViteLibConfig no longer forces unplugin-dts entryRoot src. It follows the tsconfig rootDir, so ui and renderer emit the same declarations as before. Docs: SDK and monolith AGENTS.md and README; ISSUES.md now lists only outstanding front-end tasks; the sync skill validates through the SDK build and tests; root AGENTS.md and the package guide list the new exports. Verified: SDK tsc, 204 tests and build pass; consumers have no new tsc errors or test failures vs HEAD; cli and chrome-extension build.
✅ 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. |
- Add buildPixel and rawPixel with validated Pixel serialization - Infer reactor outputs in runPixel and usePixel while preserving existing calls - Catalog 1,542 built-in names and trace outputs through backend implementations - Extend sync documentation with provenance, coverage, and remaining contract gaps - Test serialization, hook behavior, inference, and published exports Validated with 345 unit tests, 5 integration tests, TypeScript, and Biome.
Contributor
Author
|
Example usage: import { Env, buildPixel, rawPixel, runPixel } from "@semoss/sdk";
import { getProjects } from "@semoss/sdk/api/monolith/auth/project";
Env.update({ MODULE: "/Monolith", CSRF: true });
// Typed REST calls return the response body directly.
const projects = await getProjects(
{ limit: 20 },
{ signal: AbortSignal.timeout(10_000) },
);
// Pixel parameters and successful outputs are inferred.
const result = await runPixel(buildPixel("GetProjectList", {}), insightId);
const total = await runPixel(buildPixel("SUM", [10, 20, 30]), insightId);
// Ordinary strings are literals; rawPixel marks trusted expressions.
const query = buildPixel("Select", [
rawPixel("department"),
rawPixel("Sum(cost)"),
]);Inside a React component or custom hook: import { useAPI, usePixel } from "@semoss/sdk/react";
const api = useAPI(
enabled ? [getProjects, { limit: 20 }] : null,
);
const pixel = usePixel(
enabled ? buildPixel("GetProjectList", {}) : "",
{ data: [] },
insightId,
);Both hooks expose REST resources share authentication, CSRF, and session handling, support cancellation, and expose structured |
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
Align the SDK with the Monolith and Semoss backend implementations and provide typed REST resources, React API requests, and Pixel builders. Preserve existing SDK entry points while improving request handling, response contracts, and affected application consumers.
Changes Made
@semoss/sdk/api/monolith/<resource>and servlet-specific subpaths.useAPIwith typed method/argument tuples, inferred responses and callbacks, refresh/update actions, disabled requests, and stale-response cleanup.buildPixelandrawPixel, backed by a catalog of 1,542 built-in reactor names, aliases, and frame variants. Infer outputs in bothrunPixelandusePixelwhile retaining raw strings and explicit generics.How to Test
With Node 24 and pnpm 10.13.1, run the SDK checks:
Expected: TypeScript passes, 345 SDK unit tests pass, and all 5 production integration tests pass. Published imports, declarations, inferred types, tree shaking, and initialization remain valid.
Run the affected consumer regression tests:
Expected: progress remains separate from subagents, directory candidates display usable identities, and partial completion events preserve earlier tool details.
Against a configured backend, exercise the SDK README examples for typed resource calls,
useAPI, andrunPixel(buildPixel("GetProjectList", {})). VerifyusePixelinfers the result, disabling prevents requests, and refresh reruns the call. Existing raw Pixel strings and explicit response generics should continue working.Notes
unknown; remaining input and nested-output audit gaps are documented in the catalog andlibs/sdk/ISSUES.md.semoss-sync.json. This PR does not modify backend implementations.