Skip to content

[TS] Patch-safe correctness fixes: Training typos, missing barrel exports, ImportPointCloud variant, dead dependency #310

Description

@aruniverse

Context

These are all verified, low-risk fixes on main @ dafc2ce. They are safe as patches because the SDK never runtime-validates responses (zero .parse/.safeParse in src/service/ — every response is a blind cast like resp.data.job as Job, service.ts:84,94,124), so none of these change SDK runtime behavior. The damage today is type-level lies and broken schemas for consumers who parse manually.

Bugs

1. JobSchema Training literals are typo'd

  • src/service/job.ts:238z.literal("TraningO2D") (missing "i")
  • src/service/job.ts:243z.literal("TraningS3D") (missing "i")
  • vs JobType.TRAINING_O2D = "TrainingO2D" / TRAINING_S3D = "TrainingS3D" (job.ts:47–48)
  • Regression introduced in merge e10fe6e (2.1.0, Jan 2026); 6d8b25b was spelled correctly.
  • Effect: the inferred Job union can never narrow to Training variants; consumer-side JobSchema.parse fails on real server payloads.
  • Why it survived: no test parses a Training job through JobSchema (grep → 0 hits); nyc's 90% per-file line coverage cannot catch a wrong string literal inside a covered expression.

2. Public spec types unreachable — missing barrel exports

  • src/index.node.ts and src/index.web.ts: missing export * from "./specifications/eval_s3d" and "./specifications/clearance" — while job.ts:24,26 imports both and JobType.EVAL_S3D / CLEARANCE_CALCULATION are public.
  • src/index.node.ts only: missing export * from "./service/detectors" (present in index.web.ts:7; gap introduced by 248facf). Node consumers can call the 13 detector methods on RealityCaptureService but cannot import DetectorBase, DetectorResponse, DetectorUpdate, etc.
  • Deep imports are blocked because the exports map defines only "." — these types are fully unreachable.
  • Note: no tsconfig change needed — tsconfig.web.json already includes "src/specifications/**/*.ts" via glob.

3. ImportPointCloud commented out of JobSchema while live in JobCreateSchema

  • Variant commented out at job.ts:196–200; ImportPCSpecificationsCreateSchema IS in JobCreateSchema (job.ts:108).
  • Effect: submit works; job.type === JobType.IMPORT_POINT_CLOUD is a TS2367 compile error; consumer-side parse fails.
  • Safe to re-enable: Python has the variant enabled and tested (job.py:55,189; tests/test_job_validator.py:187–200); the TS ImportPCSpecificationsSchema matches the Python model field-for-field.
  • The commented-out JobResponseSchema test (src/tests/service/job.test.ts:149–172) uses IMPORT_POINT_CLOUD — evidently disabled because of this variant; re-enable it as the natural regression test.

4. Small defects in the same area

  • getAppropriateService lists JobType.TRAINING_O2D twice (job.ts:73,75).
  • class-validator ^0.14.0 is a production dependency (reality-capture/package.json:54) with zero imports anywhere in src/ or tests (also drags in libphonenumber-js). CI uses --frozen-lockfile=true, so the lockfile refresh must be committed in the same PR.
  • Download failures report "Upload" errors: data_handler.ts:90–100 returns code: "UploadInterrupted" / "UploadFailure" from downloadData. Python correctly uses DownloadInterrupted/DownloadFailure (data_handler.py:80–86).
  • Empty-token hardening (interim, 2 lines): data_handler.ts:214 calls getRealityData("", …) and :223 getBlobUrl("", "", …) — works only because resolveAccessToken (RealityDataClient.ts:153–163, self-described "workaround") silently prefers the options-injected authorizationClient. Pass await authorizationClient.getAccessToken() instead of "" to remove the silent dependence on that precedence. (Full rework tracked in the data-handler sub-issue.)
  • reality-data-client: deleteRealityData passes "POST" to getRequestConfig (RealityDataClient.ts:661) then calls axios.delete (:666) — cosmetic (axios overrides method) but wrong; dissociateRealityData does it correctly (:697).

Task list

  • Fix TraningO2DTrainingO2D (job.ts:238) and TraningS3DTrainingS3D (job.ts:243)
  • Dedupe TRAINING_O2D in getAppropriateService (job.ts:73,75)
  • Un-comment the ImportPointCloud variant in JobSchema (job.ts:196–200)
  • Re-enable + fix the JobResponseSchema test (job.test.ts:149–172)
  • Add JobSchema.parse regression tests for TrainingO2D / TrainingS3D / ImportPointCloud server-shaped payloads
  • Add eval_s3d + clearance exports to index.node.ts and index.web.ts
  • Add detectors export to index.node.ts
  • (Optional) add src/service/detectors.ts to the tsconfig.web.json include whitelist for consistency
  • Remove class-validator from dependencies + refresh pnpm-lock.yaml in the same PR
  • Fix download error labels in data_handler.ts:90–100
  • Interim empty-token hardening in data_handler.ts:214,223
  • reality-data-client: "POST""DELETE" in deleteRealityData (RealityDataClient.ts:661)

⚠️ Branch coordination (required)

origin/feature/AnalyseV2 and origin/feature/AnalyseRelease26.0.2 (June 2026, commit 27a25de "Updated training specs for release") delete TrainingO2D entirely and keep TraningS3D typo'd (line 236 there). Fixing main alone will merge-conflict and the typo will re-ship on the next Analysis release. Open equivalent fixes there (S3D-only where O2D is deleted) or agree merge order before this lands.

Semver

Patch. Runtime-wise strictly a bug fix (exported schemas start accepting real server payloads they previously rejected). Type-wise, a consumer who wrote case "TraningO2D": against the typo'd literal would get a compile error — theoretical, and the SDK's distribution is GitHub Release tarballs (not npm), so the installed base is minimal. Add a changelog note.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions