refactor(global): unify OpenAPI types and brand IDs consistently - #49
Merged
Merged
Conversation
Move Brand/JobId/StageId/TaskId from jobnik-sdk into jobnik-openapi and wire generateTypes.mts to brand jobId/stageId/taskId schema refs, so jobnik-openapi becomes the single place OpenAPI-derived types (brands included) are generated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Stop regenerating a duplicate openapi.ts/brands.ts and import paths/components/operations/JobId/StageId/TaskId straight from jobnik-openapi, removing the second independently-generated copy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Retype every jobId parameter in the job service layer and the job-id flow through the stage manager to JobId from jobnik-openapi, so the compiler rejects a StageId/TaskId passed where a job id is expected. Prisma-sourced job ids are cast at the DB boundary, since Prisma keeps plain strings while the branded id only exists in the API/service layer. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Retype every stageId parameter in the stage service layer, the stage-id flow through the task manager, and stageRepository. updateStageSummary to StageId from jobnik-openapi, so getStageById and the repository reject a JobId/TaskId at compile time. Prisma-sourced stage ids are cast at the DB boundary, matching the JobId pattern from the previous commit. Also casts the Prisma->API boundary in convertPrismaToStageResponse, and closes a couple of JobId gaps in the stages integration spec that the job-id-branding commit missed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Retype every taskId parameter in the task service layer to TaskId from jobnik-openapi, so getTaskById rejects a JobId/StageId at compile time. Casts the Prisma->API boundary in convertPrismaToTaskResponse and convertPrismaToJobResponse (the latter closes a JobId gap the job-id-branding commit missed), matching the pattern already used for JobId/StageId. This is the last of the three id-branding commits; jobnik-manager now type-checks, builds, and its full test suite passes with the branded ids threaded end-to-end. Also fixes import ordering (eslint import-x/order) flagged in a couple of test files touched by the earlier job/stage id commits. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- Export Brand from jobnik-openapi's brands.ts/index.ts, matching ticket 01's acceptance checklist (JobId/StageId/TaskId were already re-exported, Brand itself was missed). - Hoist the repeated stage.jobId/stage.job.id as JobId cast in StageManager.executeUpdateStatus into a single local, removing four near-identical casts and a stage.jobId/stage.job.id inconsistency. - Fix a test that cast a job id to StageId and passed it to addTasks instead of the actual stage id (tests/unit/tasks/tasks.spec.ts). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Coverage Report for apps/jobnik-manager
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rror classes/mapping jobnik-sdk and jobnik-manager each independently regenerated error classes/mapping from the same spec. jobnik-openapi now generates both once; jobnik-manager imports them directly (never published, so a runtime dependency is safe), while jobnik-sdk stages a physical local copy at build time via a new copy:errors step, since it publishes standalone and jobnik-openapi is a private, unpublished package. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…moval pnpm-lock.yaml still listed @map-colonies/openapi-helpers for jobnik-sdk after 467c03f dropped it from package.json, breaking frozen-lockfile CI installs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ead of at each cast site getStageEntityById/getJobEntityById/getTaskEntityById and their raw ad-hoc query call sites now cast Prisma results to JobId/StageId/TaskId once, at the point the value leaves Prisma, instead of scattering `as JobId`/ `as StageId`/`as TaskId` casts across every call site that reads the field. Prisma has no concept of branded scalars, so this can't be pushed further down into schema.prisma: prisma-json-types-generator throws on `@db.Uuid` string columns (breaks its UuidFilter handling and silently drops Json overrides for later models). Revisit once that's fixed upstream. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…y:generated step copySpec.mts and copyErrors.mts each did the same thing (copy a file resolved through jobnik-openapi's exports into src/, since jobnik-openapi is private and unpublished so jobnik-sdk must vendor these at build time). Collapse both into a single copyGenerated.mts and one prebuild step. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…n knip src/generated/openapi-errors.ts is staged by the copy:generated prebuild step and gitignored, so it doesn't exist on a fresh checkout — knip's static analysis (which doesn't run build scripts) flagged the import in sdkErrors.ts as unresolved, failing CI. Same pattern already used for jobnik-manager's generated ./instrumentation.mjs. Also drop the now-stale ignore entry for src/types/openapi.ts, removed when the SDK started consuming jobnik-openapi types directly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ronenkapelian
requested changes
Sep 22, 2026
… function for clarity
…s import 1b3a062 dropped this entry while cleaning up the unrelated @prismaClient ignoreDependencies hint, regressing the CI failure fixed in acd7990. src/generated/openapi-errors.ts is still only staged by the gitignored copy:generated prebuild step, so it still doesn't exist on a fresh checkout and knip's static analysis still can't resolve the import in sdkErrors.ts without this entry. Reproduced and verified locally by deleting the staged file before running knip. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1b3a062 dropped @prismaClient from ignoreDependencies based on a knip "unused config" hint, but that hint only held locally where the generated Prisma client was already built. Only src/db/prisma/generated/client/sql is committed to git (see apps/jobnik-manager/.gitignore); the rest of the client, including its index, is gitignored and generated at build time. On a fresh checkout knip's static analysis can't resolve @prismaClient and flags it as an unlisted dependency in ~35 files, failing CI. Verified by simulating a true fresh checkout (git checkout -- the generated dir, which restores only the tracked sql/ subfolder) and running knip against it: fails without this entry, passes with it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ronenkapelian
approved these changes
Sep 24, 2026
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
jobnik-openapibecomes the single place OpenAPI-derived types are generated, withJobId/StageId/TaskIdbranding baked intopaths/components/operations/TypedRequestHandlersjobnik-sdkstops regenerating its own duplicate types and consumesjobnik-openapi's types directlyjobnik-managerretypes job/stage/task ids end-to-end (service layer + DAL) to the branded ids, so the compiler rejects a mismatched id kind anywhere in the call chainTest plan
pnpm --filter jobnik-openapi type-check/generate:checkpnpm --filter jobnik-sdk type-check/generate:checkpnpm --filter jobnik-manager type-check🤖 Generated with Claude Code