SuperFlyTV / casparcg-connection

node.js Javascript/TypeScript library for CasparCG connection and commands.
https://www.npmjs.com/package/casparcg-connection
MIT License
87 stars 22 forks source link

Feat: Return data with types #185

Closed nytamin closed 1 year ago

nytamin commented 1 year ago

Return-data can now be strictly typed, so consumers can use it without having to manually parse the data.

By default, I've set all return-data types to be ~undefined~ unknown, since most where missing data-deserializers for them anyway. For the ones that do have deserializers, I've set the return type to equal the deserialized data.

codecov-commenter commented 1 year ago

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (18a2ee0) 79.60% compared to head (ceaed83) 81.32%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #185 +/- ## ========================================== + Coverage 79.60% 81.32% +1.72% ========================================== Files 6 14 +8 Lines 554 723 +169 Branches 101 164 +63 ========================================== + Hits 441 588 +147 - Misses 109 131 +22 Partials 4 4 ``` | [Files](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV) | Coverage Δ | | |---|---|---| | [src/commands.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2NvbW1hbmRzLnRz) | `100.00% <100.00%> (ø)` | | | [src/deserializers/deserializeInfoChannel.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2Rlc2VyaWFsaXplcnMvZGVzZXJpYWxpemVJbmZvQ2hhbm5lbC50cw==) | `100.00% <100.00%> (ø)` | | | [src/deserializers/deserializeXML.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2Rlc2VyaWFsaXplcnMvZGVzZXJpYWxpemVYTUwudHM=) | `100.00% <100.00%> (ø)` | | | [src/lib.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2xpYi50cw==) | `100.00% <100.00%> (ø)` | | | [src/serializers.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL3NlcmlhbGl6ZXJzLnRz) | `52.12% <ø> (-1.00%)` | :arrow_down: | | [src/deserializers/deserializeClipInfo.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2Rlc2VyaWFsaXplcnMvZGVzZXJpYWxpemVDbGlwSW5mby50cw==) | `93.75% <93.75%> (ø)` | | | [src/deserializers/deserializeInfo.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2Rlc2VyaWFsaXplcnMvZGVzZXJpYWxpemVJbmZvLnRz) | `85.71% <85.71%> (ø)` | | | [src/deserializers/deserializeInfoLayer.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2Rlc2VyaWFsaXplcnMvZGVzZXJpYWxpemVJbmZvTGF5ZXIudHM=) | `66.66% <66.66%> (ø)` | | | [src/deserializers/index.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2Rlc2VyaWFsaXplcnMvaW5kZXgudHM=) | `94.44% <94.44%> (ø)` | | | [src/connection.ts](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV#diff-c3JjL2Nvbm5lY3Rpb24udHM=) | `84.96% <88.88%> (+0.83%)` | :arrow_up: | | ... and [3 more](https://app.codecov.io/gh/SuperFlyTV/casparcg-connection/pull/185?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=SuperFlyTV) | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ianshade commented 1 year ago

By default, I've set all return-data types to be undefined, since most where missing data-deserializers for them anyway.

@nytamin Wouldn't unknown instead of undefined result in a slightly better development experience for the consumers of the library?

mint-dewit commented 1 year ago

@nytamin do you want to just merge this? Like I said, my last point is regarding the callback in the constructor but I'm not convinced either solution is better.

nytamin commented 1 year ago

Yeah I'll go ahead and merge it then, I we come up with something better we can adress that later.