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

[soap] Update SOAP definitions #18511

Closed
wants to merge 9 commits into from
Closed

[soap] Update SOAP definitions #18511

wants to merge 9 commits into from

Conversation

onury
Copy link

@onury onury commented Jul 30, 2017

Please fill in this template.

  • Use a meaningful title for the pull request. Include the name of the package modified.
  • Test the change in your own code. (Compile and run.)
  • Follow the advice from the readme.
  • Avoid common mistakes.
  • Run npm run lint package-name (or tsc if no tslint.json is present).

Select one of these and delete the others:

If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: https://github.com/vpulim/node-soap
  • Increase the version number in the header if appropriate.
  • If you are making substantial changes, consider adding a tslint.json containing { "extends": "dtslint/dt.json" }.

Changes

  • Server and Client are now exported as classes instead of interfaces. This allows proper inheritance.
  • Added missing soap module exports: WSDL, WSSecurityCert, ClientSSLSecurityPFX, passwordDigest
  • Updated existing signatures for missing arguments or members.
  • Added interfaces: IWSDLBaseOptions, IServerOptions, IXMLAttribute, IServicePort, IService, IServices.
  • Semantics:
    • Refactored Security to ISecurity (Security is still declared for compatibility reasons) - Refactored Option to IOptions (Option is still declared for compatibility reasons)
    • Refactored SoapMethod to ISOAPMethod (SoapMethod is still declared for compatibility reasons)
  • Updated tests.
  • Fixes incorrect type definition @types/soap #18497

- `Server` and `Client` are now exported as classes instead of interfaces. This allows extending these classes.
- Added missing soap module exports: `WSDL`, `WSSecurityCert`, `ClientSSLSecurityPFX`, `passwordDigest`
- Updated existing signatures for missing arguments or members.
- Added interfaces: `IWSDLBaseOptions`, `IServerOptions`, `IXMLAttribute`, `IServicePort`, `IService`, `IServices`.
- Semantics: 
  - Refactored `Security` to `ISecurity` (`Security` is still declared for compatibility reasons)
  - Refactored `Option` to `IOptions` (`Option` is still declared for compatibility reasons)
  - Refactored `SoapMethod` to `ISOAPMethod` (`SoapMethod` is still declared for compatibility reasons)
the new `defaults` parameter is optional.
@dt-bot
Copy link
Member

dt-bot commented Jul 30, 2017

types/soap/index.d.ts

to authors (@aleung @CageFox). Could you review this PR?
👍 or 👎?

Checklist

  • pass the Travis CI test?

@CageFox
Copy link
Contributor

CageFox commented Jul 30, 2017

Seems good and useful

Copy link
Contributor

@aleung aleung left a comment

Choose a reason for hiding this comment

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

I'm still reviewing. Submit the comment about naming convention first.

@@ -1,18 +1,18 @@
import * as soap from 'soap';
import * as SOAP from 'soap';
Copy link
Contributor

Choose a reason for hiding this comment

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

SOAP doesn't align with naming conventions.

Copy link
Author

Choose a reason for hiding this comment

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

This is ok.


interface Security {
export interface ISOAPMethod {
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to treat abbreviations as if they were lower case words. See this highest vote answer in SO.

ISoapMethod is more readable than ISOAPMethod.

This comment also apply to WSDL, e.g. IWSDLBaseOptions.

Copy link
Author

Choose a reason for hiding this comment

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

The soap module itself has the followings:

  • WSSecurity - not WsSecurity
  • ClientSSLSecurity - not ClientSslSecurity
  • ClientSSLSecurityPFX - not ClientSslSecurityPfx

Also, the original module exports WSDL not Wsdl

I'm not only following my preferences, this is the original module's style/convention.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there is a consistent style in node-soap project.

You can also find these:

  • wsdl_headers
  • wsdl_options
  • wsdlOptions
  • addSoapHeader
  • changeSoapHeader
  • soapError

Treating abbreviations as normal words increases readability. For example, a glance at ISOAPMethod might become ISO-AP-Method or IS-OAP-Method.

Copy link
Author

@onury onury Jul 31, 2017

Choose a reason for hiding this comment

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

ok. see final changes. I'll keep WSDL as is, since it's exported all in uppercase in node-soap.

@typescript-bot
Copy link
Contributor

@onury Please address comments from the code reviewers.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Jul 31, 2017
setSecurity(s: Security): void;
[method: string]: SoapMethod | Function;
setSecurity(security: ISecurity): void;
[key: string]: any; // [method: string]: ISOAPMethod | Function;
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be [key: string]: any; otherwise TS will complain on any member you add to the extended class if it doesn't have a type of SoapMethod | Function.

Can you give example code of extended class? I tried to write a sub class without changing it to any and there was no error reported by TSC.

@typescript-bot typescript-bot removed the Revision needed This PR needs code changes before it can be merged. label Jul 31, 2017
@typescript-bot
Copy link
Contributor

@aleung - Thanks for your review of this PR! Can you please look at the new code and update your review status if appropriate?

@aleung
Copy link
Contributor

aleung commented Aug 1, 2017

@onury Thanks for your update.

Another thing I didn't point out yesterday. But after revisiting the code and doing some reading online, I think this definition should follow TypeScript coding guidelines interface naming rule:

Do not use "I" as a prefix for interface names.

There was a lot of discussion on it, e.g. microsoft/TypeScript-Handbook#121, inversify/InversifyJS#242. I‘m disposed to agree the argument in https://softwareengineering.stackexchange.com/a/117393/42485.

I know style choice is somewhat personal favor. But since TypeScript team chooses this one and most of the files in https://github.com/DefinitelyTyped/DefinitelyTyped follow it, why us not?

@onury
Copy link
Author

onury commented Aug 1, 2017

@aleung this is my preference. I'm proposing this PR as is. Let me know if I should close this. Thanks.

@aleung
Copy link
Contributor

aleung commented Aug 1, 2017

@onury Thank you very much for your great work. Your PR fills up the missing APIs and makes it complete. I really don't want to see that the effort you pay is wasted.

Keeping unified code style is one of the job that maintainer needs to do. @types/soap was using the no I prefix interface naming style from its beginning. I should raised this comment together with previous ones.

Copy link
Contributor

@aleung aleung left a comment

Choose a reason for hiding this comment

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

Do not use "I" as a prefix for interface names.

@typescript-bot typescript-bot added the Revision needed This PR needs code changes before it can be merged. label Aug 1, 2017
@CageFox
Copy link
Contributor

CageFox commented Aug 1, 2017

Use "I" prefix in interfaces or don't use is personal or team choice. As you @aleung mentioned above there is a lot of discussion about it and there is no single "right" point about it. Personally I and my team use "I" prefix for many practical reasons.

So, you trying to force your personal preference upon independent author. For my point of view it looks bad. @onury types is much better then it is now and you rejecting his PR just because, let's talk it so: you didn't like his naming style

@aleung
Copy link
Contributor

aleung commented Aug 1, 2017

While existing code were using one style (SoapMethod, Option), changing it to another style in a PR because "this is my preference", isn't it trying to force personal preference upon other authors?

Personally I don't feel using "I" prefix in interfaces is a good idea in TypeScript. As it was said in TypeScript Handbook:

In general, you shouldn’t prefix interfaces with I (e.g. IColor). Because the concept of an interface in TypeScript is much more broad than in C# or Java, the IFoo naming convention is not broadly useful.

interface ISoapMethod {
    (args: any, callback: (err: any, result: any, raw: any, soapHeader: any) => void, options?: any, extraHeaders?: any): void;
}

can be rewritten to:

type ISoapMethod = (args: any, callback: (err: any, result: any, raw: any, soapHeader: any) => void, options?: any, extraHeaders?: any) => void;

Are you saying that it's still an interface?

@CageFox
Copy link
Contributor

CageFox commented Aug 1, 2017

While existing code were using one style (SoapMethod, Option), changing it to another style

Existing soap javascript code have no interfaces by obvious reasons, this is new entities in soap types. Those new entities may be styled as "without "I" prefix" and "with "I" prefix" and it's personal choice of author

There is no "right" choice wich accepted by all or almost all community, and I think it's wrong to force one style

And yes, interfaces can be rewritten as abstract classes or even types, but this changes nothing: existing soap code not exporting abstract classes nor types, so how to make this new entities is author choice

And one more thing: if there was crowd of authors in entrance with different styled typings we would be able to choose "right" and "good" style. But there is only one PR and it's good PR - except you didn't like it's styling very much

@onury
Copy link
Author

onury commented Aug 2, 2017

@aleung Yes, you can write it as an interface or a type. Is it really an interface, you ask...

Well, is it really a type?.. It still enforces certain properties on an object/class which is what interfaces are for. Can you do new ISoapMethod()? or ISoapMethod.property? An interface/type transpiles to "nothing" in JS. Besides, I've used ISoapMethod for an actual interface. What's the purpose of that example?

The coding guide-lines for TypeScript you've mentioned is meant to be for contributors of the TypeScript project on GitHub. See the huge note here? That's not how TS developers should mandatorily write code. I personally adapt most of the suggestions there but not all.

But that's not the point...

I've previously made many changes you've asked, including naming style bec. I've agreed with you on for example, abbreviations to be treated as words for better readability. On interface names, I simply do not agree. But you won't come half-way, will you?

I've given time and effort to complete the typings bec. you said "I had only add definitions for my need". Well, I've added the complete definitions (even the ones I don't use), even fixed bugs, out-dated signatures — for community needs. But It all got stuck with your style authoritarianism.

So, will not wait anymore for your approval. here you go..

@onury onury closed this Aug 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Revision needed This PR needs code changes before it can be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants