feat(api): bundle getTariffPeriods from tesla-fleet-api - #82
Merged
Conversation
Adds getTariffPeriods and TariffContentV2 to @teslemetry/api's public surface, co-located with the existing tariff_content_v2 SSE handling. The implementation is inlined from tesla-fleet-api at build time (a devDependency, bundled by tsdown, not a runtime dependency) so consumers like the Homey app can drop their fragile github-source dependency on tesla-fleet-api and import this from @teslemetry/api, which they already depend on.
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.
Intent
github:Teslemetry/node-tesla-fleet-apisource dependency with its own fragile build step, just to getgetTariffPeriods. It already depends on@teslemetry/api- re-exporting the helper from there lets it drop the github dependency entirely.src/tariff.ts, co-located with the existingtariff_content_v2SSE handling (TeslemetryStream.ts/SseTariffContentV2inconst.ts), and re-exported from the package root alongsidegetTariffPeriods'sTariffContentV2/TariffRate/TariffPeriod/TariffResolutiontypes.tesla-fleet-api@^0.2.2(confirmed the tariff code is present on npm; earlier0.2.1was never published) as adevDependency, not a runtime one - tsdown externalizesdependencies/peerDependenciesby default but bundlesdevDependencies, so it gets inlined intodist/instead.tsdown.config.ts'sdeps.onlyBundle: ["tesla-fleet-api"]marks that bundling intentional.src/tariff.tsdeep-importstesla-fleet-api/dist/tariff.js+.../types/site_info.jsdirectly rather than the package root, so the bundle only pulls in that helper's own closure (no vehicle/signing/commands code). Verified: rebuilding added ~12.5 KB todist/index.{cjs,mjs}(168.8 KB -> 181.6 KB), and grepping the output forTeslaFleetApi/Session/SignedCommandError/etc. class names comes back empty - confirmed via the rawdist/index.mjs, not just tsdown's own report.SseTariffContentV2/TariffInfotypes carrytariff_content_v2as untyped{ [key: string]: unknown } | null(the server spec doesn't describe its shape), so a consumer narrows/casts that payload to the newly-exportedTariffContentV2before callinggetTariffPeriods- documented with an example in the README. Confirmed a standalone consumer importing bothgetTariffPeriodsandTariffContentV2from the builtdist/index.d.mtstype-checks cleanly.package.jsonstill has nodependencies/peerDependenciesentries.@teslemetry/apiis needed before Homey can switch away from its github dependency.