Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up types #813

Merged
merged 6 commits into from Jun 13, 2023
Merged

Clean up types #813

merged 6 commits into from Jun 13, 2023

Conversation

cjbarth
Copy link
Collaborator

@cjbarth cjbarth commented Nov 15, 2022

Description

Based on the discussion here, there are too many types being emitted from passport-saml from node-saml. This PR correct that and cleans up some linting errors.

@cjbarth cjbarth added the chore Refactoring, etc. to keep code-rot in check. label Nov 15, 2022
markstos
markstos previously approved these changes Nov 16, 2022
Copy link
Contributor

@markstos markstos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/index.ts Outdated
@@ -8,7 +8,7 @@ import type {
MultiStrategyConfig,
} from "./types";

export * from "@node-saml/node-saml";
export { Profile, SAML, SamlConfig } from "@node-saml/node-saml";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markstos , as I look at this more, it seems that if a consumer doesn't need it, than node-saml shouldn't export it, so really, we are doing the correct thing by exporting everything someone might need via passport-saml. I came across this when doing node-saml/node-saml#224.

@RopoMen, In your experience, when types reference other types, should those nested types also be exported? I ask because that is what is the case with SamlOption and node-saml/node-saml#220 shows how someone needs those nested types, so I want your perspective before I land this PR.

Copy link

@ghusse ghusse Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I'm using this new version, it seems that at least types that need to be used by people should be exported. I suppose that every type referenced by options should be exported in order to be sure that people will be able to construct a valid option object without needing to reference node-saml by themselves.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can look this closer on monday.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghusse , I completely agree, which is why I've changed passport-saml in this PR to not import from node-saml throughout the code, but, instead, to import from '.', which guarantees that anything we use internally can also be used externally by a consumer. It is these nested types that I have questions about.

I'm thinking that we need to export them since someone might want to use them to type-check the properties they are sending as config; then again, they may not care and just deal with the type warning when compiling TypeScript as the type checker will still inform for improper use of types, they just won't be directly consumable e.g. 'as SomeNodeSamlType` unless they are exported. Thus the conundrum.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitively, I prefer the version with *

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjbarth I think passport-saml can be left as it is. When the previous discussion was made I did not look into node-saml "main"/"entrypoint" at all, which is https://github.com/node-saml/node-saml/blob/master/src/index.ts

That is the most important file, it provides the public interface to node-saml. Thereof in passport saml it's ok to export everyting from there. I was afraid of that node-saml was exporting everything, even the internal stuff.

But for type exports, is there any good usage for this MandatorySamlOptions? It is already part of SamlOptions and SamlConfig which I consider main configuration objects.

@codecov
Copy link

codecov bot commented Nov 22, 2022

Codecov Report

Merging #813 (4ef23d9) into master (a14f25a) will decrease coverage by 0.68%.
The diff coverage is 100.00%.

❗ Current head 4ef23d9 differs from pull request most recent head a301150. Consider uploading reports for the commit a301150 to get more accurate results

@@            Coverage Diff             @@
##           master     #813      +/-   ##
==========================================
- Coverage   65.10%   64.42%   -0.68%     
==========================================
  Files           4        4              
  Lines         149      149              
  Branches       37       37              
==========================================
- Hits           97       96       -1     
- Misses         29       30       +1     
  Partials       23       23              
Impacted Files Coverage Δ
src/index.ts 100.00% <ø> (ø)
src/types.ts 0.00% <ø> (ø)
src/multiSamlStrategy.ts 78.78% <100.00%> (ø)
src/strategy.ts 58.71% <100.00%> (-0.92%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cjbarth cjbarth added the semver-major This change requires at least a semver-major version bump label Nov 22, 2022
@cjbarth
Copy link
Collaborator Author

cjbarth commented Nov 22, 2022

I've updated some more of the types here to make the typing much clearer. This could result in a break from some users, so I've added that label and this will have to wait until we're preparing for the 5.x release.

@cjbarth cjbarth merged commit 930082a into node-saml:master Jun 13, 2023
6 checks passed
@cjbarth cjbarth deleted the type-cleanup branch June 13, 2023 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Refactoring, etc. to keep code-rot in check. semver-major This change requires at least a semver-major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants