Skip to content

Feat cleanup api - #3796

Open
neelneelneel wants to merge 11 commits into
devfrom
feat-cleanup-api
Open

neelneelneel wants to merge 11 commits into
devfrom
feat-cleanup-api

Conversation

@neelneelneel

@neelneelneel neelneelneel commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Add 49 REST resource modules with 371 request wrappers and 15 URL builders, exposed through @semoss/sdk/api/monolith/<resource> and servlet-specific subpaths.
  • Share authentication, CSRF handling, headless cookies, redirects, and session state between typed resources and existing HTTP helpers. Add request cancellation options, structured route errors, and backend-specific request/response encoding.
  • Add useAPI with typed method/argument tuples, inferred responses and callbacks, refresh/update actions, disabled requests, and stale-response cleanup.
  • Add buildPixel and rawPixel, backed by a catalog of 1,542 built-in reactor names, aliases, and frame variants. Infer outputs in both runPixel and usePixel while retaining raw strings and explicit generics.
  • Trace reactor outputs through implementations, helpers, SQL mappers, and serializers. Validate Pixel serialization, including nested values, escaping, numeric boundaries, and trusted expressions.
  • Correct permission-candidate and agent response contracts. Update Playground sharing and partial tool-event handling, and distinguish automation progress from subagent activity.
  • Extend SDK builds and declarations for resource subpaths, separate unit and production integration tests, and verify tree shaking and initialization.
  • Add independent API/reactor sync metadata, source evidence, coverage checks, migration guidance, and tracked contract gaps.

How to Test

  1. With Node 24 and pnpm 10.13.1, run the SDK checks:

    pnpm install --frozen-lockfile
    pnpm --filter @semoss/sdk exec tsc --noEmit --emitDeclarationOnly false
    pnpm --filter @semoss/sdk test
    pnpm --filter @semoss/sdk test:integration

    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.

  2. Run the affected consumer regression tests:

    pnpm --filter @semoss/automation test src/components/agent-run/agent-run-graph.test.ts
    pnpm --filter @semoss/playground test src/components/workspace/members/workspace-sharing-modal.test.tsx src/stores/message/agent-harness.test.ts

    Expected: progress remains separate from subagents, directory candidates display usable identities, and partial completion events preserve earlier tool details.

  3. Against a configured backend, exercise the SDK README examples for typed resource calls, useAPI, and runPixel(buildPixel("GetProjectList", {})). Verify usePixel infers the result, disabling prevents requests, and refresh reruns the call. Existing raw Pixel strings and explicit response generics should continue working.

Notes

  • Existing root helpers remain available; 18 thin REST wrappers now include deprecation guidance.
  • Reactor name coverage is complete for the recorded backend snapshot. Twenty runtime-dependent outputs remain unknown; remaining input and nested-output audit gaps are documented in the catalog and libs/sdk/ISSUES.md.
  • Backend findings and source provenance are recorded in semoss-sync.json. This PR does not modify backend implementations.
  • Recorded validation includes SDK tests, production builds, TypeScript, focused Biome checks, and local backend parser/serializer probes. Authenticated live-service and browser UI testing remain manual.

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.
@neelneelneel
neelneelneel requested a review from a team as a code owner October 22, 2026 16:38
@snyk-io

snyk-io Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 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.
@neelneelneel

Copy link
Copy Markdown
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 status, data, error, refresh(), and update(), with inferred response types.

REST resources share authentication, CSRF, and session handling, support cancellation, and expose structured ApiError errors. Existing raw Pixel strings, explicit generics, and legacy helpers remain supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant