fix(knex)!: scope KnexQueueSchemaService to the driver module - #27
Open
gerardp wants to merge 2 commits into
Open
fix(knex)!: scope KnexQueueSchemaService to the driver module#27gerardp wants to merge 2 commits into
gerardp wants to merge 2 commits into
Conversation
The root barrel re-exported QueueSchemaService, whose constructor takes a Knex instance. That single export made build/index.d.ts import 'knex', so every consumer type checking with skipLibCheck disabled had to install the optional peer, even when using the Kysely, Redis or Sync adapter. Export it from src/drivers/knex_adapter.ts instead, the way the Kysely module already exports KyselyQueueSchemaService, so the type stays reachable only from the subpath that owns the dependency. BREAKING CHANGE: QueueSchemaService is no longer exported from the package root. Import it from '@boringnode/queue/drivers/knex_adapter'.
Now that the schema service is exported from the Knex driver module, the name mirrors KyselyQueueSchemaService and src/services/knex_queue_schema.ts mirrors src/services/kysely_queue_schema.ts, so neither module carries the unqualified name. BREAKING CHANGE: QueueSchemaService is now named KnexQueueSchemaService.
Author
|
Went ahead with the rename I asked about in the description: the schema service is now |
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.
Closes #24.
Problem
The root barrel exported
QueueSchemaService, whose constructor signature isconstructor(connection: Knex). That single export was the only reason the generated rootdeclaration file imported
knex:Since
knexis an optional peer dependency, any consumer type checking withskipLibCheck: falsehad to install it — even when using the Kysely, Redis or Sync adapter,or a custom
Adapter.Change
Two commits, in the order they are easiest to read:
fix(knex)!— the export moves next to the adapter that needs it, mirroring what theKysely module already does at
src/drivers/kysely_adapter.ts:17.refactor(knex)!— the class is renamedKnexQueueSchemaServiceand its filesrc/services/knex_queue_schema.ts, so the two driver modules are symmetrical and neitherone holds the unqualified name.
Consumers now import it the same way they already import the Kysely equivalent:
The class body is untouched, and nothing changes at runtime. Updated along with it: the README's
two examples (plain Knex and the AdonisJS migration), the three test suites that construct it,
and the dedup guidance in the
KnexAdaptererror message, which now namesKnexQueueSchemaService.addDedupColumns().The second commit is independent — drop it if you would rather keep the name as it is.
Verification
After
yarn build,from 'knex'appears in exactly one declaration file, the one that owns thedependency:
End to end with the reproduction from the issue —
npm packof this branch, installed in aclean project with
typescript@7.0.2and@types/node@25.9.4:npx tsc --noEmit0.7.1, root import, noknexinstalledbuild/index.d.ts(4,22): error TS2307: Cannot find module 'knex'knexinstalledKnexQueueSchemaServicefrom the driver subpath withknexinstalled, including acreateJobsTablecall with anextendcallbackyarn typecheck,yarn lintandyarn formatare clean (the twooxlintwarnings insrc/otel.tsandtests/sync_adapter.spec.tsare pre-existing onmain).Note on the breaking change
This removes
QueueSchemaServicefrom the package root and renames it, so it is breaking foranyone importing it today; the upgrade is a one-line import change. The alternative mentioned in
the issue — keeping the root export and typing the constructor structurally to drop the
import { Knex }— avoids the break but leaves the export in a barrel it does not belong to.Happy to switch to that version if you would rather not break the current release line.